public static void createSkyblock(World world, BlockPos pos) { for(int i = 0; i < 3; i++) for(int j = 0; j < 4; j++) for(int k = 0; k < 3; k++) world.setBlockState(pos.add(-1 + i, -1 - j, -1 + k), j == 0 ? Blocks.GRASS.getDefaultState() : Blocks.DIRT.getDefaultState()); world.setBlockState(pos.add(-1, -2, 0), Blocks.FLOWING_WATER.getDefaultState()); world.setBlockState(pos.add(1, 2, 1), ModBlocks.manaFlame.getDefaultState()); ((TileManaFlame) world.getTileEntity(pos.add(1, 2, 1))).setColor(new Color(70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185)).getRGB()); int[][] rootPositions = new int[][] { { -1, -3, -1 }, { -2, -4, -1 }, { -2, -4, -2 }, { +1, -4, -1 }, { +1, -5, -1 }, { +2, -5, -1 }, { +2, -6, +0 }, { +0, -4, +2 }, { +0, -5, +2 }, { +0, -5, +3 }, { +0, -6, +3 }, }; for(int[] root : rootPositions) world.setBlockState(pos.add(root[0], root[1], root[2]), ModBlocks.root.getDefaultState()); world.setBlockState(pos.down(4), Blocks.BEDROCK.getDefaultState()); }
public ToolEntropyManipulator() { super( AEConfig.instance().getEntropyManipulatorBattery() ); this.heatUp = new HashMap<>(); this.coolDown = new HashMap<>(); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE.getDefaultState() ), new InWorldToolOperationResult( Blocks.COBBLESTONE.getDefaultState() ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONEBRICK.getDefaultState() ), new InWorldToolOperationResult( Blocks.STONEBRICK.getStateFromMeta( 2 ) ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( Blocks.DIRT.getDefaultState() ) ); final List<ItemStack> snowBalls = new ArrayList<>(); snowBalls.add( new ItemStack( Items.SNOWBALL ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult( null, snowBalls ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult( Blocks.ICE.getDefaultState() ) ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ICE.getDefaultState() ), new InWorldToolOperationResult( Blocks.WATER.getDefaultState() ) ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult() ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult() ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ), new InWorldToolOperationResult( Blocks.FLOWING_WATER.getStateFromMeta( 7 ) ) ); }
private boolean spreadWaterFromCenter(World world, EntityPlayer player, BlockPos posCenter) { int count = 0; for (BlockPos pos : UtilWorld.findBlocks(world, posCenter, Blocks.WATER, RADIUS)) { // world.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState()); // , state.withProperty(LEVEL, 0) //instead of just setBlockState, get the correct state for max level and for this fluid material, then schedule a tick update. //this way, it sends correct block update and avoids 'stuck' water that doesnt flow BlockDynamicLiquid blockdynamicliquid = BlockLiquid.getFlowingBlock(Material.WATER); IBlockState state = blockdynamicliquid.getDefaultState(); world.setBlockState(pos, blockdynamicliquid.getDefaultState().withProperty(BlockLiquid.LEVEL, state.getValue(BlockLiquid.LEVEL)), 2); world.scheduleUpdate(pos, blockdynamicliquid, blockdynamicliquid.tickRate(world)); UtilParticle.spawnParticle(world, EnumParticleTypes.WATER_SPLASH, pos); UtilParticle.spawnParticle(world, EnumParticleTypes.WATER_SPLASH, pos.up()); count++; } boolean success = count > 0; if (success) {//particles are on each location, sound is just once player.getCooldownTracker().setCooldown(this, COOLDOWN); UtilSound.playSound(player, SoundEvents.ENTITY_PLAYER_SPLASH); } return success; }
private void placeLava(EntityPlayer player, BlockPos pos, EnumHand hand) { PlayerHelper.checkedPlaceBlock(((EntityPlayerMP) player), pos, Blocks.FLOWING_LAVA.getDefaultState(), hand); }
@Override public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) { if (!world.isRemote) world.setBlockState(pos, Blocks.FLOWING_LAVA.getDefaultState(), 11); }
@Override public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) { if (!world.isRemote) world.setBlockState(pos, Blocks.FLOWING_LAVA.getDefaultState(), 11); } }
living.world.setBlockState(new BlockPos(living), Blocks.FLOWING_WATER.getDefaultState()); break;
/** * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes * Mineshafts at the end, it adds Fences... */ public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) { if (this.averageGroundLvl < 0) { this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn); if (this.averageGroundLvl < 0) { return true; } this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 3, 0); } IBlockState iblockstate = this.getBiomeSpecificBlockState(Blocks.PACKED_ICE.getDefaultState()); IBlockState iblockstate1 = this.getBiomeSpecificBlockState(Blocks.TORCH.getDefaultState()); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, 1, 4, 12, 4, iblockstate, Blocks.FLOWING_WATER.getDefaultState(), false); this.setBlockState(worldIn, Blocks.FLOWING_WATER.getDefaultState(), 2, 12, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.FLOWING_WATER.getDefaultState(), 3, 12, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.FLOWING_WATER.getDefaultState(), 2, 12, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.FLOWING_WATER.getDefaultState(), 3, 12, 3, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate1, 1, 12, 1, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate1, 4, 12, 1, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate1, 1, 12, 4, structureBoundingBoxIn); this.setBlockState(worldIn, iblockstate1, 4, 12, 4, structureBoundingBoxIn); return true; }
private void placeWater(World world, EntityPlayer player, BlockPos pos, EnumHand hand) { Material material = world.getBlockState(pos).getMaterial(); if (world.provider.doesWaterVaporize()) { world.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.PLAYERS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D); } } else { if (!world.isRemote && !material.isSolid() && !material.isLiquid()) { world.destroyBlock(pos, true); } world.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState()); PlayerHelper.checkedPlaceBlock(((EntityPlayerMP) player), pos, Blocks.FLOWING_WATER.getDefaultState(), hand); } }
placeState = Blocks.FLOWING_WATER.getDefaultState(); placeState = Blocks.FLOWING_WATER.getDefaultState();
private void tryFlowInto(World worldIn, BlockPos pos, IBlockState state, int level) { if (this.canFlowInto(state)) { if (state.getMaterial() != net.minecraft.block.material.Material.AIR) { if (state.getBlock() != Blocks.SNOW_LAYER) { state.getBlock().dropBlockAsItem(worldIn, pos, state, 0); } } worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState().withProperty(LEVEL, level), 3); } }
private void tryPlaceWater(BlockPos target) { if (world.getBlockState(target).getBlock().isReplaceable(world, target) && tank.getFluidAmount() >= Fluid.BUCKET_VOLUME && tank.drain(Fluid.BUCKET_VOLUME, true) != null) { tank.drain(Fluid.BUCKET_VOLUME, false); world.setBlockState(target, Blocks.FLOWING_WATER.getDefaultState()); } }
BlockPos pos = new BlockPos(xx, yy, zz); if (world.getBlockState(pos) == ModBlocks.UMBERSTONE.getDefaultState() && world.isAirBlock(pos.down())) { world.setBlockState(pos, Blocks.FLOWING_LAVA.getDefaultState()); world.immediateBlockTick(pos, Blocks.FLOWING_LAVA.getDefaultState(), rand);
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (!player.capabilities.isCreativeMode) { stack.shrink(1); } BlockPos offsetPos = pos.offset(facing); if (!player.canPlayerEdit(offsetPos, facing, stack)) { return EnumActionResult.FAIL; } else { if (world.isAirBlock(offsetPos)) { world.playSound(player, player.getPosition(), SoundEvents.ENTITY_GHAST_SCREAM, SoundCategory.PLAYERS, 0.4F, 0.8F); world.setBlockState(offsetPos, Blocks.FLOWING_LAVA.getDefaultState()); } stack.damageItem(1, player); return EnumActionResult.SUCCESS; } }
@Override protected void apply(RayTraceResult mop) { if (this.getEntityWorld().isRemote) { return; } if (tryConsumeEmc(((ItemPE) ObjHandler.volcanite), 32)) { switch (mop.typeOfHit) { case BLOCK: PlayerHelper.checkedPlaceBlock(((EntityPlayerMP) getThrower()), mop.getBlockPos().offset(mop.sideHit), Blocks.FLOWING_LAVA.getDefaultState()); break; case ENTITY: Entity ent = mop.entityHit; ent.setFire(5); ent.attackEntityFrom(DamageSource.IN_FIRE, 5); } } } }
@Override protected void apply(RayTraceResult mop) { if (this.getEntityWorld().isRemote) { return; } if (mop.typeOfHit == Type.BLOCK) { BlockPos pos = mop.getBlockPos().offset(mop.sideHit); if (world.isAirBlock(pos)) { PlayerHelper.checkedPlaceBlock(((EntityPlayerMP) getThrower()), pos, Blocks.FLOWING_WATER.getDefaultState()); } } else if (mop.typeOfHit == Type.ENTITY) { Entity ent = mop.entityHit; if (ent.isBurning()) { ent.extinguish(); } ent.addVelocity(this.motionX * 2, this.motionY * 2, this.motionZ * 2); } } }
worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
for (int yy = 0; yy < 8; ++yy) if (placeWater[(xx * 16 + zz) * 8 + yy]) worldIn.setBlockState(position.add(xx, yy, zz), yy >= 4 ? Blocks.AIR.getDefaultState() : Blocks.FLOWING_WATER.getDefaultState(), 3);
public void addInteractions() { addInteraction(Blocks.GRASS, Blocks.DIRT); addInteraction(Blocks.WATER.getDefaultState(), Blocks.ICE); addInteraction(Blocks.WATER, Blocks.SNOW); addInteraction(Blocks.FLOWING_WATER.getDefaultState(), Blocks.ICE); addInteraction(Blocks.FLOWING_WATER, Blocks.SNOW); addInteraction(Blocks.LAVA.getDefaultState(), Blocks.OBSIDIAN); addInteraction(Blocks.LAVA, Blocks.STONE); addInteraction(Blocks.LEAVES, Blocks.AIR); addInteraction(Blocks.LEAVES2, Blocks.AIR); addInteraction(Blocks.TALLGRASS, Blocks.AIR); addInteraction(Blocks.FIRE, Blocks.AIR); addInteraction(TFFluids.blockFluidGlowstone.getDefaultState(), Blocks.GLOWSTONE); }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (world.isRemote) { return new ActionResult<>(EnumActionResult.SUCCESS, stack); } BlockPos pos = BlockTools.getBlockClickedOn(player, world, true); if (pos == null) { return new ActionResult<>(EnumActionResult.PASS, stack); } if (!world.isAirBlock(pos)) { return new ActionResult<>(EnumActionResult.PASS, stack); } IBlockState state = world.getBlockState(pos); FloodFillPathfinder pf = new FloodFillPathfinder(player.world, pos, state.getBlock(), state, false, true); Set<BlockPos> blocks = pf.doFloodFill(); for (BlockPos p : blocks) { player.world.setBlockState(p, Blocks.FLOWING_WATER.getDefaultState()); } if (!player.capabilities.isCreativeMode) { stack.shrink(1); } return new ActionResult<>(EnumActionResult.SUCCESS, stack); }