use of reborncore.api.tile.IUpgradeable in project TechReborn by TechReborn.
the class GuiBase method drawGuiContainerBackgroundLayer.
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int mouseX, int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
builder.drawDefaultBackground(this, guiLeft, guiTop, xSize, ySize);
if (drawPlayerSlots()) {
builder.drawPlayerSlots(this, guiLeft + xSize / 2, guiTop + 93, true);
}
if (tryAddUpgrades() && tile instanceof IUpgradeable) {
IUpgradeable upgradeable = (IUpgradeable) tile;
if (upgradeable.canBeUpgraded()) {
builder.drawUpgrades(this, upgradeable, guiLeft, guiTop);
upgrades = true;
}
}
builder.drawSlotTab(this, guiLeft, guiTop, mouseX, mouseY, upgrades);
}
use of reborncore.api.tile.IUpgradeable in project TechReborn by TechReborn.
the class PacketSyncSideConfig method processData.
@Override
public void processData(PacketSyncSideConfig message, MessageContext context) {
TileEntity tileEntity = context.getServerHandler().player.world.getTileEntity(message.pos);
if (tileEntity instanceof IUpgradeable) {
ItemStack stack = ((IUpgradeable) tileEntity).getUpgradeInvetory().getStackInSlot(message.slotID);
ItemNBTHelper.setInt(stack, "side", message.side);
}
}
use of reborncore.api.tile.IUpgradeable in project RebornCore by TechReborn.
the class BlockMachineBase method onBlockActivated.
/*
* Right-click should open GUI for all non-wrench items
* Shift-Right-click should apply special action, like fill\drain bucket, install upgrade, etc.
*/
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (fillBlockWithFluid(worldIn, pos, playerIn)) {
return true;
}
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos);
// We extended BlockTileBase. Thus we should always have tile entity. I hope.
if (tileEntity == null) {
return false;
}
if (!stack.isEmpty()) {
if (ToolManager.INSTANCE.canHandleTool(stack)) {
if (ToolManager.INSTANCE.handleTool(stack, pos, worldIn, playerIn, side, false)) {
if (playerIn.isSneaking()) {
if (tileEntity instanceof IToolDrop) {
ItemStack drop = ((IToolDrop) tileEntity).getToolDrop(playerIn);
if (drop == null) {
return false;
}
if (!drop.isEmpty()) {
spawnAsEntity(worldIn, pos, drop);
}
if (!worldIn.isRemote) {
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
return true;
}
} else {
rotateBlock(worldIn, pos, side);
return true;
}
}
} else if (stack.getItem() instanceof IUpgrade && tileEntity instanceof IUpgradeable) {
IUpgradeable upgradeableEntity = (IUpgradeable) tileEntity;
if (upgradeableEntity.canBeUpgraded()) {
if (InventoryHelper.testInventoryInsertion(upgradeableEntity.getUpgradeInvetory(), stack, null) > 0) {
InventoryHelper.insertItemIntoInventory(upgradeableEntity.getUpgradeInvetory(), stack);
playerIn.setHeldItem(EnumHand.MAIN_HAND, stack);
return true;
}
}
}
}
if (getGui() != null && !playerIn.isSneaking()) {
getGui().open(playerIn, pos, worldIn);
return true;
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
use of reborncore.api.tile.IUpgradeable in project RebornCore by TechReborn.
the class BlockMachineBase method dropInventory.
protected void dropInventory(World world, BlockPos pos) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity == null) {
return;
}
if (!(tileEntity instanceof IInventory)) {
return;
}
IInventory inventory = (IInventory) tileEntity;
List<ItemStack> items = new ArrayList<ItemStack>();
addItemsToList(inventory, items);
if (tileEntity instanceof IUpgradeable) {
addItemsToList(((IUpgradeable) tileEntity).getUpgradeInvetory(), items);
}
WorldUtils.dropItems(items, world, pos);
}
use of reborncore.api.tile.IUpgradeable in project TechReborn by TechReborn.
the class UpgradeSlot method handleRightClick.
@Override
public boolean handleRightClick(int slotID, EntityPlayer player, BuiltContainer container) {
if (inventory instanceof Inventory) {
Inventory inv = (Inventory) inventory;
TileEntity tileEntity = inv.getTileBase();
if (tileEntity instanceof IUpgradeable) {
IUpgradeable upgradeable = (IUpgradeable) tileEntity;
if (upgradeable.canBeUpgraded()) {
ItemStack stack = upgradeable.getUpgradeInvetory().getStackInSlot(slotID);
if (!stack.isEmpty() && stack.getItem() instanceof IUpgrade) {
if (player.world.isRemote) {
((IUpgrade) stack.getItem()).handleRightClick(tileEntity, stack, container, slotID);
}
}
}
}
}
return true;
}
Aggregations