mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-25 14:44:35 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
a314fccd1b
commit
8f026dad8f
161 files changed
+14073
-12846
No files matched your search
@@ -3,6 +3,7 @@ package team.chisel.network;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import team.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import team.chisel.block.tileentity.TileEntityPresent;
|
||||
import team.chisel.client.gui.GuiAutoChisel;
|
||||
@@ -16,39 +17,41 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class ChiselGuiHandler implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch (ID) {
|
||||
case 0:
|
||||
return new ContainerChisel(player.inventory, new InventoryChiselSelection(player.getCurrentEquippedItem()));
|
||||
case 1:
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if (tileentity instanceof TileEntityAutoChisel)
|
||||
return new ContainerAutoChisel(player.inventory, (TileEntityAutoChisel) tileentity);
|
||||
case 2:
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity instanceof TileEntityPresent)
|
||||
return new ContainerPresent(player.inventory, (TileEntityPresent) tileEntity);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch (ID) {
|
||||
case 0:
|
||||
return new ContainerChisel(
|
||||
player.inventory,
|
||||
new InventoryChiselSelection(player.getCurrentEquippedItem()));
|
||||
case 1:
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if (tileentity instanceof TileEntityAutoChisel)
|
||||
return new ContainerAutoChisel(player.inventory, (TileEntityAutoChisel) tileentity);
|
||||
case 2:
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity instanceof TileEntityPresent)
|
||||
return new ContainerPresent(player.inventory, (TileEntityPresent) tileEntity);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch (ID) {
|
||||
case 0:
|
||||
return new GuiChisel(player.inventory, new InventoryChiselSelection(player.getCurrentEquippedItem()));
|
||||
case 1:
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if (tileentity instanceof TileEntityAutoChisel)
|
||||
return new GuiAutoChisel(player.inventory, (TileEntityAutoChisel) tileentity);
|
||||
case 2:
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity instanceof TileEntityPresent)
|
||||
return new GuiPresent(player.inventory, (TileEntityPresent) tileEntity);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch (ID) {
|
||||
case 0:
|
||||
return new GuiChisel(player.inventory, new InventoryChiselSelection(player.getCurrentEquippedItem()));
|
||||
case 1:
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if (tileentity instanceof TileEntityAutoChisel)
|
||||
return new GuiAutoChisel(player.inventory, (TileEntityAutoChisel) tileentity);
|
||||
case 2:
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity instanceof TileEntityPresent)
|
||||
return new GuiPresent(player.inventory, (TileEntityPresent) tileEntity);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,16 @@ import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class PacketHandler {
|
||||
|
||||
public static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(Chisel.MOD_ID);
|
||||
public static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(Chisel.MOD_ID);
|
||||
|
||||
public static void init() {
|
||||
int id = 0;
|
||||
public static void init() {
|
||||
int id = 0;
|
||||
|
||||
INSTANCE.registerMessage(MessageChiselSound.Handler.class, MessageChiselSound.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageSlotUpdate.Handler.class, MessageSlotUpdate.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageAutoChisel.Handler.class, MessageAutoChisel.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageChiselMode.Handler.class, MessageChiselMode.class, id++, Side.SERVER);
|
||||
INSTANCE.registerMessage(MessagePresentConnect.Handler.class, MessagePresentConnect.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageScrollUpdate.Handler.class, MessageScrollUpdate.class, id++, Side.SERVER);
|
||||
}
|
||||
INSTANCE.registerMessage(MessageChiselSound.Handler.class, MessageChiselSound.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageSlotUpdate.Handler.class, MessageSlotUpdate.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageAutoChisel.Handler.class, MessageAutoChisel.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageChiselMode.Handler.class, MessageChiselMode.class, id++, Side.SERVER);
|
||||
INSTANCE.registerMessage(MessagePresentConnect.Handler.class, MessagePresentConnect.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageScrollUpdate.Handler.class, MessageScrollUpdate.class, id++, Side.SERVER);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,65 @@
|
||||
package team.chisel.network.message;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import team.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import team.chisel.network.message.base.MessageCoords;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class MessageAutoChisel extends MessageCoords {
|
||||
|
||||
public MessageAutoChisel() {
|
||||
}
|
||||
public MessageAutoChisel() {}
|
||||
|
||||
ItemStack base;
|
||||
boolean playSound, breakChisel;
|
||||
int chiseled;
|
||||
ItemStack base;
|
||||
boolean playSound, breakChisel;
|
||||
int chiseled;
|
||||
|
||||
public MessageAutoChisel(TileEntityAutoChisel tile, int chiseled, boolean playSound, boolean breakChisel) {
|
||||
super(tile);
|
||||
this.base = tile.getStackInSlot(TileEntityAutoChisel.BASE);
|
||||
if (base != null) {
|
||||
base = base.copy();
|
||||
}
|
||||
this.playSound = playSound;
|
||||
this.breakChisel = breakChisel;
|
||||
this.chiseled = chiseled;
|
||||
}
|
||||
public MessageAutoChisel(TileEntityAutoChisel tile, int chiseled, boolean playSound, boolean breakChisel) {
|
||||
super(tile);
|
||||
this.base = tile.getStackInSlot(TileEntityAutoChisel.BASE);
|
||||
if (base != null) {
|
||||
base = base.copy();
|
||||
}
|
||||
this.playSound = playSound;
|
||||
this.breakChisel = breakChisel;
|
||||
this.chiseled = chiseled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeBoolean(playSound);
|
||||
buf.writeBoolean(breakChisel);
|
||||
buf.writeInt(chiseled);
|
||||
ByteBufUtils.writeItemStack(buf, base);
|
||||
}
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeBoolean(playSound);
|
||||
buf.writeBoolean(breakChisel);
|
||||
buf.writeInt(chiseled);
|
||||
ByteBufUtils.writeItemStack(buf, base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
this.playSound = buf.readBoolean();
|
||||
this.breakChisel = buf.readBoolean();
|
||||
this.chiseled = buf.readInt();
|
||||
this.base = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
this.playSound = buf.readBoolean();
|
||||
this.breakChisel = buf.readBoolean();
|
||||
this.chiseled = buf.readInt();
|
||||
this.base = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<MessageAutoChisel, IMessage> {
|
||||
public static class Handler implements IMessageHandler<MessageAutoChisel, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageAutoChisel message, MessageContext ctx) {
|
||||
@Override
|
||||
public IMessage onMessage(MessageAutoChisel message, MessageContext ctx) {
|
||||
|
||||
TileEntity te = message.getTileEntity(ctx);
|
||||
if (te instanceof TileEntityAutoChisel) {
|
||||
((TileEntityAutoChisel) te).doChiselAnim(message.base, message.chiseled, message.playSound, message.breakChisel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
TileEntity te = message.getTileEntity(ctx);
|
||||
if (te instanceof TileEntityAutoChisel) {
|
||||
((TileEntityAutoChisel) te)
|
||||
.doChiselAnim(message.base, message.chiseled, message.playSound, message.breakChisel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +1,53 @@
|
||||
package team.chisel.network.message;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import team.chisel.item.chisel.ChiselMode;
|
||||
import team.chisel.utils.General;
|
||||
|
||||
import com.cricketcraft.chisel.api.IAdvancedChisel;
|
||||
import com.cricketcraft.chisel.api.IChiselItem;
|
||||
import com.cricketcraft.chisel.api.carving.IChiselMode;
|
||||
|
||||
import team.chisel.item.chisel.ChiselMode;
|
||||
import team.chisel.utils.General;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class MessageChiselMode implements IMessage {
|
||||
|
||||
public MessageChiselMode() {
|
||||
}
|
||||
public MessageChiselMode() {}
|
||||
|
||||
private String mode;
|
||||
private String mode;
|
||||
|
||||
public MessageChiselMode(IChiselMode iChiselMode) {
|
||||
this.mode = iChiselMode.name();
|
||||
}
|
||||
public MessageChiselMode(IChiselMode iChiselMode) {
|
||||
this.mode = iChiselMode.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, mode);
|
||||
}
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.mode = ByteBufUtils.readUTF8String(buf);
|
||||
}
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.mode = ByteBufUtils.readUTF8String(buf);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<MessageChiselMode, IMessage> {
|
||||
public static class Handler implements IMessageHandler<MessageChiselMode, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageChiselMode message, MessageContext ctx) {
|
||||
ItemStack stack = ctx.getServerHandler().playerEntity.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() instanceof IChiselItem) {
|
||||
if (stack.getItem() instanceof IAdvancedChisel) {
|
||||
General.setChiselMode(stack, ((IAdvancedChisel) stack.getItem()).getMode(stack, message.mode));
|
||||
} else {
|
||||
General.setChiselMode(stack, ChiselMode.valueOf(message.mode));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IMessage onMessage(MessageChiselMode message, MessageContext ctx) {
|
||||
ItemStack stack = ctx.getServerHandler().playerEntity.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() instanceof IChiselItem) {
|
||||
if (stack.getItem() instanceof IAdvancedChisel) {
|
||||
General.setChiselMode(stack, ((IAdvancedChisel) stack.getItem()).getMode(stack, message.mode));
|
||||
} else {
|
||||
General.setChiselMode(stack, ChiselMode.valueOf(message.mode));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +1,64 @@
|
||||
package team.chisel.network.message;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import team.chisel.item.chisel.ItemChisel;
|
||||
import team.chisel.network.message.base.MessageCoords;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
|
||||
public class MessageChiselSound extends MessageCoords {
|
||||
|
||||
public MessageChiselSound() {
|
||||
super();
|
||||
}
|
||||
public MessageChiselSound() {
|
||||
super();
|
||||
}
|
||||
|
||||
private int block;
|
||||
private byte meta;
|
||||
private boolean breakChisel;
|
||||
private int block;
|
||||
private byte meta;
|
||||
private boolean breakChisel;
|
||||
|
||||
public MessageChiselSound(int x, int y, int z, ICarvingVariation v, boolean breakChisel) {
|
||||
super(x, y, z);
|
||||
this.block = Block.getIdFromBlock(v.getBlock());
|
||||
this.meta = (byte) v.getBlockMeta();
|
||||
this.breakChisel = breakChisel;
|
||||
}
|
||||
public MessageChiselSound(int x, int y, int z, ICarvingVariation v, boolean breakChisel) {
|
||||
super(x, y, z);
|
||||
this.block = Block.getIdFromBlock(v.getBlock());
|
||||
this.meta = (byte) v.getBlockMeta();
|
||||
this.breakChisel = breakChisel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(block);
|
||||
buf.writeByte(meta);
|
||||
buf.writeBoolean(breakChisel);
|
||||
}
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(block);
|
||||
buf.writeByte(meta);
|
||||
buf.writeBoolean(breakChisel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
block = buf.readInt();
|
||||
meta = buf.readByte();
|
||||
breakChisel = buf.readBoolean();
|
||||
}
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
block = buf.readInt();
|
||||
meta = buf.readByte();
|
||||
breakChisel = buf.readBoolean();
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<MessageChiselSound, IMessage> {
|
||||
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);
|
||||
if (message.breakChisel) {
|
||||
EntityPlayer player = Chisel.proxy.getClientPlayer();
|
||||
player.renderBrokenItemStack(player.getCurrentEquippedItem());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@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);
|
||||
if (message.breakChisel) {
|
||||
EntityPlayer player = Chisel.proxy.getClientPlayer();
|
||||
player.renderBrokenItemStack(player.getCurrentEquippedItem());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,66 @@
|
||||
package team.chisel.network.message;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import team.chisel.block.tileentity.TileEntityPresent;
|
||||
import team.chisel.network.message.base.MessageCoords;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
|
||||
public class MessagePresentConnect extends MessageCoords {
|
||||
|
||||
private ForgeDirection dir;
|
||||
private boolean connect, preserveDir;
|
||||
private ForgeDirection dir;
|
||||
private boolean connect, preserveDir;
|
||||
|
||||
public MessagePresentConnect() {
|
||||
super();
|
||||
}
|
||||
public MessagePresentConnect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MessagePresentConnect(TileEntityPresent present, ForgeDirection dir, boolean connecting) {
|
||||
this(present, dir, connecting, false);
|
||||
}
|
||||
public MessagePresentConnect(TileEntityPresent present, ForgeDirection dir, boolean connecting) {
|
||||
this(present, dir, connecting, false);
|
||||
}
|
||||
|
||||
public MessagePresentConnect(TileEntityPresent present, ForgeDirection dir, boolean connecting, boolean preserveDir) {
|
||||
super(present);
|
||||
this.dir = dir;
|
||||
this.connect = connecting;
|
||||
this.preserveDir = preserveDir;
|
||||
}
|
||||
public MessagePresentConnect(TileEntityPresent present, ForgeDirection dir, boolean connecting,
|
||||
boolean preserveDir) {
|
||||
super(present);
|
||||
this.dir = dir;
|
||||
this.connect = connecting;
|
||||
this.preserveDir = preserveDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(dir.ordinal());
|
||||
buf.writeBoolean(connect);
|
||||
buf.writeBoolean(preserveDir);
|
||||
}
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(dir.ordinal());
|
||||
buf.writeBoolean(connect);
|
||||
buf.writeBoolean(preserveDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
dir = ForgeDirection.values()[buf.readInt()];
|
||||
connect = buf.readBoolean();
|
||||
preserveDir = buf.readBoolean();
|
||||
}
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
dir = ForgeDirection.values()[buf.readInt()];
|
||||
connect = buf.readBoolean();
|
||||
preserveDir = buf.readBoolean();
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<MessagePresentConnect, IMessage> {
|
||||
public static class Handler implements IMessageHandler<MessagePresentConnect, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessagePresentConnect message, MessageContext ctx) {
|
||||
TileEntity te = message.getTileEntity(ctx);
|
||||
if (te instanceof TileEntityPresent) {
|
||||
if (message.connect) {
|
||||
((TileEntityPresent) te).connectTo(message.dir);
|
||||
} else {
|
||||
((TileEntityPresent) te).disconnect(message.preserveDir);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IMessage onMessage(MessagePresentConnect message, MessageContext ctx) {
|
||||
TileEntity te = message.getTileEntity(ctx);
|
||||
if (te instanceof TileEntityPresent) {
|
||||
if (message.connect) {
|
||||
((TileEntityPresent) te).connectTo(message.dir);
|
||||
} else {
|
||||
((TileEntityPresent) te).disconnect(message.preserveDir);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package team.chisel.network.message;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import team.chisel.inventory.ContainerChisel;
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
import team.chisel.inventory.ContainerChisel;
|
||||
|
||||
public class MessageScrollUpdate implements IMessage {
|
||||
|
||||
private int currentScroll;
|
||||
|
||||
public MessageScrollUpdate() {
|
||||
}
|
||||
public MessageScrollUpdate() {}
|
||||
|
||||
public MessageScrollUpdate(int scroll) {
|
||||
currentScroll = scroll;
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
package team.chisel.network.message;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.network.message.base.MessageCoords;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.network.message.base.MessageCoords;
|
||||
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;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class MessageSlotUpdate extends MessageCoords {
|
||||
|
||||
public MessageSlotUpdate() {
|
||||
}
|
||||
public MessageSlotUpdate() {}
|
||||
|
||||
private int slot;
|
||||
private ItemStack stack;
|
||||
private int slot;
|
||||
private ItemStack stack;
|
||||
|
||||
public MessageSlotUpdate(TileEntity te, int slot, ItemStack stack) {
|
||||
super(te);
|
||||
this.slot = slot;
|
||||
this.stack = stack;
|
||||
}
|
||||
public MessageSlotUpdate(TileEntity te, int slot, ItemStack stack) {
|
||||
super(te);
|
||||
this.slot = slot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(slot);
|
||||
ByteBufUtils.writeItemStack(buf, stack);
|
||||
}
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeInt(slot);
|
||||
ByteBufUtils.writeItemStack(buf, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
this.slot = buf.readInt();
|
||||
this.stack = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
this.slot = buf.readInt();
|
||||
this.stack = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<MessageSlotUpdate, IMessage> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +1,60 @@
|
||||
package team.chisel.network.message.base;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public abstract class MessageCoords implements IMessage {
|
||||
|
||||
public int x, y, z;
|
||||
public int x, y, z;
|
||||
|
||||
protected MessageCoords() {
|
||||
;
|
||||
}
|
||||
protected MessageCoords() {
|
||||
;
|
||||
}
|
||||
|
||||
protected MessageCoords(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
protected MessageCoords(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
protected MessageCoords(TileEntity te) {
|
||||
this(te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
protected MessageCoords(TileEntity te) {
|
||||
this(te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
}
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
}
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
}
|
||||
|
||||
protected Block getBlock(MessageContext ctx) {
|
||||
return getWorld(ctx).getBlock(x, y, z);
|
||||
}
|
||||
protected Block getBlock(MessageContext ctx) {
|
||||
return getWorld(ctx).getBlock(x, y, z);
|
||||
}
|
||||
|
||||
protected TileEntity getTileEntity(MessageContext ctx) {
|
||||
return getWorld(ctx).getTileEntity(x, y, z);
|
||||
}
|
||||
protected TileEntity getTileEntity(MessageContext ctx) {
|
||||
return getWorld(ctx).getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
protected World getWorld(MessageContext ctx) {
|
||||
if (ctx.side == Side.CLIENT) {
|
||||
return Chisel.proxy.getClientWorld();
|
||||
} else {
|
||||
return ctx.getServerHandler().playerEntity.worldObj;
|
||||
}
|
||||
}
|
||||
protected World getWorld(MessageContext ctx) {
|
||||
if (ctx.side == Side.CLIENT) {
|
||||
return Chisel.proxy.getClientWorld();
|
||||
} else {
|
||||
return ctx.getServerHandler().playerEntity.worldObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user