aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common/covers
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-08-14 20:04:13 +0100
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-08-14 20:04:13 +0100
commitede55e818ba0312f061e154402cd82ec4603480d (patch)
treec5cb3074cc45f9bc36b2e2a891dd00da87498c12 /src/Java/gtPlusPlus/xmod/gregtech/common/covers
parent800119d6a1e75ffd0201a9dfc44c53a7604a9f37 (diff)
downloadGT5-Unofficial-ede55e818ba0312f061e154402cd82ec4603480d.tar.gz
GT5-Unofficial-ede55e818ba0312f061e154402cd82ec4603480d.tar.bz2
GT5-Unofficial-ede55e818ba0312f061e154402cd82ec4603480d.zip
+ Attempted to add custom covers for Ztones blocks. Should close #521.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/covers')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java41
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java123
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_VisualPlate.java67
3 files changed, 164 insertions, 67 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java
new file mode 100644
index 0000000000..b412e0fe60
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java
@@ -0,0 +1,41 @@
+package gtPlusPlus.xmod.gregtech.common.covers;
+
+import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_AGON;
+import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_BITT;
+import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_ISZM;
+import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_JELT;
+import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_KORP;
+
+import cpw.mods.fml.common.Loader;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers;
+import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem;
+
+public class CoverManager {
+
+ //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;
+
+
+ public static void generateCustomCovers() {
+
+ // init textures
+ TexturesGtCutomCovers.init();
+
+ 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]);
+ }
+ }
+
+ }
+
+
+}
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
new file mode 100644
index 0000000000..f5e27c05d5
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java
@@ -0,0 +1,123 @@
+package gtPlusPlus.xmod.gregtech.common.covers;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.util.GT_CoverBehavior;
+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.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+
+public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
+
+ private static final Map<String, Boolean> sConnectionStateForEntityMap = new ConcurrentHashMap<String, Boolean>();
+ private static final Map<String, String> sPrefixMap = new ConcurrentHashMap<String, String>();
+
+ public static String generateUniqueKey(byte aSide, ICoverable aEntity) {
+ try {
+ BlockPos aPos = new BlockPos(aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord()));
+ ForgeDirection aDir = ForgeDirection.getOrientation(aSide);
+ String s = aEntity.getInventoryName()+"."+aPos.getUniqueIdentifier()+aDir.name();
+ return s;
+ }
+ catch (Throwable t) {}
+ XSTR x = new XSTR();
+ return "ERROR."+x.getSeed()+x.hashCode()+x.nextDouble()+".ID";
+ }
+
+ public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
+ EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return true;
+ }
+
+ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
+ EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ return aCoverVariable;
+ }
+
+ public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return getConnectionState(aSide, aTileEntity);
+ }
+
+ public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return getConnectionState(aSide, aTileEntity);
+ }
+
+ public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return getConnectionState(aSide, aTileEntity);
+ }
+
+ public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return getConnectionState(aSide, aTileEntity);
+ }
+
+ public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return getConnectionState(aSide, aTileEntity);
+ }
+
+ public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return getConnectionState(aSide, aTileEntity);
+ }
+
+ public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return this.trans("756", "Connectable: ") + getConnectionState(aSide, aTileEntity);
+ }
+
+ public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return 0;
+ }
+
+ @Override
+ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
+ long aTimer) {
+ return aCoverVariable;
+ }
+
+ @Override
+ public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return getConnectionState(aSide, aTileEntity);
+ }
+
+ @Override
+ public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return getConnectionState(aSide, aTileEntity);
+ }
+
+ @Override
+ public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return super.alwaysLookConnected(aSide, aCoverID, aCoverVariable, aTileEntity);
+ }
+
+ @Override
+ public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable,
+ ICoverable aTileEntity) {
+ if (!getConnectionState(aSide, aTileEntity)) {
+ return 0;
+ }
+ return super.getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity);
+ }
+
+ @Override
+ public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) {
+ String aKey = generateUniqueKey(aSide, aTileEntity);
+ sPrefixMap.put(aKey, aCover.getUnlocalizedName());
+ sConnectionStateForEntityMap.put(aKey, MetaCustomCoverItem.getCoverConnections(aCover));
+ super.placeCover(aSide, aCover, aTileEntity);
+ }
+
+ @Override
+ public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
+ boolean aForced) {
+ sConnectionStateForEntityMap.remove(generateUniqueKey(aSide, aTileEntity));
+ return true;
+ }
+
+ public static boolean getConnectionState(byte aSide, ICoverable aTile) {
+ return sConnectionStateForEntityMap.get(generateUniqueKey(aSide, aTile));
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_VisualPlate.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_VisualPlate.java
deleted file mode 100644
index 7d2ed2c21a..0000000000
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_VisualPlate.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package gtPlusPlus.xmod.gregtech.common.covers;
-
-import gregtech.api.interfaces.tileentity.ICoverable;
-import gregtech.api.util.GT_CoverBehavior;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraftforge.fluids.Fluid;
-
-public class GTPP_Cover_VisualPlate extends GT_CoverBehavior {
-
- public GTPP_Cover_VisualPlate() {
- }
-
- public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
- long aTimer) {
- return aCoverVariable;
- }
-
- public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
- EntityPlayer aPlayer, float aX, float aY, float aZ) {
- return aCoverVariable;
- }
-
- public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
- EntityPlayer aPlayer, float aX, float aY, float aZ) {
- return true;
- }
-
- public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return false;
- }
-
- public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return false;
- }
-
- public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return false;
- }
-
- public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return false;
- }
-
- public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
- return false;
- }
-
- public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
- return false;
- }
-
- public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
- return false;
- }
-
- public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
- return false;
- }
-
- public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return false;
- }
-
- public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return 0;
- }
-} \ No newline at end of file