Fix GOG sound #285

This commit is contained in:
Vincent Lee committed 2016-05-18 11:13:38 -05:00
1 parent b1fad332b8
commit 1deb617f72
3 files changed
+17 -2

No files matched your search

@@ -1,6 +1,7 @@
package vazkii.botania.common.core.handler;
import com.google.common.base.Throwables;
import net.minecraft.block.SoundType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.tileentity.MobSpawnerBaseLogic;
import net.minecraftforge.fml.common.FMLLog;
@@ -22,7 +23,8 @@ public final class MethodHandles {
spawnRange_getter, spawnCount_getter, maxNearbyEntities_getter,
maxSpawnDelay_getter, minSpawnDelay_getter,
spawnDelay_getter, spawnDelay_setter, prevMobRotation_setter, mobRotation_setter, potentialSpawns_getter,
randomEntity_getter, isActivated; // MobSpawnerBaseLogic
randomEntity_getter, isActivated, // MobSpawnerBaseLogic
breakSound_getter; // SoundType
static {
try {
@@ -79,6 +81,10 @@ public final class MethodHandles {
f.setAccessible(true);
randomEntity_getter = publicLookup().unreflectGetter(f);
f = ReflectionHelper.findField(SoundType.class, LibObfuscation.BREAK_SOUND);
f.setAccessible(true);
breakSound_getter = publicLookup().unreflectGetter(f);
Method m = ReflectionHelper.findMethod(MobSpawnerBaseLogic.class, null, LibObfuscation.IS_ACTIVATED);
m.setAccessible(true);
isActivated = publicLookup().unreflect(m);
@@ -102,4 +102,7 @@ public final class LibObfuscation {
public static final String[] PREV_EQUIPPED_PROGRESS = { "prevEquippedProgress", "field_78451_d", "f" };
public static final String[] EQUIPPED_PROGRESS = { "equippedProgress", "field_78454_c", "e" };
// SoundType
public static final String[] BREAK_SOUND = { "breakSound", "field_185862_o", "o" };
}
@@ -19,6 +19,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
@@ -28,6 +29,7 @@ import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileManaFlame;
import vazkii.botania.common.core.handler.MethodHandles;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
@@ -74,7 +76,11 @@ public final class SkyblockWorldEvents {
if(event.getWorld().isRemote)
event.getEntityPlayer().swingArm(event.getHand());
else {
event.getWorld().playSound(null, event.getPos(), block.getSoundType().getBreakSound(), SoundCategory.BLOCKS, block.getSoundType().getVolume() * 0.4F, block.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1));
try {
SoundEvent breakSound = (SoundEvent) MethodHandles.breakSound_getter.invokeExact(block.getSoundType());
event.getWorld().playSound(null, event.getPos(), breakSound, SoundCategory.BLOCKS, block.getSoundType().getVolume() * 0.4F, block.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1));
} catch (Throwable ignore) {}
if(Math.random() < 0.8)
event.getEntityPlayer().dropPlayerItemWithRandomChoice(new ItemStack(ModItems.manaResource, 1, 21), false);
}