@Override public void update() { super.update(); if (!worldObj.isRemote && boundedRect != null && worldObj.getTotalWorldTime() % 20L == 0) { if (currentCheckingVec == null) currentCheckingVec = new Vector3<Integer>(boundedRect.min.x.intValue(), pos.getY(), boundedRect.min.y.intValue()); // ProjectZed.logHelper.info("boundedRect", boundedRect, "currentCheckingVec", currentCheckingVec, getCurrentFacing()); final Block currentBlock = BlockUtils.getBlock(worldObj, currentCheckingVec).getBlock(); final int currentMeta = BlockUtils.getBlockMetadata(worldObj, currentCheckingVec); if (currentBlock instanceof BlockLog || (currentBlock instanceof BlockCrops && currentMeta >= 7)) { // chopTree((BlockLog) currentBlock); chopTree(); return; } incrementVector(); } }
private BlockLog.EnumAxis getLogAxis(BlockPos p_175938_1_, BlockPos p_175938_2_) { BlockLog.EnumAxis blocklog$enumaxis = BlockLog.EnumAxis.Y; int i = Math.abs(p_175938_2_.getX() - p_175938_1_.getX()); int j = Math.abs(p_175938_2_.getZ() - p_175938_1_.getZ()); int k = Math.max(i, j); if (k > 0) { if (i == k) { blocklog$enumaxis = BlockLog.EnumAxis.X; } else if (j == k) { blocklog$enumaxis = BlockLog.EnumAxis.Z; } } return blocklog$enumaxis; }
/** * Convert the BlockState into the correct metadata value */ @SuppressWarnings("incomplete-switch") public int getMetaFromState(IBlockState state) { int i = 0; switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) { case X: i |= 0; break; case Z: i |= 1; break; case NONE: i |= 2; } int j = state.getValue(GENERATED); i += j*3; return i; }
public int getAmountPerTick(World world, BlockPos pos,EnumFacing facing){ int amtPerBlock = 2; //mb BlockPos start = pos.offset(facing); int totalAmount = 0 ; if(world.getBlockState(start) instanceof BlockLog){ for(int k= -1;k<14;k++){ for(int i= -1;i<2;i++){ for(int j= -1;j<2;j++){ if(world.getBlockState(start.add(i, j, k)) instanceof BlockLog){ totalAmount += amtPerBlock; } } } } } return totalAmount; }
@Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState(); switch (meta) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 1: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 2: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
public int getAmountPerTick(World world, BlockPos pos, EnumFacing facing) { int amtPerBlock = 2; //mb BlockPos start = pos.offset(facing); int totalAmount = 0; if (world.getBlockState(start) instanceof BlockLog) { for (int k = -1; k < 14; k++) { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (world.getBlockState(start.add(i, j, k)) instanceof BlockLog) { totalAmount += amtPerBlock; } } } } } return totalAmount; }
private BlockLog.EnumAxis func_175938_b(BlockPos p_175938_1_, BlockPos p_175938_2_) { BlockLog.EnumAxis blocklog$enumaxis = BlockLog.EnumAxis.Y; int i = Math.abs(p_175938_2_.getX() - p_175938_1_.getX()); int j = Math.abs(p_175938_2_.getZ() - p_175938_1_.getZ()); int k = Math.max(i, j); if (k > 0) { if (i == k) { blocklog$enumaxis = BlockLog.EnumAxis.X; } else if (j == k) { blocklog$enumaxis = BlockLog.EnumAxis.Z; } } return blocklog$enumaxis; }
@Override public boolean generate(World world, Random rand, BlockPos pos) { int height = getTreeHeight(rand); int trunkHeight = height - variant.leavesHeightTotal; // if (!BlockVolumeShape.region(-1, 1, -1, 1, trunkHeight - 1, 1) // .and(-3, trunkHeight, -3, 3, height, 3) // .hasSpace(pos, isEmptySpace(world))) // return false; for (int i = 0; i < trunkHeight; i++) { setBlockInWorld(world, pos.up(i), LOG.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); } generateTreeLeavesAndBranches(world, pos.add(0, trunkHeight, 0), pos, rand); return true; }
private void generateBranch(World world, Random rand, BlockPos trunkPos, Vec3d endPos) { Vec3d curr = new Vec3d(trunkPos); Vec3d next = next(world, curr, endPos.subtract(curr).normalize(), endPos, trunkPos); BlockPos prev; do { BlockPos currBlock = new BlockPos(curr); Vec3d dir = endPos.subtract(curr).normalize(); prev = currBlock; curr = next; next = next(world, curr, dir, endPos, trunkPos); IBlockState state = (xzEqual(currBlock, trunkPos) ? LOG : LOG.withProperty(BlockLog.LOG_AXIS, getLogAxis(world, currBlock, dir))); setBlockInWorld(world, currBlock, state); // check to avoid long straight up branches BlockPos nextBlock = new BlockPos(next); if (endPos.squareDistanceTo(next) > Math.sqrt(3) && xzEqual(prev, currBlock) && xzEqual(currBlock, nextBlock)) { next = next.addVector(rand.nextBoolean() ? -1 : 1, 0, rand.nextBoolean() ? -1 : 1); } } while (endPos.squareDistanceTo(curr) > Math.sqrt(3)); generateLeaves(world, rand, curr); generateLeaves(world, rand, new Vec3d(prev)); }
@Override public IBlockState getStateFromMeta(int meta) { IBlockState state = getDefaultState(); switch (meta & LOG_NO_AXIS_FLAG) { case 0: state = state.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case LOG_X_AXIS_FLAG: state = state.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case LOG_Z_AXIS_FLAG: state = state.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: state = state.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return state; }
/** * Convert the given metadata into a BlockState for this Block */ @Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, WoodType.byMetadata((meta & 3) % 4)); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
@Override @Nonnull public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState(); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
@Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState().withProperty(wood_type, EnumLogType.getType(meta)).withProperty(double_drop, Boolean.valueOf((meta % 4) < 2)); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
@Override public IBlockState getStateFromMeta(int meta) { IBlockState state = this.getDefaultState(); switch (meta & 12) { case 0: return state.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); case 4: return state.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); case 8: return state.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); default: return state.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } }
@SuppressWarnings("incomplete-switch") public Trunk(World world, BlockPos pos, EnumFacing direction, IBlockState blockState, int treeHeight) { super(world, pos, direction, blockState, treeHeight); switch (this.direction) { case NORTH : case SOUTH : this.blockState = this.blockState .withProperty(BlockLog.LOG_AXIS, EnumAxis.Z); break; case EAST : case WEST : this.blockState = this.blockState .withProperty(BlockLog.LOG_AXIS, EnumAxis.X); } }
/** Checks and fells tree starting at given position. */ public static void checkTreeFall(World world, BlockPos pos) { boolean logFall = world.isAirBlock(pos.down()); for (BlockPos offset : TreeFallUtils.TRUNK_OFFSETS) { if (world.getBlockState(pos.subtract(offset)).getBlock() instanceof BlockLog) { logFall = false; break; } } if (logFall) { fellTree(world, pos); } }
@Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState(); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
@Override public int getMetaFromState(IBlockState state) { byte b0 = 0; int i = b0 | ((IMetadataEnum) state.getValue(getVariant())).getMetadata(); switch (SwitchEnumAxis.AXIS_LOOKUP[((net.minecraft.block.BlockLog.EnumAxis) state.getValue(LOG_AXIS)).ordinal()]) { case 1: i |= 4; break; case 2: i |= 8; break; case 3: i |= 12; } return i; }
@Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, MWoodType.byMetadata((meta & 3) % 4)); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
public static boolean onBlockDestroyedHook(boolean result, ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entity) { if (stack.hasTagCompound()) { NBTTagCompound tag = stack.getTagCompound(); if (!tag.hasKey("isHeavyAxe", 1) && !HeavyMeddleMod.allAxesHeavy) return result; } else if (!HeavyMeddleMod.allAxesHeavy) return result; if (entity.isSneaking()) return result; Block block = state.getBlock(); if (block instanceof BlockLog && entity instanceof EntityPlayer) { HashSet<BlockPos> tree = new HashSet<BlockPos>(); boolean hasLeaves = addNeighbors(block, world, pos, pos, (EntityPlayer)entity, tree); if (hasLeaves || ignoreLeaves) { for (BlockPos currentPos : tree) { if (!destroyBlock(block, world, currentPos, (EntityPlayer)entity)) break; } } } return result; }
/** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState(); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
/** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { byte b0 = 0; int i = b0; switch (BlockCherryLog.SwitchEnumAxis.AXIS_LOOKUP[((BlockLog.EnumAxis)state.getValue(LOG_AXIS)).ordinal()]) { case 1: i |= 4; break; case 2: i |= 8; break; case 3: i |= 12; } return i; }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand enumHand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { Block targetBlock = BlockUtils.getBlock(world, pos); if (targetBlock != null && targetBlock instanceof BlockLog) { world.destroyBlock(pos, false); Block blockToPlace = ModBlocks.TOTEM_WOOD; if (blockToPlace != null) { world.setBlockState(pos, blockToPlace.getDefaultState()); return EnumActionResult.SUCCESS; } } } return EnumActionResult.FAIL; }
@Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = getDefaultState(); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
@Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (worldIn.isRemote) return; BlockPos outpos = pos.offset(getFacing(this.getMetaFromState(state))); IBlockState outblock = worldIn.getBlockState(outpos); worldIn.playAuxSFX(2001, outpos, Block.getIdFromBlock(state.getBlock())); if (outblock.getBlock() instanceof BlockLog) { this.breakWood(worldIn, outpos, outblock, rand); } else if (outblock.getBlock().getMaterial() == Material.wood) { worldIn.setBlockToAir(outpos); this.dropBlockAsItem(worldIn, outpos, outblock, 0); } }
/** * Convert the given metadata into a BlockState for this Block */ @Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata((meta & 3) + 4)); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
/** * Convert the BlockState into the correct metadata value */ @Override public int getMetaFromState(IBlockState state) { byte b0 = 0; int i = b0 | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4; switch (BlockReinforcedNewLog.SwitchEnumAxis.AXIS_LOOKUP[((BlockLog.EnumAxis)state.getValue(LOG_AXIS)).ordinal()]) { case 1: i |= 4; break; case 2: i |= 8; break; case 3: i |= 12; } return i; }
/** * Convert the given metadata into a BlockState for this Block */ @Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata((meta & 3) % 4)); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
/** * Convert the BlockState into the correct metadata value */ @Override public int getMetaFromState(IBlockState state) { byte b0 = 0; int i = b0 | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); switch (BlockReinforcedOldLog.SwitchEnumAxis.AXIS_LOOKUP[((BlockLog.EnumAxis)state.getValue(LOG_AXIS)).ordinal()]) { case 1: i |= 4; break; case 2: i |= 8; break; case 3: i |= 12; } return i; }