mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
104 lines
3.0 KiB
Java
104 lines
3.0 KiB
Java
package com.hbm.packet;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import com.hbm.entity.logic.EntityBomber;
|
|
import com.hbm.main.ResourceManager;
|
|
import com.hbm.sound.MovingSoundBomber;
|
|
import com.hbm.sound.SoundLoopAssembler;
|
|
import com.hbm.sound.SoundLoopBroadcaster;
|
|
import com.hbm.sound.SoundLoopCentrifuge;
|
|
import com.hbm.sound.SoundLoopChemplant;
|
|
import com.hbm.sound.SoundLoopIGen;
|
|
import com.hbm.sound.SoundLoopMiner;
|
|
import com.hbm.sound.SoundLoopTurbofan;
|
|
import com.hbm.tileentity.machine.TileEntityBroadcaster;
|
|
import com.hbm.tileentity.machine.TileEntityMachineAssembler;
|
|
import com.hbm.tileentity.machine.TileEntityMachineCentrifuge;
|
|
import com.hbm.tileentity.machine.TileEntityMachineChemplant;
|
|
import com.hbm.tileentity.machine.TileEntityMachineGasCent;
|
|
import com.hbm.tileentity.machine.TileEntityMachineIGenerator;
|
|
import com.hbm.tileentity.machine.TileEntityMachineMiningDrill;
|
|
import com.hbm.tileentity.machine.TileEntityMachineTurbofan;
|
|
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import io.netty.buffer.ByteBuf;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
public class LoopedEntitySoundPacket implements IMessage {
|
|
|
|
int entityID;
|
|
|
|
public LoopedEntitySoundPacket()
|
|
{
|
|
|
|
}
|
|
|
|
public LoopedEntitySoundPacket(int entityID)
|
|
{
|
|
this.entityID = entityID;
|
|
}
|
|
|
|
@Override
|
|
public void fromBytes(ByteBuf buf) {
|
|
entityID = buf.readInt();
|
|
}
|
|
|
|
@Override
|
|
public void toBytes(ByteBuf buf) {
|
|
buf.writeInt(entityID);
|
|
}
|
|
|
|
public static class Handler implements IMessageHandler<LoopedEntitySoundPacket, IMessage> {
|
|
|
|
@Override
|
|
//Tamaized, I love you!
|
|
@SideOnly(Side.CLIENT)
|
|
public IMessage onMessage(LoopedEntitySoundPacket m, MessageContext ctx) {
|
|
|
|
Entity e = Minecraft.getMinecraft().theWorld.getEntityByID(m.entityID);
|
|
|
|
if(e instanceof EntityBomber) {
|
|
|
|
int n = 1;
|
|
int x = e.getDataWatcher().getWatchableObjectByte(16);
|
|
|
|
switch(x) {
|
|
case 0:
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
case 4: n = 2; break;
|
|
case 5:
|
|
case 6:
|
|
case 7:
|
|
case 8: n = 1; break;
|
|
default: n = 2; break;
|
|
}
|
|
|
|
boolean flag = true;
|
|
for(int i = 0; i < MovingSoundBomber.globalSoundList.size(); i++) {
|
|
if(MovingSoundBomber.globalSoundList.get(i).bomber == e && !MovingSoundBomber.globalSoundList.get(i).isDonePlaying())
|
|
flag = false;
|
|
}
|
|
|
|
if(flag) {
|
|
if(n == 2)
|
|
Minecraft.getMinecraft().getSoundHandler().playSound(new MovingSoundBomber(new ResourceLocation("hbm:entity.bomberSmallLoop"), (EntityBomber)e));
|
|
if(n == 1)
|
|
Minecraft.getMinecraft().getSoundHandler().playSound(new MovingSoundBomber(new ResourceLocation("hbm:entity.bomberLoop"), (EntityBomber)e));
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|