@Override public void simulateBlockMine(BlockVector3 position) { BlockPos pos = ForgeAdapter.toBlockPos(position); IBlockState state = getWorld().getBlockState(pos); state.getBlock().dropBlockAsItem(getWorld(), pos, state, 0); getWorld().setBlockToAir(pos); }
@Override public BlockState getBlock(BlockVector3 position) { World world = getWorld(); BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); IBlockState mcState = world.getBlockState(pos); BlockType blockType = BlockType.REGISTRY.get(Block.REGISTRY.getNameForObject(mcState.getBlock()).toString()); return blockType.getState(adaptProperties(blockType, mcState.getProperties())); }
@Override public int hashCode() { return this.state.getBlock().hashCode(); }
@Override public void recieveMana(int mana) { this.mana = Math.max(0, Math.min(MAX_MANA, this.mana + mana)); world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock()); }
@Override public boolean isAirBlock( BlockPos pos ) { IBlockState state = this.getBlockState( pos ); return state.getBlock().isAir( state, this.world, pos ); }
@Nonnull @Override public IBlockState getBlockState(@Nonnull BlockPos pos) { IBlockState state = compose.getBlockState(pos); if(state.getBlock() instanceof BlockCamo) { state = ((TileCamo) compose.getTileEntity(pos)).camoState; } return state == null ? Blocks.AIR.getDefaultState() : state; }
@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; }
private boolean doNotSkip( final int y ) { final ExtendedBlockStorage[] storage = this.c.getBlockStorageArray(); final ExtendedBlockStorage extendedblockstorage = storage[y >> 4]; if( CachedPlane.this.reg.isBlacklisted( extendedblockstorage.get( this.x, y & 15, this.z ).getBlock() ) ) { return false; } return this.skipThese == null || !this.skipThese.contains( y ); }
@SideOnly(Side.CLIENT) @Override public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) { Block block = world.getBlockState(pos.offset(side)).getBlock(); return block == this ? false : super.shouldSideBeRendered(state, world, pos, side); }
@Override public void recieveMana(int mana) { int old = this.mana; this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap)); if(old != this.mana) { world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock()); markDispatchable(); } }
public static boolean isBlockAir( final World w, final BlockPos pos ) { try { return w.getBlockState( pos ).getBlock().isAir( w.getBlockState( pos ), w, pos ); } catch( final Throwable e ) { return false; } }
@Override public boolean matches(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); return !state.getBlock().isAir(state, world, pos) && state.getCollisionBoundingBox(world, pos) != null; }
@Override public int getLightValue(@Nonnull IBlockState state, IBlockAccess world, @Nonnull BlockPos pos) { if(world.getBlockState(pos).getBlock() != this) return world.getBlockState(pos).getLightValue(world, pos); return world.getTileEntity(pos) == null ? 0 : ((TileSpecialFlower) world.getTileEntity(pos)).getLightValue(); }
@Override @Optional.Method(modid = "easycoloredlights") public int getLightValue(@Nonnull IBlockState state, IBlockAccess world, @Nonnull BlockPos pos) { if(world.getBlockState(pos).getBlock() != this) return world.getBlockState(pos).getLightValue(world, pos); return ((TileManaFlame) world.getTileEntity(pos)).getLightColor(); }
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; }
@Override public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { TileEnchanter enchanter = (TileEnchanter) world.getTileEntity(pos); if(!enchanter.itemToEnchant.isEmpty()) { world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), enchanter.itemToEnchant)); } world.updateComparatorOutputLevel(pos, state.getBlock()); super.breakBlock(world, pos, state); }
@Override public boolean acceptBlock(BlockPos pos) { if(pos.equals(getPos().up())) return false; Block block = world.getBlockState(pos).getBlock(); TileEntity tile = world.getTileEntity(pos); return (block instanceof BlockFlower || block instanceof BlockMushroom || block instanceof BlockDoublePlant) && (tile == null || !(tile instanceof ISubTileContainer)); }
public boolean canEject() { IBlockState stateBelow = world.getBlockState(pos.down()); Block blockBelow = stateBelow.getBlock(); return blockBelow.isAir(stateBelow, world, pos.down()) || stateBelow.getCollisionBoundingBox(world, pos.down()) == null; }
private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) { RayTraceResult mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D()); if(mop == null) return prevresistance; if(mop.typeOfHit == RayTraceResult.Type.BLOCK) { Block block = world.getBlockState(mop.getBlockPos()).getBlock(); if(world.isAirBlock(mop.getBlockPos())) return prevresistance; return prevresistance + block.getExplosionResistance(null) + 0.3F; } else return prevresistance; }
@Override public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor ) { if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) { final TileEntity te = this.getHost().getTile(); final AEPartLocation side = this.getSide(); final BlockPos tePos = te.getPos().offset( side.getFacing() ); this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ); } }