mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Use IBlockState instead of old IBlockType
This commit is contained in:
1 parent
ff1ff5ae2c
commit
9d563bc953
10 files changed
+7
-247
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user