-
-
Save DiabolicaTrix/2b18e4f4ad8dd3307a717e1211aea57c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz.diabolicatrixlab.showcasemod.container; | |
import net.minecraft.entity.item.EntityItem; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.item.ItemStack; | |
import net.minecraftforge.items.IItemHandler; | |
import net.minecraftforge.items.SlotItemHandler; | |
import xyz.diabolicatrixlab.showcasemod.NetRegistry; | |
import xyz.diabolicatrixlab.showcasemod.packet.PacketSyncItem; | |
import xyz.diabolicatrixlab.showcasemod.tileentity.TileEntityShowcase; | |
public class SlotShowcase extends SlotItemHandler { | |
public TileEntityShowcase te; | |
public SlotShowcase(IItemHandler itemHandler, TileEntityShowcase te, int index, int xPosition, int yPosition) { | |
super(itemHandler, index, xPosition, yPosition); | |
this.te = te; | |
} | |
@Override | |
public void onSlotChanged() { | |
super.onSlotChanged(); | |
ItemStack stack = this.te.getStackInSlot(0); | |
if(stack == null){ | |
te.item = null; | |
} | |
if(te.item == null || stack.getItem() != te.item.getItem().getItem()){ | |
te.item = new EntityItem(te.getWorld(), 0, 0, 0, stack); | |
if(!te.getWorld().isRemote) | |
{ | |
NetRegistry.network.sendToAll(new PacketSyncItem(te.getPos(), stack)); | |
} | |
} | |
} | |
@Override | |
public boolean canTakeStack(EntityPlayer playerIn) { | |
return te.isOwner(playerIn); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment