aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java85
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java32
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java53
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java36
5 files changed, 169 insertions, 39 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java
index b412e0fe60..2fba1b0448 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java
@@ -7,35 +7,96 @@ import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCov
import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_KORP;
import cpw.mods.fml.common.Loader;
+import gtPlusPlus.core.lib.VanillaColours;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers;
import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem;
+import gtPlusPlus.xmod.gregtech.common.items.covers.MetaItemCoverCasings;
public class CoverManager {
-
- //ZTones
+
+ // ZTones
public static MetaCustomCoverItem Cover_Agon;
public static MetaCustomCoverItem Cover_Iszm;
public static MetaCustomCoverItem Cover_Korp;
public static MetaCustomCoverItem Cover_Jelt;
public static MetaCustomCoverItem Cover_Bitt;
-
+
+ // GT
+ public static MetaItemCoverCasings Cover_Gt_Machine_Casing;
public static void generateCustomCovers() {
// init textures
TexturesGtCutomCovers.init();
-
+
+ // GT Machine Casings
+ Cover_Gt_Machine_Casing = new MetaItemCoverCasings();
+
if (Loader.isModLoaded("Ztones")) {
String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" };
- MetaCustomCoverItem[] aZtoneCoverItems = new MetaCustomCoverItem[] { Cover_Agon, Cover_Iszm, Cover_Korp, Cover_Jelt, Cover_Bitt};
- CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT };
- for (int y=0;y<aZtoneCoverTextureNames.length;y++) {
- aZtoneCoverItems[y] = new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y]);
- }
+ MetaCustomCoverItem[] aZtoneCoverItems = new MetaCustomCoverItem[] { Cover_Agon, Cover_Iszm, Cover_Korp,
+ Cover_Jelt, Cover_Bitt };
+ CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP,
+ TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT };
+ short[][][] aRGB = new short[][][] { ZTONES.RGB_AGON, ZTONES.RGB_ISZM, ZTONES.RGB_KORP, ZTONES.RGB_JELT,
+ ZTONES.RGB_BITT };
+ for (int y = 0; y < aZtoneCoverTextureNames.length; y++) {
+ aZtoneCoverItems[y] = new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y],
+ aRGB[y]);
+ }
}
-
+
}
-
-
+
+ final static class ZTONES {
+
+ private static final short[][] RGB_AGON = new short[][] { VanillaColours.DYE_WHITE.getAsShort(),
+ VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_LIME.getAsShort(),
+ VanillaColours.DYE_GREEN.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(),
+ VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(),
+ VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(),
+ VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_BROWN.getAsShort(),
+ VanillaColours.DYE_BLACK.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_LIGHT_GRAY.getAsShort(), };
+ private static final short[][] RGB_ISZM = new short[][] { VanillaColours.DYE_LIGHT_GRAY.getAsShort(),
+ VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(),
+ VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(),
+ VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
+ VanillaColours.DYE_DARK_PURPLE.getAsShort(),
+ };
+ private static final short[][] RGB_KORP = new short[][] { new short[] { 125, 125, 125 },
+ VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(), new short[] { 22, 156, 156 }, new short[] { 22, 156, 156 },
+ VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), };
+ private static final short[][] RGB_JELT = new short[][] { VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(), };
+ private static final short[][] RGB_BITT = new short[][] { VanillaColours.DYE_BLACK.getAsShort(),
+ VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(),
+ VanillaColours.DYE_LIME.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(),
+ VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
+ VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(),
+ VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(),
+ VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_RED.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_BROWN.getAsShort(), };
+
+ }
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java
index f5e27c05d5..7e5b07916e 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java
@@ -5,11 +5,13 @@ import java.util.concurrent.ConcurrentHashMap;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.util.GT_CoverBehavior;
+import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.minecraft.BlockPos;
import gtPlusPlus.api.objects.random.XSTR;
import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@@ -32,12 +34,12 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
EntityPlayer aPlayer, float aX, float aY, float aZ) {
- return true;
+ return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ);
}
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
EntityPlayer aPlayer, float aX, float aY, float aZ) {
- return aCoverVariable;
+ return super.onCoverScrewdriverclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ);
}
public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
@@ -69,7 +71,7 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
}
public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return 0;
+ return 1;
}
@Override
@@ -105,19 +107,37 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
@Override
public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) {
String aKey = generateUniqueKey(aSide, aTileEntity);
+ boolean state = getCoverConnections(aCover);
sPrefixMap.put(aKey, aCover.getUnlocalizedName());
- sConnectionStateForEntityMap.put(aKey, MetaCustomCoverItem.getCoverConnections(aCover));
+ //Logger.INFO("Mapping key "+aKey+" to "+state);
+ sConnectionStateForEntityMap.put(aKey, state);
super.placeCover(aSide, aCover, aTileEntity);
}
@Override
public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
boolean aForced) {
- sConnectionStateForEntityMap.remove(generateUniqueKey(aSide, aTileEntity));
+ String aKey = generateUniqueKey(aSide, aTileEntity);
+ sConnectionStateForEntityMap.remove(aKey);
+ //Logger.INFO("Unmapping key "+aKey+".");
return true;
}
public static boolean getConnectionState(byte aSide, ICoverable aTile) {
- return sConnectionStateForEntityMap.get(generateUniqueKey(aSide, aTile));
+ String aKey = generateUniqueKey(aSide, aTile);
+ boolean b = sConnectionStateForEntityMap.get(aKey);
+ //Logger.INFO("Get State: "+b+" | "+aKey);
+ return b;
+ }
+
+ public static final boolean getCoverConnections(final ItemStack aStack) {
+ NBTTagCompound aNBT = aStack.getTagCompound();
+ if (aNBT != null) {
+ aNBT = aNBT.getCompoundTag("CustomCoverMeta");
+ if (aNBT != null) {
+ return aNBT.getBoolean("AllowConnections");
+ }
+ }
+ return false;
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java
index 6075261254..6915ea2112 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java
@@ -2,9 +2,12 @@ package gtPlusPlus.xmod.gregtech.common.items;
import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+
import cofh.core.render.IconRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
+import gregtech.api.interfaces.IIconContainer;
import gregtech.api.interfaces.ITexture;
import gregtech.api.objects.GT_MultiTexture;
import gregtech.api.objects.GT_RenderedTexture;
@@ -12,6 +15,9 @@ import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.client.renderer.CustomItemBlockRenderer;
import gtPlusPlus.core.common.CommonProxy;
import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.sys.KeyboardUtils;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon;
@@ -28,19 +34,22 @@ import net.minecraft.world.World;
public class MetaCustomCoverItem extends Item {
- private final IIcon[] icons;
+ protected final IIcon[] icons;
private final String mModID;
private final String mTextureSetName;
- private final CustomIcon[] mTextures;
+ protected final IIconContainer[] mTextures;
+ private final short[][] mRGB;
- public MetaCustomCoverItem(String aModId, int aTextureCount, String aTextureSetName, CustomIcon[] aTextures) {
+ public MetaCustomCoverItem(String aModId, int aTextureCount, String aTextureSetName, IIconContainer[] aTextures, short[][] aRGB) {
super();
icons = new IIcon[aTextureCount];
mModID = aModId;
- mTextureSetName = aTextureSetName;
+ mTextureSetName = Utils.sanitizeString(aTextureSetName);
mTextures = aTextures;
+ mRGB = aRGB;
+ this.setTextureName(CORE.MODID + ":" + "itemPlate");
this.setHasSubtypes(true);
- String unlocalizedName = "itemCustomMetaCover." + mModID + "." + mTextureSetName + "." + aTextureCount;
+ String unlocalizedName = "itemCustomMetaCover." + mModID + "." + mTextureSetName;
this.setUnlocalizedName(unlocalizedName);
this.setCreativeTab(AddToCreativeTab.tabMisc);
this.setMaxStackSize(1);
@@ -62,17 +71,13 @@ public class MetaCustomCoverItem extends Item {
}
}
- @Override
- public void registerIcons(IIconRegister reg) {
- for (int i = 0; i < icons.length; i++) {
- this.icons[i] = mTextures[i].getIcon();
- }
- }
-
- @Override
- public IIcon getIconFromDamage(int meta) {
- return this.icons[meta];
- }
+ /*
+ * @Override public void registerIcons(IIconRegister reg) { for (int i = 0; i <
+ * icons.length; i++) { this.icons[i] = mTextures[i].getIcon(); } }
+ *
+ * @Override public IIcon getIconFromDamage(int meta) { return this.icons[meta];
+ * }
+ */
@Override
public void getSubItems(Item item, CreativeTabs tab, List list) {
@@ -88,7 +93,7 @@ public class MetaCustomCoverItem extends Item {
@Override
public String getItemStackDisplayName(final ItemStack tItem) {
- return EnumChatFormatting.LIGHT_PURPLE + super.getItemStackDisplayName(tItem);
+ return EnumChatFormatting.LIGHT_PURPLE + StringUtils.capitalize(mTextureSetName) + " [" + tItem.getItemDamage() + "]"; //super.getItemStackDisplayName(tItem);
}
private static boolean createNBT(ItemStack rStack) {
@@ -168,9 +173,8 @@ public class MetaCustomCoverItem extends Item {
boolean con = getCoverConnections(stack);
if (con) {
setCoverConnections(stack, false);
- }
- else {
- setCoverConnections(stack, true);
+ } else {
+ setCoverConnections(stack, true);
}
}
return stack;
@@ -201,4 +205,13 @@ public class MetaCustomCoverItem extends Item {
return super.isFull3D();
}
+ @Override
+ public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) {
+ if (this.mRGB == null){
+ return super.getColorFromItemStack(stack, HEX_OxFFFFFF);
+ }
+ int aMeta = stack.getItemDamage();
+ return Utils.rgbtoHexValue(mRGB[aMeta][0], mRGB[aMeta][1], mRGB[aMeta][2]);
+ }
+
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
index d64fcfb6b2..8fc5996c6e 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
@@ -333,7 +333,7 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 {
}
else {
aTierName = GT_Values.VN[i];
- mMachineCasingCovers[i].set(this.addItem(aFirstMachineCasingID++, aTierName+" Machine Plate Cover", "Change connection status with Shift+Rmb", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L)}));
+ mMachineCasingCovers[i].set(this.addItem(aFirstMachineCasingID++, aTierName+" Machine Plate Cover", "Deprecated - Shapeless Craft to new version", new Object[]{}));
GregTech_API.registerCover(mMachineCasingCovers[i].get(1L, new Object[0]), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[i][0]}), new GTPP_Cover_ToggleVisual());
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java
new file mode 100644
index 0000000000..f9a3451106
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java
@@ -0,0 +1,36 @@
+package gtPlusPlus.xmod.gregtech.common.items.covers;
+
+import gregtech.api.enums.GT_Values;
+import gregtech.api.enums.Textures;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.IIcon;
+
+public class MetaItemCoverCasings extends MetaCustomCoverItem {
+
+ public MetaItemCoverCasings() {
+ super(CORE.MODID, Textures.BlockIcons.MACHINECASINGS_SIDE.length, "Gt Machine Casings", Textures.BlockIcons.MACHINECASINGS_SIDE, null);
+ }
+
+ @Override
+ public void registerIcons(IIconRegister reg) {
+ for (int i = 0; i < icons.length; i++) {
+ this.icons[i] = reg.registerIcon(CORE.MODID+":"+"covers/"+i);
+ }
+ }
+
+ @Override
+ public IIcon getIconFromDamage(int meta) {
+ return this.icons[MathUtils.balance(meta, 0, 15)];
+ }
+
+ @Override
+ public String getItemStackDisplayName(final ItemStack tItem) {
+ return EnumChatFormatting.LIGHT_PURPLE + GT_Values.VOLTAGE_NAMES[MathUtils.balance(tItem.getItemDamage(), 0, GT_Values.VOLTAGE_NAMES.length-1)]+" Machine Plate Cover"; //super.getItemStackDisplayName(tItem);
+ }
+
+}