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()); }
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()); } }
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; }
@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); } } }
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); }
@Override public Object execute(SpellContext context) throws SpellRuntimeException { if(context.caster.getEntityWorld().isRemote || context.caster.getEntityWorld().provider.doesWaterVaporize()) return null; Vector3 positionVal = this.getParamValue(context, position); if(positionVal == null) throw new SpellRuntimeException(SpellRuntimeException.NULL_VECTOR); if(!context.isInRadius(positionVal)) throw new SpellRuntimeException(SpellRuntimeException.OUTSIDE_RADIUS); BlockPos pos = positionVal.toBlockPos(); IBlockState state = context.caster.getEntityWorld().getBlockState(pos); if(state.getBlock().isAir(state, context.caster.getEntityWorld(), pos) || state.getBlock().isReplaceable(context.caster.getEntityWorld(), pos)) context.caster.getEntityWorld().setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState()); else { pos = pos.up(); state = context.caster.getEntityWorld().getBlockState(pos); if(state.getBlock().isAir(state, context.caster.getEntityWorld(), pos) || state.getBlock().isReplaceable(context.caster.getEntityWorld(), pos)) context.caster.getEntityWorld().setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState()); } return null; }
protected void digBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop) { Biome biome = world.getBiome(new BlockPos(x + chunkX * 16, 0, z + chunkZ * 16)); IBlockState top = isExceptionBiome(biome) ? Blocks.GRASS.getDefaultState() : biome.topBlock; IBlockState filler = isExceptionBiome(biome) ? Blocks.DIRT.getDefaultState() : biome.fillerBlock; IBlockState state = data.getBlockState(x, y, z); if (state.getBlock() == ModBlocks.UMBERSTONE || state.getBlock() == top.getBlock() || state.getBlock() == filler.getBlock()) { if (y < 3) data.setBlockState(x, y, z, Blocks.BEDROCK.getDefaultState()); else if (y < 4) data.setBlockState(x, y, z, ModBlocks.UMBERSTONE.getDefaultState()); else if (y < 10 && Biome.getIdForBiome(biome) == Biome.getIdForBiome(ModBiomes.VOLCANIC_DESERT)) data.setBlockState(x, y, z, Blocks.FLOWING_LAVA.getDefaultState()); else if (y < ChunkProviderErebus.swampWaterHeight - 1 && Biome.getIdForBiome(biome) == Biome.getIdForBiome(ModBiomes.SUBMERGED_SWAMP)) data.setBlockState(x, y, z, Blocks.FLOWING_WATER.getDefaultState()); else { data.setBlockState(x, y, z, Blocks.AIR.getDefaultState()); if (foundTop && data.getBlockState(x, y - 1, z).getBlock() == filler.getBlock()) data.setBlockState(x, y - 1, z, top.getBlock().getDefaultState()); } } } }
@Override public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } int maxEffects = currentEssence / getRefreshCost(); int totalEffects = 0; AreaDescriptor waterRange = masterRitualStone.getBlockRange(WATER_RANGE); for (BlockPos newPos : waterRange.getContainedPositions(masterRitualStone.getBlockPos())) { if (world.isAirBlock(newPos)) { world.setBlockState(newPos, Blocks.FLOWING_WATER.getDefaultState()); totalEffects++; } if (totalEffects >= maxEffects) { break; } } masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); }
world.setBlockState(pos, Blocks.FLOWING_LAVA.getDefaultState());