mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Did some more stuff and things
This commit is contained in:
parent
5d34bce194
commit
23f8ccc75c
14 changed files with 105 additions and 47 deletions
|
@ -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<Block>());
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -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<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Item> colorProdividingItemsForRegistering = new ArrayList<Item>();
|
||||
private static Map<ItemStack, ResourceLocation> modelLocationsForRegistering = new HashMap<ItemStack, ResourceLocation>();
|
||||
private static Map<Item, ResourceLocation[]> modelVariantsForRegistering = new HashMap<Item, ResourceLocation[]>();
|
||||
|
||||
|
@ -97,9 +98,13 @@ public class ClientProxy implements IProxy{
|
|||
|
||||
PersistentClientData.setTheFile(new File(Minecraft.getMinecraft().mcDataDir, ModUtil.MOD_ID+"Data.dat"));
|
||||
|
||||
for(Map.Entry<ItemStack, ResourceLocation> entry : modelLocationsForRegistering.entrySet()){
|
||||
ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), new ModelResourceLocation(entry.getValue(), "inventory"));
|
||||
}
|
||||
for(Map.Entry<Item, ResourceLocation[]> 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<ItemStack, ResourceLocation> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,6 @@ public interface IProxy{
|
|||
void addRenderRegister(ItemStack stack, ResourceLocation location);
|
||||
|
||||
void addRenderVariant(Item item, ResourceLocation... location);
|
||||
|
||||
void addColoredItem(Item item);
|
||||
}
|
||||
|
|
|
@ -45,4 +45,9 @@ public class ServerProxy implements IProxy{
|
|||
public void addRenderVariant(Item item, ResourceLocation... location){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addColoredItem(Item item){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue