diff --git a/src/main/java/binnie/extratrees/block/EnumETLog.java b/src/main/java/binnie/extratrees/block/EnumETLog.java index 94a655d9..e1e2d3d4 100644 --- a/src/main/java/binnie/extratrees/block/EnumETLog.java +++ b/src/main/java/binnie/extratrees/block/EnumETLog.java @@ -49,8 +49,7 @@ public enum EnumETLog implements IWoodType { Eucalyptus3("Eucalyptus", PlankType.ExtraTreePlanks.Eucalyptus), PinkIvory("Pink Ivory", PlankType.ExtraTreePlanks.PinkIvory), Cherry("Cherry", PlankType.ForestryPlanks.CHERRY), - Cinnamon("Cinnamon", PlankType.VanillaPlanks.JUNGLE), - Shrub("Shrub", PlankType.VanillaPlanks.OAK); + Cinnamon("Cinnamon", PlankType.VanillaPlanks.JUNGLE); public static final EnumETLog[] VALUES = values(); diff --git a/src/main/java/binnie/extratrees/block/EnumShrubLog.java b/src/main/java/binnie/extratrees/block/EnumShrubLog.java new file mode 100644 index 00000000..64b59796 --- /dev/null +++ b/src/main/java/binnie/extratrees/block/EnumShrubLog.java @@ -0,0 +1,78 @@ +package binnie.extratrees.block; + +import java.util.Locale; + +import binnie.Constants; +import forestry.api.arboriculture.IWoodType; +import forestry.api.arboriculture.TreeManager; +import forestry.api.arboriculture.WoodBlockKind; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + +public enum EnumShrubLog implements IWoodType { + INSTANCE; + + public static final EnumShrubLog[] VALUES = values(); + + @Override + public String getName() { + return "shrub_log"; + } + + @Override + public String toString() { + return getName(); + } + + @Override + public float getHardness() { + return 5; + } + + @Override + public int getCarbonization() { + return 4; + } + + @Override + public float getCharcoalChance(int numberOfCharcoal) { + if (numberOfCharcoal == 3) { + return 0.75F; + } else if (numberOfCharcoal == 4) { + return 0.5F; + } else if (numberOfCharcoal == 5) { + return 0.25F; + } + return 0.15F; + } + + @Override + public String getPlankTexture() { + return Constants.EXTRA_TREES_MOD_ID + ":null"; + } + + @Override + public String getHeartTexture() { + return Constants.EXTRA_TREES_MOD_ID + ":null"; + } + + @Override + public String getDoorLowerTexture() { + return Constants.EXTRA_TREES_MOD_ID + ":null"; + } + + @Override + public String getDoorUpperTexture() { + return Constants.EXTRA_TREES_MOD_ID + ":null"; + } + + @Override + public String getBarkTexture() { + return Constants.EXTRA_TREES_MOD_ID + ":null"; + } + + @Override + public int getMetadata() { + return 0; + } +} diff --git a/src/main/java/binnie/extratrees/block/ModuleBlocks.java b/src/main/java/binnie/extratrees/block/ModuleBlocks.java index 562f6b5d..5303730c 100644 --- a/src/main/java/binnie/extratrees/block/ModuleBlocks.java +++ b/src/main/java/binnie/extratrees/block/ModuleBlocks.java @@ -16,6 +16,7 @@ import binnie.extratrees.block.wood.BlockETFence; import binnie.extratrees.block.wood.BlockETLog; import binnie.extratrees.block.wood.BlockETPlank; import binnie.extratrees.block.wood.BlockETSlab; +import binnie.extratrees.block.wood.BlockShrubLog; import binnie.extratrees.block.wood.ItemBlockETWood; import binnie.extratrees.block.wood.ItemETSlab; import binnie.extratrees.genetics.ETTreeDefinition; @@ -29,6 +30,8 @@ import forestry.api.recipes.RecipeManagers; import forestry.arboriculture.WoodAccess; import forestry.arboriculture.blocks.BlockForestryFenceGate; import forestry.arboriculture.blocks.BlockForestryStairs; +import forestry.arboriculture.items.ItemBlockWood; +import forestry.arboriculture.items.ItemBlockWoodDoor; import forestry.core.recipes.RecipeUtil; import forestry.core.utils.OreDictUtil; import net.minecraft.block.Block; @@ -72,6 +75,7 @@ public class ModuleBlocks implements IInitializable { public Block blockDoor; public BlockMultiFence blockMultiFence; public BlockHedge blockHedge; + public BlockShrubLog shrubLog; //???? public Block blockBranch; @@ -242,6 +246,11 @@ public class ModuleBlocks implements IInitializable { speciesToLeavesDecorative.put(speciesUid, new ItemStack(leaves, 1, meta)); } } + + shrubLog = new BlockShrubLog(); + ExtraTrees.proxy.registerBlock(shrubLog, new ItemBlockETWood(shrubLog)); + woodAccess.register(EnumShrubLog.INSTANCE, WoodBlockKind.LOG, false, shrubLog.getStateFromMeta(0), new ItemStack(shrubLog, 1, 0)); + woodAccess.register(EnumShrubLog.INSTANCE, WoodBlockKind.LOG, true, shrubLog.getStateFromMeta(1), new ItemStack(shrubLog, 1, 1)); } @Override diff --git a/src/main/java/binnie/extratrees/block/WoodManager.java b/src/main/java/binnie/extratrees/block/WoodManager.java index acc4e8b3..26c25710 100644 --- a/src/main/java/binnie/extratrees/block/WoodManager.java +++ b/src/main/java/binnie/extratrees/block/WoodManager.java @@ -26,7 +26,7 @@ public class WoodManager { String displayName; - if (woodType instanceof EnumETLog) { + if (woodType instanceof EnumETLog || woodType instanceof EnumShrubLog) { String customUnlocalizedName = "tile.et." + blockKind + "." + woodType + ".name"; if (Translator.canTranslateToLocal(customUnlocalizedName)) { displayName = Translator.translateToLocal(customUnlocalizedName); diff --git a/src/main/java/binnie/extratrees/block/wood/BlockShrubLog.java b/src/main/java/binnie/extratrees/block/wood/BlockShrubLog.java new file mode 100644 index 00000000..fc34b99f --- /dev/null +++ b/src/main/java/binnie/extratrees/block/wood/BlockShrubLog.java @@ -0,0 +1,251 @@ +package binnie.extratrees.block.wood; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nullable; + +import binnie.Constants; +import binnie.core.models.DefaultStateMapper; +import binnie.extratrees.block.EnumShrubLog; +import forestry.api.arboriculture.IWoodType; +import forestry.api.arboriculture.WoodBlockKind; +import forestry.api.core.IItemModelRegister; +import forestry.api.core.IModelManager; +import forestry.api.core.IStateMapperRegister; +import forestry.apiculture.blocks.BlockAlveary; +import forestry.arboriculture.IWoodTyped; +import forestry.greenhouse.blocks.BlockGreenhouseDoor; +import net.minecraft.block.Block; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.block.state.pattern.BlockStateMatcher; +import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.block.statemap.BlockStateMapper; +import net.minecraft.client.renderer.block.statemap.StateMap; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Mirror; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class BlockShrubLog extends Block implements IWoodTyped, IStateMapperRegister, IItemModelRegister { + + public static final PropertyBool FIREPROOF = PropertyBool.create("fireproof"); + public static final PropertyBool NORTH = PropertyBool.create("north"); + public static final PropertyBool EAST = PropertyBool.create("east"); + public static final PropertyBool SOUTH = PropertyBool.create("south"); + public static final PropertyBool WEST = PropertyBool.create("west"); + protected static final AxisAlignedBB[] BOUNDING_BOXES = new AxisAlignedBB[] { + new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), + new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), + new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), + new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), + new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), + new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), + new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), + new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), + new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), + new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), + new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), + new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), + new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), + new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), + new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), + new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D) }; + public static final AxisAlignedBB PILLAR_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.5D, 0.625D); + public static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.625D, 0.625D, 1.5D, 1.0D); + public static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.375D, 1.5D, 0.625D); + public static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.5D, 0.375D); + public static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.625D, 0.0D, 0.375D, 1.0D, 1.5D, 0.625D); + + public BlockShrubLog() { + super(Material.WOOD); + this.setDefaultState(this.blockState.getBaseState() + .withProperty(NORTH, false) + .withProperty(EAST, false) + .withProperty(SOUTH, false) + .withProperty(WEST, false) + .withProperty(FIREPROOF, false)); + setRegistryName(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "shrub_log")); + setUnlocalizedName("shrub_log"); + setSoundType(SoundType.WOOD); + } + + @Override + public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, + List collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) { + if (!p_185477_7_) { + state = state.getActualState(worldIn, pos); + } + + addCollisionBoxToList(pos, entityBox, collidingBoxes, PILLAR_AABB); + + if (state.getValue(NORTH)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB); + } + + if (state.getValue(EAST)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); + } + + if (state.getValue(SOUTH)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB); + } + + if (state.getValue(WEST)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); + } + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + state = this.getActualState(state, source, pos); + return BOUNDING_BOXES[getBoundingBoxIdx(state)]; + } + + private static int getBoundingBoxIdx(IBlockState state) { + int i = 0; + + if (state.getValue(NORTH)) { + i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); + } + + if (state.getValue(EAST)) { + i |= 1 << EnumFacing.EAST.getHorizontalIndex(); + } + + if (state.getValue(SOUTH)) { + i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); + } + + if (state.getValue(WEST)) { + i |= 1 << EnumFacing.WEST.getHorizontalIndex(); + } + + return i; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public boolean isFullCube(IBlockState state) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, + EnumFacing side) { + return true; + } + + @Override + public int getMetaFromState(IBlockState state) { + return state.getValue(FIREPROOF) ? 1 : 0; + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return getDefaultState().withProperty(FIREPROOF, meta == 1); + } + + @Override + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + return state.withProperty(NORTH, canFenceConnectTo(worldIn, pos, EnumFacing.NORTH)) + .withProperty(EAST, canFenceConnectTo(worldIn, pos, EnumFacing.EAST)) + .withProperty(SOUTH, canFenceConnectTo(worldIn, pos, EnumFacing.SOUTH)) + .withProperty(WEST, canFenceConnectTo(worldIn, pos, EnumFacing.WEST)); + } + + private boolean canFenceConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing) { + IBlockState blockState = world.getBlockState(pos.offset(facing)); + Block block = blockState.getBlock(); + return block.isLeaves(blockState, world, pos); + } + + @Override + public IBlockState withRotation(IBlockState state, Rotation rot) { + switch (rot) { + case CLOCKWISE_180: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)) + .withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST)); + case COUNTERCLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)) + .withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH)); + case CLOCKWISE_90: + return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)) + .withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH)); + default: + return state; + } + } + + @Override + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + switch (mirrorIn) { + case LEFT_RIGHT: + return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); + case FRONT_BACK: + return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); + default: + return super.withMirror(state, mirrorIn); + } + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, new IProperty[] { NORTH, EAST, WEST, SOUTH, FIREPROOF }); + } + + @Override + public WoodBlockKind getBlockKind() { + return WoodBlockKind.LOG; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerStateMapper() { + ModelLoader.setCustomStateMapper(this, new StateMap.Builder().ignore(FIREPROOF).build()); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerModel(Item item, IModelManager manager) { + manager.registerItemModel(item, 0, "shrub_trunk"); + manager.registerItemModel(item, 1, "shrub_trunk"); + } + + //TODO: Add meta to forestry api + @Override + public boolean isFireproof() { + return false; + } + + @Override + public IWoodType getWoodType(int meta) { + return EnumShrubLog.INSTANCE; + } + + @Override + public Collection getWoodTypes() { + return Collections.singletonList(EnumShrubLog.INSTANCE); + } + +} diff --git a/src/main/java/binnie/extratrees/gen/WorldGenShrub.java b/src/main/java/binnie/extratrees/gen/WorldGenShrub.java index 793023b0..f8493c8a 100644 --- a/src/main/java/binnie/extratrees/gen/WorldGenShrub.java +++ b/src/main/java/binnie/extratrees/gen/WorldGenShrub.java @@ -1,41 +1,80 @@ package binnie.extratrees.gen; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import java.util.Set; + +import javax.annotation.Nullable; + +import forestry.api.arboriculture.ITreeModifier; +import forestry.api.arboriculture.TreeManager; import forestry.api.world.ITreeGenData; +import forestry.arboriculture.worldgen.TreeBlockTypeLeaf; +import forestry.arboriculture.worldgen.TreeBlockTypeLog; +import forestry.arboriculture.worldgen.WorldGenArboriculture; +import forestry.core.worldgen.WorldGenHelper; +import forestry.core.worldgen.WorldGenHelper.EnumReplaceMode; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; public class WorldGenShrub { - public static class Shrub extends WorldGenTree { + public static class Shrub extends WorldGenArboriculture { + private static final int minHeight = 1; + private static final int maxHeight = 10; + + protected int girth; + protected int height; + public Shrub(ITreeGenData tree) { super(tree); } - + @Override - public void generate() { - float leafSpawn = this.height; - float width = this.height * this.randBetween(0.7f, 0.9f); + public Set generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) { + WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + return Collections.emptySet(); + } + + @Override + protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List branchEnds, BlockPos startPos) { + float leafSpawn = this.height + 1; + float width = this.height * WorldGenUtils.randBetween(rand, 0.7f, 0.9f); if (width < 1.5f) { width = 1.5f; } final float f = 0.0f; final float h = leafSpawn; leafSpawn = h - 1.0f; - this.generateCylinder(new Vector(f, h, 0.0f), 0.4f * width, 1, this.leaf, false); - final float f2 = 0.0f; - final float h2 = leafSpawn; - leafSpawn = h2 - 1.0f; - this.generateCylinder(new Vector(f2, h2, 0.0f), 0.8f * width, 1, this.leaf, false); + WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn--, 0), girth, 0.25f * width + girth, 1, EnumReplaceMode.SOFT); + WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn--, 0), girth, 0.5f * width + girth, 1, EnumReplaceMode.SOFT); while (leafSpawn >= 0.0f) { - final float f3 = 0.0f; - final float h3 = leafSpawn; - leafSpawn = h3 - 1.0f; - this.generateCylinder(new Vector(f3, h3, 0.0f), width, 1, this.leaf, false); + WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn--, 0), girth, width + girth, 1, EnumReplaceMode.SOFT); } } + + @Override + protected void generateExtras(World world, Random rand, BlockPos startPos) { + } @Override - public void preGenerate() { - this.minHeight = 1; - this.height = this.determineHeight(1, 1); - this.girth = this.determineGirth(this.treeGen.getGirth()); + @Nullable + public BlockPos getValidGrowthPos(World world, BlockPos pos) { + return tree.canGrow(world, pos, girth, height); + } + + @Override + public final void preGenerate(World world, Random rand, BlockPos startPos) { + super.preGenerate(world, rand, startPos); + height = determineHeight(world, rand, 1, 1); + girth = tree.getGirth(); + } + + private int determineHeight(World world, Random rand, int required, int variation) { + ITreeModifier treeModifier = TreeManager.treeRoot.getTreekeepingMode(world); + int baseHeight = required + rand.nextInt(variation); + int height = Math.round(baseHeight * tree.getHeightModifier() * treeModifier.getHeightModifier(tree.getGenome(), 1f)); + return height < minHeight ? minHeight : height > maxHeight ? maxHeight : height; } } } diff --git a/src/main/java/binnie/extratrees/genetics/ETTreeDefinition.java b/src/main/java/binnie/extratrees/genetics/ETTreeDefinition.java index 6d357f13..0c43bdda 100644 --- a/src/main/java/binnie/extratrees/genetics/ETTreeDefinition.java +++ b/src/main/java/binnie/extratrees/genetics/ETTreeDefinition.java @@ -2,7 +2,9 @@ package binnie.extratrees.genetics; import binnie.Constants; import binnie.core.genetics.ForestryAllele; +import binnie.extratrees.ExtraTrees; import binnie.extratrees.block.EnumETLog; +import binnie.extratrees.block.EnumShrubLog; import binnie.extratrees.gen.WorldGenAlder; import binnie.extratrees.gen.WorldGenApple; import binnie.extratrees.gen.WorldGenAsh; @@ -1548,7 +1550,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(AlleleManager.alleleRegistry.getFruitFamily("forestry.nuts")); } }, - Blackcurrant("ribes", "nigrum", EnumLeafType.DECIDUOUS, new Color(0xA6DA5C), new Color(0xA6DA5C), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + Blackcurrant("ribes", "nigrum", EnumLeafType.DECIDUOUS, new Color(0xA6DA5C), new Color(0xA6DA5C), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -1571,7 +1573,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(ETFruitFamily.Berry); } }, - Redcurrant("ribes", "rubrum", EnumLeafType.DECIDUOUS, new Color(0x74AC00), new Color(0x74AC00), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + Redcurrant("ribes", "rubrum", EnumLeafType.DECIDUOUS, new Color(0x74AC00), new Color(0x74AC00), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -1594,7 +1596,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(ETFruitFamily.Berry); } }, - Blackberry("rubus", "fruticosus", EnumLeafType.DECIDUOUS, new Color(0x92C15B), new Color(0x92C15B), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + Blackberry("rubus", "fruticosus", EnumLeafType.DECIDUOUS, new Color(0x92C15B), new Color(0x92C15B), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -1616,7 +1618,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(ETFruitFamily.Berry); } }, - Raspberry("rubus", "idaeus", EnumLeafType.DECIDUOUS, new Color(0x83B96E), new Color(0x83B96E), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + Raspberry("rubus", "idaeus", EnumLeafType.DECIDUOUS, new Color(0x83B96E), new Color(0x83B96E), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -1639,7 +1641,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(ETFruitFamily.Berry); } }, - Blueberry("vaccinium", "corymbosum", EnumLeafType.DECIDUOUS, new Color(0x72C750), new Color(0x72C750), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + Blueberry("vaccinium", "corymbosum", EnumLeafType.DECIDUOUS, new Color(0x72C750), new Color(0x72C750), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -1662,7 +1664,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(ETFruitFamily.Berry); } }, - Cranberry("vaccinium", "oxycoccos", EnumLeafType.DECIDUOUS, new Color(0x96D179), new Color(0x96D179), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + Cranberry("vaccinium", "oxycoccos", EnumLeafType.DECIDUOUS, new Color(0x96D179), new Color(0x96D179), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -1685,7 +1687,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(ETFruitFamily.Berry); } }, - Juniper("juniperus", "communis", EnumLeafType.CONIFERS, new Color(0x90B149), new Color(0x90B149), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + Juniper("juniperus", "communis", EnumLeafType.CONIFERS, new Color(0x90B149), new Color(0x90B149), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -1708,7 +1710,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(ETFruitFamily.Berry); } }, - Gooseberry("ribes", "grossularia", EnumLeafType.DECIDUOUS, new Color(0x79BB00), new Color(0x79BB00), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + Gooseberry("ribes", "grossularia", EnumLeafType.DECIDUOUS, new Color(0x79BB00), new Color(0x79BB00), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -1730,7 +1732,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT species.addFruitFamily(ETFruitFamily.Berry); } }, - GoldenRaspberry("rubus", "occidentalis", EnumLeafType.DECIDUOUS, new Color(0x83B96E), new Color(0x83B96E), EnumSaplingType.Shrub, EnumETLog.Shrub, new Color(0xFFFFFF)) { + GoldenRaspberry("rubus", "occidentalis", EnumLeafType.DECIDUOUS, new Color(0x83B96E), new Color(0x83B96E), EnumSaplingType.Shrub, EnumShrubLog.INSTANCE, new Color(0xFFFFFF)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenShrub.Shrub(tree); @@ -2156,7 +2158,10 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT IBlockState logBlock = TreeManager.woodAccess.getBlock(woodType, WoodBlockKind.LOG, fireproof); BlockLog.EnumAxis axis = BlockLog.EnumAxis.fromFacingAxis(facing.getAxis()); - return world.setBlockState(pos, logBlock.withProperty(BlockLog.LOG_AXIS, axis)); + if(logBlock.getBlock() instanceof BlockLog){ + logBlock = logBlock.withProperty(BlockLog.LOG_AXIS, axis); + } + return world.setBlockState(pos, logBlock); } @Override diff --git a/src/main/resources/assets/extratrees/blockstates/shrub_log.json b/src/main/resources/assets/extratrees/blockstates/shrub_log.json new file mode 100644 index 00000000..643f9062 --- /dev/null +++ b/src/main/resources/assets/extratrees/blockstates/shrub_log.json @@ -0,0 +1,17 @@ +{ + "multipart": [ + { "apply": { "model": "extratrees:shrub_trunk" }}, + { "when": { "north": "true" }, + "apply": { "model": "extratrees:shrub_side", "y": 90, "uvlock": true } + }, + { "when": { "east": "true" }, + "apply": { "model": "extratrees:shrub_side", "y": 180, "uvlock": true } + }, + { "when": { "south": "true" }, + "apply": { "model": "extratrees:shrub_side", "y": 270, "uvlock": true } + }, + { "when": { "west": "true" }, + "apply": { "model": "extratrees:shrub_side", "uvlock": true } + } + ] +} diff --git a/src/main/resources/assets/extratrees/lang/en_US.lang b/src/main/resources/assets/extratrees/lang/en_US.lang index 35b7bb30..8982fc74 100644 --- a/src/main/resources/assets/extratrees/lang/en_US.lang +++ b/src/main/resources/assets/extratrees/lang/en_US.lang @@ -62,7 +62,7 @@ et.trees.woodType.pinkivory=Pink Ivory et.trees.woodType.banana=Banana et.trees.woodType.cherry=Cherry et.trees.woodType.cinnamon=Cinnamon -et.trees.woodType.shrub=Shrub +et.trees.woodType.shrub_log=Shrub extratrees.block.planks.fir=Fir extratrees.block.planks.cedar=Cedar diff --git a/src/main/resources/assets/extratrees/models/block/shrub_side.json b/src/main/resources/assets/extratrees/models/block/shrub_side.json new file mode 100644 index 00000000..2bfc0096 --- /dev/null +++ b/src/main/resources/assets/extratrees/models/block/shrub_side.json @@ -0,0 +1,74 @@ +{ + "textures": { + "particle": "blocks/log_oak", + "top": "blocks/log_oak_top", + "log": "blocks/log_oak" + }, + "elements": [ + { + "from": [ 5, 6, 7 ], + "to": [ 6, 8, 9 ], + "faces": { + "down": { "uv": [ 5, 7, 6, 9 ], "texture": "#log" }, + "north": { "uv": [ 10, 8, 11, 10 ], "texture": "#log" }, + "south": { "uv": [ 5, 8, 6, 10 ], "texture": "#log" }, + "west": { "uv": [ 7, 8, 9, 10 ], "texture": "#log" }, + "east": { "uv": [ 7, 8, 9, 10 ], "texture": "#log" } + } + }, + { + "from": [ 2, 8, 7 ], + "to": [ 5, 10, 9 ], + "faces": { + "down": { "uv": [ 2, 7, 5, 9 ], "texture": "#log" }, + "up": { "uv": [ 2, 7, 5, 9 ], "texture": "#log" }, + "north": { "uv": [ 11, 6, 14, 8 ], "texture": "#log" }, + "south": { "uv": [ 2, 6, 5, 8 ], "texture": "#log" }, + "west": { "uv": [ 7, 6, 9, 8 ], "texture": "#log" }, + "east": { "uv": [ 7, 6, 9, 8 ], "texture": "#log" } + } + }, + { + "from": [ 0, 9, 7 ], + "to": [ 2, 11, 9 ], + "faces": { + "down": { "uv": [ 0, 7, 2, 9 ], "texture": "#log" }, + "up": { "uv": [ 0, 7, 2, 9 ], "texture": "#log" }, + "north": { "uv": [ 14, 5, 16, 7 ], "texture": "#log" }, + "south": { "uv": [ 0, 5, 2, 7 ], "texture": "#log" }, + "west": { "uv": [ 7, 7, 9, 9 ], "texture": "#top" } + } + }, + { + "from": [ 4, 7, 7 ], + "to": [ 5, 8, 9 ], + "faces": { + "down": { "uv": [ 4, 7, 5, 9 ], "texture": "#log" }, + "north": { "uv": [ 11, 8, 12, 9 ], "texture": "#log" }, + "south": { "uv": [ 4, 8, 5, 9 ], "texture": "#log" }, + "west": { "uv": [ 7, 8, 9, 9 ], "texture": "#log" } + } + }, + { + "from": [ 2, 10, 7 ], + "to": [ 3, 11, 9 ], + "faces": { + "up": { "uv": [ 2, 7, 3, 9 ], "texture": "#log" }, + "north": { "uv": [ 13, 5, 14, 6 ], "texture": "#log" }, + "south": { "uv": [ 2, 5, 3, 6 ], "texture": "#log" }, + "west": { "uv": [ 7, 5, 9, 6 ], "texture": "#log" }, + "east": { "uv": [ 7, 5, 9, 6 ], "texture": "#log" } + } + }, + { + "from": [ 5, 8, 7 ], + "to": [ 6, 9, 9 ], + "faces": { + "up": { "uv": [ 5, 7, 6, 9 ], "texture": "#log" }, + "north": { "uv": [ 10, 7, 11, 8 ], "texture": "#log" }, + "south": { "uv": [ 5, 7, 6, 8 ], "texture": "#log" }, + "east": { "uv": [ 7, 7, 9, 8 ], "texture": "#log" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/extratrees/models/block/shrub_trunk.json b/src/main/resources/assets/extratrees/models/block/shrub_trunk.json index b53fa8c6..bcf6496a 100644 --- a/src/main/resources/assets/extratrees/models/block/shrub_trunk.json +++ b/src/main/resources/assets/extratrees/models/block/shrub_trunk.json @@ -1,21 +1,53 @@ { "textures": { "particle": "blocks/log_oak", - "side": "blocks/log_oak", - "top": "blocks/log_oak_top" + "top": "blocks/log_oak_top", + "log": "blocks/log_oak" }, "elements": [ { "from": [ 6, 0, 6 ], "to": [ 10, 16, 10 ], "faces": { - "down": { "uv": [ 6, 6, 10, 10 ], "texture": "#top" }, - "up": { "uv": [ 6, 6, 10, 10 ], "texture": "#top" }, - "north": { "uv": [ 6, 0, 10, 16 ], "texture": "#side" }, - "south": { "uv": [ 6, 0, 10, 16 ], "texture": "#side" }, - "west": { "uv": [ 6, 0, 10, 16 ], "texture": "#side" }, - "east": { "uv": [ 6, 0, 10, 16 ], "texture": "#side" } + "down": { "uv": [ 6, 6, 10, 10 ], "texture": "#top", "cullface": "down" }, + "up": { "uv": [ 6, 6, 10, 10 ], "texture": "#top", "cullface": "up" }, + "north": { "uv": [ 6, 0, 10, 16 ], "texture": "#log", "cullface": "north" }, + "south": { "uv": [ 6, 0, 10, 16 ], "texture": "#log", "cullface": "south" }, + "west": { "uv": [ 6, 0, 10, 16 ], "texture": "#log", "cullface": "west" }, + "east": { "uv": [ 6, 0, 10, 16 ], "texture": "#log", "cullface": "east" } } } - ] + ], + "display": { + "gui": { + "rotation": [ 30, 225, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.625, 0.625, 0.625 ] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 3, 0], + "scale":[ 0.25, 0.25, 0.25 ] + }, + "fixed": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.5, 0.5, 0.5 ] + }, + "thirdperson_righthand": { + "rotation": [ 75, 45, 0 ], + "translation": [ 0, 2.5, 0], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "firstperson_righthand": { + "rotation": [ 0, 45, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 225, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + } + } } \ No newline at end of file diff --git a/src/main/resources/assets/extratrees/models/item/shrub_trunk.json b/src/main/resources/assets/extratrees/models/item/shrub_trunk.json new file mode 100644 index 00000000..13963330 --- /dev/null +++ b/src/main/resources/assets/extratrees/models/item/shrub_trunk.json @@ -0,0 +1,10 @@ +{ + "parent": "extratrees:block/shrub_trunk", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +}