From 5016917fb9c45a36536c757283787b335fda78db Mon Sep 17 00:00:00 2001 From: Cheeserolls Date: Sat, 23 May 2015 23:47:23 +0100 Subject: [PATCH] Fix some leaf rendering problems, and a couple of other minor TODOs --- .../common/block/BlockBOPDirt.java | 1 + .../common/block/BlockBOPGrass.java | 2 + .../common/block/BlockBOPLeaves.java | 70 ++++++++++++++++++- .../common/block/BlockCoral.java | 7 +- .../entities/projectiles/EntityDart.java | 3 - .../models/block/leaves_overlay.json | 12 ++-- 6 files changed, 82 insertions(+), 13 deletions(-) diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPDirt.java b/src/main/java/biomesoplenty/common/block/BlockBOPDirt.java index ef9789c42..f61a1190e 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPDirt.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPDirt.java @@ -32,6 +32,7 @@ import biomesoplenty.common.item.ItemBOPBlock; public class BlockBOPDirt extends Block implements IBOPBlock { + // TODO: make it ploughable into farmland // add properties public static enum BOPDirtType implements IStringSerializable diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPGrass.java b/src/main/java/biomesoplenty/common/block/BlockBOPGrass.java index 47ec7cf62..51dd8d85a 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPGrass.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPGrass.java @@ -40,6 +40,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class BlockBOPGrass extends BlockGrass implements IBOPBlock { + // TODO: make it ploughable into farmland + // add properties (note we also inherit the SNOWY property from BlockGrass) public static enum BOPGrassType implements IStringSerializable { diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPLeaves.java b/src/main/java/biomesoplenty/common/block/BlockBOPLeaves.java index 8f712a20b..bec4b4a7b 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPLeaves.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPLeaves.java @@ -28,14 +28,16 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeColorHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -// TODO: sort out proper base color when using fast graphics -// TODO: flowers look tinted when using fast graphics -// TODO: inside surface not visible with fast graphics +// TODO: using fast graphics - transparent color is always rendered as black - can we override this somehow? +// TODO: using fast graphics - flowering leaves overlay seems to be tinted green - I think that is because it doesn't use distinct tintindexes on fast graphics +// In older versions a completely different single texture could be used for fast graphics, but I'm not sure that's an option any more public class BlockBOPLeaves extends BlockLeaves implements IBOPBlock { @@ -127,6 +129,68 @@ public class BlockBOPLeaves extends BlockLeaves implements IBOPBlock return meta; } + + public enum ColoringType {PLAIN, TINTED, OVERLAY}; + + public static ColoringType getColoringType(BOPTrees tree) + { + switch (tree) + { + case BAMBOO: case DEAD: case ETHEREAL: case FIR: case HELLBARK: case JACARANDA: case MAGIC: case MAPLE: case ORANGE_AUTUMN: case ORIGIN: case PINK_CHERRY: case WHITE_CHERRY: case YELLOW_AUTUMN: case RED_BIG_FLOWER: case YELLOW_BIG_FLOWER: + return ColoringType.PLAIN; + case FLOWERING: + return ColoringType.OVERLAY; + case DARK: case MAHOGANY: case MANGROVE: case PALM: case PINE: case REDWOOD: case SACRED_OAK: case WILLOW: default: + return ColoringType.TINTED; + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + return 0xFFFFFF; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderColor(IBlockState state) + { + switch (getColoringType((BOPTrees) state.getValue(this.variantProperty))) + { + case TINTED: + return ColorizerFoliage.getFoliageColorBasic(); + case OVERLAY: + return ColorizerFoliage.getFoliageColorBasic(); + case PLAIN: default: + return 0xFFFFFF; + } + } + + @Override + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int tintIndex) + { + switch (getColoringType((BOPTrees) worldIn.getBlockState(pos).getValue(this.variantProperty))) + { + case TINTED: + return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos); + case OVERLAY: + switch (tintIndex) + { + case 0: + return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos); + case 1: default: + return 0xFFFFFF; + } + case PLAIN: default: + return 0xFFFFFF; + } + } + + + + @Override protected int getSaplingDropChance(IBlockState state) { diff --git a/src/main/java/biomesoplenty/common/block/BlockCoral.java b/src/main/java/biomesoplenty/common/block/BlockCoral.java index bff6ff1ed..586480462 100644 --- a/src/main/java/biomesoplenty/common/block/BlockCoral.java +++ b/src/main/java/biomesoplenty/common/block/BlockCoral.java @@ -70,7 +70,6 @@ public class BlockCoral extends BlockDecoration // set some defaults this.setHardness(0.6F); this.setStepSound(Block.soundTypeSand); - this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F); // TODO: account for offset this.setDefaultState( this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(VARIANT, CoralType.PINK) ); } @@ -87,6 +86,12 @@ public class BlockCoral extends BlockDecoration { return ((CoralType) state.getValue(VARIANT)).ordinal(); } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) + { + this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.4F, 0.8F, pos); + } // glowing_coral emits light @Override diff --git a/src/main/java/biomesoplenty/common/entities/projectiles/EntityDart.java b/src/main/java/biomesoplenty/common/entities/projectiles/EntityDart.java index 65a4f3385..88f1c70da 100644 --- a/src/main/java/biomesoplenty/common/entities/projectiles/EntityDart.java +++ b/src/main/java/biomesoplenty/common/entities/projectiles/EntityDart.java @@ -49,9 +49,6 @@ public class EntityDart extends EntityArrow super(world, x, y, z); } - - // TODO: figure out what this dataWatcher stuff is all about - @Override protected void entityInit() { diff --git a/src/main/resources/assets/biomesoplenty/models/block/leaves_overlay.json b/src/main/resources/assets/biomesoplenty/models/block/leaves_overlay.json index 80b475870..0885dd7cf 100644 --- a/src/main/resources/assets/biomesoplenty/models/block/leaves_overlay.json +++ b/src/main/resources/assets/biomesoplenty/models/block/leaves_overlay.json @@ -17,12 +17,12 @@ { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { - "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "down" }, - "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "up" }, - "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "north" }, - "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "south" }, - "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "west" }, - "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "east" } + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "down", "tintindex": 1 }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "up", "tintindex": 1 }, + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "north", "tintindex": 1 }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "south", "tintindex": 1 }, + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "west", "tintindex": 1 }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#over", "cullface": "east", "tintindex": 1 } } } ]