mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Fix #1224 wood items have wrong metadata
This commit is contained in:
1 parent
fdef1ba84a
commit
2cfd0dae0a
6 files changed
+41
-18
No files matched your search
@@ -27,6 +27,7 @@ import forestry.arboriculture.blocks.BlockArbLog;
|
||||
import forestry.arboriculture.blocks.BlockArbPlanks;
|
||||
import forestry.arboriculture.blocks.BlockArbSlab;
|
||||
import forestry.arboriculture.blocks.BlockArbStairs;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class WoodAccess implements IWoodAccess {
|
||||
@@ -84,51 +85,52 @@ public class WoodAccess implements IWoodAccess {
|
||||
|
||||
public static void registerLogs(List<BlockArbLog> blocks) {
|
||||
for (BlockArbLog block : blocks) {
|
||||
register(block, logs);
|
||||
registerWithVariants(block, logs, block.getVariant());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerPlanks(List<BlockArbPlanks> blocks) {
|
||||
for (BlockArbPlanks block : blocks) {
|
||||
register(block, planks);
|
||||
registerWithVariants(block, planks, block.getVariant());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerSlabs(List<BlockArbSlab> blocks) {
|
||||
for (BlockArbSlab block : blocks) {
|
||||
register(block, slabs);
|
||||
registerWithVariants(block, slabs, block.getVariant());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerFences(List<BlockArbFence> blocks) {
|
||||
for (BlockArbFence block : blocks) {
|
||||
register(block, fences);
|
||||
registerWithVariants(block, fences, block.getVariant());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerFenceGates(List<BlockArbFenceGate> blocks) {
|
||||
for (BlockArbFenceGate block : blocks) {
|
||||
register(block, fenceGates);
|
||||
registerWithoutVariants(block, fenceGates);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerStairs(List<BlockArbStairs> blocks) {
|
||||
for (BlockArbStairs block : blocks) {
|
||||
register(block, stairs);
|
||||
registerWithoutVariants(block, stairs);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerDoors(List<BlockArbDoor> blocks) {
|
||||
for (BlockArbDoor block : blocks) {
|
||||
register(block, doors);
|
||||
registerWithoutVariants(block, doors);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends Block & IWoodTyped> void register(T woodTyped, WoodMap woodMap) {
|
||||
private static <T extends Block & IWoodTyped> void registerWithVariants(T woodTyped, WoodMap woodMap, PropertyWoodType property) {
|
||||
boolean fireproof = woodTyped.isFireproof();
|
||||
EnumMap<EnumWoodType, ItemStack> itemRegistryMap = woodMap.getItem(fireproof);
|
||||
EnumMap<EnumWoodType, IBlockState> blockRegistryMap = woodMap.getBlock(fireproof);
|
||||
for (IBlockState blockState : woodTyped.getBlockState().getValidStates()) {
|
||||
for (EnumWoodType value : property.getAllowedValues()) {
|
||||
IBlockState blockState = woodTyped.getDefaultState().withProperty(property, value);
|
||||
int meta = woodTyped.getMetaFromState(blockState);
|
||||
EnumWoodType woodType = woodTyped.getWoodType(meta);
|
||||
ItemStack itemStack = new ItemStack(woodTyped, 1, meta);
|
||||
@@ -138,6 +140,22 @@ public class WoodAccess implements IWoodAccess {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register wood blocks that have no variant property
|
||||
*/
|
||||
private static <T extends Block & IWoodTyped, P extends Comparable<P>, V extends P> void registerWithoutVariants(T woodTyped, WoodMap woodMap) {
|
||||
boolean fireproof = woodTyped.isFireproof();
|
||||
EnumMap<EnumWoodType, ItemStack> itemRegistryMap = woodMap.getItem(fireproof);
|
||||
EnumMap<EnumWoodType, IBlockState> blockRegistryMap = woodMap.getBlock(fireproof);
|
||||
|
||||
IBlockState blockState = woodTyped.getDefaultState();
|
||||
EnumWoodType woodType = woodTyped.getWoodType(0);
|
||||
ItemStack itemStack = new ItemStack(woodTyped);
|
||||
|
||||
itemRegistryMap.put(woodType, itemStack);
|
||||
blockRegistryMap.put(woodType, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPlanks(EnumWoodType woodType, boolean fireproof) {
|
||||
return getItem(woodType, fireproof, planks);
|
||||
|
||||
@@ -61,7 +61,7 @@ public abstract class BlockArbFence extends BlockFence implements IWoodTyped, II
|
||||
BlockArbFence block = new BlockArbFence(fireproof, blockNumber) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected PropertyWoodType getVariant() {
|
||||
public PropertyWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
@@ -95,7 +95,7 @@ public abstract class BlockArbFence extends BlockFence implements IWoodTyped, II
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract PropertyWoodType getVariant();
|
||||
public abstract PropertyWoodType getVariant();
|
||||
|
||||
@Override
|
||||
public boolean isFireproof() {
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
BlockArbLog log = new BlockArbLog(fireproof, blockNumber) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected PropertyWoodType getVariant() {
|
||||
public PropertyWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
@@ -70,7 +70,7 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
this.blockNumber = blockNumber;
|
||||
|
||||
PropertyWoodType variant = getVariant();
|
||||
setDefaultState(this.blockState.getBaseState().withProperty(variant, variant.getFirstType()).withProperty(LOG_AXIS, EnumAxis.NONE));
|
||||
setDefaultState(this.blockState.getBaseState().withProperty(variant, variant.getFirstType()).withProperty(LOG_AXIS, EnumAxis.Y));
|
||||
|
||||
setHarvestLevel("axe", 0);
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
@@ -88,7 +88,7 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract PropertyWoodType getVariant();
|
||||
public abstract PropertyWoodType getVariant();
|
||||
|
||||
public int getBlockNumber() {
|
||||
return blockNumber;
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class BlockArbPlanks extends Block implements IWoodTyped, IState
|
||||
BlockArbPlanks block = new BlockArbPlanks(fireproof, blockNumber) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected PropertyWoodType getVariant() {
|
||||
public PropertyWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
@@ -83,7 +83,7 @@ public abstract class BlockArbPlanks extends Block implements IWoodTyped, IState
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract PropertyWoodType getVariant();
|
||||
public abstract PropertyWoodType getVariant();
|
||||
|
||||
public int getBlockNumber() {
|
||||
return blockNumber;
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
BlockArbSlab block = new BlockArbSlab(fireproof, blockNumber) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected PropertyWoodType getVariant() {
|
||||
public PropertyWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract PropertyWoodType getVariant();
|
||||
public abstract PropertyWoodType getVariant();
|
||||
|
||||
public int getBlockNumber() {
|
||||
return blockNumber;
|
||||
|
||||
@@ -40,4 +40,9 @@ public class PropertyWoodType extends PropertyEnum<EnumWoodType> {
|
||||
public EnumWoodType getFirstType() {
|
||||
return getAllowedValues().iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumWoodType> getAllowedValues() {
|
||||
return super.getAllowedValues();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user