mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-11 15:57:31 +00:00
Add new files
This commit is contained in:
1 parent
28f8a41d0e
commit
48380bee4a
2 files changed
+119
No files matched your search
@@ -0,0 +1,58 @@
|
||||
package com.cricketcraft.chisel.network.message;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvingVariation;
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
import com.cricketcraft.chisel.item.chisel.ItemChisel;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class MessageChiselSound implements IMessage {
|
||||
|
||||
public MessageChiselSound() {
|
||||
}
|
||||
|
||||
private int x, y, z;
|
||||
private int block;
|
||||
private byte meta;
|
||||
|
||||
public MessageChiselSound(int x, int y, int z, CarvingVariation v) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.block = Block.getIdFromBlock(v.block);
|
||||
this.meta = (byte) v.meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(block);
|
||||
buf.writeByte(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
block = buf.readInt();
|
||||
meta = buf.readByte();
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<MessageChiselSound, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageChiselSound message, MessageContext ctx) {
|
||||
String sound = ItemChisel.carving.getVariationSound(Block.getBlockById(message.block), message.meta);
|
||||
GeneralChiselClient.spawnChiselEffect(message.x, message.y, message.z, sound);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.cricketcraft.chisel.network.message;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class MessageSlotUpdate implements IMessage {
|
||||
|
||||
public MessageSlotUpdate() {
|
||||
}
|
||||
|
||||
private int x, y, z;
|
||||
private int slot;
|
||||
private ItemStack stack;
|
||||
|
||||
public MessageSlotUpdate(TileEntity te, int slot, ItemStack stack) {
|
||||
this.x = te.xCoord;
|
||||
this.y = te.yCoord;
|
||||
this.z = te.zCoord;
|
||||
this.slot = slot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(slot);
|
||||
ByteBufUtils.writeItemStack(buf, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
this.slot = buf.readInt();
|
||||
this.stack = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<MessageSlotUpdate, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageSlotUpdate message, MessageContext ctx) {
|
||||
TileEntity te = Chisel.proxy.getClientWorld().getTileEntity(message.x, message.y, message.z);
|
||||
if (te != null && te instanceof IInventory) {
|
||||
((IInventory) te).setInventorySlotContents(message.slot, message.stack);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user