Compare commits

...

3 Commits

Author SHA1 Message Date
Brady 35cb592d09
Clean up BaritoneResourcePack 2018-12-15 18:11:18 -06:00
Leijurv 863db53b24
improved fitmc 2018-12-15 15:59:36 -08:00
Brady fa3dab0adb
Startup FitMC intro sound 2018-12-15 17:50:01 -06:00
6 changed files with 100 additions and 4 deletions

View File

@ -25,15 +25,18 @@ import baritone.api.event.events.TickEvent;
import baritone.api.event.events.WorldEvent;
import baritone.api.event.events.type.EventState;
import baritone.utils.BaritoneAutoTest;
import baritone.utils.resource.BaritoneResourcePack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.lib.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -42,6 +45,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.List;
/**
* @author Brady
* @since 7/31/2018
@ -49,10 +54,9 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(Minecraft.class)
public class MixinMinecraft {
@Shadow
public EntityPlayerSP player;
@Shadow
public WorldClient world;
@Shadow public EntityPlayerSP player;
@Shadow public WorldClient world;
@Shadow @Final private List<IResourcePack> defaultResourcePacks;
@Inject(
method = "init",
@ -71,6 +75,7 @@ public class MixinMinecraft {
)
private void preInit(CallbackInfo ci) {
BaritoneAutoTest.INSTANCE.onPreInit();
this.defaultResourcePacks.add(new BaritoneResourcePack());
}
@Inject(

View File

@ -35,6 +35,9 @@ import baritone.utils.InputOverrideHandler;
import baritone.utils.PathingControlManager;
import baritone.utils.player.PrimaryPlayerContext;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import java.io.File;
import java.io.IOException;
@ -93,11 +96,18 @@ public class Baritone implements IBaritone {
this.gameEventHandler = new GameEventHandler(this);
}
public void fitmc() {
SoundEvent event = new SoundEvent(new ResourceLocation("baritone", "fitmc_intro"));
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(event, 0.8F + (float) Math.random() * 0.4F));
}
public synchronized void init() {
if (initialized) {
return;
}
fitmc();
// Define this before behaviors try and get it, or else it will be null and the builds will fail!
this.playerContext = PrimaryPlayerContext.INSTANCE;

View File

@ -201,6 +201,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
} else if (pathingBehavior.isPathing()) {
logDirect("Currently executing a path. Please cancel it first.");
} else {
baritone.fitmc();
customGoalProcess.setGoalAndPath(pathingBehavior.getGoal());
}
return true;

View File

@ -0,0 +1,70 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.utils.resource;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.client.resources.data.IMetadataSection;
import net.minecraft.client.resources.data.MetadataSerializer;
import net.minecraft.util.ResourceLocation;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.util.Collections;
import java.util.Set;
/**
* @author Brady
* @since 12/15/2018
*/
@SuppressWarnings("NullableProblems")
public class BaritoneResourcePack implements IResourcePack {
@Override
public InputStream getInputStream(ResourceLocation location) {
return getResourceStream(location);
}
@Override
public boolean resourceExists(ResourceLocation location) {
return getResourceStream(location) != null;
}
@Override
public Set<String> getResourceDomains() {
return Collections.singleton("baritone");
}
@Override
public <T extends IMetadataSection> T getPackMetadata(MetadataSerializer metadataSerializer, String metadataSectionName) {
return null;
}
@Override
public BufferedImage getPackImage() {
return null;
}
@Override
public String getPackName() {
return "baritone";
}
private InputStream getResourceStream(ResourceLocation location) {
return BaritoneResourcePack.class.getResourceAsStream("/assets/" + location.getNamespace() + "/" + location.getPath());
}
}

View File

@ -0,0 +1,10 @@
{
"fitmc_intro": {
"category": "master",
"sounds": [
{
"name": "baritone:fitmc/intro"
}
]
}
}