now you're thinking with OOP

This commit is contained in:
pheo 2025-05-01 10:41:21 +01:00
parent 0aeeda9113
commit 395acea899
3 changed files with 11 additions and 25 deletions

View File

@ -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);

View File

@ -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());
}
}

View File

@ -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());
}
}