diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/item/base')
-rw-r--r-- | src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java | 237 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java | 44 |
2 files changed, 258 insertions, 23 deletions
diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index ec0b490f63..4dbb5851f2 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -7,15 +7,6 @@ import java.util.Map; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TextureSet; import gregtech.api.util.GT_OreDictUnificator; @@ -32,15 +23,23 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; public class BaseItemComponent extends Item{ private final static Class<TextureSet> mTextureSetPreload; - + static { mTextureSetPreload = TextureSet.class; } - + public final Material componentMaterial; public final String materialName; public final String unlocalName; @@ -62,9 +61,9 @@ public class BaseItemComponent extends Item{ //this.setTextureName(this.getCorrectTextures()); this.componentColour = material.getRgbAsHex(); GameRegistry.registerItem(this, this.unlocalName); - + //if (componentType != ComponentTypes.DUST) - + GT_OreDictUnificator.registerOre(componentType.getOreDictName()+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); if (LoadedMods.Thaumcraft) { ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.METALLUM, 1); @@ -91,7 +90,7 @@ public class BaseItemComponent extends Item{ GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+unlocalName, ItemUtils.getSimpleStack(this)); registerComponent(); } - + public boolean registerComponent() { if (this.componentMaterial == null) { return false; @@ -197,6 +196,7 @@ public class BaseItemComponent extends Item{ super.addInformation(stack, aPlayer, list, bool); } + @SuppressWarnings("unchecked") @Override public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { if (this.componentMaterial != null){ @@ -206,6 +206,19 @@ public class BaseItemComponent extends Item{ } } } + + if (extraData != null) { + if (componentMaterial != null && componentMaterial.getRGBA()[3] > 1) { + if (((Map<Integer, Short[]>) extraData).get(9999) == null) { + ((Map<Integer, Short[]>) extraData).put(9999, new Short[] {0}); + } + Short aCurrentFrame = ((Map<Integer, Short[]>) extraData).get(9999)[0]; + short fC = (short) (aCurrentFrame >= Short.MAX_VALUE ? 0 : aCurrentFrame+1); + ((Map<Integer, Short[]>) extraData).put((int) 9999, new Short[] {(short) (fC), 0}); + ((Map<Integer, Short[]>) extraData).put((int) 9998, new Short[] {aCurrentFrame, 0}); + + } + } } @@ -221,15 +234,209 @@ public class BaseItemComponent extends Item{ return (CORE.ConfigSwitches.useGregtechTextures ? true : false); } + @SuppressWarnings("unchecked") @Override public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + + if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures){ return Utils.rgbtoHexValue(255, 255, 255); } if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures){ return Utils.rgbtoHexValue(255, 255, 255); } + + + + try { + if (this.componentMaterial == null) { + if (extraData != null) { + if (short.class.isInstance(extraData)){ + short[] abc = (short[]) extraData; + return Utils.rgbtoHexValue(abc[0], abc[1], abc[2]); + } + } + return this.componentColour; + } + + if (this.componentMaterial.getRGBA()[3] <= 1) { + return this.componentColour; + } + else { + + //Mild Glow Effect + if (this.componentMaterial.getRGBA()[3] == 2) { + if (extraData == null) { + extraData = new HashMap<Integer, Short[]>(); + ((Map<Integer, Short[]>) extraData).put((int) Short.MAX_VALUE, new Short[] {0}); + ((Map<Integer, Short[]>) extraData).put((int) Short.MAX_VALUE-1, new Short[] {0}); + short[] er = this.componentMaterial.getRGBA(); + short value = 1; + Short[] ht = new Short[] {er[0], er[1], er[2]}; + for (int y = 0; y < 40; y++) { + if (y < 20) { + value = 1; + } + else { + value = -1; + } + short r = (short) (ht[0] + value); + short g = (short) (ht[1] + value); + short b = (short) (ht[2] + value); + Short[] qq = new Short[] {(short) Math.min(255, r), (short) Math.min(255, g), (short) Math.min(255, b)}; + ht = qq; + ((Map<Integer, Short[]>) extraData).put(y, qq); + } + } + if (extraData != null) { + + Short aCurrentFrame = ((Map<Integer, Short[]>) extraData).get((int) Short.MAX_VALUE)[0]; + Short aSize = 40; + short nextFrame = (short) ((aCurrentFrame < aSize) ? (aCurrentFrame+1) : 0); + Short[] aCurrentFrameRGB = ((Map<Integer, Short[]>) extraData).get(aCurrentFrame < aSize ? (int) aCurrentFrame : 0); + ((Map<Integer, Short[]>) extraData).put((int) Short.MAX_VALUE, new Short[] {nextFrame}); + return Utils.rgbtoHexValue(aCurrentFrameRGB[0], aCurrentFrameRGB[1], aCurrentFrameRGB[2]); + + + /*Short aCurrentFrame = ((Map<Integer, Short[]>) extraData).get((int) Short.MAX_VALUE)[0]; + Short[] aCurrentFrameRGB = ((Map<Integer, Short[]>) extraData).get((int) aCurrentFrame); + short nextFrame = aCurrentFrame < 40 ? aCurrentFrame++ : 0; + ((Map<Integer, Short[]>) extraData).put((int) Short.MAX_VALUE, new Short[] {nextFrame}); + return Utils.rgbtoHexValue(aCurrentFrameRGB[0], aCurrentFrameRGB[1], aCurrentFrameRGB[2]);*/ + } + } + + //Rainbow Hue Cycle + else if (this.componentMaterial.getRGBA()[3] == 3) { + if (extraData == null) { + extraData = new HashMap<Integer, Short[]>(); + ((Map<Integer, Short[]>) extraData).put((int) Short.MAX_VALUE, new Short[] {0}); + ((Map<Integer, Short[]>) extraData).put((int) Short.MAX_VALUE-1, new Short[] {0}); + int aSlot = 0; + + //Let's say you're starting with green: + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 0}); + //Slowly start adding in some red to get to yellow: + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 51, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 51, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 51, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 255, 0}); + //Then, take out the green to get to red: + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 0}); + //Now, add blue to get to purple: + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {255, 0, 255}); + //Then, remove red to get to blue: + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 51, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 51, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 51, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 0, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 0, 255}); + //Add the green back in to get to cyan: + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 51, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 51, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 51, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 102, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 102, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 102, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 153, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 153, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 153, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 204, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 204, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 204, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 255}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 255}); + //And finally remove the blue to get back to green: + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 204}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 204}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 204}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 153}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 153}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 153}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 102}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 102}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 102}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 51}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 51}); + ((Map<Integer, Short[]>) extraData).put(aSlot++, new Short[] { 0, 255, 51}); + ((Map<Integer, Short[]>) extraData).put((int) Byte.MAX_VALUE, new Short[] {(short) (((Map<Integer, Short[]>) extraData).size()-1)}); + + + } + if (extraData != null) { + Short aCurrentFrame = ((Map<Integer, Short[]>) extraData).get((int) Short.MAX_VALUE)[0]; + Short aSize = (short) (((Map<Integer, Short[]>) extraData).size() - 3); + short nextFrame = (short) ((aCurrentFrame < aSize) ? (aCurrentFrame+1) : 0); + Short[] aCurrentFrameRGB = ((Map<Integer, Short[]>) extraData).get(aCurrentFrame < aSize ? (int) aCurrentFrame : 0); + ((Map<Integer, Short[]>) extraData).put((int) Short.MAX_VALUE, new Short[] {nextFrame}); + return Utils.rgbtoHexValue(aCurrentFrameRGB[0], aCurrentFrameRGB[1], aCurrentFrameRGB[2]); + } + } + } + + + } + catch (Throwable t) { + + } return this.componentColour; + + + + + } @Override @@ -307,7 +514,7 @@ public class BaseItemComponent extends Item{ public OrePrefixes getGtOrePrefix() { return this.a_GT_EQUAL; } - + } } diff --git a/src/Java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java b/src/Java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java index 363b9ad00d..89cd1e55ae 100644 --- a/src/Java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java +++ b/src/Java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java @@ -1,26 +1,54 @@ package gtPlusPlus.core.item.base.misc; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -public class BaseItemParticle extends CoreItem { - - private final Material mParticleMaterial; +public abstract class BaseItemParticle extends CoreItem { + + protected static final Map<Integer, Integer> aColourMap = new LinkedHashMap<Integer, Integer> (); + private final int aMaxCount; - public BaseItemParticle(Material aMat, String aType) { - super("particle"+aMat.getLocalizedName()+aType, aMat.getLocalizedName()+" "+aType, AddToCreativeTab.tabOther, 64, 0, new String[] {}, EnumRarity.rare, EnumChatFormatting.DARK_AQUA, false, null); + public BaseItemParticle(String aType, int aCount, EnumRarity aRarity) { + super("particle"+aType, aType, AddToCreativeTab.tabOther, 64, 0, new String[] {}, aRarity, EnumChatFormatting.DARK_AQUA, false, null); this.setTextureName(CORE.MODID + ":" + "science/Atom"); - mParticleMaterial = aMat; + aMaxCount = aCount; + this.setHasSubtypes(true); + } @Override public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return this.mParticleMaterial.getRgbAsHex(); + return aColourMap.get(stack.getItemDamage()); + } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < aMaxCount; i ++) { + list.add(new ItemStack(item, 1, i)); + } } + + @Override + public final String getItemStackDisplayName(final ItemStack tItem) { + String aReturnValue = super.getItemStackDisplayName(tItem); + String[] a2 = getAffixes(); + aReturnValue = (a2[0] + aReturnValue + a2[1]); + return aReturnValue; + } + + public abstract String[] getAffixes(); + } |