Skip to content
This repository was archived by the owner on May 26, 2024. It is now read-only.

Commit b5e6865

Browse files
committed
+ Re-added Tiered Machine Covers. (Old ones will be deprecated) Closes #516.
+ Added extra tiered covers. (For use in GTNH mostly) + Added textures and colour coding for Ztones covers. + Localized some cover names.
1 parent d9fbb08 commit b5e6865

File tree

22 files changed

+197
-39
lines changed

22 files changed

+197
-39
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package gtPlusPlus.core.lib;
2+
3+
import gtPlusPlus.core.util.Utils;
4+
5+
public enum VanillaColours {
6+
7+
BONE_MEAL(249, 255, 254), INK_BLACK(29, 29, 33), COCOA_BEANS(131, 84, 50), LAPIS_LAZULI(60, 68, 170),
8+
DYE_WHITE(249, 255, 254), DYE_BLACK(29, 29, 33), DYE_RED(176, 46, 38), DYE_GREEN(94, 124, 22),
9+
DYE_CYAN(22, 156, 156), DYE_PINK(243, 139, 170), DYE_LIME(128, 199, 31), DYE_YELLOW(254, 216, 61),
10+
DYE_ORANGE(249, 128, 29), DYE_BROWN(131, 84, 50), DYE_LIGHT_BLUE(58, 179, 218), DYE_LIGHT_PURPLE(199, 78, 189),
11+
DYE_LIGHT_GRAY(157, 157, 151), DYE_DARK_BLUE(60, 68, 170), DYE_DARK_PURPLE(137, 50, 184), DYE_DARK_GRAY(71, 79, 82);
12+
13+
private final int r, g, b;
14+
15+
private VanillaColours(int aR, int aG, int aB) {
16+
r = aR;
17+
g = aG;
18+
b = aB;
19+
}
20+
21+
public short[] getAsShort() {
22+
return new short[] { (short) r, (short) g, (short) b };
23+
}
24+
25+
public int getAsInt() {
26+
return Utils.rgbtoHexValue(r, g, b);
27+
}
28+
}

src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java

+73-12
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,96 @@
77
import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_KORP;
88

99
import cpw.mods.fml.common.Loader;
10+
import gtPlusPlus.core.lib.VanillaColours;
1011
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon;
1112
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers;
1213
import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem;
14+
import gtPlusPlus.xmod.gregtech.common.items.covers.MetaItemCoverCasings;
1315

