Fixed machine sounds
This commit is contained in:
parent
4a29abe00a
commit
721f417a7c
5 changed files with 103 additions and 26 deletions
|
@ -23,6 +23,8 @@ import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
@ -219,8 +221,11 @@ public class GregTech_API {
|
||||||
/**
|
/**
|
||||||
* Adds Biomes to the Biome Lists for World Generation
|
* Adds Biomes to the Biome Lists for World Generation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
private static int size = 0; /* Used to assign Minecraft IDs to our SoundEvents. We don't use them. */
|
||||||
static {
|
static {
|
||||||
sItemStackMappings.add(sCoverItems);
|
sItemStackMappings.add(sCoverItems);
|
||||||
|
size = SoundEvent.REGISTRY.getKeys().size();
|
||||||
|
|
||||||
sDimensionalList.add(-1);
|
sDimensionalList.add(-1);
|
||||||
sDimensionalList.add(0);
|
sDimensionalList.add(0);
|
||||||
|
@ -230,33 +235,42 @@ public class GregTech_API {
|
||||||
sSoundList.put(1, "block.anvil.use");//SoundEvents.BLOCK_ANVIL_USE.getSoundName().toString());
|
sSoundList.put(1, "block.anvil.use");//SoundEvents.BLOCK_ANVIL_USE.getSoundName().toString());
|
||||||
sSoundList.put(2, "block.anvil.break");//SoundEvents.BLOCK_ANVIL_BREAK.getSoundName().toString());
|
sSoundList.put(2, "block.anvil.break");//SoundEvents.BLOCK_ANVIL_BREAK.getSoundName().toString());
|
||||||
sSoundList.put(3, "block.stone_button.click_on");//SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON.getSoundName().toString());
|
sSoundList.put(3, "block.stone_button.click_on");//SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON.getSoundName().toString());
|
||||||
sSoundList.put(4, "entity.item.break");//SoundEvents.ENTITY_ITEM_BREAK.getSoundName().toString());
|
sSoundList.put(4, "block.fire.extinguish");//SoundEvents.ENTITY_ITEM_BREAK.getSoundName().toString());
|
||||||
sSoundList.put(5, "entity.generic.explode");//SoundEvents.ENTITY_GENERIC_EXPLODE.getSoundName().toString());
|
sSoundList.put(5, "entity.generic.explode");//SoundEvents.ENTITY_GENERIC_EXPLODE.getSoundName().toString());
|
||||||
sSoundList.put(6, "item.firecharge.use");//SoundEvents.ITEM_FIRECHARGE_USE.getSoundName().toString());
|
sSoundList.put(6, "item.firecharge.use");//SoundEvents.ITEM_FIRECHARGE_USE.getSoundName().toString());
|
||||||
|
|
||||||
sSoundList.put(100, aTextIC2Lower + ":" + "tools.Wrench");
|
registerSound(100, aTextIC2Lower + ":" + "tools.Wrench");
|
||||||
sSoundList.put(101, aTextIC2Lower + ":" + "tools.RubberTrampoline");
|
registerSound(101, aTextIC2Lower + ":" + "tools.RubberTrampoline");
|
||||||
sSoundList.put(102, aTextIC2Lower + ":" + "tools.Painter");
|
registerSound(102, aTextIC2Lower + ":" + "tools.Painter");
|
||||||
sSoundList.put(103, aTextIC2Lower + ":" + "tools.BatteryUse");
|
registerSound(103, aTextIC2Lower + ":" + "tools.BatteryUse");
|
||||||
sSoundList.put(104, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseOne");
|
registerSound(104, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseOne");
|
||||||
sSoundList.put(105, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseTwo");
|
registerSound(105, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseTwo");
|
||||||
sSoundList.put(106, aTextIC2Lower + ":" + "tools.drill.DrillSoft");
|
registerSound(106, aTextIC2Lower + ":" + "tools.drill.DrillSoft");
|
||||||
sSoundList.put(107, aTextIC2Lower + ":" + "tools.drill.DrillHard");
|
registerSound(107, aTextIC2Lower + ":" + "tools.drill.DrillHard");
|
||||||
sSoundList.put(108, aTextIC2Lower + ":" + "tools.ODScanner");
|
registerSound(108, aTextIC2Lower + ":" + "tools.ODScanner");
|
||||||
|
|
||||||
sSoundList.put(200, aTextIC2Lower + ":" + "machines.ExtractorOp");
|
registerSound(200, aTextIC2Lower + ":" + "machines.ExtractorOp");
|
||||||
sSoundList.put(201, aTextIC2Lower + ":" + "machines.MaceratorOp");
|
registerSound(201, aTextIC2Lower + ":" + "machines.MaceratorOp");
|
||||||
sSoundList.put(202, aTextIC2Lower + ":" + "machines.InductionLoop");
|
registerSound(202, aTextIC2Lower + ":" + "machines.InductionLoop");
|
||||||
sSoundList.put(203, aTextIC2Lower + ":" + "machines.CompressorOp");
|
registerSound(203, aTextIC2Lower + ":" + "machines.CompressorOp");
|
||||||
sSoundList.put(204, aTextIC2Lower + ":" + "machines.RecyclerOp");
|
registerSound(204, aTextIC2Lower + ":" + "machines.RecyclerOp");
|
||||||
sSoundList.put(205, aTextIC2Lower + ":" + "machines.MinerOp");
|
registerSound(205, aTextIC2Lower + ":" + "machines.MinerOp");
|
||||||
sSoundList.put(206, aTextIC2Lower + ":" + "machines.PumpOp");
|
registerSound(206, aTextIC2Lower + ":" + "machines.PumpOp");
|
||||||
sSoundList.put(207, aTextIC2Lower + ":" + "machines.ElectroFurnaceLoop");
|
registerSound(207, aTextIC2Lower + ":" + "machines.ElectroFurnaceLoop");
|
||||||
sSoundList.put(208, aTextIC2Lower + ":" + "machines.InductionLoop");
|
registerSound(208, aTextIC2Lower + ":" + "machines.InductionLoop");
|
||||||
sSoundList.put(209, aTextIC2Lower + ":" + "machines.MachineOverload");
|
registerSound(209, aTextIC2Lower + ":" + "machines.MachineOverload");
|
||||||
sSoundList.put(210, aTextIC2Lower + ":" + "machines.InterruptOne");
|
registerSound(210, aTextIC2Lower + ":" + "machines.InterruptOne");
|
||||||
sSoundList.put(211, aTextIC2Lower + ":" + "machines.KaChing");
|
registerSound(211, aTextIC2Lower + ":" + "machines.KaChing");
|
||||||
sSoundList.put(212, aTextIC2Lower + ":" + "machines.MagnetizerLoop");
|
registerSound(212, aTextIC2Lower + ":" + "machines.MagnetizerLoop");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerSound(int id, String name) {
|
||||||
|
ResourceLocation loc = new ResourceLocation(name);
|
||||||
|
SoundEvent e = new SoundEvent(loc);
|
||||||
|
if(!SoundEvent.REGISTRY.containsKey(loc)) {
|
||||||
|
SoundEvent.REGISTRY.register(size++, loc, e);
|
||||||
|
}
|
||||||
|
sSoundList.put(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ package gregtech.api.metatileentity;
|
||||||
|
|
||||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||||
import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
|
import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
|
||||||
|
import gregtech.api.net.GT_Packet_Block_Event;
|
||||||
import gregtech.api.util.GT_Utility;
|
import gregtech.api.util.GT_Utility;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -472,7 +473,14 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void sendBlockEvent(byte aID, byte aValue) {
|
public final void sendBlockEvent(byte aID, byte aValue) {
|
||||||
//NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(getXCoord(), (short) getYCoord(), getZCoord(), aID, aValue), getXCoord(), getZCoord());
|
NW.sendToAllAround(worldObj, new GT_Packet_Block_Event(getXCoord(),
|
||||||
|
(short) getYCoord(),
|
||||||
|
getZCoord(),
|
||||||
|
aID,
|
||||||
|
aValue),
|
||||||
|
getXCoord(),
|
||||||
|
getYCoord(),
|
||||||
|
getZCoord());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean crossedChunkBorder(int aX, int aZ) {
|
private boolean crossedChunkBorder(int aX, int aZ) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class GT_PacketHandler extends SimpleNetworkWrapper {
|
||||||
super("gregtech_network");
|
super("gregtech_network");
|
||||||
registerMessage(0, GT_Packet_TileEntity.class, Side.CLIENT);
|
registerMessage(0, GT_Packet_TileEntity.class, Side.CLIENT);
|
||||||
registerMessage(2, GT_Packet_Sound.class, Side.CLIENT);
|
registerMessage(2, GT_Packet_Sound.class, Side.CLIENT);
|
||||||
|
registerMessage(3, GT_Packet_Block_Event.class, Side.CLIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerMessage(int discriminator, Class packet, Side handleSide) {
|
public void registerMessage(int discriminator, Class packet, Side handleSide) {
|
||||||
|
|
55
src/main/java/gregtech/api/net/GT_Packet_Block_Event.java
Normal file
55
src/main/java/gregtech/api/net/GT_Packet_Block_Event.java
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package gregtech.api.net;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to transfer Block Events in a much better fashion
|
||||||
|
*/
|
||||||
|
public class GT_Packet_Block_Event extends GT_Packet {
|
||||||
|
private int mX, mZ;
|
||||||
|
private short mY;
|
||||||
|
private byte mID, mValue;
|
||||||
|
|
||||||
|
public GT_Packet_Block_Event() {}
|
||||||
|
|
||||||
|
public GT_Packet_Block_Event(int aX, short aY, int aZ, byte aID, byte aValue) {
|
||||||
|
mX = aX;
|
||||||
|
mY = aY;
|
||||||
|
mZ = aZ;
|
||||||
|
mID = aID;
|
||||||
|
mValue = aValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void encode(ByteBuf buf) {
|
||||||
|
buf.writeInt(mX);
|
||||||
|
buf.writeShort(mY);
|
||||||
|
buf.writeInt(mZ);
|
||||||
|
buf.writeByte(mID);
|
||||||
|
buf.writeByte(mValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decode(ByteBuf buf) {
|
||||||
|
mX = buf.readInt();
|
||||||
|
mY = buf.readShort();
|
||||||
|
mZ = buf.readInt();
|
||||||
|
mID = buf.readByte();
|
||||||
|
mValue = buf.readByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(World aWorld) {
|
||||||
|
if (aWorld != null) {
|
||||||
|
TileEntity tTileEntity = aWorld.getTileEntity(new BlockPos(mX, mY, mZ));
|
||||||
|
if (tTileEntity != null) tTileEntity.receiveClientEvent(mID, mValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,8 +33,7 @@ public class GT_Runnable_Sound implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
SoundEvent soundEvent = SoundEvent.REGISTRY.getObject(mSoundLocation);
|
SoundEvent soundEvent = SoundEvent.REGISTRY.getObject(mSoundLocation);
|
||||||
if(soundEvent != null) {
|
if(soundEvent != null) {
|
||||||
PositionedSound sound = new PositionedSound(soundEvent, SoundCategory.BLOCKS) {};
|
mWorld.playSound((double)mX, (double)mY, (double)mZ, soundEvent, SoundCategory.BLOCKS, 1.0f, 1.0f, false);
|
||||||
Minecraft.getMinecraft().getSoundHandler().playSound(sound);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue