From 108b581df217e7265786fa5008029641164ee4d0 Mon Sep 17 00:00:00 2001 From: pheo Date: Mon, 28 Apr 2025 23:05:59 +0100 Subject: [PATCH 1/5] tinted vegetation --- .../hbm/blocks/generic/BlockNTMFlower.java | 47 +++++++++++++++++- .../textures/blocks/plant_flower.tobacco.png | Bin 248 -> 248 bytes 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hbm/blocks/generic/BlockNTMFlower.java b/src/main/java/com/hbm/blocks/generic/BlockNTMFlower.java index f9c84a96c..6dead7fd8 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockNTMFlower.java +++ b/src/main/java/com/hbm/blocks/generic/BlockNTMFlower.java @@ -9,6 +9,8 @@ import com.hbm.blocks.ModBlocks; import com.hbm.blocks.generic.BlockDeadPlant.EnumDeadPlantType; import com.hbm.blocks.generic.BlockTallPlant.EnumTallFlower; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; @@ -16,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; @@ -98,7 +101,7 @@ public class BlockNTMFlower extends BlockEnumMulti implements IPlantable, IGrowa public boolean renderAsNormalBlock() { return false; } - + @Override public int getRenderType() { return 1; @@ -198,6 +201,48 @@ public class BlockNTMFlower extends BlockEnumMulti implements IPlantable, IGrowa this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); } + + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + double d0 = 0.5D; + double d1 = 1.0D; + return ColorizerGrass.getGrassColor(d0, d1); + } + + /** + * Returns the color this block should be rendered. Used by leaves. + */ + @SideOnly(Side.CLIENT) + public int getRenderColor(int meta) + { + return meta == 0 ? 16777215 : ColorizerGrass.getGrassColor(0.5F, 1F); + } + + /** + * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called + * when first determining what to render. + */ + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess world, int x, int y, int z) + { + int l = 0; + int i1 = 0; + int j1 = 0; + + for (int k1 = -1; k1 <= 1; ++k1) + { + for (int l1 = -1; l1 <= 1; ++l1) + { + int i2 = world.getBiomeGenForCoords(x + l1, z + k1).getBiomeFoliageColor(x + l1, y, z + k1); + l += (i2 & 16711680) >> 16; + i1 += (i2 & 65280) >> 8; + j1 += i2 & 255; + } + } + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? 16777215 : ((l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255); + } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { } diff --git a/src/main/resources/assets/hbm/textures/blocks/plant_flower.tobacco.png b/src/main/resources/assets/hbm/textures/blocks/plant_flower.tobacco.png index 56f0815de2b241687ecc179c02aabcb71f948c21..4ccbc10beec7401ed516794a10101382fe10cfb8 100644 GIT binary patch delta 46 zcmV+}0MY;W0r&xsMi$-O-KnXmm6esq$jEkfb^rhXSyTB+kz5@L!2kdb!2!6DYweMP EbstI Date: Tue, 29 Apr 2025 21:57:53 +0100 Subject: [PATCH 2/5] terrible hacks, part 2 --- src/main/java/com/hbm/blocks/ModBlocks.java | 5 ++- .../hbm/blocks/generic/BlockNTMFlower.java | 27 +++++-------- .../hbm/blocks/generic/BlockTallPlant.java | 38 ++++++++++++++++++ .../hbm/items/block/ItemBlockBaseColored.java | 23 +++++++++++ .../hbm/textures/blocks/plant_flower.weed.png | Bin 267 -> 266 bytes .../textures/blocks/plant_tall.weed.lower.png | Bin 542 -> 301 bytes .../textures/blocks/plant_tall.weed.upper.png | Bin 361 -> 267 bytes 7 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/hbm/items/block/ItemBlockBaseColored.java diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 076a86b1c..65a87d2e2 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -30,6 +30,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemColored; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; @@ -2810,8 +2811,8 @@ public class ModBlocks { GameRegistry.registerBlock(deco_pipe_quad_green_rusted, ItemBlockBase.class, deco_pipe_quad_green_rusted.getUnlocalizedName()); GameRegistry.registerBlock(deco_pipe_quad_red, ItemBlockBase.class, deco_pipe_quad_red.getUnlocalizedName()); GameRegistry.registerBlock(deco_pipe_quad_marked, ItemBlockBase.class, deco_pipe_quad_marked.getUnlocalizedName()); - register(plant_flower); - register(plant_tall); + GameRegistry.registerBlock(plant_flower, ItemBlockBaseColored.class, plant_flower.getUnlocalizedName()); + GameRegistry.registerBlock(plant_tall, ItemBlockBaseColored.class, plant_tall.getUnlocalizedName()); register(plant_dead); register(reeds); register(vine_phosphor); diff --git a/src/main/java/com/hbm/blocks/generic/BlockNTMFlower.java b/src/main/java/com/hbm/blocks/generic/BlockNTMFlower.java index 6dead7fd8..7717d7a88 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockNTMFlower.java +++ b/src/main/java/com/hbm/blocks/generic/BlockNTMFlower.java @@ -202,27 +202,19 @@ public class BlockNTMFlower extends BlockEnumMulti implements IPlantable, IGrowa this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); } - @SideOnly(Side.CLIENT) - public int getBlockColor() - { - double d0 = 0.5D; - double d1 = 1.0D; - return ColorizerGrass.getGrassColor(d0, d1); - } - /** - * Returns the color this block should be rendered. Used by leaves. - */ + @SideOnly(Side.CLIENT) public int getRenderColor(int meta) { - return meta == 0 ? 16777215 : ColorizerGrass.getGrassColor(0.5F, 1F); + if (meta == 1 || meta == 3) { + return ColorizerGrass.getGrassColor(0.5D, 1.0D); + } else return 0xFFFFFF; } + // if you need to make another tinted plant just throw the metadata value + // into the if statements above and below i really do not want to make this more + // complicated than it needs to be - /** - * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called - * when first determining what to render. - */ @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess world, int x, int y, int z) { @@ -241,8 +233,11 @@ public class BlockNTMFlower extends BlockEnumMulti implements IPlantable, IGrowa } } int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? 16777215 : ((l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255); + if (meta == 1 || meta == 3) { + return ((l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255); + } else return 0xFFFFFF; } + @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { } diff --git a/src/main/java/com/hbm/blocks/generic/BlockTallPlant.java b/src/main/java/com/hbm/blocks/generic/BlockTallPlant.java index f52da4c41..dc8be96d3 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockTallPlant.java +++ b/src/main/java/com/hbm/blocks/generic/BlockTallPlant.java @@ -24,6 +24,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; +import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; @@ -300,6 +301,43 @@ public class BlockTallPlant extends BlockEnumMulti implements IPlantable, IGrowa return world.getBlockMetadata(x, y, z); } + @SideOnly(Side.CLIENT) + public int getRenderColor(int meta) + { + if (meta == 0 || meta == 8) { + return ColorizerGrass.getGrassColor(0.5D, 1.0D); + } else return 0xFFFFFF; + } + // if you need to make another tinted plant just throw the metadata value + // into the if statements above and below i really do not want to make this more + // complicated than it needs to be + // the second meta value is for the top of the plant + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess world, int x, int y, int z) + { + int l = 0; + int i1 = 0; + int j1 = 0; + + for (int k1 = -1; k1 <= 1; ++k1) + { + for (int l1 = -1; l1 <= 1; ++l1) + { + int i2 = world.getBiomeGenForCoords(x + l1, z + k1).getBiomeFoliageColor(x + l1, y, z + k1); + l += (i2 & 16711680) >> 16; + i1 += (i2 & 65280) >> 8; + j1 += i2 & 255; + } + } + int meta = world.getBlockMetadata(x, y, z); + + if (meta == 0 || meta == 8) { + return ((l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255); + } else return 0xFFFFFF; + } + + @Override public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { diff --git a/src/main/java/com/hbm/items/block/ItemBlockBaseColored.java b/src/main/java/com/hbm/items/block/ItemBlockBaseColored.java new file mode 100644 index 000000000..c17bf16ce --- /dev/null +++ b/src/main/java/com/hbm/items/block/ItemBlockBaseColored.java @@ -0,0 +1,23 @@ +package com.hbm.items.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +public class ItemBlockBaseColored extends ItemBlockBase { + + private Block block; + + public ItemBlockBaseColored(Block block) { + super(block); + this.block = block; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int p_82790_2_) + { + return this.block.getRenderColor(stack.getItemDamage()); + } + +} diff --git a/src/main/resources/assets/hbm/textures/blocks/plant_flower.weed.png b/src/main/resources/assets/hbm/textures/blocks/plant_flower.weed.png index 68ee791b794dc61f13a0eb77fdac73eae33a2bd9..56a1bc961773212c2e0e326f2a8d70ff6239e861 100644 GIT binary patch delta 209 zcmeBX>SCJUST7gg6XKeemv{U2?Slsou2``mI5>F1gb7==Y^kcMvbMHnU|=xab2I@+ zag_x51^TCk0R;}{Tt@SE z^$!(aobfrv|Fm`6+5VsG-fMdG8C)m6^7?C_YH=h}mvKYnJWdC%>)FkQ%R0>6J}_!(h delta 210 zcmeBT>SmhYST7pj6XLq&Xn19hdH)iZx@*?i+YMtDX)!P`oL;}(2uQJ)1o;L32LlEv zZ)P{35NCl$WHAE+-yslY6xHx*01D=Kx;Tbt1gG{g@*OeYIDD$%&;OIp513_It;$+? z^wHwE&wsb=c*k(!jQ#{I_LOOkl?qd@p1S+OTd%d^d|UIbJB~Mak6tWIdc`A5+p1C_5g1b~#S!UcQ*uJRn$9!WwhU+ z7I;J!GcfQS24TkI`72U@f=!`LWcu5oN5;){+HI9b#6;ttFYs`iO&Ql zhQ8a^_3p}ob{@fvvokv~#AZ~6?(1V+cK*W=jnu}H3G>cdnuToY`q{H4{pQS*?&tPv zzhHAxWG_km)iuX8?ECVoU+eBoZECn3X598o;e+J5| zHuK9j0T@e->w0?P7B4a%1%Lo}^Zls=DCcW}2wuK>D1RMXp_@cu6jo1462Nv`x}gui`rF@>Uf&%#K0s{P1KV){==({n zyIF7XbI+z5`hVDtt0e=(qhtWj>QS9*7~XWeDL%aVGE#0_jT|Lbw+hiQ{3sN& zsQ;DW|21)GEhhoKed=>Bm*(-ar14#O5gW+{Ru*?f&>nDoGKG5@(5$y;)>}F!N^*Rd zsQl=LKGtyu4le5d*0@h)qbQYJ5hX@D1AP75$2|==KYt5#A}dd}4cW2it;)=9=+msX zjLF7Q<4k8V+8d+6k39>|>QTUM>hh2+S`^as1>^;u{` S6!icA00{s|MNUMnLSTXnfA{_X diff --git a/src/main/resources/assets/hbm/textures/blocks/plant_tall.weed.upper.png b/src/main/resources/assets/hbm/textures/blocks/plant_tall.weed.upper.png index e7a23bdbe5185425575d4c4717ea90f2fde514ee..bc1de0720ce84c3b81b96c246ecdcd8bc2a9f74c 100644 GIT binary patch delta 250 zcmaFK)Xg+OvYwfNfk8u;KNv_c76-XIF|0c$^AgBmNq6*hWMJ6X&;2Kn708zh@Ck9v z%geic`}Vb?SjBePgS8;?CbPq-YpZM1eFY8Y9p=pw^bBpdGFMN{;Z8xc+q3(t mSTwB7efD~DK5D$i|D9dZl09-&)+!sIWelFKelF{r5}E*z7G7xp delta 345 zcmV-f0jBjP+_rCYu_uYNKzs6PXLX_3)>4@R1Qz|Yr7=O+>B8WXP9jBmVQEFu9 z2tRbiB-+R2-3gqk4aN!G)<|2Q!(Zmlbs*biobd9Lq1GS_u3xvNno`I(fpNk-U7=!S zpk$51?V5^R2@sUsw$SjQKxvLCtv04Q0Y+Zq`^ r%Wv%ng{xd|Ix0DcJ#lbkX;=Ce+u3wW`yPQA00000NkvXXu0mjf9+jB- From f0db8853e6769ac2cbb95eb0d7fc67e32cf44f16 Mon Sep 17 00:00:00 2001 From: pheo Date: Wed, 30 Apr 2025 15:35:34 +0100 Subject: [PATCH 3/5] Minor Cleanup --- src/main/java/com/hbm/items/ItemEnumMulti.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/hbm/items/ItemEnumMulti.java b/src/main/java/com/hbm/items/ItemEnumMulti.java index 3d677b7ff..396fa9464 100644 --- a/src/main/java/com/hbm/items/ItemEnumMulti.java +++ b/src/main/java/com/hbm/items/ItemEnumMulti.java @@ -102,4 +102,5 @@ public class ItemEnumMulti extends Item { return super.getUnlocalizedName(stack); } } + } From 64d3cdcf78519707c259ee62e7aac5374f24f503 Mon Sep 17 00:00:00 2001 From: pheo <88721823+7pheonix@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:38:58 +0100 Subject: [PATCH 4/5] Update changelog --- changelog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 2ad29c2c0..bc2382073 100644 --- a/changelog +++ b/changelog @@ -5,10 +5,11 @@ * Flamethrower turrets now use the green fire effect when using balefire fuel * Flamethrower turret projectile damage is now capped to 20 * Balefire fuel should no longer instantly vaporize bosses +* Tobacco and Hemp plants are now biome tinted and are no longer radioactive green ## Fixed * Fixed a potential crash caused by cargo dropships landing on cargo docks with no satellite chip installed * Fixed potential crash related to hazard handling for dropped items * Fixed errors thrown when loading in old system bullet entities * Fixed dupe regarding breaking transport drones -* Fixed 12 gauge flechette DT negation not being the intended value \ No newline at end of file +* Fixed 12 gauge flechette DT negation not being the intended value From 395acea899f2619e787ff559ac3add7fdf83cbb9 Mon Sep 17 00:00:00 2001 From: pheo Date: Thu, 1 May 2025 10:41:21 +0100 Subject: [PATCH 5/5] now you're thinking with OOP --- src/main/java/com/hbm/blocks/ModBlocks.java | 4 ++-- .../com/hbm/items/block/ItemBlockBase.java | 9 ++++++++ .../hbm/items/block/ItemBlockBaseColored.java | 23 ------------------- 3 files changed, 11 insertions(+), 25 deletions(-) delete mode 100644 src/main/java/com/hbm/items/block/ItemBlockBaseColored.java diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 65a87d2e2..b4f77d6ab 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -2811,8 +2811,8 @@ public class ModBlocks { GameRegistry.registerBlock(deco_pipe_quad_green_rusted, ItemBlockBase.class, deco_pipe_quad_green_rusted.getUnlocalizedName()); GameRegistry.registerBlock(deco_pipe_quad_red, ItemBlockBase.class, deco_pipe_quad_red.getUnlocalizedName()); GameRegistry.registerBlock(deco_pipe_quad_marked, ItemBlockBase.class, deco_pipe_quad_marked.getUnlocalizedName()); - GameRegistry.registerBlock(plant_flower, ItemBlockBaseColored.class, plant_flower.getUnlocalizedName()); - GameRegistry.registerBlock(plant_tall, ItemBlockBaseColored.class, plant_tall.getUnlocalizedName()); + register(plant_flower); + register(plant_tall); register(plant_dead); register(reeds); register(vine_phosphor); diff --git a/src/main/java/com/hbm/items/block/ItemBlockBase.java b/src/main/java/com/hbm/items/block/ItemBlockBase.java index 97286b3a2..c2a224390 100644 --- a/src/main/java/com/hbm/items/block/ItemBlockBase.java +++ b/src/main/java/com/hbm/items/block/ItemBlockBase.java @@ -20,9 +20,12 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; public class ItemBlockBase extends ItemBlock { + + private Block block; public ItemBlockBase(Block block) { super(block); + this.block = block; if(block instanceof IBlockMulti) { this.setMaxDamage(0); @@ -88,4 +91,10 @@ public class ItemBlockBase extends ItemBlock { return EnumRarity.common; } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + return this.block.getRenderColor(stack.getItemDamage()); + } } diff --git a/src/main/java/com/hbm/items/block/ItemBlockBaseColored.java b/src/main/java/com/hbm/items/block/ItemBlockBaseColored.java deleted file mode 100644 index c17bf16ce..000000000 --- a/src/main/java/com/hbm/items/block/ItemBlockBaseColored.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hbm.items.block; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -public class ItemBlockBaseColored extends ItemBlockBase { - - private Block block; - - public ItemBlockBaseColored(Block block) { - super(block); - this.block = block; - } - - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int p_82790_2_) - { - return this.block.getRenderColor(stack.getItemDamage()); - } - -}