1416
public class CoverManager {
15-
16-
//ZTones
17+
18+
// ZTones
1719
public static MetaCustomCoverItem Cover_Agon;
1820
public static MetaCustomCoverItem Cover_Iszm;
1921
public static MetaCustomCoverItem Cover_Korp;
2022
public static MetaCustomCoverItem Cover_Jelt;
2123
public static MetaCustomCoverItem Cover_Bitt;
22-
24+
25+
// GT
26+
public static MetaItemCoverCasings Cover_Gt_Machine_Casing;
2327

2428
public static void generateCustomCovers() {
2529

2630
// init textures
2731
TexturesGtCutomCovers.init();
28-
32+
33+
// GT Machine Casings
34+
Cover_Gt_Machine_Casing = new MetaItemCoverCasings();
35+
2936
if (Loader.isModLoaded("Ztones")) {
3037
String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" };
31-
MetaCustomCoverItem[] aZtoneCoverItems = new MetaCustomCoverItem[] { Cover_Agon, Cover_Iszm, Cover_Korp, Cover_Jelt, Cover_Bitt};
32-
CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT };
33-
for (int y=0;y<aZtoneCoverTextureNames.length;y++) {
34-
aZtoneCoverItems[y] = new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y]);
35-
}
38+
MetaCustomCoverItem[] aZtoneCoverItems = new MetaCustomCoverItem[] { Cover_Agon, Cover_Iszm, Cover_Korp,
39+
Cover_Jelt, Cover_Bitt };
40+
CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP,
41+
TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT };
42+
short[][][] aRGB = new short[][][] { ZTONES.RGB_AGON, ZTONES.RGB_ISZM, ZTONES.RGB_KORP, ZTONES.RGB_JELT,
43+
ZTONES.RGB_BITT };
44+
for (int y = 0; y < aZtoneCoverTextureNames.length; y++) {
45+
aZtoneCoverItems[y] = new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y],
46+
aRGB[y]);
47+
}
3648
}
37-
49+
3850
}
39-
40-
51+
52+
final static class ZTONES {
53+
54+
private static final short[][] RGB_AGON = new short[][] { VanillaColours.DYE_WHITE.getAsShort(),
55+
VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_LIME.getAsShort(),
56+
VanillaColours.DYE_GREEN.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(),
57+
VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(),
58+
VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(),
59+
VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
60+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_BROWN.getAsShort(),
61+
VanillaColours.DYE_BLACK.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
62+
VanillaColours.DYE_LIGHT_GRAY.getAsShort(), };
63+
private static final short[][] RGB_ISZM = new short[][] { VanillaColours.DYE_LIGHT_GRAY.getAsShort(),
64+
VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
65+
VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(),
66+
VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
67+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(),
68+
VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
69+
VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(),
70+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
71+
VanillaColours.DYE_DARK_PURPLE.getAsShort(),
72+
};
73+
private static final short[][] RGB_KORP = new short[][] { new short[] { 125, 125, 125 },
74+
VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
75+
VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
76+
VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
77+
VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
78+
VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
79+
VanillaColours.DYE_DARK_GRAY.getAsShort(), new short[] { 22, 156, 156 }, new short[] { 22, 156, 156 },
80+
VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), };
81+
private static final short[][] RGB_JELT = new short[][] { VanillaColours.DYE_ORANGE.getAsShort(),
82+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
83+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
84+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
85+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
86+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
87+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
88+
VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
89+
VanillaColours.DYE_ORANGE.getAsShort(), };
90+
private static final short[][] RGB_BITT = new short[][] { VanillaColours.DYE_BLACK.getAsShort(),
91+
VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(),
92+
VanillaColours.DYE_LIME.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(),
93+
VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
94+
VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(),
95+
VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(),
96+
VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
97+
VanillaColours.DYE_RED.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
98+
VanillaColours.DYE_BROWN.getAsShort(), };
99+
100+
}
101+
41102
}

src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java

+26-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66
import gregtech.api.interfaces.tileentity.ICoverable;
77
import gregtech.api.util.GT_CoverBehavior;
8+
import gtPlusPlus.api.objects.Logger;
89
import gtPlusPlus.api.objects.minecraft.BlockPos;
910
import gtPlusPlus.api.objects.random.XSTR;
1011
import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem;
1112
import net.minecraft.entity.player.EntityPlayer;
1213
import net.minecraft.item.ItemStack;
14+
import net.minecraft.nbt.NBTTagCompound;
1315
import net.minecraftforge.common.util.ForgeDirection;
1416
import net.minecraftforge.fluids.Fluid;
1517

@@ -32,12 +34,12 @@ public static String generateUniqueKey(byte aSide, ICoverable aEntity) {
3234

3335
public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
3436
EntityPlayer aPlayer, float aX, float aY, float aZ) {
35-
return true;
37+
return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ);
3638
}
3739

3840
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
3941
EntityPlayer aPlayer, float aX, float aY, float aZ) {
40-
return aCoverVariable;
42+
return super.onCoverScrewdriverclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ);
4143
}
4244

4345
public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
@@ -69,7 +71,7 @@ public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICove
6971
}
7072

7173
public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
72-
return 0;
74+
return 1;
7375
}
7476

7577
@Override
@@ -105,19 +107,37 @@ public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int
105107
@Override
106108
public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) {
107109
String aKey = generateUniqueKey(aSide, aTileEntity);
110+
boolean state = getCoverConnections(aCover);
108111
sPrefixMap.put(aKey, aCover.getUnlocalizedName());
109-
sConnectionStateForEntityMap.put(aKey, MetaCustomCoverItem.getCoverConnections(aCover));
112+
//Logger.INFO("Mapping key "+aKey+" to "+state);
113+
sConnectionStateForEntityMap.put(aKey, state);
110114
super.placeCover(aSide, aCover, aTileEntity);
111115
}
112116

