public static boolean moveBlock( World world, Coord src, Coord tgt, boolean allowBlockReplacement) { if (!world.isRemote && !src.isAirBlock(world) && (tgt.isAirBlock(world) || allowBlockReplacement)) { int blockID = src.getBlockID(world); int metadata = src.getBlockMetadata(world); world.setBlock(tgt.x, tgt.y, tgt.z, blockID, metadata, BlockNotifyFlags.ALL); if (world.blockHasTileEntity(src.x, src.y, src.z)) { TileEntity te = world.getBlockTileEntity(src.x, src.y, src.z); if (te != null) { NBTTagCompound nbt = new NBTTagCompound(); te.writeToNBT(nbt); nbt.setInteger("x", tgt.x); nbt.setInteger("y", tgt.y); nbt.setInteger("z", tgt.z); te = world.getBlockTileEntity(tgt.x, tgt.y, tgt.z); if (te != null) te.readFromNBT(nbt); } } world.setBlockToAir(src.x, src.y, src.z); return true; } return false; }
public boolean feed() { World world = worldObj; int x = xCoord; int y = yCoord; int z = zCoord; int id = world.getBlockId(x, y - 1, z); int meta = world.getBlockMetadata(x, y - 1, z); TileEntity tile = world.getBlockTileEntity(x, y - 1, z); if (tile instanceof Feedable) { if (((Feedable) tile).feedIn(inv[3])) { inv[3] = inv[2]; inv[2] = inv[1]; inv[1] = inv[0]; id = world.getBlockId(x, y + 1, z); meta = world.getBlockMetadata(x, y + 1, z); tile = world.getBlockTileEntity(x, y + 1, z); if (tile instanceof Feedable) { inv[0] = ((Feedable) tile).feedOut(); } else inv[0] = null; } } this.collapseInventory(); return false; }
public ItemStack dispenseStack(IBlockSource blockSource, ItemStack itemstack) { EnumFacing facing = EnumFacing.func_82600_a(blockSource.func_82620_h()); World world = blockSource.getWorld(); int targetX = blockSource.getXInt() + facing.func_82601_c(); int targetY = blockSource.getYInt(); int targetZ = blockSource.getZInt() + facing.func_82599_e(); TileEntity te = world.getBlockTileEntity(targetX, targetY, targetZ); if (te != null && te instanceof ITankContainer) { return fillOrEmptyContainer((ITankContainer) te, itemstack, facing); } if (world.isAirBlock(targetX, targetY, targetZ)) { TileEntity tileabove = world.getBlockTileEntity(targetX, targetY + 1, targetZ); TileEntity tilebelow = world.getBlockTileEntity(targetX, targetY - 1, targetZ); if (tileabove != null && LiquidContainerRegistry.isEmptyContainer(itemstack)) { return fillContainer((ITankContainer) tileabove, itemstack, EnumFacing.UP); } if (tilebelow != null && LiquidContainerRegistry.isFilledContainer(itemstack)) { return emptyContainer((ITankContainer) tilebelow, itemstack, EnumFacing.DOWN); } } System.out.println("Not matched"); return null; }
private void setPanMeta( World world, int x, int y, int z, EntityPlayer player, ItemStack itemstack, int setMeta) { TilePanHandle tile = (TilePanHandle) world.getBlockTileEntity(x, y, z); byte dir = tile.getDirectionByte(); if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null); } if (!world.isRemote && itemstack.getItemDamage() < 4) { world.setBlock(x, y, z, DCsAppleMilk.filledPan.blockID, setMeta, 3); TilePanHandle tile2 = (TilePanHandle) world.getBlockTileEntity(x, y, z); tile2.setDirectionByte(dir); } else if (!world.isRemote && itemstack.getItemDamage() >= 4 && itemstack.getItemDamage() < 8) { world.setBlock(x, y, z, DCsAppleMilk.filledPan2.blockID, setMeta, 3); TilePanHandle tile2 = (TilePanHandle) world.getBlockTileEntity(x, y, z); tile2.setDirectionByte(dir); } else if (!world.isRemote && itemstack.getItemDamage() == 8) { world.setBlock(x, y, z, DCsAppleMilk.filledChocoPan.blockID); TileChocoPan tile2 = (TileChocoPan) world.getBlockTileEntity(x, y, z); tile2.setRemainByte((byte) 11); } world.playSoundAtEntity(player, "random.pop", 0.4F, 1.8F); }
@Override public void breakBlock(World world, int x, int y, int z, int unk1, int unk2) { super.breakBlock(world, x, y, z, unk1, unk2); if (world.getBlockMetadata(x, y, z) == 0) { int xOff = 0; int zOff = 0; int yOff = 0; boolean isBroken = false; for (int off = 0; off < 3; off++) { for (int i = -1; i <= 1; i++) { boolean broken = false; for (int j = -1; j <= 1; j++) { TileEntity te = world.getBlockTileEntity(x - i, y - off, z - j); if (te != null && te instanceof TileHearth) { xOff = i; zOff = j; yOff = off; broken = true; if (((TileHearth) te).isMultiblockPart()) isBroken = true; break; } } if (broken) break; } } if (isBroken) { ((TileHearth) world.getBlockTileEntity(x - xOff, y - yOff, z - zOff)) .invalidateMultiblock(); } } }
/** Called when the block is placed in the world. */ public void onBlockPlacedBy(World var1, int var2, int var3, int var4, EntityLiving var5) { int var6 = MathHelper.floor_double((double) (var5.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (var6 == 0) { ((FF_TileEntityMetalFurnace) ((FF_TileEntityMetalFurnace) var1.getBlockTileEntity(var2, var3, var4))) .setDirection(2); } if (var6 == 1) { ((FF_TileEntityMetalFurnace) ((FF_TileEntityMetalFurnace) var1.getBlockTileEntity(var2, var3, var4))) .setDirection(5); } if (var6 == 2) { ((FF_TileEntityMetalFurnace) ((FF_TileEntityMetalFurnace) var1.getBlockTileEntity(var2, var3, var4))) .setDirection(3); } if (var6 == 3) { ((FF_TileEntityMetalFurnace) ((FF_TileEntityMetalFurnace) var1.getBlockTileEntity(var2, var3, var4))) .setDirection(4); } FF_TileEntityMetalFurnace var7 = (FF_TileEntityMetalFurnace) var1.getBlockTileEntity(var2, var3, var4); int var8 = var1.getBlockMetadata(var2, var3, var4); var7.setSpeed((int) (20.0F * ConfigFantasy.extractorSpeeds[var8])); }
public void GiveAir(World world, int i, int j, int k) { int meta = world.getBlockMetadata(i, j, k); int x = blockMap[meta][0]; int z = blockMap[meta][1]; Random random = new Random(); float f = (float) i + x + 0.5F; float f1 = j + 0.1F + random.nextFloat() * 6F / 16F; float f2 = (float) k + z + 0.5F; float f3 = 0.82F; float f4 = random.nextFloat() * 0.6F; float f5 = random.nextFloat() * -0.6F; float f6 = random.nextFloat() * -0.6F; world.spawnParticle("smoke", f + f4 - 0.3F, f1, f2 + f5 + 0.3F, 0.0D, 0.0D, 0.0D); TileEntity te = world.getBlockTileEntity(i + x, j, k + z); TileEntity te2 = world.getBlockTileEntity(i + x, j - 1, k + z); TileEntityFireEntity tileentityfirepit = null; ; if (te != null && te instanceof TileEntityFireEntity) { tileentityfirepit = (TileEntityFireEntity) te; } else if (te2 != null && te2 instanceof TileEntityFireEntity) { tileentityfirepit = (TileEntityFireEntity) te2; } if (tileentityfirepit != null) { tileentityfirepit.receiveAirFromBellows(); } }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, * world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer entity) { MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, entity, true); FoodStatsTFC fs = TFC_Core.getPlayerFoodStats(entity); if (mop == null) { if (is.getItemDamage() > 1 && fs.needDrink()) { entity.setItemInUse(is, this.getMaxItemUseDuration(is)); } } else { if (mop.typeOfHit == EnumMovingObjectType.TILE) { int i = mop.blockX; int j = mop.blockY; int k = mop.blockZ; if (world.getBlockTileEntity(i, j, k) != null && world.getBlockTileEntity(i, j, k) instanceof TEBarrel) { TEBarrel TE = (TEBarrel) world.getBlockTileEntity(i, j, k); if (TE.checkValidAddition(13)) { return new ItemStack(TFCItems.WoodenBucketEmpty); } } } } return is; }
private void updateFlow(World world, int x, int y, int z) { // System.out.println("x: "+x+", y: "+y+", z: "+z); int tex = ((LiquidTextureLogic) world.getBlockTileEntity(x, y, z)).getLiquidType(); int meta = world.getBlockMetadata(x, y, z); world.setBlockAndMetadata(x, y, z, stillLiquidId(), meta); world.markBlockRangeForRenderUpdate(x, y, z, x, y, z); world.markBlockForUpdate(x, y, z); ((LiquidTextureLogic) world.getBlockTileEntity(x, y, z)).setTexturePos(tex); }
@Override protected void updateTemperature(World world, int x, int y, int z) { super.updateTemperature(world, x, y, z); int Tamb = ReikaBiomeHelper.getBiomeTemp(world, x, z); int dT = temperature - Tamb; if (dT != 0 && ReikaWorldHelper.checkForAdjBlock(world, x, y, z, 0) != null) temperature -= (1 + dT / 32); if (dT > 0) { for (int i = 2; i < 6; i++) { ForgeDirection dir = dirs[i]; int dx = x + dir.offsetX; int dy = y + dir.offsetY; int dz = z + dir.offsetZ; int id = world.getBlockId(dx, dy, dz); int meta = world.getBlockMetadata(dx, dy, dz); if (id == ReactorTiles.COOLANT.getBlockID() && meta == ReactorTiles.COOLANT.getBlockMetadata()) { TileEntityWaterCell te = (TileEntityWaterCell) world.getBlockTileEntity(dx, dy, dz); if (te.getLiquidState().isWater() && temperature >= 100 && ReikaRandomHelper.doWithChance(40)) { te.setLiquidState(LiquidStates.EMPTY); temperature -= 20; } } if (id == this.getTileEntityBlockID() && meta == ReactorTiles.TEList[this.getIndex()].getBlockMetadata()) { TileEntityNuclearCore te = (TileEntityNuclearCore) world.getBlockTileEntity(dx, dy, dz); int dTemp = temperature - te.temperature; if (dTemp > 0) { temperature -= dTemp / 16; te.temperature += dTemp / 16; } } } } if (hydrogen > 0) hydrogen--; if (temperature >= 500) { ReactorAchievements.HOTCORE.triggerAchievement(this.getPlacer()); } if (temperature > this.getMaxTemperature()) { this.onMeltdown(world, x, y, z); ReactorAchievements.MELTDOWN.triggerAchievement(this.getPlacer()); } if (temperature > HYDROGEN) { hydrogen += 1; if (hydrogen > 200) { this.onMeltdown(world, x, y, z); } } }
public void getLiq(World world, int x, int y, int z, int metadata) { int oldLevel = 0; if (liquidLevel < CAPACITY) { if (MachineRegistry.getMachine(world, x + 1, y, z) == MachineRegistry.PIPE) { TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x + 1, y, z); if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) { liquidID = tile.liquidID; oldLevel = tile.liquidLevel; tile.liquidLevel = ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max"); liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max"); } } if (MachineRegistry.getMachine(world, x - 1, y, z) == MachineRegistry.PIPE) { TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x - 1, y, z); if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) { liquidID = tile.liquidID; oldLevel = tile.liquidLevel; tile.liquidLevel = ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max"); liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max"); } } if (MachineRegistry.getMachine(world, x, y - 1, z) == MachineRegistry.PIPE) { TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x, y - 1, z); if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) { liquidID = tile.liquidID; oldLevel = tile.liquidLevel; tile.liquidLevel = ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max"); liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max"); } } if (MachineRegistry.getMachine(world, x, y, z + 1) == MachineRegistry.PIPE) { TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x, y, z + 1); if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) { liquidID = tile.liquidID; oldLevel = tile.liquidLevel; tile.liquidLevel = ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max"); liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max"); } } if (MachineRegistry.getMachine(world, x, y, z - 1) == MachineRegistry.PIPE) { TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x, y, z - 1); if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) { liquidID = tile.liquidID; oldLevel = tile.liquidLevel; tile.liquidLevel = ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max"); liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max"); } } } }
public Boolean tryToFall(World world, int i, int j, int k, int meta) { int xCoord = i; int yCoord = j; int zCoord = k; int fallingBlockID = dropBlock; if (world.getBlockId(xCoord, yCoord, zCoord) == Block.bedrock.blockID || world.getBlockId(xCoord, yCoord, zCoord) == fallingBlockID) { return false; } if (canFallBelow(world, xCoord, yCoord - 1, zCoord) && !isNearSupport(world, i, j, k) && isUnderLoad(world, i, j, k) /*&& !hasNaturalSupport(world,i,j,k)*/) { if (!world.isRemote && fallingBlockID != -1) { EntityFallingSand ent = new EntityFallingSand(world, i + 0.5F, j + 0.5F, k + 0.5F, fallingBlockID, meta); ent.setIsAnvil(true); ent.fallTime = -5000; world.spawnEntityInWorld(ent); Random R = new Random(i * j + k); if (R.nextInt(100) > 90) world.playSoundAtEntity( ent, TFC_Sounds.FALLININGROCKLONG, 1.0F, 0.8F + (R.nextFloat() / 2)); world.setBlockToAir(i, j, k); if (world.getBlockId(i, j - 1, k) == TFCBlocks.stoneSlabs.blockID && ((TileEntityPartial) world.getBlockTileEntity(i, j - 1, k)).TypeID == this.blockID && ((TileEntityPartial) world.getBlockTileEntity(i, j - 1, k)).MetaID == meta) { world.setBlockToAir(i, j - 1, k); if (world.getBlockId(i, j - 2, k) == TFCBlocks.stoneSlabs.blockID && ((TileEntityPartial) world.getBlockTileEntity(i, j - 2, k)).TypeID == this.blockID && ((TileEntityPartial) world.getBlockTileEntity(i, j - 2, k)).MetaID == meta) { world.setBlockToAir(i, j - 2, k); if (world.getBlockId(i, j - 3, k) == TFCBlocks.stoneSlabs.blockID && ((TileEntityPartial) world.getBlockTileEntity(i, j - 3, k)).TypeID == this.blockID && ((TileEntityPartial) world.getBlockTileEntity(i, j - 3, k)).MetaID == meta) { world.setBlockToAir(i, j - 3, k); } } } return true; } } return false; }
@Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == 10) return new GuiReactorBook(player, world, 0, 0); ReactorTiles r = ReactorTiles.getTE(world, x, y, z); if (r != null) { TileEntity te = world.getBlockTileEntity(x, y, z); switch (r) { case FUEL: case BREEDER: return new GuiNuclearCore(player, (TileEntityNuclearCore) te); case WASTECONTAINER: return new GuiWasteContainer(player, (TileEntityWasteContainer) te); case PROCESSOR: return new GuiProcessor(player, (TileEntityUProcessor) te); case CENTRIFUGE: return new GuiCentrifuge(player, (TileEntityCentrifuge) te); case SYNTHESIZER: return new GuiSynthesizer(player, (TileEntitySynthesizer) te); case ELECTROLYZER: return new GuiElectrolyzer(player, (TileEntityElectrolyzer) te); case STORAGE: return new GuiWasteStorage(player, (TileEntityWasteStorage) te); case PEBBLEBED: return new GuiPebbleBed(player, (TileEntityPebbleBed) te); case CPU: return new GuiCPU(player, (TileEntityCPU) te); default: return null; } } return null; }
@Override public HashMap getExtendedDetails(World world) { HashMap retMap = getBasicDetails(world); TileEntity crucible = world.getBlockTileEntity(xCoord, yCoord, zCoord); NBTTagCompound compound = this.getTagCompound(crucible); retMap.put("Heat", compound.getShort("Heat")); retMap.put("Liquid", compound.getBoolean("Liquid")); retMap.put("LiquidQty", compound.getShort("liquidQty")); int[] tb = compound.getIntArray("Tags"); EnumTag tag; int a = 1; HashMap tagMap; HashMap tags = new HashMap(); for (int i = 0; i < tb.length; i++) { try { if (tb[i] > 0) { tagMap = new HashMap(); tag = EnumTag.get(i); tagMap.put("Name", tag.name); tagMap.put("Aggro", tag.aggro); tagMap.put("Amount", tb[i]); tags.put(a, tagMap); a++; } } catch (Exception e) { } } retMap.put("Aspects", tags); return retMap; }
@Override public boolean placeBlockAt( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { GunBoxType type = GunBoxType.getBox(stack.getItemDamage()); if (type == null) return false; boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); if (place) { TileEntityGunBox entity = (TileEntityGunBox) world.getBlockTileEntity(x, y, z); entity.setShortName(type.shortName); } return place; }
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; TileEntityLimekiln tileEntity = (TileEntityLimekiln) world.getBlockTileEntity(x, y, z); if (tileEntity != null) { if (tileEntity.facing != ForgeDirection.getOrientation(par6).getOpposite()) { tileEntity.facing = ForgeDirection.getOrientation(par6).getOpposite(); } if (!tileEntity.getIsValid()) { if (tileEntity.checkIfProperlyFormed()) { tileEntity.convertDummies(); } } // Check if the multi-block structure has been formed. if (tileEntity.getIsValid()) player.openGui(ConcreteCore.instance, ConfigHandler.GUIIDs.limekiln, world, x, y, z); } return true; }
/** Called upon block activation (right click on the block.) */ public boolean onBlockActivated( World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return true; } else { TileEntity var10 = par1World.getBlockTileEntity(par2, par3, par4); if (var10 == null || par5EntityPlayer.isSneaking()) { return false; } if (var10 != null && var10 instanceof TileEntityMysticFurnace) { par5EntityPlayer.openGui(MysticAdditions.instance, 0, par1World, par2, par3, par4); } return true; } }
public void handlePacket(Packet250CustomPayload packet) throws IOException { DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet.data)); byte type = dis.readByte(); World world = net.minecraft.client.Minecraft.getMinecraft().theWorld; ISyncHandler handler = null; if (type == TYPE_TILE) { int x = dis.readInt(); int y = dis.readInt(); int z = dis.readInt(); if (world != null) { if (world.blockExists(x, y, z)) { TileEntity tile = world.getBlockTileEntity(x, y, z); if (tile instanceof ISyncHandler) { handler = (ISyncHandler) tile; } } } } else if (type == TYPE_ENTITY) { int entityId = dis.readInt(); Entity entity = world.getEntityByID(entityId); if (entity != null && entity instanceof ISyncHandler) { handler = (ISyncHandler) entity; } } if (handler != null) { List<ISyncableObject> changes = handler.getSyncMap().readFromStream(dis); handler.onSynced(changes); } dis.close(); }
@Override public void breakBlock(World world, int x, int y, int z, int par5, int par6) { // Remove the ghost block. world.setBlockToAir(x, y + 1, z); // Spawn the required number of extra sudes. TileEntitySudis tileEntitySudis = (TileEntitySudis) world.getBlockTileEntity(x, y, z); if (tileEntitySudis != null && tileEntitySudis.getHasMultipleSudes()) { for (int i = 0; i < tileEntitySudis.getNumberOfSudes() - 1; i++) { float spawnX = x + world.rand.nextFloat(); float spawnY = y + world.rand.nextFloat(); float spawnZ = z + world.rand.nextFloat(); EntityItem droppedItem = new EntityItem( world, spawnX, spawnY, spawnZ, new ItemStack(BlockManager.blockSudis, 1)); float mult = 0.05F; droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * mult; droppedItem.motionY = (4 + world.rand.nextFloat()) * mult; droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * mult; world.spawnEntityInWorld(droppedItem); } } super.breakBlock(world, x, y, z, par5, par6); }
private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); if (item != null && item.stackSize > 0) { float rx = rand.nextFloat() * 0.8F + 0.1F; float ry = rand.nextFloat() * 0.8F + 0.1F; float rz = rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem( world, x + rx, y + ry, z + rz, new ItemStack(item.itemID, item.stackSize, item.getItemDamage())); if (item.hasTagCompound()) { entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy()); } float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; world.spawnEntityInWorld(entityItem); item.stackSize = 0; } } }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer entityplayer, int side, float hitX, float hitY, float hitZ) { super.onBlockActivated(world, x, y, z, entityplayer, side, hitX, hitY, hitZ); TileEntityQuern te = (TileEntityQuern) world.getBlockTileEntity(x, y, z); if (!world.isRemote) { if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.storage[2] != null) { te.shouldRotate = true; world.playSoundEffect(x, y, z, TFC_Sounds.STONEDRAG, 1, 1); } else if ((!te.shouldRotate && (hitX < 0.65 || hitZ < 0.65)) || te.storage[2] == null) { entityplayer.openGui(TerraFirmaCraft.instance, 33, world, x, y, z); } } else if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.hasQuern) { te.shouldRotate = true; } return true; }
@Override public boolean placeBlockAt( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); if (place) { TileEntityEnergyCube tileEntity = (TileEntityEnergyCube) world.getBlockTileEntity(x, y, z); tileEntity.tier = ((IEnergyCube) stack.getItem()).getEnergyCubeTier(stack); tileEntity.electricityStored = getEnergy(stack); ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); if (!world.isRemote) { PacketHandler.sendPacket( Transmission.ALL_CLIENTS, new PacketTileEntity() .setParams(Object3D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList()))); } } return place; }
/** Called upon block activation (right click on the block.) */ public boolean onBlockActivated( World var1, int var2, int var3, int var4, EntityPlayer var5, int var6, float var7, float var8, float var9) { if (var1.isRemote) { return true; } else if (var5.isSneaking()) { return false; } else { FF_TileEntityMetalFurnace var10 = (FF_TileEntityMetalFurnace) var1.getBlockTileEntity(var2, var3, var4); if (var10 != null) { var5.openGui(MetallurgyFantasy.instance, 0, var1, var2, var3, var4); } return true; } }
public void onBlockPlacedBy( World world, int x, int y, int z, EntityLiving entity, ItemStack stack) { super.onBlockPlacedBy(world, x, y, z, entity, stack); IRotatable rotate = (IRotatable) world.getBlockTileEntity(x, y, z); rotate.setRotation( ForgeDirection.getOrientation(PlayerUtil.determineOrientation(world, x, y, z, entity))); }
@Override public void breakBlock(World world, int x, int y, int z, int par5, int par6) { TileEntityTent tile = (TileEntityTent) world.getBlockTileEntity(x, y, z); if (tile != null) { color = tile.color; BlockUtil.dropItems(world, x, y, z); tile.structures[tile.rotation].destroyStructure(world, tile.tracker[tile.rotation]); super.breakBlock(world, x, y, z, par5, par6); if (!tile.dropped) { ArrayList<ItemStack> stacks = getDroppes(world, x, y, z, world.getBlockMetadata(x, y, z), 1); stacks.addAll(tile.getContends()); for (ItemStack stack : stacks) { dropBlockAsItem_do(world, x, y, z, stack); } tile.dropped = true; } } world.setBlock(x, y, z, 0); }
@Override public void randomDisplayTick(World par1World, int x, int y, int z, Random par5Random) { TileEntity tile = par1World.getBlockTileEntity(x, y, z); if (tile instanceof GCCoreTileEntityCoalGenerator) { GCCoreTileEntityCoalGenerator tileEntity = (GCCoreTileEntityCoalGenerator) tile; if (tileEntity.generateWatts > 0) { int metadata = par1World.getBlockMetadata(x, y, z); float var7 = x + 0.5F; float var8 = y + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; float var9 = z + 0.5F; float var10 = 0.52F; float var11 = par5Random.nextFloat() * 0.6F - 0.3F; if (metadata == 3) { par1World.spawnParticle("smoke", var7 - var10, var8, var9 + var11, 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", var7 - var10, var8, var9 + var11, 0.0D, 0.0D, 0.0D); } else if (metadata == 2) { par1World.spawnParticle("smoke", var7 + var10, var8, var9 + var11, 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", var7 + var10, var8, var9 + var11, 0.0D, 0.0D, 0.0D); } else if (metadata == 1) { par1World.spawnParticle("smoke", var7 + var11, var8, var9 - var10, 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", var7 + var11, var8, var9 - var10, 0.0D, 0.0D, 0.0D); } else if (metadata == 0) { par1World.spawnParticle("smoke", var7 + var11, var8, var9 + var10, 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", var7 + var11, var8, var9 + var10, 0.0D, 0.0D, 0.0D); } } } }
private void setDefaultDirection(World world, int x, int y, int z) { if (!DCsAppleMilk.noUseCupDirection) { TilePanHandle tileHandle = (TilePanHandle) world.getBlockTileEntity(x, y, z); if (!world.isRemote) { int var5 = world.getBlockId(x, y, z - 1); int var6 = world.getBlockId(x, y, z + 1); int var7 = world.getBlockId(x - 1, y, z); int var8 = world.getBlockId(x + 1, y, z); byte var9 = 0; if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6]) { var9 = 0; } if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5]) { var9 = 1; } if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8]) { var9 = 2; } if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7]) { var9 = 4; } tileHandle.setDirectionByte(var9); } } }
public void onBlockPlacedBy( World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int playerFacing = MathHelper.floor_double((double) ((par5EntityLivingBase.rotationYaw * 4F) / 360F) + 0.5D) & 3; if (!DCsAppleMilk.noUseCupDirection) { byte facing = 0; if (playerFacing == 0) { facing = 0; } if (playerFacing == 1) { facing = 1; } if (playerFacing == 2) { facing = 2; } if (playerFacing == 3) { facing = 4; } TileEntity tileEntity = par1World.getBlockTileEntity(par2, par3, par4); if (tileEntity != null && tileEntity instanceof TilePanHandle) { ((TilePanHandle) tileEntity).setDirectionByte(facing); // System.out.println("[AppleMilk]Now fasing " + facing); par1World.markBlockForRenderUpdate(par2, par3, par4); } } }
@Override public void handle(NetHandler handler, Packet131MapData mapData) { ByteArrayDataInput in = ByteStreams.newDataInput(mapData.itemData); EntityPlayer player = handler.getPlayer(); World world = player.worldObj; int x; int y; int z; switch (mapData.uniqueID) { // this is your PACKET_ID from above case EXPORTER_GUI: x = in.readInt(); y = in.readInt(); z = in.readInt(); if (QBEBlockType.NonSolids.EXPORTER.matches(world, x, y, z)) { TileEntityExporter eb = (TileEntityExporter) world.getBlockTileEntity(x, y, z); eb.xSize = in.readInt(); eb.ySize = in.readInt(); eb.zSize = in.readInt(); } break; case INTERFACE_GUI_SAVE: x = in.readInt(); y = in.readInt(); z = in.readInt(); int dimX = in.readInt(); int dimY = in.readInt(); int dimZ = in.readInt(); } }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { TileEntityWire tileEntity = (TileEntityWire) world.getBlockTileEntity(x, y, z); if (entityPlayer.getCurrentEquippedItem() != null) { if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID) { tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage()); return true; } else if (entityPlayer.getCurrentEquippedItem().itemID == Block.cloth.blockID && !tileEntity.isInsulated) { tileEntity.setInsulated(); tileEntity.setDye( BlockColored.getDyeFromBlock(entityPlayer.getCurrentEquippedItem().getItemDamage())); entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1); return true; } } return false; }