Vastly improve conduit/facade sounds, facades play painted block sounds

Ref #2510
This commit is contained in:
tterrag1098 committed 2015-05-27 18:53:57 -04:00
1 parent 129ef251c1
commit 17d18995e9
6 files changed
+109 -8

No files matched your search

@@ -65,9 +65,7 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
if(te instanceof IConduitBundle) {
IConduitBundle bundle = (IConduitBundle) te;
bundle.addConduit(createConduit(stack, player));
Block b = EnderIO.blockConduitBundle;
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, b.stepSound.getStepResourcePath(),
(b.stepSound.getVolume() + 1.0F) / 2.0F, b.stepSound.getPitch() * 0.8F);
ConduitUtil.playBreakSound(Block.soundTypeMetal, world, placeAt.x, placeAt.y, placeAt.z);
}
}
}
@@ -98,6 +96,7 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
return false;
}
bundle.addConduit(con);
ConduitUtil.playBreakSound(Block.soundTypeMetal, world, placeX, placeY, placeZ);
if(!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
@@ -8,6 +8,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -21,8 +22,10 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.sound.PlaySoundSourceEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import powercrystals.minefactoryreloaded.api.rednet.IRedNetOmniNode;
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType;
@@ -64,6 +67,7 @@ import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.tool.ToolUtil;
import crazypants.render.BoundingBox;
import crazypants.render.RenderUtil;
import crazypants.util.BlockCoord;
import crazypants.util.IFacade;
import crazypants.util.Util;
@@ -111,6 +115,17 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
setHardness(1.5f);
setResistance(10.0f);
setCreativeTab(null);
this.stepSound = new SoundType("silence", 0, 0) {
@Override
public String getBreakSound() {
return "EnderIO:" + soundName + ".dig";
}
@Override
public String getStepResourcePath() {
return "EnderIO:" + soundName + ".step";
}
};
}
@SideOnly(Side.CLIENT)
@@ -157,7 +172,6 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
}
}
return true;
}
@SideOnly(Side.CLIENT)
@@ -185,6 +199,39 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
effectRenderer.addEffect(digFX);
}
@SubscribeEvent
public void onPlaySound(PlaySoundSourceEvent event) {
String path = event.sound.getPositionedSoundLocation().getResourcePath();
if ("silence.step".equals(path)) {
ISound snd = event.sound;
World world = EnderIO.proxy.getClientWorld();
BlockCoord bc = new BlockCoord(snd.getXPosF(), snd.getYPosF(), snd.getZPosF());
TileConduitBundle te = (TileConduitBundle) bc.getTileEntity(world);
if (te != null && te.hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playHitSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playHitSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@SubscribeEvent
public void onPlaySoundAtEntity(PlaySoundAtEntityEvent event) {
String path = event.name;
World world = event.entity.worldObj;
if ("EnderIO:silence.step".equals(path) && world.isRemote) {
BlockCoord bc = new BlockCoord(event.entity.posX, event.entity.posY - 2, event.entity.posZ);
TileConduitBundle te = (TileConduitBundle) bc.getTileEntity(world);
if (te != null && te.hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playStepSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playStepSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@Override
protected void init() {
super.init();
@@ -379,6 +426,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
ItemStack fac = new ItemStack(EnderIO.itemConduitFacade, 1, te.getFacadeType().ordinal());
PainterUtil.setSourceBlock(fac, te.getFacadeId(), te.getFacadeMetadata());
drop.add(fac);
ConduitUtil.playBreakSound(te.getFacadeId().stepSound, world, x, y, z);
te.setFacadeId(null);
te.setFacadeMetadata(0);
te.setFacadeType(FacadeType.BASIC);
@@ -447,6 +495,9 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
drop.addAll(con.getDrops());
}
}
BlockCoord bc = te.getLocation();
ConduitUtil.playBreakSound(Block.soundTypeMetal, te.getWorld(), bc.x, bc.y, bc.z);
return true;
}
@@ -598,8 +649,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
if(!world.isRemote) {
bundle.addConduit(equipped.createConduit(stack, player));
if(!player.capabilities.isCreativeMode) {
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, stepSound.getStepResourcePath(), (stepSound.getVolume() + 1.0F) / 2.0F,
stepSound.getPitch() * 0.8F);
ConduitUtil.playBreakSound(soundTypeMetal, world, x, y, z);
player.getCurrentEquippedItem().stackSize--;
}
}
@@ -625,7 +675,8 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
bundle.setFacadeId(facadeID);
bundle.setFacadeMetadata(facadeMeta);
bundle.setFacadeType(FacadeType.values()[player.getCurrentEquippedItem().getItemDamage()]);
if(!player.capabilities.isCreativeMode) {
ConduitUtil.playBreakSound(facadeID.stepSound, world, x, y, z);
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
world.markBlockForUpdate(x, y, z);
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
import net.minecraft.block.Block.SoundType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -18,6 +19,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -418,4 +420,39 @@ public class ConduitUtil {
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_SELECTOR, world, x, y, z);
}
public static void playBreakSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, snd.func_150496_b(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
} else {
playClientBreakSound(snd);
}
}
private static void playClientBreakSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity().playSound(snd.func_150496_b(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
}
public static void playHitSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
} else {
playClientHitSound(snd);
}
}
private static void playClientHitSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity().playSound(snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 8.0F, snd.getPitch() * 0.5F);
}
public static void playStepSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
} else {
playClientStepSound(snd);
}
}
private static void playClientStepSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity().playSound(snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 8.0F, snd.getPitch());
}
}
@@ -18,6 +18,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import crazypants.enderio.conduit.ConduitUtil;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.config.Config;
import crazypants.enderio.gui.IAdvancedTooltipProvider;
@@ -128,7 +129,8 @@ public class ItemConduitFacade extends Item implements IAdvancedTooltipProvider,
bundle.setFacadeId(facadeID);
bundle.setFacadeMetadata(facadeMeta);
bundle.setFacadeType(FacadeType.values()[itemStack.getItemDamage()]);
if(!player.capabilities.isCreativeMode) {
ConduitUtil.playBreakSound(facadeID.stepSound, world, x, y, z);
if (!player.capabilities.isCreativeMode) {
itemStack.stackSize--;
}
return true;