mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-13 17:04:24 +00:00
Fix possible packet hacking (https://github.com/N1nt4nd0/Xenobyte/tree/master/src/main/java/forgefuck/team/xenobyte/modules)
This commit is contained in:
1 parent
1ba27e2761
commit
cae72b2db6
5 files changed
+81
-50
No files matched your search
@@ -4,8 +4,11 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import mantle.common.network.AbstractPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.armor.ArmorProxyCommon;
|
||||
import tconstruct.armor.TinkerArmor;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
|
||||
public class AccessoryInventoryPacket extends AbstractPacket
|
||||
{
|
||||
@@ -52,7 +55,12 @@ public class AccessoryInventoryPacket extends AbstractPacket
|
||||
player.openGui(TConstruct.instance, ArmorProxyCommon.armorGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
break;
|
||||
case ArmorProxyCommon.knapsackGuiID:
|
||||
player.openGui(TConstruct.instance, ArmorProxyCommon.knapsackGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ package tconstruct.util.network;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import mantle.common.network.AbstractPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.StencilBuilder;
|
||||
import tconstruct.tools.inventory.PatternShaperContainer;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
|
||||
public class PatternTablePacket extends AbstractPacket
|
||||
{
|
||||
@@ -56,13 +57,34 @@ public class PatternTablePacket extends AbstractPacket
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof InventoryLogic)
|
||||
if (player.openContainer instanceof PatternShaperContainer)
|
||||
{
|
||||
((InventoryLogic) te).setInventorySlotContents(1, contents);
|
||||
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
|
||||
{
|
||||
ItemStack stackBlank = logic.getStackInSlot(0);
|
||||
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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class SignDataPacket extends AbstractPacket
|
||||
{
|
||||
TileEntity te = player.worldObj.getTileEntity(x, y, z);
|
||||
|
||||
if (te != null && te instanceof BattlesignLogic)
|
||||
if (te instanceof BattlesignLogic)
|
||||
{
|
||||
BattlesignLogic logic = (BattlesignLogic) te;
|
||||
|
||||
@@ -73,9 +73,14 @@ public class SignDataPacket extends AbstractPacket
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
if (player.worldObj.blockExists(x, y, z))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity te = player.worldObj.getTileEntity(x, y, z);
|
||||
|
||||
if (te != null && te instanceof BattlesignLogic)
|
||||
if (te instanceof BattlesignLogic)
|
||||
{
|
||||
BattlesignLogic logic = (BattlesignLogic) te;
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ package tconstruct.util.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import mantle.common.network.*;
|
||||
import mantle.common.network.AbstractPacket;
|
||||
import mantle.common.network.PacketUpdateTE;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.smeltery.inventory.SmelteryContainer;
|
||||
import tconstruct.smeltery.logic.SmelteryLogic;
|
||||
|
||||
public class SmelteryPacket extends AbstractPacket
|
||||
@@ -64,34 +64,33 @@ public class SmelteryPacket extends AbstractPacket
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof SmelteryLogic)
|
||||
if (player.openContainer instanceof SmelteryContainer)
|
||||
{
|
||||
FluidStack temp = null;
|
||||
|
||||
for (FluidStack liquid : ((SmelteryLogic) te).moltenMetal)
|
||||
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 (liquid.getFluidID() == fluidID)
|
||||
FluidStack temp = null;
|
||||
|
||||
for (FluidStack liquid : logic.moltenMetal)
|
||||
{
|
||||
temp = liquid;
|
||||
if (liquid.getFluidID() == this.fluidID)
|
||||
temp = liquid;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
((SmelteryLogic) te).moltenMetal.remove(temp);
|
||||
if (isShiftPressed)
|
||||
((SmelteryLogic) te).moltenMetal.add(temp);
|
||||
else
|
||||
((SmelteryLogic) te).moltenMetal.add(0, temp);
|
||||
}
|
||||
if (temp != null)
|
||||
{
|
||||
logic.moltenMetal.remove(temp);
|
||||
if (this.isShiftPressed)
|
||||
logic.moltenMetal.add(temp);
|
||||
else
|
||||
logic.moltenMetal.add(0, temp);
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
te.writeToNBT(data);
|
||||
TConstruct.packetPipeline.sendToDimension(new PacketUpdateTE(x, y, z, data), dimension);
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
logic.writeToNBT(data);
|
||||
TConstruct.packetPipeline.sendToDimension(new PacketUpdateTE(this.x, this.y, this.z, data), this.dimension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import mantle.common.network.AbstractPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.tools.logic.*;
|
||||
import tconstruct.tools.inventory.ToolStationContainer;
|
||||
import tconstruct.tools.logic.ToolStationLogic;
|
||||
|
||||
public class ToolStationPacket extends AbstractPacket
|
||||
{
|
||||
@@ -53,16 +52,14 @@ public class ToolStationPacket extends AbstractPacket
|
||||
@Override
|
||||
public void handleServerSide (EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof ToolStationLogic)
|
||||
if (player.openContainer instanceof ToolStationContainer)
|
||||
{
|
||||
((ToolStationLogic) te).setToolname(toolName);
|
||||
}
|
||||
if (te instanceof ToolForgeLogic)
|
||||
{
|
||||
((ToolForgeLogic) te).setToolname(toolName);
|
||||
ToolStationContainer container = (ToolStationContainer) player.openContainer;
|
||||
ToolStationLogic logic = container.logic;
|
||||
if (logic != null && logic.xCoord == x && logic.yCoord == y && logic.zCoord == z)
|
||||
{
|
||||
logic.setToolname(toolName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user