@Override public void onSpaceDimensionChanged( World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) { if (BlankPlanet.makelandingplatform) { int X = player.getPlayerCoordinates().posX; int Z = player.getPlayerCoordinates().posZ; if (newWorld.isAirBlock(X, 100, Z) && newWorld == DimensionManager.getWorld(BlankPlanet.dimensionid)) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { newWorld.setBlock(X + i, 100, Z + j, Blocks.stone); } } for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { newWorld.setBlock(X - i, 100, Z + j, Blocks.stone); } } for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { newWorld.setBlock(X + i, 100, Z - j, Blocks.stone); } } for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { newWorld.setBlock(X - i, 100, Z - j, Blocks.stone); } } } } }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { int meta = world.getBlockMetadata(x, y, z); if (meta == dataHangerFruit) { ItemStack item = new ItemStack(ModItems.food, 1, ItemErebusFood.FoodType.DARK_FRUIT.ordinal()); world.playSoundAtEntity(player, "random.pop", 0.5F, 2.0F); if (!player.inventory.addItemStackToInventory(item)) Utils.dropStack(world, (int) (x + 0.5D), (int) (y + 0.5D), (int) (z + 0.5D), item); world.setBlock(x, y, z, this, dataHanger4, 2); return true; } if (meta == dataHangerSeed) { ItemStack item = new ItemStack(ModItems.materials, 1, DATA.darkFruitSeeds.ordinal()); world.playSoundAtEntity(player, "random.pop", 0.5F, 2.0F); if (!player.inventory.addItemStackToInventory(item)) Utils.dropStack(world, (int) (x + 0.5D), (int) (y + 0.5D), (int) (z + 0.5D), item); world.setBlock(x, y, z, this, dataHanger4, 2); return true; } return true; }
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); }
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { for (int var6 = 0; var6 < 10; ++var6) { int var7 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); int var8 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); int var9 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); if (par1World.isAirBlock(var7, var8, var9)) { if (!par1World.isAirBlock(var7 - 1, var8 - 1, var9)) { if (!par1World.isAirBlock(var7 + 1, var8 - 1, var9)) { if (!par1World.isAirBlock(var7, var8 - 1, var9 - 1)) { if (!par1World.isAirBlock(var7, var8 - 1, var9 + 1)) { int var10 = 1 + par2Random.nextInt(par2Random.nextInt(2) + 2); for (int var11 = 0; var11 < var10; ++var11) { if (Blocks.plants.get().canBlockStay(par1World, var7, var8 + var11, var9)) { par1World.setBlock(var7, var8 - 1, var9, Block.sand.blockID); par1World.setBlock(var7, var8 + var11, var9, Block.cactus.blockID); } } } } } } } } return true; }
private boolean checkAndBuildWorktable(World world, int x, int y, int z) { if (!ReikaWorldHelper.matchWithItemStack(world, x, y - 1, z, ItemStacks.steelblock)) return false; if (world.getBlock(x, y - 2, z) != Blocks.redstone_block) return false; for (int i = -1; i <= 1; i++) { for (int k = -1; k <= 1; k++) { if (i != 0 || k != 0) { if (world.getBlock(x + i, y - 1, z + k) != Blocks.brick_block) return false; if (!ReikaWorldHelper.matchWithItemStack( world, x + i, y - 2, z + k, ReikaItemHelper.stoneDoubleSlab)) return false; } } } for (int i = -1; i <= 1; i++) { for (int k = -1; k <= 1; k++) { world.setBlock(x + i, y - 1, z + k, Blocks.air); world.setBlock(x + i, y - 2, z + k, Blocks.air); } } world.setBlock(x, y, z, Blocks.air); SoundRegistry.CRAFT.playSoundAtBlock(world, x, y, z); world.setBlock( x, y - 2, z, MachineRegistry.WORKTABLE.getBlock(), MachineRegistry.WORKTABLE.getMachineMetadata(), 3); return true; }
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { for (int l = 0; l < 2; l++) { int i1 = par3 + par2Random.nextInt(4); int j1 = par4; int k1 = par5 + par2Random.nextInt(4); if (par1World.isAirBlock(i1, par4, k1) && (par1World.getBlockMaterial(i1 - 1, par4 - 1, k1) == Material.lava || par1World.getBlockMaterial(i1 + 1, par4 - 1, k1) == Material.lava || par1World.getBlockMaterial(i1, par4 - 1, k1 - 1) == Material.lava || par1World.getBlockMaterial(i1, par4 - 1, k1 + 1) == Material.lava)) { for (int x = 0; x < 2; x++) { if (par1World.getBlockId(i1, j1 - 1, k1) == Block.dirt.blockID || par1World.getBlockId(i1, j1 - 1, k1) == Block.stone.blockID || par1World.getBlockId(i1, j1 - 1, k1) == Block.sand.blockID) { par1World.setBlock(i1, j1 - 1, k1, Fossil.volcanicAsh.blockID, 0, 2); par1World.setBlock(i1, j1 - 1, k1 + 1, Fossil.volcanicRock.blockID, 0, 2); par1World.setBlock(i1 + 1, j1 - 1, k1, Fossil.volcanicRock.blockID, 0, 2); } } } } return true; }
public void onNeighborBlockChange(World world, int i, int j, int k, int l) { int dir = world.getBlockMetadata(i, j, k); if (dir == 0) { if (!world.isBlockOpaqueCube(i, j, k + 1)) { this.breakBlock(world, i, j, k, blockID, dir); world.setBlock(i, j, k, 0); } } else if (dir == 1) { if (!world.isBlockOpaqueCube(i - 1, j, k)) { this.breakBlock(world, i, j, k, blockID, dir); world.setBlock(i, j, k, 0); } } else if (dir == 2) { if (!world.isBlockOpaqueCube(i, j, k - 1)) { this.breakBlock(world, i, j, k, blockID, dir); world.setBlock(i, j, k, 0); } } else if (dir == 3) { if (!world.isBlockOpaqueCube(i + 1, j, k)) { this.breakBlock(world, i, j, k, blockID, dir); world.setBlock(i, j, k, 0); } } }
// Adapted from BCs oilspout gen code @Override public boolean generate(World world, Random random, int x, int y, int z) { // Find ground level int groundLevel = this.getTopBlock(world, x, z); if (groundLevel < 5) { return false; } int wellX = x; int wellZ = z; int wellHeight = 6 + random.nextInt(3); int maxHeight = groundLevel + wellHeight; if (maxHeight >= (world.getActualHeight() - 1)) { return false; } new WorldGenLakes(this.block).generate(world, random, x, y, z); int wellY = 50 + random.nextInt(10); for (int i = wellY + 1; i <= maxHeight; ++i) { world.setBlock(wellX, i, wellZ, this.block, 0, 3); } for (int i = wellY; i <= (maxHeight - (wellHeight / 2)); ++i) { world.setBlock(wellX + 1, i, wellZ, this.block, 0, 3); world.setBlock(wellX - 1, i, wellZ, this.block, 0, 3); world.setBlock(wellX, i, wellZ + 1, this.block, 0, 3); world.setBlock(wellX, i, wellZ - 1, this.block, 0, 3); } return true; }
public void ignite(World world, int x, int y, int z, int metadata, int step) { if (world.getBlockId(x + 1, y, z) == 0) world.setBlock(x + 1, y, z, Block.fire.blockID); if (world.getBlockId(x - 1, y, z) == 0) world.setBlock(x - 1, y, z, Block.fire.blockID); if (world.getBlockId(x, y + 1, z) == 0) world.setBlock(x, y + 1, z, Block.fire.blockID); if (world.getBlockId(x, y - 1, z) == 0) world.setBlock(x, y - 1, z, Block.fire.blockID); if (world.getBlockId(x, y, z + 1) == 0) world.setBlock(x, y, z + 1, Block.fire.blockID); if (world.getBlockId(x, y, z - 1) == 0) world.setBlock(x, y, z - 1, Block.fire.blockID); }
/** Sets the block in the world, notifying neighbors if enabled. */ protected void setBlockAndMetadata( World par1World, int par2, int par3, int par4, int par5, int par6) { if (this.doBlockNotify) { par1World.setBlock(par2, par3, par4, par5, par6, 3); } else { par1World.setBlock(par2, par3, par4, par5, par6, 2); } }
public static void PlaceSchematic(Schematic schematic, World world, int x, int y, int z) { for (int i = 0; i < schematic.getHeight(); i++) { for (int j = 0; j < schematic.getLength(); j++) { for (int k = 0; k < schematic.getWidth(); k++) { try { int index = i * schematic.getWidth() * schematic.getLength() + j * schematic.getWidth() + k; short blockId = schematic.getBlocks()[index]; short blockMeta = schematic.getBlockData()[index]; if (blockId == 4093) continue; if (blockId < 0 || blockId >= 4096) TechWorld.logging.severe("Error here"); world.setBlock(k + x, i + y, j + z, blockId, blockMeta, 2); } catch (Exception e) { e.printStackTrace(); TechWorld.logging.severe( String.format( "Failed placing block: rx=%d ry=%d rz=%d x=%d y=%d z=%d with error: %s", k, i, j, k + x, i + y, j + z, e.toString())); } } } } TechWorld.logging.info( String.format("This array has %d indices", schematic.getBlocks().length)); for (TileEntity entity : schematic.getTileEntities()) { if (entity instanceof SchematicTileEntity) { SchematicTileEntity schemTile = (SchematicTileEntity) entity; if (schemTile.getBlockName().startsWith("B-")) { BuildcraftPipeParser.BuildCraftPlace(schemTile, world, x, y, z); continue; } int blockNum = 0; int blockData = 0; try { blockNum = Integer.parseInt(schemTile.getBlockName()); } catch (NumberFormatException e) { blockNum = BlockManager.GetId(schemTile.getBlockName()); } try { blockData = Integer.parseInt(schemTile.getBlockData()); } catch (NumberFormatException e) { // TODO: handle name of block data here later } world.setBlock( entity.xCoord + x, entity.yCoord + y, entity.zCoord + z, blockNum, blockData, 2); TileEntity internalTE = TileEntity.createAndLoadEntity(schemTile.getTileEntity()); world.setBlockTileEntity( entity.xCoord + x, entity.yCoord + y, entity.zCoord + z, internalTE); continue; } world.setBlockTileEntity(entity.xCoord + x, entity.yCoord + y, entity.zCoord + z, entity); } }
/** * Generates Ore in a specific pattern * * @param only if true only the listed bioms else not the listed Bioms */ public void generateIt( Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider, Block ID, Block target, String[] bioms, boolean only, int tries) { boolean nosucsess; int trieCount = 0; BiomeGenBase b = world.getBiomeGenForCoords(chunkX, chunkZ); int yRandom; int zRandom; int xRandom; if (isBiom(bioms, b.biomeName) == only) { do { zRandom = random.nextInt(16); xRandom = random.nextInt(16); int S1 = world.getTopSolidOrLiquidBlock(xRandom + chunkX * 16, zRandom + chunkZ * 16); if (S1 > 19) { yRandom = random.nextInt(S1 - 19); } else { yRandom = 2; } int x = chunkX * 16 + xRandom; int y = yRandom; int z = chunkZ * 16 + zRandom; if (world.getBlock(x, y, z).isReplaceableOreGen(world, x, y, z, target) && world.getBlock(x, y - 1, z).isReplaceableOreGen(world, x, y - 1, z, target) && world.getBlock(x + 1, y, z).isReplaceableOreGen(world, x, y, z, target) && world.getBlock(x + 1, y - 1, z).isReplaceableOreGen(world, x, y, z, target)) { world.setBlock(x, y, z, ID); world.setBlock(x, y - 1, z, ID); world.setBlock(x + 1, y, z, ID); world.setBlock(x + 1, y - 1, z, ID); nosucsess = false; LogHelper.debug( "Generated " + ID.getLocalizedName() + " at " + " X: " + x + " Y: " + y + " Z: " + z); } else { nosucsess = true; trieCount++; LogHelper.debug("Had no sucess,try :" + trieCount + "/" + tries); } } while (nosucsess && trieCount < tries); } }
private void generateEntrance(World world, int x, int y, int z, int surface) { for (int i = 0; i < surface; i++) { world.setBlockToAir(x, y + surface, z); world.setBlock(x + 1, y + surface, z, ZenScape.blockZenBricks, 4, 3); world.setBlock(x - 1, y + surface, z, ZenScape.blockZenBricks, 4, 3); world.setBlock(x, y + surface, z + 1, ZenScape.blockZenBricks, 4, 3); world.setBlock(x, y + surface, z - 1, ZenScape.blockZenBricks, 4, 3); } }
public void updateTick(World world, int x, int y, int z, Random par5Random) { // world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world)); world.setBlock(x, y + 1, z, 204); world.setBlock(x, y + 2, z, 0); blockint = 0; // world.setBlock(x, y, z, 0); }
@Override public void handleClearAction( World world, int x, int y, int z, StructureTemplate template, StructureBB bb) { int maxWaterY = bb.min.y + template.yOffset - 1; if (y <= maxWaterY) { world.setBlock(x, y, z, Blocks.water); } else { world.setBlock(x, y, z, Blocks.air); } }
public static void updateFurnaceBlockState( boolean flag, World world, int i, int j, int k, Block activeID, Block idleID, boolean sounds) { int l = world.getBlockMetadata(i, j, k); TileEntity tileentity = world.getTileEntity(i, j, k); setKeepInventory(true); if (flag) { if (sounds) { world.playSoundEffect( i + 0.5F, j + 0.5F, k + 0.5F, "mob.ghast.fireball", 1.0F, 0.8F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F); world.playSoundEffect( i + 0.5F, j + 0.5F, k + 0.5F, "mob.zombiepig.zpigdeath", 0.1F, 0.1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.6F); world.playSoundEffect( i + 0.5F, j + 0.5F, k + 0.5F, "fire.ignite", 1.5F, 1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } world.setBlock(i, j, k, activeID); } else { if (sounds) world.playSoundEffect( i + 0.5F, j + 0.5F, k + 0.5F, "ambient.cave.cave", 0.1F, 0.1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); world.setBlock(i, j, k, idleID); } setKeepInventory(false); world.setBlockMetadataWithNotify(i, j, k, l, 2); if (tileentity != null) { tileentity.validate(); world.setTileEntity(i, j, k, tileentity); } }
public static void CreateSmooth(World world, int x, int y, int z, int id, int meta) { if (id == TFCBlocks.StoneIgIn.blockID) { world.setBlock(x, y, z, TFCBlocks.StoneIgInSmooth.blockID, meta, 0x2); } else if (id == TFCBlocks.StoneIgEx.blockID) { world.setBlock(x, y, z, TFCBlocks.StoneIgExSmooth.blockID, meta, 0x2); } else if (id == TFCBlocks.StoneSed.blockID) { world.setBlock(x, y, z, TFCBlocks.StoneSedSmooth.blockID, meta, 0x2); } else if (id == TFCBlocks.StoneMM.blockID) { world.setBlock(x, y, z, TFCBlocks.StoneMMSmooth.blockID, meta, 0x2); } }
public void updateTick(World world, int x, int y, int z, Random par5Random) { world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world)); EntitySergeantStrongstack entity = new EntitySergeantStrongstack(world); entity.setLocationAndAngles(x, y + 1, z, world.rand.nextFloat() * 360.0F, 0.0F); world.spawnEntityInWorld(entity); world.setBlock(x, y + 1, z, 0); world.setBlock(x, y + 2, z, 0); world.setBlock(x, y + 3, z, 0); // world.setBlock(x, y, z, 0); }
/** Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition var1) { int var2 = this.worldObj.getBlockId(var1.blockX, var1.blockY, var1.blockZ); int var3 = this.worldObj.getBlockMetadata(var1.blockX, var1.blockY, var1.blockZ); int x = var1.blockX; int y = var1.blockY; int z = var1.blockZ; if (status == 0) { // if (world.getBlockMaterial(x, y, z)== Material.water && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.ice.blockID); // } // if (world.getBlockMaterial(x, y, z )== Material.lava && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.stone.blockID); // } if (world.getBlockMaterial(x, y + 1, z) == Material.air && world.getBlockMaterial(x, y, z) != Material.snow && world.getBlockMaterial(x, y, z) != Material.ice) { world.setBlock(x, y + 1, z, Block.snow.blockID); } } else if (status == 1) { // if (world.getBlockMaterial(x, y, z )== Material.rock && world.getBlockMetadata(x,y,z) == // 0){ // world.setBlockToAir(x,y,z); // world.setBlock(x, y, z, Block.lavaStill.blockID); // } if (world.getBlockMaterial(x, y, z) == Material.ice && world.getBlockMetadata(x, y, z) == 0) { world.setBlockToAir(x, y, z); world.setBlock(x, y, z, Block.waterStill.blockID); } if (world.getBlockMaterial(x, y, z) == Material.snow && world.getBlockMetadata(x, y, z) == 0) { world.setBlockToAir(x, y, z); } } if (var1.entityHit != null) { var1.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), damage); if (status == 1) { var1.entityHit.setFire(20); } else if (status == 0 && var1.entityHit instanceof EntityLiving) { ((EntityLiving) var1.entityHit) .addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 2)); } } if (!this.worldObj.isRemote) { this.setDead(); } }
public boolean generate(World world, Random rand, int i, int j, int k) { world.setBlock(i + 0, j + 0, k + 1, VetheaBlockHelper.darkEverstone.blockID); world.setBlock(i + 1, j + 0, k + 0, VetheaBlockHelper.darkEverstone.blockID); world.setBlock(i + 1, j + 0, k + 1, VetheaBlockHelper.darkEverstone.blockID); world.setBlock(i + 1, j + 0, k + 2, VetheaBlockHelper.darkEverstone.blockID); world.setBlock(i + 1, j + 1, k + 1, VetheaBlockHelper.darkEverstone.blockID); world.setBlock(i + 1, j + 2, k + 1, VetheaBlockHelper.dreamlamp.blockID); world.setBlock(i + 2, j + 0, k + 1, VetheaBlockHelper.darkEverstone.blockID); return true; }
@Override public boolean onBlockDestroyed( ItemStack stack, World world, int blockID, int x, int y, int z, EntityPlayer player) { boolean b = false; Block block = Block.blocksList[blockID]; int plant = (int) ModuleManager.computeModularProperty(stack, PLANT_RADIUS); int leaf = (int) ModuleManager.computeModularProperty(stack, LEAF_RADIUS); int totalEnergyDrain = 0; // Leaves if (block != null && block.isLeaves(world, x, y, z)) { for (int i = -leaf; i < leaf; i++) { for (int j = -leaf; j < leaf; j++) { for (int k = -leaf; k < leaf; k++) { int id = world.getBlockId(x + i, y + j, z + k); int meta = world.getBlockId(x + i, y + j, z + k); Block tempBlock = Block.blocksList[id]; if (tempBlock != null && tempBlock.isLeaves(world, x + i, y + j, z + k)) { if (block.canHarvestBlock(player, meta)) { block.harvestBlock(world, player, x + i, y + j, z + k, meta); totalEnergyDrain += ModuleManager.computeModularProperty(stack, LEAF_BLOWER_ENERGY_CONSUMPTION); } world.setBlock(x + i, y + j, z + k, 0); b = true; } } } } } for (int i = -plant; i < plant; i++) { for (int j = -plant; j < plant; j++) { for (int k = -plant; k < plant; k++) { int id = world.getBlockId(x + i, y + j, z + k); int meta = world.getBlockId(x + i, y + j, z + k); Block tempBlock = Block.blocksList[id]; if (tempBlock != null && tempBlock instanceof BlockFlower) { if (block.canHarvestBlock(player, meta)) { block.harvestBlock(world, player, x + i, y + j, z + k, meta); totalEnergyDrain += ModuleManager.computeModularProperty(stack, LEAF_BLOWER_ENERGY_CONSUMPTION); } world.setBlock(x + i, y + j, z + k, 0); b = true; } } } } ElectricItemUtils.drainPlayerEnergy(player, totalEnergyDrain); return b; }
/** Called upon block activation (right click on the block.) */ public boolean onBlockActivated( World world, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par5EntityPlayer.getCurrentEquippedItem().itemID == this.blockID) { if (world.getBlockMetadata(par2, par3, par4) == 0 /*0 = Slab at bottom half*/) { if (par6 == 1 /*1 = top of the block*/) { if (!par5EntityPlayer.capabilities.isCreativeMode) { --par5EntityPlayer.getCurrentEquippedItem().stackSize; } world.playSoundEffect( (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), this.stepSound.getPlaceSound(), (this.stepSound.getVolume() + 1.0F) / 2.0F, this.stepSound.getPitch() * 0.8F); world.setBlock(par2, par3, par4, BOPBlocks.firDoubleSlab.blockID); return true; } } if (world.getBlockMetadata(par2, par3, par4) == 8 /*8 = Slab at top half*/) { if (par6 == 0 /*0 = bottom of the block*/) { if (!par5EntityPlayer.capabilities.isCreativeMode) { --par5EntityPlayer.getCurrentEquippedItem().stackSize; } world.playSoundEffect( (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), this.stepSound.getPlaceSound(), (this.stepSound.getVolume() + 1.0F) / 2.0F, this.stepSound.getPitch() * 0.8F); world.setBlock(par2, par3, par4, BOPBlocks.firDoubleSlab.blockID); return true; } } } return false; }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float hitVecX, float hitVecY, float hitVecZ) { if (player.getCurrentEquippedItem() != null) { if (player.getCurrentEquippedItem().getDisplayName().toLowerCase().contains("hoe")) { if (world.getBlockMetadata(x, y, z) == 0) { Block farmland = KoentusBlocks.crystal_farmland; world.playSoundEffect( x + 0.5F, y + 0.5F, z + 0.5F, farmland.stepSound.getStepResourcePath(), (farmland.stepSound.getVolume() + 1.0F) / 2.0F, farmland.stepSound.getPitch() * 0.8F); if (!world.isRemote) { world.setBlock(x, y, z, farmland, 0, 2); } player.getCurrentEquippedItem().damageItem(1, player); } else if (world.getBlockMetadata(x, y, z) == 1) { Block farmland = this; world.playSoundEffect( x + 0.5F, y + 0.5F, z + 0.5F, farmland.stepSound.getStepResourcePath(), (farmland.stepSound.getVolume() + 1.0F) / 2.0F, farmland.stepSound.getPitch() * 0.8F); if (!world.isRemote) { world.setBlock(x, y, z, farmland, 0, 2); } player.getCurrentEquippedItem().damageItem(1, player); } return true; } else { return false; } } else { return false; } }
public static void replaceBlock(World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); if (block.getMaterial() == Material.glass) { world.setBlock(x, y, z, OpenBlocks.Blocks.canvasGlass); } else { world.setBlock(x, y, z, OpenBlocks.Blocks.canvas); } TileEntityCanvas tile = (TileEntityCanvas) world.getTileEntity(x, y, z); tile.paintedBlock.setValue(block); tile.paintedBlockMeta.set(meta); }
public static void smashBlock(World world, int posX, int posY, int posZ) { Block block = world.getBlock(posX, posY, posZ); if (block == Blocks.stone) { world.setBlock(posX, posY, posZ, Blocks.cobblestone); return; } else if (block == Blocks.cobblestone) { world.setBlock(posX, posY, posZ, Blocks.gravel); return; } else if (block == Blocks.gravel) { world.setBlock(posX, posY, posZ, Blocks.sand); return; } }
public static void smashBlock(World world, int posX, int posY, int posZ) { Block block = Block.blocksList[world.getBlockId(posX, posY, posZ)]; if (block == Block.stone) { world.setBlock(posX, posY, posZ, Block.cobblestone.blockID); return; } else if (block == Block.cobblestone) { world.setBlock(posX, posY, posZ, Block.gravel.blockID); return; } else if (block == Block.gravel) { world.setBlock(posX, posY, posZ, Block.sand.blockID); return; } }
/** checks if the block can stay, if not drop as item */ protected void checkAndDropBlock(World w, int x, int y, int z) { if (!this.canBlockStay(w, x, y, z)) { int l = w.getBlockMetadata(x, y, z); if (!func_149887_c(l)) { this.dropBlockAsItem(w, x, y, z, l, 0); if (w.getBlock(x, y + 1, z) == this) { w.setBlock(x, y + 1, z, Blocks.air, 0, 2); } } w.setBlock(x, y, z, Blocks.air, 0, 2); } }
@Override public void applyModuleEffect(World world, EntityPlayer player, ItemStack stack) { int pX = (int) Math.round(player.posX); int pY = (int) Math.round(player.posY) - 1; int pZ = (int) Math.round(player.posZ); if (world.getBlock(pX, pY, pZ).getMaterial() == Material.water) { world.setBlock(pX, pY, pZ, InitBlocks.blockMeltingIce); } for (int i = 2; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; if (world.getBlock(pX + dir.offsetX, pY, pZ + dir.offsetZ).getMaterial() == Material.water) { world.setBlock(pX + dir.offsetX, pY, pZ + dir.offsetZ, InitBlocks.blockMeltingIce); } } }
@Override public boolean generate(World world, Random rand, int var3, int var4, int var5) { for (int i = var3; i < var3 + 16; i++) { for (int k = var5; k < var5 + 16; k++) { for (int j = 255; j >= var4; --j) { Block block = world.getBlock(i, j, k); int meta = 0; if (block == Blocks.sand) { meta = 1; } else if (block == Blocks.grass) { meta = 2; } else if (block == Blocks.clay) { meta = 3; } else if (block == Blocks.dirt) { meta = 2; } else { continue; } world.setBlock(i, j, k, Ids.blockFrass, meta, 3); break; } } } return true; }
/** The redstone ore glows. */ private void glow(World par1World, int par2, int par3, int par4) { this.sparkle(par1World, par2, par3, par4); if (this.blockID == TheVoid.voidMineralBlock.blockID) { par1World.setBlock(par2, par3, par4, TheVoid.voidMineralGlowingBlock.blockID); } }