Fix JABBA-related issues with crafting station slots (#54)

* Fix shift-merging tools voiding items

fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392>

* Change 0-sized ItemStacks into null stacks in crafting station attached slots

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425>

* Update buildscript

* spotlessApply
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-09-22 20:51:23 +02:00
1 parent 18bfeaff32
commit 39be06c23b
571 files changed
+25959 -28223

No files matched your search

@@ -10,58 +10,63 @@ import tconstruct.armor.ArmorProxyCommon;
import tconstruct.armor.TinkerArmor;
import tconstruct.armor.player.TPlayerStats;
public class AccessoryInventoryPacket extends AbstractPacket
{
public class AccessoryInventoryPacket extends AbstractPacket {
int type;
public AccessoryInventoryPacket()
{
public AccessoryInventoryPacket() {}
}
public AccessoryInventoryPacket(int type)
{
public AccessoryInventoryPacket(int type) {
this.type = type;
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
buffer.writeInt(type);
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
type = buffer.readInt();
}
@Override
public void handleClientSide (EntityPlayer player)
{
}
public void handleClientSide(EntityPlayer player) {}
@Override
public void handleServerSide (EntityPlayer player)
{
switch (type)
{
case ArmorProxyCommon.inventoryGui:
player.openGui(TConstruct.instance, ArmorProxyCommon.inventoryGui, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
case ArmorProxyCommon.armorGuiID:
player.openGui(TConstruct.instance, ArmorProxyCommon.armorGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
case ArmorProxyCommon.knapsackGuiID:
TPlayerStats stats = TPlayerStats.get(player);
ItemStack itemStack = stats.armor.getStackInSlot(2);
if (itemStack != null && itemStack.getItem() == TinkerArmor.knapsack && itemStack.stackSize > 0)
{
player.openGui(TConstruct.instance, ArmorProxyCommon.knapsackGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
}
break;
public void handleServerSide(EntityPlayer player) {
switch (type) {
case ArmorProxyCommon.inventoryGui:
player.openGui(
TConstruct.instance,
ArmorProxyCommon.inventoryGui,
player.worldObj,
(int) player.posX,
(int) player.posY,
(int) player.posZ);
break;
case ArmorProxyCommon.armorGuiID:
player.openGui(
TConstruct.instance,
ArmorProxyCommon.armorGuiID,
player.worldObj,
(int) player.posX,
(int) player.posY,
(int) player.posZ);
break;
case ArmorProxyCommon.knapsackGuiID:
TPlayerStats stats = TPlayerStats.get(player);
ItemStack itemStack = stats.armor.getStackInSlot(2);
if (itemStack != null && itemStack.getItem() == TinkerArmor.knapsack && itemStack.stackSize > 0) {
player.openGui(
TConstruct.instance,
ArmorProxyCommon.knapsackGuiID,
player.worldObj,
(int) player.posX,
(int) player.posY,
(int) player.posZ);
}
break;
}
}
}
@@ -1,61 +1,50 @@
package tconstruct.util.network;
import tconstruct.TConstruct;
import tconstruct.armor.TinkerArmor;
import tconstruct.armor.player.TPlayerStats;
import cpw.mods.fml.common.network.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import mantle.common.network.AbstractPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.armor.TinkerArmor;
import tconstruct.armor.player.TPlayerStats;
/**
* This Packet is for sending the players TPlayerStats from the server to the client.
*
*
* @author covers1624
*/
public class ArmourGuiSyncPacket extends AbstractPacket
{
public class ArmourGuiSyncPacket extends AbstractPacket {
NBTTagCompound playerStats = new NBTTagCompound();
public ArmourGuiSyncPacket()
{
}
public ArmourGuiSyncPacket() {}
/**
* For sending the players TPlayerStats to the client.
* @param tag, The players TPlayerStats written to NBT.
*/
public ArmourGuiSyncPacket(NBTTagCompound tag)
{
public ArmourGuiSyncPacket(NBTTagCompound tag) {
playerStats = tag;
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
ByteBufUtils.writeTag(buffer, playerStats);
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
playerStats = ByteBufUtils.readTag(buffer);
}
@Override
public void handleClientSide (EntityPlayer player)
{
public void handleClientSide(EntityPlayer player) {
TPlayerStats stats = new TPlayerStats(player);
stats.loadNBTData(playerStats);
TinkerArmor.proxy.updatePlayerStats(stats);
}
@Override
public void handleServerSide (EntityPlayer player)
{
//NO-OP. this is a Server -> client packet.
public void handleServerSide(EntityPlayer player) {
// NO-OP. this is a Server -> client packet.
}
}
@@ -7,32 +7,20 @@ import net.minecraft.entity.player.EntityPlayer;
import tconstruct.armor.PlayerAbilityHelper;
import tconstruct.armor.player.TPlayerStats;
public class BeltPacket extends AbstractPacket
{
public BeltPacket()
{
}
public class BeltPacket extends AbstractPacket {
public BeltPacket() {}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
}
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
}
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {}
@Override
public void handleClientSide (EntityPlayer player)
{
}
public void handleClientSide(EntityPlayer player) {}
@Override
public void handleServerSide (EntityPlayer player)
{
public void handleServerSide(EntityPlayer player) {
PlayerAbilityHelper.swapBelt(player, TPlayerStats.get(player).armor);
}
}
@@ -5,33 +5,21 @@ import io.netty.channel.ChannelHandlerContext;
import mantle.common.network.AbstractPacket;
import net.minecraft.entity.player.EntityPlayer;
public class DoubleJumpPacket extends AbstractPacket
{
public class DoubleJumpPacket extends AbstractPacket {
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
}
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
}
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {}
@Override
public void handleClientSide (EntityPlayer player)
{
}
public void handleClientSide(EntityPlayer player) {}
@Override
public void handleServerSide (EntityPlayer player)
{
public void handleServerSide(EntityPlayer player) {
// String user = inputStream.readUTF();
// EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
player.fallDistance = 0;
}
}
@@ -6,43 +6,32 @@ import mantle.common.network.AbstractPacket;
import net.minecraft.entity.player.EntityPlayer;
import tconstruct.armor.PlayerAbilityHelper;
public class GogglePacket extends AbstractPacket
{
public class GogglePacket extends AbstractPacket {
boolean active;
public GogglePacket()
{
}
public GogglePacket() {}
public GogglePacket(boolean active)
{
public GogglePacket(boolean active) {
this.active = active;
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
buffer.writeBoolean(active);
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
active = buffer.readBoolean();
}
@Override
public void handleClientSide (EntityPlayer player)
{
}
public void handleClientSide(EntityPlayer player) {}
@Override
public void handleServerSide (EntityPlayer player)
{
public void handleServerSide(EntityPlayer player) {
PlayerAbilityHelper.toggleGoggles(player, active);
/*TPlayerStats stats = TPlayerStats.get(player);
stats.activeGoggles = active;*/
}
}
@@ -1,20 +1,16 @@
package tconstruct.util.network;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import mantle.common.network.AbstractPacket;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.armor.ArmorProxyClient;
import tconstruct.armor.player.TPlayerStats;
public class HealthUpdatePacket extends AbstractPacket {
private float health;
public HealthUpdatePacket() {
}
public HealthUpdatePacket() {}
public HealthUpdatePacket(float health) {
this.health = health;
@@ -38,7 +34,5 @@ public class HealthUpdatePacket extends AbstractPacket {
}
@Override
public void handleServerSide(EntityPlayer player) {
}
public void handleServerSide(EntityPlayer player) {}
}
@@ -4,7 +4,6 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import mantle.common.network.AbstractPacket;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
public class MovementUpdatePacket extends AbstractPacket {
@@ -15,8 +14,7 @@ public class MovementUpdatePacket extends AbstractPacket {
public float yaw;
public float pitch;
public MovementUpdatePacket() {
}
public MovementUpdatePacket() {}
public MovementUpdatePacket(Entity entity) {
this.entityID = entity.getEntityId();
@@ -50,7 +48,7 @@ public class MovementUpdatePacket extends AbstractPacket {
@Override
public void handleClientSide(EntityPlayer player) {
Entity entity = player.worldObj.getEntityByID(entityID);
if(entity != null) {
if (entity != null) {
entity.motionX = x;
entity.motionY = y;
entity.motionZ = z;
@@ -16,12 +16,11 @@ import net.minecraft.network.*;
/**
* Packet pipeline class. Directs all registered packet data to be handled by
* the packets themselves.
*
*
* @author sirgingalot some code from: cpw
*/
@ChannelHandler.Sharable
public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket>
{
public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket> {
private EnumMap<Side, FMLEmbeddedChannel> channels;
private LinkedList<Class<? extends AbstractPacket>> packets = new LinkedList<Class<? extends AbstractPacket>>();
@@ -30,30 +29,26 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
/**
* Register your packet with the pipeline. Discriminators are automatically
* set.
*
*
* @param clazz
* the class to register
*
*
* @return whether registration was successful. Failure may occur if 256
* packets have been registered or if the registry already contains
* this packet
*/
public boolean registerPacket (Class<? extends AbstractPacket> clazz)
{
if (this.packets.size() > 256)
{
public boolean registerPacket(Class<? extends AbstractPacket> clazz) {
if (this.packets.size() > 256) {
// You should log here!!
return false;
}
if (this.packets.contains(clazz))
{
if (this.packets.contains(clazz)) {
// You should log here!!
return false;
}
if (this.isPostInitialised)
{
if (this.isPostInitialised) {
// You should log here!!
return false;
}
@@ -64,31 +59,29 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
// In line encoding of the packet, including discriminator setting
@Override
protected void encode (ChannelHandlerContext ctx, AbstractPacket msg, List<Object> out) throws Exception
{
protected void encode(ChannelHandlerContext ctx, AbstractPacket msg, List<Object> out) throws Exception {
ByteBuf buffer = Unpooled.buffer();
Class<? extends AbstractPacket> clazz = msg.getClass();
if (!this.packets.contains(msg.getClass()))
{
throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName());
if (!this.packets.contains(msg.getClass())) {
throw new NullPointerException(
"No Packet Registered for: " + msg.getClass().getCanonicalName());
}
byte discriminator = (byte) this.packets.indexOf(clazz);
buffer.writeByte(discriminator);
msg.encodeInto(ctx, buffer);
FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
FMLProxyPacket proxyPacket = new FMLProxyPacket(
buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
out.add(proxyPacket);
}
// In line decoding and handling of the packet
@Override
protected void decode (ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
{
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
ByteBuf payload = msg.payload();
byte discriminator = payload.readByte();
Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);
if (clazz == null)
{
if (clazz == null) {
throw new NullPointerException("No packet registered for discriminator: " + discriminator);
}
@@ -96,32 +89,30 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
pkt.decodeInto(ctx, payload.slice());
EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide())
{
case CLIENT:
player = this.getClientPlayer();
pkt.handleClientSide(player);
break;
switch (FMLCommonHandler.instance().getEffectiveSide()) {
case CLIENT:
player = this.getClientPlayer();
pkt.handleClientSide(player);
break;
case SERVER:
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player = ((NetHandlerPlayServer) netHandler).playerEntity;
pkt.handleServerSide(player);
break;
case SERVER:
INetHandler netHandler =
ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player = ((NetHandlerPlayServer) netHandler).playerEntity;
pkt.handleServerSide(player);
break;
default:
default:
}
}
// Method to call from FMLInitializationEvent
public void initalise ()
{
public void initalise() {
this.channels = NetworkRegistry.INSTANCE.newChannel("TConstruct", this);
registerPackets();
}
public void registerPackets ()
{
public void registerPackets() {
registerPacket(HealthUpdatePacket.class);
registerPacket(DoubleJumpPacket.class);
registerPacket(AccessoryInventoryPacket.class);
@@ -135,30 +126,25 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
registerPacket(GogglePacket.class);
registerPacket(MovementUpdatePacket.class);
registerPacket(ArmourGuiSyncPacket.class);
}
// Method to call from FMLPostInitializationEvent
// Ensures that packet discriminators are common between server and client
// by using logical sorting
public void postInitialise ()
{
if (this.isPostInitialised)
{
public void postInitialise() {
if (this.isPostInitialised) {
return;
}
this.isPostInitialised = true;
Collections.sort(this.packets, new Comparator<Class<? extends AbstractPacket>>()
{
Collections.sort(this.packets, new Comparator<Class<? extends AbstractPacket>>() {
@Override
public int compare (Class<? extends AbstractPacket> clazz1, Class<? extends AbstractPacket> clazz2)
{
public int compare(Class<? extends AbstractPacket> clazz1, Class<? extends AbstractPacket> clazz2) {
int com = String.CASE_INSENSITIVE_ORDER.compare(clazz1.getCanonicalName(), clazz2.getCanonicalName());
if (com == 0)
{
if (com == 0) {
com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName());
}
@@ -168,8 +154,7 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
}
@SideOnly(Side.CLIENT)
private EntityPlayer getClientPlayer ()
{
private EntityPlayer getClientPlayer() {
return Minecraft.getMinecraft().thePlayer;
}
@@ -178,13 +163,15 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
*
* @param message
* The message to send
*/
public void sendToAll (AbstractPacket message)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
public void sendToAll(AbstractPacket message) {
this.channels
.get(Side.SERVER)
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(FMLOutboundHandler.OutboundTarget.ALL);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
@@ -193,16 +180,21 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
*
* @param message
* The message to send
* @param player
* The player to send it to
*/
public void sendTo (AbstractPacket message, EntityPlayerMP player)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
public void sendTo(AbstractPacket message, EntityPlayerMP player) {
this.channels
.get(Side.SERVER)
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(FMLOutboundHandler.OutboundTarget.PLAYER);
this.channels
.get(Side.SERVER)
.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS)
.set(player);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
@@ -211,7 +203,7 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
*
* @param message
* The message to send
* @param point
@@ -219,10 +211,15 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
* {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint}
* around which to send
*/
public void sendToAllAround (AbstractPacket message, NetworkRegistry.TargetPoint point)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
public void sendToAllAround(AbstractPacket message, NetworkRegistry.TargetPoint point) {
this.channels
.get(Side.SERVER)
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
this.channels
.get(Side.SERVER)
.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS)
.set(point);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
@@ -231,16 +228,21 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
*
* @param message
* The message to send
* @param dimensionId
* The dimension id to target
*/
public void sendToDimension (AbstractPacket message, int dimensionId)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
public void sendToDimension(AbstractPacket message, int dimensionId) {
this.channels
.get(Side.SERVER)
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(FMLOutboundHandler.OutboundTarget.DIMENSION);
this.channels
.get(Side.SERVER)
.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS)
.set(dimensionId);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
@@ -249,13 +251,15 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
*
* @param message
* The message to send
*/
public void sendToServer (AbstractPacket message)
{
this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
public void sendToServer(AbstractPacket message) {
this.channels
.get(Side.CLIENT)
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(FMLOutboundHandler.OutboundTarget.TOSERVER);
this.channels.get(Side.CLIENT).writeAndFlush(message);
}
}
@@ -11,19 +11,14 @@ import tconstruct.library.crafting.StencilBuilder;
import tconstruct.tools.inventory.PatternShaperContainer;
import tconstruct.tools.logic.StencilTableLogic;
public class PatternTablePacket extends AbstractPacket
{
public class PatternTablePacket extends AbstractPacket {
int x, y, z;
ItemStack contents;
public PatternTablePacket()
{
public PatternTablePacket() {}
}
public PatternTablePacket(int x, int y, int z, ItemStack contents)
{
public PatternTablePacket(int x, int y, int z, ItemStack contents) {
this.x = x;
this.y = y;
this.z = z;
@@ -31,8 +26,7 @@ public class PatternTablePacket extends AbstractPacket
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
buffer.writeInt(x);
buffer.writeInt(y);
buffer.writeInt(z);
@@ -40,8 +34,7 @@ public class PatternTablePacket extends AbstractPacket
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
x = buffer.readInt();
y = buffer.readInt();
z = buffer.readInt();
@@ -49,40 +42,30 @@ public class PatternTablePacket extends AbstractPacket
}
@Override
public void handleClientSide (EntityPlayer player)
{
}
public void handleClientSide(EntityPlayer player) {}
@Override
public void handleServerSide (EntityPlayer player)
{
if (player.openContainer instanceof PatternShaperContainer)
{
public void handleServerSide(EntityPlayer player) {
if (player.openContainer instanceof PatternShaperContainer) {
PatternShaperContainer container = (PatternShaperContainer) player.openContainer;
StencilTableLogic logic = container.logic;
if (logic != null && logic.xCoord == this.x && logic.yCoord == this.y && logic.zCoord == this.z)
if (this.contents == null)
logic.setSelectedPattern(null);
else
{
if (this.contents == null) logic.setSelectedPattern(null);
else {
ItemStack stackBlank = logic.getStackInSlot(0);
if (stackBlank != null && stackBlank.stackSize > 0 && StencilBuilder.isBlank(stackBlank))
{
if (stackBlank != null && stackBlank.stackSize > 0 && StencilBuilder.isBlank(stackBlank)) {
boolean warning = true;
for (ItemStack stack : StencilBuilder.instance.stencils.values())
{
if (stack != null && this.contents.isItemEqual(stack))
{
for (ItemStack stack : StencilBuilder.instance.stencils.values()) {
if (stack != null && this.contents.isItemEqual(stack)) {
this.contents = stack.copy();
warning = false;
break;
}
}
if (warning)
TConstruct.logger.warn("Possible packet-cheating with PatternTable for player " + player.getCommandSenderName());
else
logic.setSelectedPattern(this.contents);
TConstruct.logger.warn("Possible packet-cheating with PatternTable for player "
+ player.getCommandSenderName());
else logic.setSelectedPattern(this.contents);
}
}
}
@@ -9,17 +9,13 @@ import net.minecraft.tileentity.TileEntity;
import tconstruct.TConstruct;
import tconstruct.tools.logic.BattlesignLogic;
public class SignDataPacket extends AbstractPacket
{
public class SignDataPacket extends AbstractPacket {
private int dimension, x, y, z, length;
private String[] text;
public SignDataPacket()
{
}
public SignDataPacket() {}
public SignDataPacket(int dimension, int x, int y, int z, String[] text)
{
public SignDataPacket(int dimension, int x, int y, int z, String[] text) {
this.text = text;
this.dimension = dimension;
this.x = x;
@@ -29,41 +25,35 @@ public class SignDataPacket extends AbstractPacket
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
buffer.writeInt(dimension);
buffer.writeInt(x);
buffer.writeInt(y);
buffer.writeInt(z);
buffer.writeInt(length);
for (int i = 0; i < length; i++)
{
for (int i = 0; i < length; i++) {
ByteBufUtils.writeUTF8String(buffer, text[i]);
}
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
dimension = buffer.readInt();
x = buffer.readInt();
y = buffer.readInt();
z = buffer.readInt();
length = buffer.readInt();
text = new String[length];
for (int i = 0; i < length; i++)
{
for (int i = 0; i < length; i++) {
text[i] = ByteBufUtils.readUTF8String(buffer);
}
}
@Override
public void handleClientSide (EntityPlayer player)
{
public void handleClientSide(EntityPlayer player) {
TileEntity te = player.worldObj.getTileEntity(x, y, z);
if (te instanceof BattlesignLogic)
{
if (te instanceof BattlesignLogic) {
BattlesignLogic logic = (BattlesignLogic) te;
logic.setText(text);
@@ -71,17 +61,14 @@ public class SignDataPacket extends AbstractPacket
}
@Override
public void handleServerSide (EntityPlayer player)
{
if (player.worldObj.blockExists(x, y, z))
{
public void handleServerSide(EntityPlayer player) {
if (player.worldObj.blockExists(x, y, z)) {
return;
}
TileEntity te = player.worldObj.getTileEntity(x, y, z);
if (te instanceof BattlesignLogic)
{
if (te instanceof BattlesignLogic) {
BattlesignLogic logic = (BattlesignLogic) te;
logic.setText(text);
@@ -11,19 +11,14 @@ import tconstruct.TConstruct;
import tconstruct.smeltery.inventory.SmelteryContainer;
import tconstruct.smeltery.logic.SmelteryLogic;
public class SmelteryPacket extends AbstractPacket
{
public class SmelteryPacket extends AbstractPacket {
int dimension, x, y, z, fluidID;
boolean isShiftPressed;
public SmelteryPacket()
{
public SmelteryPacket() {}
}
public SmelteryPacket(int dimension, int x, int y, int z, boolean isShiftPressed, int fluidID)
{
public SmelteryPacket(int dimension, int x, int y, int z, boolean isShiftPressed, int fluidID) {
this.dimension = dimension;
this.x = x;
this.y = y;
@@ -33,20 +28,17 @@ public class SmelteryPacket extends AbstractPacket
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
buffer.writeInt(dimension);
buffer.writeInt(x);
buffer.writeInt(y);
buffer.writeInt(z);
buffer.writeBoolean(isShiftPressed);
buffer.writeInt(fluidID);
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
dimension = buffer.readInt();
x = buffer.readInt();
y = buffer.readInt();
@@ -56,41 +48,36 @@ public class SmelteryPacket extends AbstractPacket
}
@Override
public void handleClientSide (EntityPlayer player)
{
}
public void handleClientSide(EntityPlayer player) {}
@Override
public void handleServerSide (EntityPlayer player)
{
if (player.openContainer instanceof SmelteryContainer)
{
public void handleServerSide(EntityPlayer player) {
if (player.openContainer instanceof SmelteryContainer) {
SmelteryContainer container = (SmelteryContainer) player.openContainer;
SmelteryLogic logic = container.logic;
if (logic != null && logic.hasWorldObj() && logic.getWorldObj().provider.dimensionId == this.dimension && logic.xCoord == this.x && logic.yCoord == this.y && logic.zCoord == this.z)
{
if (logic != null
&& logic.hasWorldObj()
&& logic.getWorldObj().provider.dimensionId == this.dimension
&& logic.xCoord == this.x
&& logic.yCoord == this.y
&& logic.zCoord == this.z) {
FluidStack temp = null;
for (FluidStack liquid : logic.moltenMetal)
{
if (liquid.getFluidID() == this.fluidID)
temp = liquid;
for (FluidStack liquid : logic.moltenMetal) {
if (liquid.getFluidID() == this.fluidID) temp = liquid;
}
if (temp != null)
{
if (temp != null) {
logic.moltenMetal.remove(temp);
if (this.isShiftPressed)
logic.moltenMetal.add(temp);
else
logic.moltenMetal.add(0, temp);
if (this.isShiftPressed) logic.moltenMetal.add(temp);
else logic.moltenMetal.add(0, temp);
}
NBTTagCompound data = new NBTTagCompound();
logic.writeToNBT(data);
TConstruct.packetPipeline.sendToDimension(new PacketUpdateTE(this.x, this.y, this.z, data), this.dimension);
TConstruct.packetPipeline.sendToDimension(
new PacketUpdateTE(this.x, this.y, this.z, data), this.dimension);
}
}
}
}
}
@@ -8,18 +8,14 @@ import net.minecraft.entity.player.EntityPlayer;
import tconstruct.tools.inventory.ToolStationContainer;
import tconstruct.tools.logic.ToolStationLogic;
public class ToolStationPacket extends AbstractPacket
{
public class ToolStationPacket extends AbstractPacket {
private int x, y, z;
private String toolName;
public ToolStationPacket()
{
}
public ToolStationPacket() {}
public ToolStationPacket(int x, int y, int z, String toolName)
{
public ToolStationPacket(int x, int y, int z, String toolName) {
this.x = x;
this.y = y;
this.z = z;
@@ -27,8 +23,7 @@ public class ToolStationPacket extends AbstractPacket
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
buffer.writeInt(x);
buffer.writeInt(y);
buffer.writeInt(z);
@@ -36,8 +31,7 @@ public class ToolStationPacket extends AbstractPacket
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
x = buffer.readInt();
y = buffer.readInt();
z = buffer.readInt();
@@ -45,22 +39,16 @@ public class ToolStationPacket extends AbstractPacket
}
@Override
public void handleClientSide (EntityPlayer player)
{
}
public void handleClientSide(EntityPlayer player) {}
@Override
public void handleServerSide (EntityPlayer player)
{
if (player.openContainer instanceof ToolStationContainer)
{
public void handleServerSide(EntityPlayer player) {
if (player.openContainer instanceof ToolStationContainer) {
ToolStationContainer container = (ToolStationContainer) player.openContainer;
ToolStationLogic logic = container.logic;
if (logic != null && logic.xCoord == x && logic.yCoord == y && logic.zCoord == z)
{
if (logic != null && logic.xCoord == x && logic.yCoord == y && logic.zCoord == z) {
logic.setToolname(toolName);
}
}
}
}