use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.
the class ClientRemoteGuiManager method getServerGuiElement.
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int posLow, int dim, int posHigh) {
long posl = ((long) posHigh << 32) | (posLow & 0xffffffffL);
BlockPos pos = BlockPos.fromLong(posl);
World targetWorld = world;
if (world.provider.getDimension() != dim) {
targetWorld = DimensionManager.getWorld(dim);
if (targetWorld == null) {
Log.warn("Unexpected failure to get dimension " + dim + " for the Inventory Panel Remote");
return null;
}
}
TileEntity te = targetWorld.getTileEntity(pos);
if (te instanceof TileInventoryPanel) {
return new InventoryPanelContainer(player.inventory, (TileInventoryPanel) te);
}
Log.warn("Unexpected failure to get tileentity at " + pos + " in dimension " + dim + " for the Inventory Panel Remote. Got: " + te);
return null;
}
use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.
the class ClientRemoteGuiManager method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileInventoryPanel te;
if (targetTE != null && targetTEtime >= EnderIO.proxy.getTickCount()) {
te = targetTE;
targetTE = null;
} else {
te = new TileInventoryPanel();
}
return new GuiInventoryPanel(te, new InventoryPanelContainer(player.inventory, te));
}
use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.
the class PacketRemoteInvPanel method onMessage.
@Override
public IMessage onMessage(PacketRemoteInvPanel message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().player;
ItemStack heldItem = player.getHeldItem(message.hand);
if (heldItem == null || !(heldItem.getItem() instanceof ItemRemoteInvAccess)) {
return null;
}
if (!REMOTE_X.hasTag(heldItem)) {
return null;
}
int x = REMOTE_X.getInt(heldItem);
int y = REMOTE_Y.getInt(heldItem);
int z = REMOTE_Z.getInt(heldItem);
int d = REMOTE_D.getInt(heldItem);
ItemRemoteInvAccessType type = ItemRemoteInvAccessType.fromStack(heldItem);
if (!type.inRange(d, x, y, z, player.getEntityWorld().provider.getDimension(), (int) player.posX, (int) player.posY, (int) player.posZ)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.outofrange")), true);
return null;
}
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null) {
return null;
}
WorldServer world = server.getWorld(d);
if (world == null) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.invalidtarget")), true);
return null;
}
final BlockPos pos = new BlockPos(x, y, z);
if (!world.isBlockLoaded(pos)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.notloaded")), true);
return null;
}
TileEntity tileEntity = player.getEntityWorld().getTileEntity(pos);
if (!(tileEntity instanceof TileInventoryPanel)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.invalidtarget")), true);
return null;
}
Container c = player.openContainer;
player.interactionManager.processRightClickBlock(player, player.world, null, EnumHand.MAIN_HAND, pos, EnumFacing.UP, 0f, 0f, 0f);
return null;
}
use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.
the class ServerRemoteGuiManager method openGui.
public static void openGui(EntityPlayerMP player, World world, BlockPos pos) {
long posl = pos.toLong();
int x = (int) posl;
int y = world.provider.getDimension();
int z = (int) (posl >>> 32);
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileInventoryPanel) {
PacketHandler.INSTANCE.sendTo(new PacketPrimeInventoryPanelRemote((TileInventoryPanel) te), player);
}
InvpanelObject.blockInventoryPanel.openGui(player.world, player, x, y, z);
Ticker.create();
}
use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.
the class ItemRemoteInvAccess method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (world.isRemote || !player.isSneaking()) {
return EnumActionResult.PASS;
}
TileEntity te = world.getTileEntity(pos);
ItemStack stack = player.getHeldItem(hand);
if (te instanceof TileInventoryPanel) {
REMOTE_X.setInt(stack, te.getPos().getX());
REMOTE_Y.setInt(stack, te.getPos().getY());
REMOTE_Z.setInt(stack, te.getPos().getZ());
REMOTE_D.setInt(stack, te.getWorld().provider.getDimension());
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.set")), true);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
Aggregations