113117
@Override
114118
public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
115119
boolean aForced) {
116-
sConnectionStateForEntityMap.remove(generateUniqueKey(aSide, aTileEntity));
120+
String aKey = generateUniqueKey(aSide, aTileEntity);
121+
sConnectionStateForEntityMap.remove(aKey);
122+
//Logger.INFO("Unmapping key "+aKey+".");
117123
return true;
118124
}
119125

120126
public static boolean getConnectionState(byte aSide, ICoverable aTile) {
121-
return sConnectionStateForEntityMap.get(generateUniqueKey(aSide, aTile));
127+
String aKey = generateUniqueKey(aSide, aTile);
128+
boolean b = sConnectionStateForEntityMap.get(aKey);
129+
//Logger.INFO("Get State: "+b+" | "+aKey);
130+
return b;
131+
}
132+
133+
public static final boolean getCoverConnections(final ItemStack aStack) {
134+
NBTTagCompound aNBT = aStack.getTagCompound();
135+
if (aNBT != null) {
136+
aNBT = aNBT.getCompoundTag("CustomCoverMeta");
137+
if (aNBT != null) {
138+
return aNBT.getBoolean("AllowConnections");
139+
}
140+
}
141+
return false;
122142
}
123143
}

src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java

+33-20
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22

33
import java.util.List;
44

5+
import org.apache.commons.lang3.StringUtils;
6+
57
import cofh.core.render.IconRegistry;
68
import cpw.mods.fml.common.registry.GameRegistry;
79
import gregtech.api.GregTech_API;
10+
import gregtech.api.interfaces.IIconContainer;
811
import gregtech.api.interfaces.ITexture;
912
import gregtech.api.objects.GT_MultiTexture;
1013
import gregtech.api.objects.GT_RenderedTexture;
1114
import gtPlusPlus.api.objects.Logger;
1215
import gtPlusPlus.core.client.renderer.CustomItemBlockRenderer;
1316
import gtPlusPlus.core.common.CommonProxy;
1417
import gtPlusPlus.core.creative.AddToCreativeTab;
18+
import gtPlusPlus.core.lib.CORE;
19+
import gtPlusPlus.core.util.Utils;
20+
import gtPlusPlus.core.util.math.MathUtils;
1521
import gtPlusPlus.core.util.minecraft.ItemUtils;
1622
import gtPlusPlus.core.util.sys.KeyboardUtils;
1723
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon;
@@ -28,19 +34,22 @@
2834

