Add a base implementation for when a Container/IInventory is usable

This commit is contained in:
tterrag1098 committed 2015-08-25 17:17:16 -04:00
1 parent 3feefd21d2
commit 555a447143
2 files changed
+16

No files matched your search

@@ -158,6 +158,10 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
public void updateScreen() {
super.updateScreen();
if (!inventorySlots.canInteractWith(mc.thePlayer)) {
mc.thePlayer.closeScreen();
}
for (GuiTextField f : textFields) {
f.updateCursorCounter();
}
@@ -1,5 +1,6 @@
package com.enderio.core.common;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
@@ -100,6 +101,17 @@ public abstract class TileEntityEnder extends TileEntity {
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readCustomNBT(pkt.func_148857_g());
}
// This implements the IInventory method in a standard way
public boolean isUseableByPlayer(EntityPlayer player) {
if (worldObj == null) {
return true;
}
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {
return false;
}
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64D;
}
protected abstract void writeCustomNBT(NBTTagCompound root);