@Override public ActionResult<ItemStack> onItemRightClick( ItemStack tape, World world, EntityPlayer player, EnumHand hand) { if (world.isRemote) { if (Minecraft.getMinecraft().objectMouseOver != null) { if (player.isSneaking()) { xa = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getX(); ya = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getY(); za = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getZ(); if (world.getTileEntity(new BlockPos(xa, ya, za)) != null) { System.out.println(world.getTileEntity(new BlockPos(xa, ya, za))); } } else { xb = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getX(); yb = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getY(); zb = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getZ(); block = world .getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos()) .getBlock(); countAxis(player); } } } return new ActionResult(EnumActionResult.PASS, tape); }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { int meta = world.getBlockMetadata(x, y, z); if (!isLampLit(meta)) { TEOilLamp te = (TEOilLamp) world.getTileEntity(x, y, z); if (te != null) { te.updateLampFuel( false); // Update lamp fuel, but don't burn fuel for time passed while lamp was off // before turning the lamp on. if (te.isFuelValid()) if (te.getFuelTimeLeft() > 0) world.setBlockMetadataWithNotify(x, y, z, meta - 8, 3); } } else { TEOilLamp te = (TEOilLamp) world.getTileEntity(x, y, z); if (te != null) { te.updateLampFuel( true); // Update lamp fuel and burn fuel for time passed before turning the lamp off. } world.setBlockMetadataWithNotify(x, y, z, meta + 8, 3); } } return true; }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if (player.isSneaking()) { return false; } if (world.getTileEntity(x, y, z) != null && ((TileEntityControler) world.getTileEntity(x, y, z)).getMultiblockController() != null && ((TileEntityControler) world.getTileEntity(x, y, z)) .getMultiblockController() .isAssembled()) { player.openGui(ZettaIndustries.instance, 3, world, x, y, z); return true; } return false; }
private void controlLoop(World w, int x, int y, int z) { ArenaCellEntity ace; if (!(w.getBlock(x, y, z) instanceof ArenaCellBlock) || w.getTileEntity(x, y, z) == null) return; ace = (ArenaCellEntity) w.getTileEntity(x, y, z); if (ace.passed) return; ace.passed = true; aaCounter += 1; if (ace.gameUsable) { aCounter += 1; if (ace.XOwnership == 1) t1T += 1; else if (ace.XOwnership == 2) t2T += 1; else nT += 1; } /*if (!ace.gameUsable) aInit = false;*/ controlLoop(w, x, y, z + 1); controlLoop(w, x, y, z - 1); controlLoop(w, x + 1, y, z); controlLoop(w, x - 1, y, z); }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (player.getCurrentEquippedItem() != null) { if (player.getCurrentEquippedItem().getItem() instanceof ItemBlock) { if (world.getTileEntity(x, y, z) instanceof TileEntityDisguiseBlock) { TileEntityDisguiseBlock te = (TileEntityDisguiseBlock) world.getTileEntity(x, y, z); if (te != null) { if (!player.isSneaking()) { if (!((ItemBlock) player.getCurrentEquippedItem().getItem()) .field_150939_a.hasTileEntity(te.getMetadata())) { te.setBlock( Block.getBlockFromItem(player.getCurrentEquippedItem().getItem()), player.getCurrentEquippedItem().getItemDamage()); return true; } } } } } } return false; }
private void cleanTeamLoop(World w, int x, int y, int z, int team) { ArenaCellEntity ace; if (!(w.getBlock(x, y, z) instanceof ArenaCellBlock) || w.getTileEntity(x, y, z) == null) return; ace = (ArenaCellEntity) w.getTileEntity(x, y, z); if (ace.passed) return; if (ace.ownership == team) { w.spawnEntityInWorld(new EntityItem(w, x, y, z, ace.getStack())); ace.stackIn = null; ace.ownership = 0; ace.XOwnership = 0; } ace.gameUsable = false; ace.passed = true; w.markBlockForUpdate(x, y, z); cleanTeamLoop(w, x, y, z + 1, team); cleanTeamLoop(w, x, y, z - 1, team); cleanTeamLoop(w, x + 1, y, z, team); cleanTeamLoop(w, x - 1, y, z, team); }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { if (!canBlockStay(world, x, y, z)) { world.setBlockToAir(x, y, z); world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(this, 1))); } else if ((TEBloomery) world.getTileEntity(x, y, z) != null) { TEBloomery te = (TEBloomery) world.getTileEntity(x, y, z); ItemStack is = entityplayer.getCurrentEquippedItem(); if (is != null && (is.getItem() == TFCItems.FireStarter || is.getItem() == TFCItems.FlintSteel)) { if (te.canLight()) entityplayer.getCurrentEquippedItem().damageItem(1, entityplayer); } else { world.playAuxSFXAtEntity(entityplayer, 1003, x, y, z, 0); if (isOpen(world.getBlockMetadata(x, y, z))) world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 8, 3); else world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) + 8, 3); } } return true; }
@Override public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { if (world.isRemote) return; if (stack.hasTagCompound()) { TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileVendorBlock) { TileVendorBlock tentity = (TileVendorBlock) te; NBTTagCompound tagCompound = stack.getTagCompound(); if (tagCompound == null) { return; } NBTTagList tagList = tagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < tentity.getSizeInventory()) { tentity.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(tag)); } } tentity.coinSum = tagCompound.getInteger("CoinSum"); tentity.userCoinSum = tagCompound.getInteger("UserCoinSum"); tentity.itemPrice = tagCompound.getInteger("ItemPrice"); tentity.blockOwner = tagCompound.getString("BlockOwner"); tentity.infiniteMode = tagCompound.getBoolean("Infinite"); } world.markBlockForUpdate(x, y, z); } else { // item has no owner so we'll set one and get out of here ((TileVendorBlock) world.getTileEntity(x, y, z)).blockOwner = entity.getCommandSenderName(); } int meta = stack.getItemDamage(); world.setBlockMetadataWithNotify(x, y, z, meta, 2); }
@Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == AliensVsPredator.properties().GUI_ASSEMBLER) { return new GuiAssembler( player.inventory, (TileEntityAssembler) world.getTileEntity(x, y, z), world, x, y, z); } if (ID == AliensVsPredator.properties().GUI_TURRET) { return new GuiTurret(player, (TileEntityTurret) world.getTileEntity(x, y, z), world, x, y, z); } if (ID == AliensVsPredator.properties().GUI_WRISTBRACER) { Item item = player.getCurrentEquippedItem().getItem(); if (item == AliensVsPredator.items().itemWristbracer) { return new GuiWristbracer( player, (ContainerWristbracer) ((ItemWristbracer) item).getNewContainer(player)); } } if (ID == AliensVsPredator.properties().GUI_LOCKER) { return new GuiLocker(player, (TileEntityLocker) (world.getTileEntity(x, y, z))); } if (ID == AliensVsPredator.properties().GUI_SUPPLYCRATE) { return new GuiSupplyCrate(player, (TileEntitySupplyCrate) (world.getTileEntity(x, y, z))); } if (ID == AliensVsPredator.properties().GUI_GRAPHICSSETTINGS) { return new GuiModSettings(Minecraft.getMinecraft().currentScreen); } return null; }
@Override public boolean onBlockActivated( World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par5EntityPlayer.isSneaking()) { TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); if (altar.manaToGet == 0) for (int i = altar.getSizeInventory() - 1; i >= 0; i--) { ItemStack stackAt = altar.getStackInSlot(i); if (stackAt != null) { ItemStack copy = stackAt.copy(); if (!par5EntityPlayer.inventory.addItemStackToInventory(copy)) par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); altar.setInventorySlotContents(i, null); par1World.func_147453_f(par2, par3, par4, this); break; } } } else { ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); if (stack != null) return ((TileRuneAltar) par1World.getTileEntity(par2, par3, par4)) .addItem(par5EntityPlayer, stack); } return false; }
protected void setBlockMode(World world, int x, int y, int z) { if (world.isRemote) return; TileEntity ent = world.getTileEntity(x, y, z); int habCount = 0; if (ent instanceof TileEntityFlickerHabitat) { TileEntityFlickerHabitat hab = (TileEntityFlickerHabitat) ent; for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { Block block = world.getBlock(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ); TileEntity te = world.getTileEntity( x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ); if (block == BlocksCommonProxy.elementalAttuner && te != null && te instanceof TileEntityFlickerHabitat) { TileEntityFlickerHabitat foundHab = (TileEntityFlickerHabitat) te; if (foundHab.isUpgrade() == false) { habCount++; if (habCount == 1) { hab.setUpgrade(true, direction); } else { world.func_147480_a(x, y, z, true); } } else { world.func_147480_a(x, y, z, true); } } } } }
@Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == AliensVsPredator.properties().GUI_ASSEMBLER) return ((TileEntityAssembler) world.getTileEntity(x, y, z)).getNewContainer(player); if (ID == AliensVsPredator.properties().GUI_TURRET) return ((TileEntityTurret) world.getTileEntity(x, y, z)).getNewContainer(player); if (ID == AliensVsPredator.properties().GUI_WRISTBRACER && player != null && player.getCurrentEquippedItem() != null) { Item item = player.getCurrentEquippedItem().getItem(); if (item instanceof ItemWristbracer) { return ((ItemWristbracer) item).getNewContainer(player); } } if (ID == AliensVsPredator.properties().GUI_LOCKER) { TileEntityLocker locker = (TileEntityLocker) (world.getTileEntity(x, y, z)); return locker.getNewContainer(player); } if (ID == AliensVsPredator.properties().GUI_SUPPLYCRATE) { TileEntitySupplyCrate supplyCrate = (TileEntitySupplyCrate) (world.getTileEntity(x, y, z)); return supplyCrate.getNewContainer(player); } return null; }
/** * Sets the block's orientation based upon the direction the player is looking when the block is * placed. */ @Override @SuppressWarnings("unchecked") public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { TileEntity te = world.getTileEntity(x, y, z); if (te != null && te instanceof TileEntityAgricraft) { TileEntityAgricraft tile = (TileEntityAgricraft) world.getTileEntity(x, y, z); if (tile.isRotatable()) { int direction = MathHelper.floor_double(entity.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; switch (direction) { case 0: tile.setOrientation(ForgeDirection.NORTH); break; case 1: tile.setOrientation(ForgeDirection.EAST); break; case 2: tile.setOrientation(ForgeDirection.SOUTH); break; case 3: tile.setOrientation(ForgeDirection.WEST); break; } } if (this.isMultiBlock() && !world.isRemote) { IMultiBlockComponent component = (IMultiBlockComponent) world.getTileEntity(x, y, z); component.getMultiBlockManager().onBlockPlaced(world, x, y, z, component); } } }
@Override public void updateTick(World world, int x, int y, int z, Random rand) { if (world.isRemote) return; int meta = world.getBlockMetadata(x, y, z); l: if (meta != 0) { ForgeDirection dir = ForgeDirection.getOrientation(meta - 1); if (world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).equals(this)) if (world.getBlockMetadata(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) == meta) return; else break l; TileEntity te = world.getTileEntity(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); if (te instanceof IFactoryLaserSource && ((IFactoryLaserSource) te).canFormBeamFrom(dir)) return; world.setBlockMetadataWithNotify(x, y, z, 0, 0); } Block upperId = world.getBlock(x, y + 1, z); if (!upperId.equals(this) && !(world.getTileEntity(x, y + 1, z) instanceof TileEntityLaserDrill)) { world.setBlockToAir(x, y, z); return; } Block lowerId = world.getBlock(x, y - 1, z); if ((!lowerId.equals(this) || world.getBlockMetadata(x, y - 1, z) != 0) && TileEntityLaserDrill.canReplaceBlock(lowerId, world, x, y - 1, z)) { world.setBlock(x, y - 1, z, this); } }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity != null && tileEntity instanceof TileVendor) { TileVendor tileVendor = (TileVendor) world.getTileEntity(x, y, z); EntityPlayer playerTest = world.getPlayerEntityByName(tileVendor.playerName); if (playerTest == null || !tileVendor.isUseableByPlayer(playerTest)) { tileVendor.inUse = false; } ; if (tileVendor.inUse && !player.getDisplayName().contentEquals(tileVendor.playerName)) { if (!world.isRemote) { player.addChatMessage( new ChatComponentText(StatCollector.translateToLocal("chat.warning.inuse"))); } return true; } else { player.openGui(UniversalCoins.instance, 0, world, x, y, z); tileVendor.playerName = player.getDisplayName(); tileVendor.inUse = true; tileVendor.updateCoinsForPurchase(); return true; } } return false; }
@Override public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { try { if (world.getTileEntity(x, y, z) instanceof TileMundaneTankPart && world.isRemote) { TileMundaneTankPart tank = (TileMundaneTankPart) world.getTileEntity(x, y, z); PlayerHelper.sendMessageToPlayer(player, "Valid multiblock: " + tank.isValidMultiBlock()); PlayerHelper.sendMessageToPlayer( player, "Has multiblock: " + (tank.getMultiBlock() != null)); PlayerHelper.sendMessageToPlayer( player, "Fluid: " + tank.getMultiBlock().getInternalTank().getFluid().getFluid().getName() + " amount: " + tank.getMultiBlock().getInternalTank().getFluid().amount); } } catch (Exception e) { // PlayerHelper.sendMessageToPlayer(player, "Wrong item"); // e.printStackTrace(); } return super.onItemUseFirst(stack, player, world, x, y, z, side, hitX, hitY, hitZ); }
public boolean onItemUse( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing par5EnumFacing, float hitX, float hitY, float hitZ) { if (!par3World.isRemote) { if (BlockUtils.getBlock(par3World, pos) == mod_SecurityCraft.frame) { String owner = ((IOwnable) par3World.getTileEntity(pos)).getOwnerName(); String uuid = ((IOwnable) par3World.getTileEntity(pos)).getOwnerUUID(); EnumFacing enumfacing = (EnumFacing) par3World.getBlockState(pos).getValue(BlockKeypad.FACING); par3World.setBlockState( pos, mod_SecurityCraft .Keypad .getDefaultState() .withProperty(BlockKeypad.FACING, enumfacing) .withProperty(BlockKeypad.POWERED, false)); ((IOwnable) par3World.getTileEntity(pos)).setOwner(uuid, owner); par1ItemStack.stackSize -= 1; } return true; } return false; }
@Override public boolean canBlockStay(World world, int x, int y, int z) { if (world.isAirBlock(x, y, z)) return true; if (world.getTileEntity(x, y, z) instanceof TEBloomery) // Prevent ClassCastException { boolean flipped = false; int dir = world.getBlockMetadata(x, y, z) & 3; TEBloomery te = (TEBloomery) world.getTileEntity(x, y, z); if (te != null) flipped = te.isFlipped; if (checkStack(world, x, y, z, dir)) { if (checkVertical(world, x, y, z, flipped)) { if (checkHorizontal(world, x, y, z, flipped)) return true; } else if (te != null && !flipped) { this.tryFlip(world, x, y, z); flipped = te.isFlipped; if (checkVertical(world, x, y, z, flipped)) { if (checkHorizontal(world, x, y, z, flipped)) return true; } } } } return false; }
/** * Called on server worlds only when the block has been replaced by a different block ID, or the * same block with a different metadata value, but before the new metadata value is set. Args: * World, x, y, z, old block ID, old metadata */ public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { TileEntityBoundChest tileentitychest = (TileEntityBoundChest) par1World.getTileEntity(par2, par3, par4); if (tileentitychest != null) { this.dropItem( new ItemStack( ThaumicExploration.blankSeal, 1, 15 - ((TileEntityBoundChest) par1World.getTileEntity(par2, par3, par4)) .getSealColor()), par1World, par2, par3, par4); for (int j1 = 0; j1 < tileentitychest.getSizeInventory(); ++j1) { ItemStack itemstack = tileentitychest.getStackInSlot(j1); this.dropItem(itemstack, par1World, par2, par3, par4); } par1World.func_147453_f(par2, par3, par4, par5); } super.breakBlock(par1World, par2, par3, par4, par5, par6); }
@Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case BACKPACK_TILE: if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack) { return new ContainerBackpack( player, (TileAdventureBackpack) world.getTileEntity(x, y, z), ContainerBackpack.SOURCE_TILE); } break; case BACKPACK_WEARING: if (Wearing.isWearingBackpack(player)) { return new ContainerBackpack( player, new InventoryBackpack(Wearing.getWearingBackpack(player)), ContainerBackpack.SOURCE_WEARING); } break; case BACKPACK_HOLDING: if (Wearing.isHoldingBackpack(player)) { return new ContainerBackpack( player, new InventoryBackpack(Wearing.getHoldingBackpack(player)), ContainerBackpack.SOURCE_HOLDING); } break; case COPTER_HOLDING: if (Wearing.isHoldingCopter(player)) { return new ContainerCopter( player, new InventoryCopterPack(Wearing.getHoldingCopter(player)), false); } break; case COPTER_WEARING: if (Wearing.isWearingCopter(player)) { return new ContainerCopter( player, new InventoryCopterPack(Wearing.getWearingCopter(player)), true); } break; case JETPACK_HOLDING: if (Wearing.isHoldingSteam(player)) { return new ContainerJetpack( player, new InventorySteamJetpack(Wearing.getHoldingSteam(player)), false); } break; case JETPACK_WEARING: if (Wearing.isWearingSteam(player)) { return new ContainerJetpack( player, new InventorySteamJetpack(Wearing.getWearingSteam(player)), true); } break; default: player.closeScreen(); break; } return null; }
@Override public void onBlockAdded(World world, int x, int y, int z) { TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null; if (tile != null) tile.onPlaced(); }
@Override public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null; if (tile != null) tile.onBroken(); super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); }
@Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { IBlockState iblockstate = world.getBlockState(pos); Block localBlock = iblockstate.getBlock(); BlockPos posThere = pos; BlockPos posOffset = pos.offset(side); if (localBlock == Blocks.snow_layer && localBlock.isReplaceable(world, pos)) side = EnumFacing.UP; else if (!localBlock.isReplaceable(world, pos)) pos = pos.offset(side); TileEntityIESlab stackSlab = null; if (side.getAxis().isVertical() && this.block.equals(world.getBlockState(posThere).getBlock()) && world.getBlockState(posThere).getBlock().getMetaFromState(world.getBlockState(posThere)) == stack.getItemDamage()) { TileEntity te = world.getTileEntity(posThere); if (te instanceof TileEntityIESlab && ((TileEntityIESlab) te).slabType + side.ordinal() == 1) stackSlab = ((TileEntityIESlab) te); } else if (this.block.equals(world.getBlockState(posOffset).getBlock()) && world .getBlockState(posOffset) .getBlock() .getMetaFromState(world.getBlockState(posOffset)) == stack.getItemDamage()) { TileEntity te = world.getTileEntity(posOffset); if (te instanceof TileEntityIESlab) { int type = ((TileEntityIESlab) te).slabType; if ((type == 0 && (side == EnumFacing.DOWN || hitY >= .5)) || (type == 1 && (side == EnumFacing.UP || hitY <= .5))) stackSlab = ((TileEntityIESlab) te); } } else return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ); if (stackSlab != null) { stackSlab.slabType = 2; world.markBlockForUpdate(stackSlab.getPos()); world.playSoundEffect( stackSlab.getPos().getX() + .5, stackSlab.getPos().getY() + .5, stackSlab.getPos().getZ() + .5, this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); --stack.stackSize; return true; } else return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ); }
@Override public boolean onBlockActivated( World w, int x, int y, int z, EntityPlayer player, int i, float f1, float f2, float f3) { if (w.getTileEntity(x, y, z) instanceof TileEntityAlchemicChemistryKit) { TileEntityAlchemicChemistryKit te = (TileEntityAlchemicChemistryKit) w.getTileEntity(x, y, z); ItemStack item = player.getCurrentEquippedItem(); if (player.isSneaking()) { if (te.getStackInSlot(0) != null && te.getStackInSlot(1) != null) { ItemStack stack = FMAlchemyAPI.instance.getAlchemicChemistryOutput( te.getStackInSlot(0).getItem(), te.getStackInSlot(1).getItem()); if (stack != null) { te.setInventorySlotContents(0, null); te.setInventorySlotContents(1, null); te.setInventorySlotContents(0, stack); } } } else { if (i == ForgeDirection.UP.ordinal()) { if (item != null) { if (te.getStackInSlot(0) != null) { if (!w.isRemote) { w.spawnEntityInWorld(new EntityItem(w, x, y + 1, z, te.getStackInSlot(0))); } te.setInventorySlotContents(0, null); } else { ItemStack toput = new ItemStack(item.getItem(), 1, item.getItemDamage()); toput.stackTagCompound = item.stackTagCompound; te.setInventorySlotContents(0, toput); item.stackSize--; } return true; } } else { if (item != null) { if (te.getStackInSlot(1) != null) { if (!w.isRemote) { w.spawnEntityInWorld(new EntityItem(w, x, y + 1, z, te.getStackInSlot(1))); } te.setInventorySlotContents(1, null); } else { ItemStack toput = new ItemStack(item.getItem(), 1, item.getItemDamage()); toput.stackTagCompound = item.stackTagCompound; te.setInventorySlotContents(1, toput); item.stackSize--; } return true; } } return false; } } return false; }
@Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: return new GuiMaschC( player.inventory, (IInventory) world.getTileEntity(new BlockPos(x, y, z)), (TileEntityMaschC) world.getTileEntity(new BlockPos(x, y, z))); default: return null; } }
@Override public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) { if (world.getTileEntity(x, y, z) instanceof TileEntityFL) { if (itemStack.hasDisplayName()) { ((TileEntityFL) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName()); } ((TileEntityFL) world.getTileEntity(x, y, z)) .setOrientation(ForgeDirection.getOrientation(getFacing(entityLiving))); world.setBlockMetadataWithNotify(x, y, z, getFacing(entityLiving), 2); } }
public boolean ifrender(TileVirtualisationScanner te) { World world = te.getWorldObj(); if (world.getTileEntity(te.xCoord + 1, te.yCoord, te.zCoord) instanceof TileVirtualisationScanner && world.getTileEntity(te.xCoord, te.yCoord, te.zCoord + 1) instanceof TileVirtualisationScanner && world.getTileEntity(te.xCoord, te.yCoord, te.zCoord - 1) instanceof TileVirtualisationScanner && world.getTileEntity(te.xCoord - 1, te.yCoord, te.zCoord) instanceof TileVirtualisationScanner && world.getTileEntity(te.xCoord, te.yCoord + 5, te.zCoord) instanceof TileVirtualisationScanner) return true; return false; }
public boolean onBlockActivated( World par1World, BlockPos pos, IBlockState state, EntityPlayer par5EntityPlayer, EnumFacing side, float par7, float par8, float par9) { if (!par1World.isRemote) { if (par5EntityPlayer.getCurrentEquippedItem() == null || (par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().getItem() != mod_SecurityCraft.Codebreaker)) { TileEntityKeypadFurnace TE = (TileEntityKeypadFurnace) par1World.getTileEntity(pos); if (TE.getPassword() != null && !TE.getPassword().isEmpty()) { par5EntityPlayer.openGui( mod_SecurityCraft.instance, GuiHandler.INSERT_PASSWORD_ID, par1World, pos.getX(), pos.getY(), pos.getZ()); } else { par5EntityPlayer.openGui( mod_SecurityCraft.instance, GuiHandler.SETUP_PASSWORD_ID, par1World, pos.getX(), pos.getY(), pos.getZ()); } } else { if (mod_SecurityCraft.instance.configHandler.allowCodebreakerItem) { if (((IPasswordProtected) par1World.getTileEntity(pos)).getPassword() != null) { activate(par1World, pos, par5EntityPlayer); } } else { PlayerUtils.sendMessageToPlayer( par5EntityPlayer, StatCollector.translateToLocal("tile.keypadFurnace.name"), StatCollector.translateToLocal("messages.codebreakerDisabled"), EnumChatFormatting.RED); } } } return true; }
public void setupStructure(World w, EntityPlayer player, int x, int y, int z) { for (Entry<String, Coord4> entry : mapStructure.entrySet()) { int xT = entry.getValue().x + x; int yT = entry.getValue().y + y; int zT = entry.getValue().z + z; TileEntity tb = w.getTileEntity(xT, yT, zT); if (tb != null && tb instanceof TileMasterPillar && ((TileMasterPillar) tb).hasMaster()) continue; if (tb != null && tb instanceof TileRenderPillarModel) { w.removeTileEntity(xT, yT, zT); w.setBlockMetadataWithNotify(xT, yT, zT, 0, 4); w.markBlockForUpdate(xT, yT, zT); } if (interfaces.containsKey(entry.getKey())) { w.setBlockMetadataWithNotify(xT, yT, zT, 2, 4); TileEntity te = (TileEntity) w.getTileEntity(xT, yT, zT); TileInterfacePillar tip; if (te != null && te instanceof TileInterfacePillar) { tip = (TileInterfacePillar) te; tip.master = new Coord4(x, y, z); for (int k = 0; k < interfaces.get(entry.getKey()).length; k++) { tip.extractSides.add( ForgeDirection.getOrientation(interfaces.get(entry.getKey())[k])); tip.recieveSides.add( ForgeDirection.getOrientation(interfaces.get(entry.getKey())[k])); } tip.updateRenderTick = 2; tip.init(); tip.isRenderingPillarModel = -1; } } else { w.setBlockMetadataWithNotify(xT, yT, zT, 1, 4); TileEntity te = (TileEntity) w.getTileEntity(xT, yT, zT); TileBlockPillar tbp; if (te != null && te instanceof TileBlockPillar) { tbp = (TileBlockPillar) te; tbp.master = new Coord4(x, y, z); tbp.updateRenderTick = 2; tbp.isRenderingPillarModel = -1; } } w.notifyBlocksOfNeighborChange(xT, yT, zT, w.getBlock(xT, yT, zT)); w.markBlockForUpdate(xT, yT, zT); } }
@Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { if (meta != 0) { TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity instanceof IMultiblockTile) { IMultiblockTile multiblockTile = (IMultiblockTile) tileEntity; if (multiblockTile.isFormed()) { if (multiblockTile.getReplaced() != null) { world.spawnEntityInWorld( new EntityItem(world, x + .5, y + .5, z + .5, multiblockTile.getReplaced().copy())); } multiblockTile.setFormed(false); int[] offset = multiblockTile.getOffset(); for (int dz = -4; dz <= 0; dz++) { for (int dx = -3; dx <= 3; dx++) { for (int dy = -1; dy <= 2; dy++) { int ddz = dz * ForgeDirection.getOrientation(offset[3]).offsetZ; int ddx = dx; if (ForgeDirection.getOrientation(offset[3]).offsetX != 0) { ddz = dx; ddx = dz * ForgeDirection.getOrientation(offset[3]).offsetX; } TileEntity tileEntity1 = world.getTileEntity( x + ddx - offset[0], y + dy - offset[1], z + ddz - offset[2]); if (tileEntity1 != tileEntity && tileEntity1 instanceof IMultiblockTile) { IMultiblockTile multiblockTileReplace = (IMultiblockTile) tileEntity1; ItemStack replaced = multiblockTileReplace.getReplaced(); multiblockTileReplace.setFormed(false); if (replaced != null) { world.setBlock( x + ddx - offset[0], y + dy - offset[1], z + ddz - offset[2], ((ItemBlock) replaced.getItem()).field_150939_a, replaced.getItemDamage(), 3); } } } } } } } } super.breakBlock(world, x, y, z, block, meta); }