diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java index 78f153dfd..b96369af3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java @@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.ConfigValues; import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; +import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -29,14 +30,16 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.HashSet; import java.util.Set; @SuppressWarnings("unchecked") -public class ItemAllToolAA extends ItemToolAA implements IItemColor{ +public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem{ - private int color; + public final int color; public ItemAllToolAA(ToolMaterial toolMat, String repairItem, String unlocalizedName, EnumRarity rarity, int color){ super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet()); @@ -51,6 +54,8 @@ public class ItemAllToolAA extends ItemToolAA implements IItemColor{ protected void registerRendering(){ ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, "itemPaxel")); ActuallyAdditions.proxy.addRenderVariant(this, new ResourceLocation(ModUtil.MOD_ID_LOWER, "itemPaxel")); + + } @Override @@ -90,8 +95,14 @@ public class ItemAllToolAA extends ItemToolAA implements IItemColor{ return this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state).isEmpty() || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) ? this.efficiencyOnProperMaterial : 1.0F; } + @SideOnly(Side.CLIENT) @Override - public int getColorFromItemstack(ItemStack stack, int tintIndex){ - return tintIndex > 0 ? this.color : 0xFFFFFF; + public IItemColor getColor(){ + return new IItemColor(){ + @Override + public int getColorFromItemstack(ItemStack stack, int pass){ + return pass > 0 ? color : 0xFFFFFF; + } + }; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java index c11872f8f..7683888dc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java @@ -81,7 +81,7 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{ if(!world.isRemote){ player.addStat(TheAchievements.OPEN_BOOKLET.ach); } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); + return new ActionResult(EnumActionResult.SUCCESS, stack); } @SuppressWarnings("unchecked") diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java index 7a5617caf..f4053b3b0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java @@ -13,8 +13,10 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.metalists.TheDusts; +import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; @@ -25,7 +27,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemDust extends ItemBase{ +public class ItemDust extends ItemBase implements IColorProvidingItem{ public static final TheDusts[] allDusts = TheDusts.values(); @@ -44,13 +46,6 @@ public class ItemDust extends ItemBase{ return stack.getItemDamage() >= allDusts.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allDusts[stack.getItemDamage()].name; } - //TODO Figure out item colors - /*@Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass){ - return stack.getItemDamage() >= allDusts.length ? 0 : allDusts[stack.getItemDamage()].color; - }*/ - @Override public EnumRarity getRarity(ItemStack stack){ return stack.getItemDamage() >= allDusts.length ? EnumRarity.COMMON : allDusts[stack.getItemDamage()].rarity; @@ -70,4 +65,15 @@ public class ItemDust extends ItemBase{ ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName())); } } + + @SideOnly(Side.CLIENT) + @Override + public IItemColor getColor(){ + return new IItemColor(){ + @Override + public int getColorFromItemstack(ItemStack stack, int pass){ + return stack.getItemDamage() >= allDusts.length ? 0xFFFFFF : allDusts[stack.getItemDamage()].color; + } + }; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java index a2cbe312d..3c1669825 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.entity.item.EntityItem; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java index 685695fb3..03dc159f3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java @@ -13,8 +13,10 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; +import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -32,7 +34,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemJams extends ItemFoodBase{ +public class ItemJams extends ItemFoodBase implements IColorProvidingItem{ public static final TheJams[] allJams = TheJams.values(); @@ -53,13 +55,6 @@ public class ItemJams extends ItemFoodBase{ return stack.getItemDamage() >= allJams.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allJams[stack.getItemDamage()].name; } - //TODO Color - /*@Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass){ - return pass > 0 ? (stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].color) : super.getColorFromItemStack(stack, pass); - }*/ - @Override public EnumRarity getRarity(ItemStack stack){ return stack.getItemDamage() >= allJams.length ? EnumRarity.COMMON : allJams[stack.getItemDamage()].rarity; @@ -110,4 +105,15 @@ public class ItemJams extends ItemFoodBase{ ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName())); } } + + @Override + @SideOnly(Side.CLIENT) + public IItemColor getColor(){ + return new IItemColor(){ + @Override + public int getColorFromItemstack(ItemStack stack, int pass){ + return pass > 0 ? (stack.getItemDamage() >= allJams.length ? 0xFFFFFF : allJams[stack.getItemDamage()].color) : 0xFFFFFF; + } + }; + } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java index abd721f01..5de85c0c3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java @@ -13,8 +13,10 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.metalists.ThePotionRings; +import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -30,7 +32,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemPotionRing extends ItemBase{ +public class ItemPotionRing extends ItemBase implements IColorProvidingItem{ public static final ThePotionRings[] allRings = ThePotionRings.values(); @@ -53,13 +55,6 @@ public class ItemPotionRing extends ItemBase{ return stack.getItemDamage() >= allRings.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allRings[stack.getItemDamage()].name; } - //TODO Color - /*@Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass){ - return stack.getItemDamage() >= allRings.length ? 0 : allRings[stack.getItemDamage()].color; - }*/ - @Override @SuppressWarnings("unchecked") public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5){ @@ -115,4 +110,15 @@ public class ItemPotionRing extends ItemBase{ ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName())); } } + + @Override + @SideOnly(Side.CLIENT) + public IItemColor getColor(){ + return new IItemColor(){ + @Override + public int getColorFromItemstack(ItemStack stack, int tintIndex){ + return stack.getItemDamage() >= allRings.length ? 0xFFFFFF : allRings[stack.getItemDamage()].color; + } + }; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java index 6b74c1b3a..7b8a360cf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java @@ -32,7 +32,7 @@ public class ItemResonantRice extends ItemBase{ stack.stackSize--; world.createExplosion(null, player.posX, player.posY, player.posZ, 0.5F, true); } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); + return new ActionResult(EnumActionResult.SUCCESS, stack); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java index 4ae0753c3..7c619a9ac 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java @@ -8,10 +8,8 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; import net.minecraftforge.oredict.OreDictionary; -import java.util.HashSet; import java.util.Set; public class ItemToolAA extends ItemTool{ @@ -51,8 +49,7 @@ public class ItemToolAA extends ItemTool{ } protected void registerRendering(){ - ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, "itemPaxel")); - ActuallyAdditions.proxy.addRenderVariant(this, new ResourceLocation(ModUtil.MOD_ID_LOWER, "itemPaxel")); + ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName())); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java index 9166a2e12..c6f2c39a6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java @@ -26,6 +26,7 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost; import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; import de.ellpeck.actuallyadditions.mod.util.FluidStateMapper; +import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.playerdata.PersistentClientData; @@ -47,9 +48,7 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import java.io.File; -import java.util.Calendar; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public class ClientProxy implements IProxy{ @@ -58,6 +57,8 @@ public class ClientProxy implements IProxy{ public static boolean bulletForMyValentine; public static int bookletWordCount; public static int bookletCharCount; + + private static List colorProdividingItemsForRegistering = new ArrayList(); private static Map modelLocationsForRegistering = new HashMap(); private static Map modelVariantsForRegistering = new HashMap(); @@ -97,9 +98,13 @@ public class ClientProxy implements IProxy{ PersistentClientData.setTheFile(new File(Minecraft.getMinecraft().mcDataDir, ModUtil.MOD_ID+"Data.dat")); + for(Map.Entry entry : modelLocationsForRegistering.entrySet()){ + ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), new ModelResourceLocation(entry.getValue(), "inventory")); + } for(Map.Entry entry : modelVariantsForRegistering.entrySet()){ ModelBakery.registerItemVariants(entry.getKey(), entry.getValue()); } + this.registerCustomFluidBlockRenderer(InitFluids.fluidCanolaOil); this.registerCustomFluidBlockRenderer(InitFluids.fluidOil); @@ -140,8 +145,10 @@ public class ClientProxy implements IProxy{ //TODO Fix villager, doesn't work in this Version of Forge //VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png")); - for(Map.Entry entry : modelLocationsForRegistering.entrySet()){ - Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(entry.getKey().getItem(), entry.getKey().getItemDamage(), new ModelResourceLocation(entry.getValue(), "inventory")); + for(Item item : colorProdividingItemsForRegistering){ + if(item instanceof IColorProvidingItem){ + Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem)item).getColor(), item); + } } } @@ -163,4 +170,9 @@ public class ClientProxy implements IProxy{ public void addRenderVariant(Item item, ResourceLocation... location){ modelVariantsForRegistering.put(item, location); } + + @Override + public void addColoredItem(Item item){ + colorProdividingItemsForRegistering.add(item); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java index e15121884..b5eeeabee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java @@ -28,4 +28,6 @@ public interface IProxy{ void addRenderRegister(ItemStack stack, ResourceLocation location); void addRenderVariant(Item item, ResourceLocation... location); + + void addColoredItem(Item item); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java index cd4b73a1c..a4a92cfd3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java @@ -45,4 +45,9 @@ public class ServerProxy implements IProxy{ public void addRenderVariant(Item item, ResourceLocation... location){ } + + @Override + public void addColoredItem(Item item){ + + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java index 9e5db3260..59046ba17 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java @@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.network.PacketParticle; import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -94,13 +95,9 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP this.boundPosBefore = this.boundPosition; this.boundBlockBefore = this.boundPosition == null ? null : PosUtil.getBlock(this.boundPosition, this.worldObj); - //TODO Find a replacement for markBlockForUpdate() - /*this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 1, 0, 0)); - this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, -1, 0, 0)); - this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 0, 1, 0)); - this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 0, -1, 0)); - this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 0, 0, 1)); - this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 0, 0, -1));*/ + IBlockState myState = this.worldObj.getBlockState(this.pos); + this.worldObj.notifyBlockUpdate(this.pos, myState, myState, 3); + this.sendUpdate(); this.markDirty(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java new file mode 100644 index 000000000..ba8fc0fd1 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java @@ -0,0 +1,12 @@ +package de.ellpeck.actuallyadditions.mod.util; + +import net.minecraft.client.renderer.color.IItemColor; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface IColorProvidingItem{ + + @SideOnly(Side.CLIENT) + IItemColor getColor(); + +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java index 123c38405..c59e174af 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.util; +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; import net.minecraft.block.Block; @@ -49,6 +50,10 @@ public class ItemUtil{ GameRegistry.registerItem(item); item.setCreativeTab(addTab ? CreativeTab.instance : null); + + if(item instanceof IColorProvidingItem){ + ActuallyAdditions.proxy.addColoredItem(item); + } } /**