net.minecraft.block.BlockLog Java Examples
The following examples show how to use
net.minecraft.block.BlockLog.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldGenBigSakura.java From Sakura_mod with MIT License | 6 votes |
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; }
Example #2
Source File: Log.java From minecraft-roguelike with GNU General Public License v3.0 | 6 votes |
public static MetaBlock get(Wood type, Cardinal dir){ MetaBlock log = new MetaBlock(getBlockId(type)); setType(log, type); if(dir == null){ log.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.NONE); return log; } switch(dir){ case UP: case DOWN: log.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y); break; case EAST: case WEST: log.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); break; case NORTH: case SOUTH: log.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); break; default: log.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.NONE); break; } return log; }
Example #3
Source File: BlockCharcoalLog.java From AdvancedRocketry with MIT License | 6 votes |
public int getMetaFromState(IBlockState state) { int i = 0; switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) { case X: i |= 4; break; case Z: i |= 8; break; case NONE: i |= 12; } return i; }
Example #4
Source File: BlockCharcoalLog.java From AdvancedRocketry with MIT License | 6 votes |
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; }
Example #5
Source File: BlockAlienWood.java From AdvancedRocketry with MIT License | 6 votes |
@Override public int getMetaFromState(IBlockState state) { int i = 0; switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) { case X: i |= 4; break; case Z: i |= 8; break; case NONE: i |= 12; } return i; }
Example #6
Source File: BlockAlienWood.java From AdvancedRocketry with MIT License | 6 votes |
@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; }
Example #7
Source File: TreeChopTask.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
public static int isLogBlock(IBlockState blockState) { if(blockState.getMaterial() == Material.AIR) { return 0; } if(blockState.getBlock() instanceof BlockLog) { return 1; } else if(blockState.getBlock() instanceof BlockLeaves) { return 2; } Item itemBlock = Item.getItemFromBlock(blockState.getBlock()); ItemStack blockStack = new ItemStack(itemBlock, 1, blockState.getBlock().damageDropped(blockState)); Set<String> blocks = OreDictUnifier.getOreDictionaryNames(blockStack); if(blocks.contains("logWood")) { return 1; } else if(blocks.contains("treeLeaves")) { return 2; } else return 0; }
Example #8
Source File: WorldGenBigMaple.java From Sakura_mod with MIT License | 6 votes |
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; }
Example #9
Source File: WorldGenBigMaple.java From Sakura_mod with MIT License | 6 votes |
void limb(BlockPos p_175937_1_, BlockPos p_175937_2_, Block p_175937_3_) { BlockPos blockpos = p_175937_2_.add(-p_175937_1_.getX(), -p_175937_1_.getY(), -p_175937_1_.getZ()); int i = this.getGreatestDistance(blockpos); float f = (float)blockpos.getX() / (float)i; float f1 = (float)blockpos.getY() / (float)i; float f2 = (float)blockpos.getZ() / (float)i; for (int j = 0; j <= i; ++j) { BlockPos blockpos1 = p_175937_1_.add(0.5F + j * f, 0.5F + j * f1, 0.5F + j * f2); BlockLog.EnumAxis blocklog$enumaxis = this.getLogAxis(p_175937_1_, blockpos1); this.setBlockAndNotifyAdequately(this.world, blockpos1, p_175937_3_.getDefaultState().withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis)); if (this.generateSap && j == 1) { if (this.world.getBlockState(blockpos1.add(0, j, 0))==this.metaWood) { this.addSapLog(this.world, blockpos1.add(0, j, 0)); } } } }
Example #10
Source File: BlockGregLog.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public BlockGregLog() { this.setDefaultState(this.blockState.getBaseState() .withProperty(VARIANT, LogVariant.RUBBER_WOOD) .withProperty(LOG_AXIS, BlockLog.EnumAxis.Y) .withProperty(NATURAL, false)); setUnlocalizedName("gt.log"); this.setCreativeTab(GregTechAPI.TAB_GREGTECH); }
Example #11
Source File: BlockTraverseWoodLog.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public BlockTraverseWoodLog(String name) { super(); setRegistryName(new ResourceLocation(TraverseConstants.MOD_ID, name + "_log")); setCreativeTab(TraverseTab.TAB); setTranslationKey(getRegistryName().toString()); setDefaultState(this.blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); ShootingStar.registerModel(new ModelCompound(TraverseConstants.MOD_ID, this, "log")); }
Example #12
Source File: BlockTraverseWoodLog.java From Traverse-Legacy-1-12-2 with MIT License | 5 votes |
public BlockTraverseWoodLog(String name) { super(); setRegistryName(new ResourceLocation(TraverseConstants.MOD_ID, name + "_log")); setCreativeTab(TraverseTab.TAB); setUnlocalizedName(getRegistryName().toString()); setDefaultState(this.blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); ShootingStar.registerModel(new ModelCompound(TraverseConstants.MOD_ID, this, "log")); }
Example #13
Source File: WrappedBlockStateTests.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@Test public void test_deserialization_propertiesAsString() { WrappedBlockState state = gson.fromJson("{ \"block\": \"minecraft:log\", \"properties\" : \"variant=spruce,axis=z\" }", WrappedBlockState.class); IBlockState blockState = state.createState(); assertNotNull(state); assertNotNull(blockState); assertSame(Blocks.LOG, blockState.getBlock()); assertSame(BlockPlanks.EnumType.SPRUCE, blockState.getValue(BlockOldLog.VARIANT)); assertSame(BlockLog.EnumAxis.Z, blockState.getValue(BlockLog.LOG_AXIS)); }
Example #14
Source File: WorldGenAlienTree.java From AdvancedRocketry with MIT License | 5 votes |
private boolean replaceBlockWithWood(World world, int x, int y, int z, EnumFacing direction) { BlockPos pos = new BlockPos(x,y,z); IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if( block.isReplaceable(world, pos) || block.isLeaves(state, world, pos) || block == AdvancedRocketryBlocks.blockAlienWood) { this.setBlockAndNotifyAdequately(world, pos, AdvancedRocketryBlocks.blockAlienWood.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.fromFacingAxis(direction.getAxis()))); return true; } else return false; }
Example #15
Source File: WorldGenSwampTree.java From AdvancedRocketry with MIT License | 5 votes |
private void buildRoots() { cachedRoots.clear(); for (double Yangle = 0; Yangle < 2*Math.PI; Yangle+=Math.PI/3.0){ // Yangle = 0.0;//Math.PI/4.0; int yOffset = (int)(1.25*arcSize*Math.sin(Math.PI)) + 1; int xOffset = (int)(1.1*arcSize*Math.cos(Math.PI)*Math.cos(Yangle)); int zOffset = (int)(1.1*arcSize*Math.cos(Math.PI)*Math.sin(Yangle)); for(double angle = Math.PI; angle > 0; angle -= Math.PI/40.0) { int yy = (int)(1.25*arcSize*Math.sin(angle)); double xzRadius = (0.75*arcSize*Math.cos(angle)); int xx = (int) (xzRadius*Math.cos(Yangle)); int zz = (int) (xzRadius*Math.sin(Yangle)); if(!cachedRoots.containsKey(new BlockPos(2 + xx - xOffset, yy - yOffset +2, zz- zOffset))) cachedRoots.put( new BlockPos(2 + xx - xOffset, yy - yOffset +2, zz- zOffset), Blocks.LOG.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y)); if(!cachedRoots.containsKey(new BlockPos(3 + xx - xOffset, yy - yOffset +2, zz- zOffset))) cachedRoots.put(new BlockPos(3 + xx - xOffset, yy - yOffset +2, zz- zOffset), Blocks.LOG.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y)); if(!cachedRoots.containsKey(new BlockPos(2 + xx - xOffset, yy - yOffset +2, 1 + zz- zOffset))) cachedRoots.put( new BlockPos(2 + xx - xOffset, yy - yOffset +2, 1 + zz- zOffset), Blocks.LOG.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y)); if(!cachedRoots.containsKey(new BlockPos(2 + xx - xOffset, yy - yOffset +3, 1 + zz- zOffset))) cachedRoots.put( new BlockPos(2 + xx - xOffset, yy - yOffset +3, 1 + zz- zOffset), Blocks.LOG.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y)); if(!cachedRoots.containsKey(new BlockPos(1 + xx - xOffset , yy - yOffset +2, zz- zOffset))) cachedRoots.put(new BlockPos(1 + xx - xOffset , yy - yOffset +2, zz- zOffset), Blocks.LOG.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y)); if(!cachedRoots.containsKey(new BlockPos(2 + xx - xOffset, yy - yOffset +2, zz- zOffset - 1))) cachedRoots.put( new BlockPos(2 + xx - xOffset, yy - yOffset +2, zz- zOffset - 1), Blocks.LOG.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y)); } } }
Example #16
Source File: WorldGenBigSakura.java From Sakura_mod with MIT License | 5 votes |
void limb(BlockPos p_175937_1_, BlockPos p_175937_2_, Block p_175937_3_) { BlockPos blockpos = p_175937_2_.add(-p_175937_1_.getX(), -p_175937_1_.getY(), -p_175937_1_.getZ()); int i = this.getGreatestDistance(blockpos); float f = (float)blockpos.getX() / (float)i; float f1 = (float)blockpos.getY() / (float)i; float f2 = (float)blockpos.getZ() / (float)i; for (int j = 0; j <= i; ++j) { BlockPos blockpos1 = p_175937_1_.add(0.5F + j * f, 0.5F + j * f1, 0.5F + j * f2); BlockLog.EnumAxis blocklog$enumaxis = this.getLogAxis(p_175937_1_, blockpos1); this.setBlockAndNotifyAdequately(this.world, blockpos1, p_175937_3_.getDefaultState().withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis)); } }
Example #17
Source File: WorldGenFallenTree.java From Traverse-Legacy-1-12-2 with MIT License | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int num = rand.nextInt(5); EnumFacing orientation; if (num == 0) { orientation = EnumFacing.EAST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.WEST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.SOUTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } else { orientation = EnumFacing.NORTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } int i = rand.nextInt(2) + this.minTreeLength; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int j3 = 0; j3 < i; ++j3) { BlockPos offsetPos = position.offset(orientation, j3); state = worldIn.getBlockState(offsetPos); if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood); } } return true; } else { return false; } } } else { return false; } }
Example #18
Source File: WorldGenCharredTree.java From AdvancedRocketry with MIT License | 4 votes |
@Override public boolean generate(World world, Random rand, BlockPos pos) { int l = rand.nextInt(3) + this.minTreeHeight; boolean flag = true; int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); if (y >= 1 && y + l + 1 <= 256) { byte b0; int k1; Block block; for (int i1 = y; i1 <= y + 1 + l; ++i1) { b0 = 1; if (i1 == y) { b0 = 0; } if (i1 >= y + 1 + l - 2) { b0 = 2; } for (int j1 = x - b0; j1 <= x + b0 && flag; ++j1) { for (k1 = z - b0; k1 <= z + b0 && flag; ++k1) { if (i1 >= 0 && i1 < 256) { BlockPos pos2 = new BlockPos(j1, i1, k1); block = world.getBlockState(pos2).getBlock(); if (!this.isReplaceable(world, pos2)) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { BlockPos pos3 = new BlockPos(x, y - 1, z); IBlockState state2 = world.getBlockState(pos3); Block block2 = state2.getBlock(); if (y < 256 - l - 1) { block2.onPlantGrow(state2, world, pos3, pos3.up()); b0 = 3; for (k1 = 0; k1 < l; ++k1) { state2 = world.getBlockState(new BlockPos(x, y + k1, z)); if (world.isAirBlock(new BlockPos(x, y + k1, z)) || state2.getBlock().isLeaves(state2, world, new BlockPos(x, y + k1, z))) { this.setBlockAndNotifyAdequately(world, new BlockPos(x, y + k1, z), AdvancedRocketryBlocks.blockCharcoalLog.getDefaultState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y)); } } return true; } else { return false; } } } else { return false; } }
Example #19
Source File: BlockAlienWood.java From AdvancedRocketry with MIT License | 4 votes |
public BlockAlienWood() { super(); this.setDefaultState(this.blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); }
Example #20
Source File: WorldGenFallenTree.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int num = rand.nextInt(5); EnumFacing orientation; if (num == 0) { orientation = EnumFacing.EAST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.WEST; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X); } else if (num == 1) { orientation = EnumFacing.SOUTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } else { orientation = EnumFacing.NORTH; stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z); } int i = rand.nextInt(2) + this.minTreeLength; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int j3 = 0; j3 < i; ++j3) { BlockPos offsetPos = position.offset(orientation, j3); state = worldIn.getBlockState(offsetPos); if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood); } } return true; } else { return false; } } } else { return false; } }
Example #21
Source File: BlockMapleLog.java From Sakura_mod with MIT License | 4 votes |
public BlockMapleLog() { super(); setCreativeTab(CommonProxy.tab); this.setDefaultState(this.blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); }
Example #22
Source File: BlockCharcoalLog.java From AdvancedRocketry with MIT License | 4 votes |
public BlockCharcoalLog() { super(); this.setDefaultState(this.blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); }