2935
public class MetaCustomCoverItem extends Item {
3036

31-
private final IIcon[] icons;
37+
protected final IIcon[] icons;
3238
private final String mModID;
3339
private final String mTextureSetName;
34-
private final CustomIcon[] mTextures;
40+
protected final IIconContainer[] mTextures;
41+
private final short[][] mRGB;
3542

36-
public MetaCustomCoverItem(String aModId, int aTextureCount, String aTextureSetName, CustomIcon[] aTextures) {
43+
public MetaCustomCoverItem(String aModId, int aTextureCount, String aTextureSetName, IIconContainer[] aTextures, short[][] aRGB) {
3744
super();
3845
icons = new IIcon[aTextureCount];
3946
mModID = aModId;
40-
mTextureSetName = aTextureSetName;
47+
mTextureSetName = Utils.sanitizeString(aTextureSetName);
4148
mTextures = aTextures;
49+
mRGB = aRGB;
50+
this.setTextureName(CORE.MODID + ":" + "itemPlate");
4251
this.setHasSubtypes(true);
43-
String unlocalizedName = "itemCustomMetaCover." + mModID + "." + mTextureSetName + "." + aTextureCount;
52+
String unlocalizedName = "itemCustomMetaCover." + mModID + "." + mTextureSetName;
4453
this.setUnlocalizedName(unlocalizedName);
4554
this.setCreativeTab(AddToCreativeTab.tabMisc);
4655
this.setMaxStackSize(1);
@@ -62,17 +71,13 @@ private final void registerCover() {
6271
}
6372
}
6473

65-
@Override
66-
public void registerIcons(IIconRegister reg) {
67-
for (int i = 0; i < icons.length; i++) {
68-
this.icons[i] = mTextures[i].getIcon();
69-
}
70-
}
71-
72-
@Override
73-
public IIcon getIconFromDamage(int meta) {
74-
return this.icons[meta];
75-
}
74+
/*
75+
* @Override public void registerIcons(IIconRegister reg) { for (int i = 0; i <
76+
* icons.length; i++) { this.icons[i] = mTextures[i].getIcon(); } }
77+
*
78+
* @Override public IIcon getIconFromDamage(int meta) { return this.icons[meta];
79+
* }
80+
*/
7681

7782
@Override
7883
public void getSubItems(Item item, CreativeTabs tab, List list) {
@@ -88,7 +93,7 @@ public String getUnlocalizedName(ItemStack stack) {
8893

8994
@Override
9095
public String getItemStackDisplayName(final ItemStack tItem) {
91-
return EnumChatFormatting.LIGHT_PURPLE + super.getItemStackDisplayName(tItem);
96+
return EnumChatFormatting.LIGHT_PURPLE + StringUtils.capitalize(mTextureSetName) + " [" + tItem.getItemDamage() + "]"; //super.getItemStackDisplayName(tItem);
9297
}
9398

9499
private static boolean createNBT(ItemStack rStack) {
@@ -168,9 +173,8 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla
168173
boolean con = getCoverConnections(stack);
169174
if (con) {
170175
setCoverConnections(stack, false);
171-
}
172-
else {
173-
setCoverConnections(stack, true);
176+
} else {
177+
setCoverConnections(stack, true);
174178
}
175179
}
176180
return stack;
@@ -201,4 +205,13 @@ public boolean isFull3D() {
201205
return super.isFull3D();
202206
}
203207

208+
@Override
209+
public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) {
210+
if (this.mRGB == null){
211+
return super.getColorFromItemStack(stack, HEX_OxFFFFFF);
212+
}
213+
int aMeta = stack.getItemDamage();
214+
return Utils.rgbtoHexValue(mRGB[aMeta][0], mRGB[aMeta][1], mRGB[aMeta][2]);
215+
}
216+
204217
}

src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public void generateMetaItems() {
333333
}
334334
else {
335335
aTierName = GT_Values.VN[i];
336-
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)}));
336+
mMachineCasingCovers[i].set(this.addItem(aFirstMachineCasingID++, aTierName+" Machine Plate Cover", "Deprecated - Shapeless Craft to new version", new Object[]{}));
337337
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());
338338
}
339339
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package gtPlusPlus.xmod.gregtech.common.items.covers;
2+
3+
import gregtech.api.enums.GT_Values;
4+
import gregtech.api.enums.Textures;
5+
import gtPlusPlus.core.lib.CORE;
6+
import gtPlusPlus.core.util.math.MathUtils;
7+
import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem;
8+
import net.minecraft.client.renderer.texture.IIconRegister;
9+
import net.minecraft.item.ItemStack;
10+
import net.minecraft.util.EnumChatFormatting;
11+
import net.minecraft.util.IIcon;
12+
13+
public class MetaItemCoverCasings extends MetaCustomCoverItem {
14+
15+
public MetaItemCoverCasings() {
16+
super(CORE.MODID, Textures.BlockIcons.MACHINECASINGS_SIDE.length, "Gt Machine Casings", Textures.BlockIcons.MACHINECASINGS_SIDE, null);
17+
}
18+
19+
@Override
20+
public void registerIcons(IIconRegister reg) {
21+
for (int i = 0; i < icons.length; i++) {
22+
this.icons[i] = reg.registerIcon(CORE.MODID+":"+"covers/"+i);
23+
}
24+
}
25+
26+
@Override
27+
public IIcon getIconFromDamage(int meta) {
28+
return this.icons[MathUtils.balance(meta, 0, 15)];
29+
}
30+
31+
@Override
32+
public String getItemStackDisplayName(final ItemStack tItem) {
33+
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);
34+
}
35+
36+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)