Startup FitMC intro sound

This commit is contained in:
Brady
2018-12-15 17:50:01 -06:00
parent 2afdaa1ac9
commit fa3dab0adb
5 changed files with 101 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;
@@ -98,6 +101,9 @@ public class Baritone implements IBaritone {
return;
}
SoundEvent event = new SoundEvent(new ResourceLocation("baritone", "fitmc_intro"));
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(event, 1.0F));
// 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

@@ -0,0 +1,76 @@
/*
* 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 javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Set;
/**
* @author Brady
* @since 12/15/2018
*/
public class BaritoneResourcePack implements IResourcePack {
@Override
public InputStream getInputStream(@Nonnull ResourceLocation location) {
return getResourceStream(location);
}
@Override
public boolean resourceExists(@Nonnull ResourceLocation location) {
return getResourceStream(location) != null;
}
@Nonnull
@Override
public Set<String> getResourceDomains() {
return Collections.singleton("baritone");
}
@Nullable
@Override
public <T extends IMetadataSection> T getPackMetadata(@Nonnull MetadataSerializer metadataSerializer, @Nonnull String metadataSectionName) throws IOException {
return null;
}
@Override
public BufferedImage getPackImage() {
return null;
}
@Nonnull
@Override
public String getPackName() {
return "baritone";
}
@Nullable
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"
}
]
}
}