From 9d563bc95317bb1be1955a9cf1f56919fd290955 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 18 May 2016 23:55:54 -0700 Subject: [PATCH] Use IBlockState instead of old IBlockType --- .../genetics/TreeDefinition.java | 11 ++-- .../arboriculture/worldgen/BlockTypeLog.java | 27 ---------- .../worldgen/BlockTypeVanillaStairs.java | 40 --------------- .../arboriculture/worldgen/BlockTypeWood.java | 51 ------------------- .../worldgen/BlockTypeWoodStairs.java | 26 ---------- .../worldgen/WorldGenArboriculture.java | 10 +--- .../arboriculture/worldgen/WorldGenEbony.java | 2 +- .../forestry/core/worldgen/BlockType.java | 38 -------------- .../forestry/core/worldgen/BlockTypeVoid.java | 28 ---------- .../forestry/core/worldgen/IBlockType.java | 21 -------- 10 files changed, 7 insertions(+), 247 deletions(-) delete mode 100644 src/main/java/forestry/arboriculture/worldgen/BlockTypeLog.java delete mode 100644 src/main/java/forestry/arboriculture/worldgen/BlockTypeVanillaStairs.java delete mode 100644 src/main/java/forestry/arboriculture/worldgen/BlockTypeWood.java delete mode 100644 src/main/java/forestry/arboriculture/worldgen/BlockTypeWoodStairs.java delete mode 100755 src/main/java/forestry/core/worldgen/BlockType.java delete mode 100644 src/main/java/forestry/core/worldgen/BlockTypeVoid.java delete mode 100644 src/main/java/forestry/core/worldgen/IBlockType.java diff --git a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java index d7b032062..4b6d06744 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java @@ -15,6 +15,8 @@ import java.util.Arrays; import java.util.Locale; import net.minecraft.block.Block; +import net.minecraft.block.BlockLog; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; @@ -49,7 +51,6 @@ import forestry.arboriculture.genetics.alleles.AlleleGrowth; import forestry.arboriculture.models.ModelProviderGermling; import forestry.arboriculture.models.ModelProviderGermlingVanilla; import forestry.arboriculture.tiles.TileLeaves; -import forestry.arboriculture.worldgen.BlockTypeLog; import forestry.arboriculture.worldgen.WorldGenAcacia; import forestry.arboriculture.worldgen.WorldGenAcaciaVanilla; import forestry.arboriculture.worldgen.WorldGenBalsa; @@ -1026,11 +1027,9 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe } else { AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF); boolean fireproof = fireproofAllele.getValue(); - ItemStack log = TreeManager.woodAccess.getLog(woodType, fireproof); - - BlockTypeLog logBlock = new BlockTypeLog(log); - logBlock.setDirection(facing); - logBlock.setBlock(world, pos); + IBlockState logBlock = TreeManager.woodAccess.getLogBlock(woodType, fireproof); + logBlock.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.fromFacingAxis(facing.getAxis())); + world.setBlockState(pos, logBlock); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLog.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeLog.java deleted file mode 100644 index b2c68f5e6..000000000 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLog.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.arboriculture.worldgen; - -import net.minecraft.block.BlockLog; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; - -public class BlockTypeLog extends BlockTypeWood { - public BlockTypeLog(ItemStack itemStack) { - super(itemStack); - } - - @Override - public void setDirection(EnumFacing facing) { - BlockLog.EnumAxis axis = BlockLog.EnumAxis.fromFacingAxis(facing.getAxis()); - state = state.withProperty(BlockLog.LOG_AXIS, axis); - } -} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVanillaStairs.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVanillaStairs.java deleted file mode 100644 index 328d58257..000000000 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVanillaStairs.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.arboriculture.worldgen; - -import net.minecraft.init.Blocks; -import net.minecraft.util.EnumFacing; - -import forestry.core.worldgen.BlockType; - -public class BlockTypeVanillaStairs extends BlockType { - public BlockTypeVanillaStairs(int meta) { - super(Blocks.OAK_STAIRS, meta); - } - - @Override - public void setDirection(EnumFacing facing) { - switch (facing) { - case NORTH: - meta = 3; - break; - case SOUTH: - meta = 2; - break; - case WEST: - meta = 1; - break; - default: - meta = 0; - break; - } - } -} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeWood.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeWood.java deleted file mode 100644 index 8cc3a13a7..000000000 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeWood.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.arboriculture.worldgen; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; - -import forestry.api.world.ITreeGenData; -import forestry.core.config.Constants; -import forestry.core.utils.ItemStackUtil; -import forestry.core.worldgen.IBlockType; - -public class BlockTypeWood implements IBlockType, ITreeBlockType { - protected Block block; - protected IBlockState state; - - public BlockTypeWood(ItemStack itemStack) { - block = ItemStackUtil.getBlock(itemStack); - if (block == null) { - throw new NullPointerException("Couldn't find block for itemStack " + itemStack); - } - state = block.getStateFromMeta(itemStack.getMetadata()); - } - - @Override - public void setBlock(World world, ITreeGenData tree, BlockPos pos) { - setBlock(world, pos); - } - - @Override - public void setBlock(World world, BlockPos pos) { - world.setBlockState(pos, state, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE); - } - - @Override - public void setDirection(EnumFacing facing) { - - } -} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeWoodStairs.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeWoodStairs.java deleted file mode 100644 index 11bc14a8e..000000000 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeWoodStairs.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.arboriculture.worldgen; - -import net.minecraft.block.BlockStairs; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; - -public class BlockTypeWoodStairs extends BlockTypeWood { - public BlockTypeWoodStairs(ItemStack itemStack) { - super(itemStack); - } - - @Override - public void setDirection(EnumFacing facing) { - state = state.withProperty(BlockStairs.FACING, facing); - } -} diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index eb356e2df..68b17d5ba 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -17,8 +17,8 @@ import java.util.Random; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import com.mojang.authlib.GameProfile; @@ -27,8 +27,6 @@ import forestry.api.world.ITreeGenData; import forestry.arboriculture.tiles.TileTreeContainer; import forestry.core.tiles.TileUtil; import forestry.core.utils.BlockUtil; -import forestry.core.worldgen.BlockType; -import forestry.core.worldgen.BlockTypeVoid; import forestry.core.worldgen.WorldGenBase; public abstract class WorldGenArboriculture extends WorldGenBase { @@ -63,8 +61,6 @@ public abstract class WorldGenArboriculture extends WorldGenBase { private static final ITreeBlockType vineEast = new TreeBlockType(Blocks.VINE, 2); private static final int minPodHeight = 3; - private static final BlockType air = new BlockTypeVoid(); - protected final ITreeGenData tree; private BlockPos startPos; @@ -322,10 +318,6 @@ public abstract class WorldGenArboriculture extends WorldGenBase { return false; } - protected final void clearBlock(World world, BlockPos pos) { - air.setBlock(world, startPos.add(pos)); - } - protected final boolean addWood(World world, BlockPos pos, EnumReplaceMode replace) { return addBlock(world, pos, wood, replace); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java index f7af78f75..f1e7935e3 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java @@ -39,7 +39,7 @@ public class WorldGenEbony extends WorldGenTree { trunksgenerated++; } else { for (int i = 0; i < 1; i++) { - clearBlock(world, new BlockPos(x, i, z)); + world.setBlockToAir(new BlockPos(x, i, z)); } } } diff --git a/src/main/java/forestry/core/worldgen/BlockType.java b/src/main/java/forestry/core/worldgen/BlockType.java deleted file mode 100755 index d28473a23..000000000 --- a/src/main/java/forestry/core/worldgen/BlockType.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.worldgen; - -import net.minecraft.block.Block; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; - -import forestry.core.config.Constants; - -public class BlockType implements IBlockType { - private final Block block; - protected int meta; - - public BlockType(Block block, int meta) { - this.block = block; - this.meta = meta; - } - - @Override - public void setDirection(EnumFacing facing) { - - } - - @Override - public void setBlock(World world, BlockPos pos) { - world.setBlockState(pos, block.getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE); - } -} diff --git a/src/main/java/forestry/core/worldgen/BlockTypeVoid.java b/src/main/java/forestry/core/worldgen/BlockTypeVoid.java deleted file mode 100644 index fb8a43704..000000000 --- a/src/main/java/forestry/core/worldgen/BlockTypeVoid.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.worldgen; - -import net.minecraft.init.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockTypeVoid extends BlockType { - - public BlockTypeVoid() { - super(Blocks.AIR, 0); - } - - @Override - public void setBlock(World world, BlockPos pos) { - world.setBlockToAir(pos); - } - -} diff --git a/src/main/java/forestry/core/worldgen/IBlockType.java b/src/main/java/forestry/core/worldgen/IBlockType.java deleted file mode 100644 index e5581d191..000000000 --- a/src/main/java/forestry/core/worldgen/IBlockType.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.worldgen; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; - -public interface IBlockType { - void setDirection(EnumFacing facing); - - void setBlock(World world, BlockPos pos); -}