Skip to content

Commit

Permalink
Fix cheating in items with capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Jun 17, 2016
1 parent 0a1994c commit d1d8df2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -5,4 +5,4 @@ curse_project_id=238222

version_major=3
version_minor=6
version_patch=4
version_patch=5
12 changes: 9 additions & 3 deletions src/main/java/mezz/jei/network/packets/PacketGiveItemStack.java
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.SoundCategory;
Expand All @@ -39,7 +40,7 @@ public IPacketId getPacketId() {

@Override
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeItemStackToBuffer(itemStack);
buf.writeNBTTagCompoundToBuffer(itemStack.serializeNBT());
}

@Override
Expand All @@ -52,8 +53,13 @@ public void readPacketData(PacketBuffer buf, EntityPlayer player) throws IOExcep
Map<String, ICommand> commands = commandManager.getCommands();
ICommand giveCommand = commands.get("give");
if (giveCommand != null && giveCommand.checkPermission(minecraftServer, sender)) {
ItemStack itemStack = buf.readItemStackFromBuffer();
executeGive(sender, itemStack);
NBTTagCompound itemStackSerialized = buf.readNBTTagCompoundFromBuffer();
if (itemStackSerialized != null) {
ItemStack itemStack = ItemStack.loadItemStackFromNBT(itemStackSerialized);
if (itemStack != null) {
executeGive(sender, itemStack);
}
}
} else {
TextComponentTranslation textcomponenttranslation1 = new TextComponentTranslation("commands.generic.permission");
textcomponenttranslation1.getStyle().setColor(TextFormatting.RED);
Expand Down

0 comments on commit d1d8df2

Please sign in to comment.