Improved 1.7.10's dyeable gloves.

This commit is contained in:
bconlon 2020-07-14 18:37:08 -07:00
parent a1ef4b6690
commit cef5ef64bc
11 changed files with 212 additions and 55 deletions

View file

@ -211,7 +211,7 @@ public class ItemsAether {
candy_cane_sword = register("candy_cane_sword", new ItemCandyCaneSword().setTextureName(Aether.find("weapons/candycane_sword")));
notch_hammer = register("notch_hammer", new ItemNotchHammer().setTextureName(Aether.find("weapons/notch_hammer")));
leather_gloves = register("leather_gloves", new ItemAccessoryDyed(AccessoryType.GLOVES).setColor(0xc65c35).setTextureName(Aether.find("accessories/solid_gloves")));
leather_gloves = register("leather_gloves", new ItemAccessoryDyed(AccessoryType.GLOVES).setTextureName(Aether.find("accessories/leather_gloves")));
iron_gloves = register("iron_gloves", new ItemAccessory(AccessoryType.GLOVES).setTextureName(Aether.find("accessories/solid_gloves")));
golden_gloves = register("golden_gloves", new ItemAccessory(AccessoryType.GLOVES).setColor(0xFBF424).setTextureName(Aether.find("accessories/solid_gloves")));
chain_gloves = register("chain_gloves", new ItemAccessory(AccessoryType.GLOVES).setTexture("chain").setTextureName(Aether.find("accessories/chain_gloves")));
@ -237,7 +237,7 @@ public class ItemsAether {
red_cape = register("red_cape", new ItemAccessory(AccessoryType.CAPE).setColor(0xe81111).setTextureName(Aether.find("accessories/cape_color_base")));
blue_cape = register("blue_cape", new ItemAccessory(AccessoryType.CAPE).setColor(0x137fb7).setTextureName(Aether.find("accessories/cape_color_base")));
yellow_cape = register("yellow_cape", new ItemAccessory(AccessoryType.CAPE).setColor(0xcdcb0e).setTextureName(Aether.find("accessories/cape_color_base")));
white_cape = register("white_cape", new ItemAccessoryDyed(AccessoryType.CAPE).setTextureName(Aether.find("accessories/cape_color_base")));
white_cape = register("white_cape", new ItemAccessory(AccessoryType.CAPE).setTextureName(Aether.find("accessories/cape_color_base")));
swet_cape = register("swet_cape", new ItemAccessory(AccessoryType.CAPE).setTexture("swet_cape").setDungeonLoot().setTextureName(Aether.find("accessories/swet_cape")));
invisibility_cape = register("invisibility_cape", new ItemAccessory(AccessoryType.CAPE).setDungeonLoot().setTextureName(Aether.find("accessories/invisibility_cape")));
agility_cape = register("agility_cape", new ItemAccessory(AccessoryType.CAPE).setTexture("agility_cape").setDungeonLoot().setTextureName(Aether.find("accessories/agility_cape")));

View file

@ -1,10 +1,14 @@
package com.legacy.aether.items.accessories;
import com.legacy.aether.Aether;
import net.minecraft.block.BlockCauldron;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.legacy.aether.api.accessories.AccessoryType;
@ -14,8 +18,12 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ItemAccessoryDyed extends ItemAccessory {
private IIcon overlayIcon;
private IIcon emptySlotIcon;
public ItemAccessoryDyed(AccessoryType type) {
super(type);
this.texture = Aether.locate("textures/armor/accessory_leather.png");
}
@Override
@ -39,51 +47,114 @@ public class ItemAccessoryDyed extends ItemAccessory {
return super.onItemUse(stack, playerIn, worldIn, x, y, z, facing, hitX, hitY, hitZ);
}
public int getStackColor(ItemStack stack, int meta) {
NBTTagCompound nbttagcompound = stack.getTagCompound();
// public int getStackColor(ItemStack stack, int meta) {
// NBTTagCompound nbttagcompound = stack.getTagCompound();
//
// if (nbttagcompound == null) {
// return super.getColor();
// }
//
// NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
//
// return nbttagcompound1 == null ? super.getColor() : (nbttagcompound1.hasKey("color", 3) ? nbttagcompound1.getInteger("color") : super.getColor());
// }
if (nbttagcompound == null) {
return super.getColor();
}
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
return nbttagcompound1 == null ? super.getColor() : (nbttagcompound1.hasKey("color", 3) ? nbttagcompound1.getInteger("color") : super.getColor());
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int meta) {
return this.getStackColor(stack, meta);
public int getColorFromItemStack(ItemStack stack, int meta)
{
if (meta > 0)
{
return 16777215;
}
else
{
int j = this.getColor(stack);
if (j < 0)
{
j = 16777215;
}
return j;
}
}
public void removeColor(ItemStack stack) {
NBTTagCompound nbttagcompound = stack.getTagCompound();
public boolean hasColor(ItemStack p_82816_1_)
{
return (p_82816_1_.hasTagCompound() && (p_82816_1_.getTagCompound().hasKey("display", 10) && p_82816_1_.getTagCompound().getCompoundTag("display").hasKey("color", 3)));
}
if (nbttagcompound != null) {
public int getColor(ItemStack p_82814_1_)
{
NBTTagCompound nbttagcompound = p_82814_1_.getTagCompound();
if (nbttagcompound == null)
{
return 10511680;
}
else
{
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
return nbttagcompound1 == null ? 10511680 : (nbttagcompound1.hasKey("color", 3) ? nbttagcompound1.getInteger("color") : 10511680);
}
}
public void removeColor(ItemStack p_82815_1_)
{
NBTTagCompound nbttagcompound = p_82815_1_.getTagCompound();
if (nbttagcompound != null)
{
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
if (nbttagcompound1.hasKey("color")) {
if (nbttagcompound1.hasKey("color"))
{
nbttagcompound1.removeTag("color");
}
}
}
public void setColorTag(ItemStack stack, int color) {
NBTTagCompound nbttagcompound = stack.getTagCompound();
public void setColorTag(ItemStack p_82813_1_, int p_82813_2_)
{
NBTTagCompound nbttagcompound = p_82813_1_.getTagCompound();
if (nbttagcompound == null) {
if (nbttagcompound == null)
{
nbttagcompound = new NBTTagCompound();
stack.setTagCompound(nbttagcompound);
p_82813_1_.setTagCompound(nbttagcompound);
}
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display");
if (!nbttagcompound.hasKey("display", 10)) {
if (!nbttagcompound.hasKey("display", 10))
{
nbttagcompound.setTag("display", nbttagcompound1);
}
nbttagcompound1.setInteger("color", color);
nbttagcompound1.setInteger("color", p_82813_2_);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister registry)
{
super.registerIcons(registry);
this.overlayIcon = registry.registerIcon(Aether.find("accessories/leather_gloves_overlay"));
this.emptySlotIcon = registry.registerIcon(Aether.find("accessories/leather_gloves"));
}
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass(int p_77618_1_, int p_77618_2_)
{
return p_77618_2_ == 1 ? this.overlayIcon : super.getIconFromDamageForRenderPass(p_77618_1_, p_77618_2_);
}
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses()
{
return true;
}
}

View file

@ -6,6 +6,7 @@ import net.minecraft.block.BlockColored;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
@ -42,51 +43,133 @@ public class RecipeAccessoryDyes implements IRecipe {
return itemstack != null && !arraylist.isEmpty();
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
// @Override
// public ItemStack getCraftingResult(InventoryCrafting inventory) {
// ItemStack itemstack = null;
// int[] aint = new int[3];
// int i = 0;
// int j = 0;
// ItemAccessoryDyed itemarmor = null;
// int k;
// int l;
// float f;
// float f1;
// int l1;
//
// for (k = 0; k < inventory.getSizeInventory(); ++k) {
// ItemStack itemstack1 = inventory.getStackInSlot(k);
//
// if (itemstack1 != null) {
// if (itemstack1.getItem() instanceof ItemAccessoryDyed) {
// itemarmor = (ItemAccessoryDyed) itemstack1.getItem();
//
// if (itemstack != null) {
// return null;
// }
//
// itemstack = itemstack1.copy();
// itemstack.stackSize = 1;
//
// l = itemarmor.getColorFromItemStack(itemstack, itemstack.getItemDamage());
// f = (float) (l >> 16 & 255) / 255.0F;
// f1 = (float) (l >> 8 & 255) / 255.0F;
// float f2 = (float) (l & 255) / 255.0F;
// i = (int) ((float) i + Math.max(f, Math.max(f1, f2)) * 255.0F);
// aint[0] = (int) ((float) aint[0] + f * 255.0F);
// aint[1] = (int) ((float) aint[1] + f1 * 255.0F);
// aint[2] = (int) ((float) aint[2] + f2 * 255.0F);
// ++j;
// } else {
// if (itemstack1.getItem() != Items.dye) {
// return null;
// }
//
// float[] afloat = EntitySheep.fleeceColorTable[BlockColored.func_150032_b(itemstack1.getItemDamage())];
// int j1 = (int) (afloat[0] * 255.0F);
// int k1 = (int) (afloat[1] * 255.0F);
// l1 = (int) (afloat[2] * 255.0F);
// i += Math.max(j1, Math.max(k1, l1));
// aint[0] += j1;
// aint[1] += k1;
// aint[2] += l1;
// ++j;
// }
// }
// }
//
// if (itemarmor == null) {
// return null;
// } else {
// k = aint[0] / j;
// int i1 = aint[1] / j;
// l = aint[2] / j;
// f = (float) i / (float) j;
// f1 = (float) Math.max(k, Math.max(i1, l));
// k = (int) ((float) k * f / f1);
// i1 = (int) ((float) i1 * f / f1);
// l = (int) ((float) l * f / f1);
// l1 = (k << 8) + i1;
// l1 = (l1 << 8) + l;
// itemarmor.setColorTag(itemstack, l1);
// return itemstack;
// }
// }
public ItemStack getCraftingResult(InventoryCrafting p_77572_1_)
{
ItemStack itemstack = null;
int[] aint = new int[3];
int i = 0;
int j = 0;
ItemAccessoryDyed itemarmor = null;
ItemAccessoryDyed itemAccessoryDyed = null;
int k;
int l;
float f;
float f1;
int l1;
for (k = 0; k < inventory.getSizeInventory(); ++k) {
ItemStack itemstack1 = inventory.getStackInSlot(k);
for (k = 0; k < p_77572_1_.getSizeInventory(); ++k)
{
ItemStack itemstack1 = p_77572_1_.getStackInSlot(k);
if (itemstack1 != null) {
if (itemstack1.getItem() instanceof ItemAccessoryDyed) {
itemarmor = (ItemAccessoryDyed) itemstack1.getItem();
if (itemstack1 != null)
{
if (itemstack1.getItem() instanceof ItemAccessoryDyed)
{
itemAccessoryDyed = (ItemAccessoryDyed) itemstack1.getItem();
if (itemstack != null) {
if (itemstack != null)
{
return null;
}
itemstack = itemstack1.copy();
itemstack.stackSize = 1;
l = itemarmor.getStackColor(itemstack, itemstack.getItemDamage());
f = (float) (l >> 16 & 255) / 255.0F;
f1 = (float) (l >> 8 & 255) / 255.0F;
float f2 = (float) (l & 255) / 255.0F;
i = (int) ((float) i + Math.max(f, Math.max(f1, f2)) * 255.0F);
aint[0] = (int) ((float) aint[0] + f * 255.0F);
aint[1] = (int) ((float) aint[1] + f1 * 255.0F);
aint[2] = (int) ((float) aint[2] + f2 * 255.0F);
++j;
} else {
if (itemstack1.getItem() != Items.dye) {
if (itemAccessoryDyed.hasColor(itemstack1))
{
l = itemAccessoryDyed.getColor(itemstack);
f = (float)(l >> 16 & 255) / 255.0F;
f1 = (float)(l >> 8 & 255) / 255.0F;
float f2 = (float)(l & 255) / 255.0F;
i = (int)((float)i + Math.max(f, Math.max(f1, f2)) * 255.0F);
aint[0] = (int)((float)aint[0] + f * 255.0F);
aint[1] = (int)((float)aint[1] + f1 * 255.0F);
aint[2] = (int)((float)aint[2] + f2 * 255.0F);
++j;
}
}
else
{
if (itemstack1.getItem() != Items.dye)
{
return null;
}
float[] afloat = EntitySheep.fleeceColorTable[BlockColored.func_150032_b(itemstack1.getItemDamage())];
int j1 = (int) (afloat[0] * 255.0F);
int k1 = (int) (afloat[1] * 255.0F);
l1 = (int) (afloat[2] * 255.0F);
int j1 = (int)(afloat[0] * 255.0F);
int k1 = (int)(afloat[1] * 255.0F);
l1 = (int)(afloat[2] * 255.0F);
i += Math.max(j1, Math.max(k1, l1));
aint[0] += j1;
aint[1] += k1;
@ -96,20 +179,23 @@ public class RecipeAccessoryDyes implements IRecipe {
}
}
if (itemarmor == null) {
if (itemAccessoryDyed == null)
{
return null;
} else {
}
else
{
k = aint[0] / j;
int i1 = aint[1] / j;
l = aint[2] / j;
f = (float) i / (float) j;
f1 = (float) Math.max(k, Math.max(i1, l));
k = (int) ((float) k * f / f1);
i1 = (int) ((float) i1 * f / f1);
l = (int) ((float) l * f / f1);
f = (float)i / (float)j;
f1 = (float)Math.max(k, Math.max(i1, l));
k = (int)((float)k * f / f1);
i1 = (int)((float)i1 * f / f1);
l = (int)((float)l * f / f1);
l1 = (k << 8) + i1;
l1 = (l1 << 8) + l;
itemarmor.setColorTag(itemstack, l1);
itemAccessoryDyed.setColorTag(itemstack, l1);
return itemstack;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B