@Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { EnumPlantType type = plantable.getPlantType(world, pos.down()); return type == EnumPlantType.Plains || type == EnumPlantType.Beach; }
@Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { return plantable.getPlantType(world, pos.down()) == EnumPlantType.Plains; }
private IItemHandler getInv() { TileEntity te = world.getTileEntity(pos.down()); IItemHandler ret = InventoryHelper.getInventory(world, pos.down(), EnumFacing.UP); if(ret == null) ret = InventoryHelper.getInventory(world, pos.down(), null); if(ret != null && !(te instanceof TileCorporeaFunnel)) return ret; te = world.getTileEntity(pos.down(2)); ret = InventoryHelper.getInventory(world, pos.down(2), EnumFacing.UP); if(ret == null) ret = InventoryHelper.getInventory(world, pos.down(2), null); if(ret != null && !(te instanceof TileCorporeaFunnel)) return ret; return null; }
public boolean isOnSpecialSoil() { return world.getBlockState(pos.down()).getBlock() == ModBlocks.enchantedSoil; }
@Override public int getAvailableSpaceForMana() { int space = Math.max(0, manaCap - getCurrentMana()); if(space > 0) return space; else if(world.getBlockState(pos.down()).getBlock() == ModBlocks.manaVoid) return manaCap; else return 0; }
@Override public boolean isFull() { Block blockBelow = world.getBlockState(pos.down()).getBlock(); return blockBelow != ModBlocks.manaVoid && getCurrentMana() >= manaCap; }
@Override public int getSlowdownFactor() { Block below = world.getBlockState(getPos().down()).getBlock(); if(below == Blocks.MYCELIUM) return SLOWDOWN_FACTOR_MYCEL; if(below == Blocks.DIRT) { BlockDirt.DirtType type = world.getBlockState(getPos().down()).getValue(BlockDirt.VARIANT); if(type == BlockDirt.DirtType.PODZOL) return SLOWDOWN_FACTOR_PODZOL; } return 0; } }
public IBlockState getUnderlyingBlock() { return supertile.getWorld().getBlockState(supertile.getPos().down(supertile instanceof IFloatingFlower ? 1 : 2)); }
@Nonnull @Override public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, @Nonnull BlockPos pos, int fortune) { ArrayList<ItemStack> ret = new ArrayList<>(); IBlockState state = world.getBlockState(pos); IBlockState stateBelow = world.getBlockState(pos.down()); if (stateBelow.getBlock() == this && stateBelow.getValue(HALF) == EnumBlockHalf.LOWER && state.getValue(HALF) == EnumBlockHalf.UPPER) { ret.add(new ItemStack(this, 1, getMetaFromState(world.getBlockState(pos.down())))); } if (state.getValue(HALF) == EnumBlockHalf.LOWER) { ret.add(new ItemStack(this, 1, getMetaFromState(state))); } return ret; }
@Nonnull @Override public IBlockState getActualState(IBlockState state, @Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos) { if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER) { IBlockState iblockstate = worldIn.getBlockState(pos.down()); if (iblockstate.getBlock() == this) { PropertyEnum<EnumDyeColor> prop = second ? BotaniaStateProps.DOUBLEFLOWER_VARIANT_2 : BotaniaStateProps.DOUBLEFLOWER_VARIANT_1; state = state.withProperty(prop, iblockstate.getValue(prop)); } } return state.withProperty(VARIANT, EnumPlantType.SUNFLOWER).withProperty(FACING, EnumFacing.SOUTH); }
public List<BlockPos> locatePylons() { List<BlockPos> list = new ArrayList(); int range = 5; IBlockState pylonState = ModBlocks.pylon.getDefaultState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.NATURA); IBlockState poolState = ModBlocks.pool.getDefaultState(); for(int i = -range; i < range + 1; i++) for(int j = -range; j < range + 1; j++) for(int k = -range; k < range + 1; k++) { BlockPos pos = new BlockPos(i, j, k); if(checkPosition(pos, pylonState, false) && checkPosition(pos.down(), poolState, true)) list.add(pos); } return list; }
@Override public boolean canBlockStay(@Nonnull World worldIn, BlockPos pos, IBlockState state) { if (pos.getY() >= 0 && pos.getY() < 256) { IBlockState iblockstate = worldIn.getBlockState(pos.down()); return iblockstate.getBlock() == Blocks.MYCELIUM || (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL || iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this)); } else { return false; } }
@Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { super.onBlockAdded(world, pos, state); if(!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) { world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2); world.setBlockState(pos.down(), Blocks.AIR.getDefaultState(), 2); world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState(), 2); EntityBlaze blaze = new EntityBlaze(world); blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F); blaze.deathLootTable = LOOT_TABLE; blaze.onInitialSpawn(world.getDifficultyForLocation(pos), null); world.spawnEntity(blaze); world.notifyNeighborsOfStateChange(pos, Blocks.AIR, false); world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR, false); world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR, false); } }
public static boolean canEnchanterExist(World world, BlockPos pos, EnumFacing.Axis axis) { for(BlockPos obsidian : OBSIDIAN_LOCATIONS) if(world.getBlockState(pos.add(obsidian)).getBlock() != Blocks.OBSIDIAN) return false; for(BlockPos pylon : PYLON_LOCATIONS.get(axis)) if(world.getBlockState(pos.add(pylon)).getBlock() != ModBlocks.pylon || !BotaniaAPI.internalHandler.isBotaniaFlower(world, pos.add(pylon).down())) return false; for(BlockPos flower : FLOWER_LOCATIONS) if(!BotaniaAPI.internalHandler.isBotaniaFlower(world, pos.add(flower))) return false; return true; }
private boolean canPullItem(EntityItem item) { if(item.isDead || SubTileSolegnolia.hasSolegnoliaAround(item)) return false; ItemStack stack = item.getItem(); if(stack.isEmpty() || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(Item.REGISTRY.getNameForObject(stack.getItem())) || BotaniaAPI.isItemBlacklistedFromMagnet(stack)) return false; BlockPos pos = new BlockPos(item); if(BotaniaAPI.isBlockBlacklistedFromMagnet(item.world.getBlockState(pos))) return false; if(BotaniaAPI.isBlockBlacklistedFromMagnet(item.world.getBlockState(pos.down()))) return false; return true; }
public void openInventory( final EntityPlayer player ) { if( !player.isSpectator() ) { this.setPlayerOpen( this.getPlayerOpen() + 1 ); this.world.addBlockEvent( this.pos, this.getBlockType(), 1, this.numPlayersUsing ); this.world.notifyNeighborsOfStateChange( this.pos, this.getBlockType(), true ); this.world.notifyNeighborsOfStateChange( this.pos.down(), this.getBlockType(), true ); if( this.getPlayerOpen() == 1 ) { this.getWorld() .playSound( player, this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F ); this.markForUpdate(); } } }
@Override public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { if(!entity.world.isRemote && !burst.isFake() && pos.getBlockPos() != null) { int harvestLevel = ConfigHandler.harvestLevelWeight; BlockPos bPos = pos.getBlockPos(); Block block = entity.world.getBlockState(bPos).getBlock(); IBlockState state = entity.world.getBlockState(bPos); int neededHarvestLevel = block.getHarvestLevel(state); if(entity.world.isAirBlock(bPos.down()) && state.getBlockHardness(entity.world, bPos) != -1 && neededHarvestLevel <= harvestLevel && entity.world.getTileEntity(bPos) == null && block.canSilkHarvest(entity.world, bPos, state, null)) { state = TECHNICAL_BLOCK_REMAP.getOrDefault(state, state); EntityFallingBlock falling = new EntityFallingBlock(entity.world, bPos.getX() + 0.5, bPos.getY(), bPos.getZ() + 0.5, state); falling.fallTime = 1; entity.world.setBlockToAir(bPos); ((WorldServer) entity.world).spawnParticle(EnumParticleTypes.FALLING_DUST, bPos.getX() + 0.5, bPos.getY() + 0.5, bPos.getZ() + 0.5, 10, 0.45, 0.45, 0.45, 5, new int[] {Block.getStateId(state)}); entity.world.spawnEntity(falling); } } return dead; }
@SubscribeEvent public static void onPlayerUpdate(LivingUpdateEvent event) { if(event.getEntityLiving() instanceof EntityPlayer && !event.getEntityLiving().world.isRemote) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); NBTTagCompound data = player.getEntityData(); if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); if(player.ticksExisted > 3 && !persist.getBoolean(TAG_MADE_ISLAND)) { World world = player.world; if(WorldTypeSkyblock.isWorldSkyblock(world)) { BlockPos coords = world.getSpawnPoint(); if(world.getBlockState(coords.down(4)).getBlock() != Blocks.BEDROCK && world.provider.getDimension() == 0) spawnPlayer(player, coords, false); } persist.setBoolean(TAG_MADE_ISLAND, true); } } }