aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-08-15 07:55:35 +0100
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-08-15 07:55:35 +0100
commite7ef217244340fe6984b79815d56d9d5b72582fc (patch)
tree5ba69d85189d2c6d876c95154b7524cee2859e87 /src/Java/gtPlusPlus/xmod/gregtech/common
parent9f9b49884e9496023cd9cd66b0dfe4301f8231bf (diff)
downloadGT5-Unofficial-e7ef217244340fe6984b79815d56d9d5b72582fc.tar.gz
GT5-Unofficial-e7ef217244340fe6984b79815d56d9d5b72582fc.tar.bz2
GT5-Unofficial-e7ef217244340fe6984b79815d56d9d5b72582fc.zip
+ Attempted to add a buggy NEI page for decayable dusts.
+ Added a way to disable ALL GT++ logging in the ASM config file. + Added recipes for Ztones covers. % Adjusted recipes for Tiered machine covers. % Updated GT++ debug command to toggle logging if desired. (Useful in-game). $ Fixed bug where smart covers would lose their state.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java84
1 files changed, 63 insertions, 21 deletions
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 7e5b07916e..561da54ceb 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
@@ -4,11 +4,12 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
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 gtPlusPlus.core.util.minecraft.PlayerUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -17,9 +18,11 @@ 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, Integer> sConnectionStateForEntityMap = new ConcurrentHashMap<String, Integer>();
private static final Map<String, String> sPrefixMap = new ConcurrentHashMap<String, String>();
-
+ private static final int VALUE_OFF = 0;
+ private static final int VALUE_ON = 1;
+
public static String generateUniqueKey(byte aSide, ICoverable aEntity) {
try {
BlockPos aPos = new BlockPos(aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord()));
@@ -33,7 +36,8 @@ 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) {
+ EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ PlayerUtils.messagePlayer(aPlayer, this.trans("756", "Connectable: ") + getConnectionState(aCoverVariable));
return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ);
}
@@ -43,31 +47,31 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
}
public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return getConnectionState(aSide, aTileEntity);
+ return getConnectionState(aCoverVariable);
}
public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return getConnectionState(aSide, aTileEntity);
+ return getConnectionState(aCoverVariable);
}
public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
- return getConnectionState(aSide, aTileEntity);
+ return getConnectionState(aCoverVariable);
}
public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
- return getConnectionState(aSide, aTileEntity);
+ return getConnectionState(aCoverVariable);
}
public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
- return getConnectionState(aSide, aTileEntity);
+ return getConnectionState(aCoverVariable);
}
public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
- return getConnectionState(aSide, aTileEntity);
+ return getConnectionState(aCoverVariable);
}
public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return this.trans("756", "Connectable: ") + getConnectionState(aSide, aTileEntity);
+ return this.trans("756", "Connectable: ") + getConnectionState(aCoverVariable);
}
public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
@@ -76,18 +80,34 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
@Override
public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
- long aTimer) {
+ long aTimer) {
+ try {
+ String aKey = generateUniqueKey(aSide, aTileEntity);
+ Integer b = sConnectionStateForEntityMap.get(aKey);
+ //Logger.INFO("Val: "+aCoverVariable);
+ if (b != null && aCoverVariable != b) {
+ aCoverVariable = b;
+ }
+ if (b == null) {
+ b = aCoverVariable;
+ sConnectionStateForEntityMap.put(aKey, b);
+ trySetState(aSide, b == VALUE_ON ? VALUE_ON : VALUE_OFF, aTileEntity);
+ }
+ }
+ catch (Throwable t) {
+
+ }
return aCoverVariable;
}
@Override
public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return getConnectionState(aSide, aTileEntity);
+ return getConnectionState(aCoverVariable);
}
@Override
public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- return getConnectionState(aSide, aTileEntity);
+ return getConnectionState(aCoverVariable);
}
@Override
@@ -98,7 +118,7 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
@Override
public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable,
ICoverable aTileEntity) {
- if (!getConnectionState(aSide, aTileEntity)) {
+ if (!getConnectionState(aCoverVariable)) {
return 0;
}
return super.getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity);
@@ -109,8 +129,11 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
String aKey = generateUniqueKey(aSide, aTileEntity);
boolean state = getCoverConnections(aCover);
sPrefixMap.put(aKey, aCover.getUnlocalizedName());
- //Logger.INFO("Mapping key "+aKey+" to "+state);
- sConnectionStateForEntityMap.put(aKey, state);
+ Logger.INFO("Mapping key "+aKey+" to "+state);
+ sConnectionStateForEntityMap.put(aKey, state ? VALUE_ON : VALUE_OFF);
+ Logger.INFO("Key Value: "+(state ? VALUE_ON : VALUE_OFF));
+ //Try set cover state directly
+ //trySetState(aSide, state ? VALUE_ON : VALUE_OFF, aTileEntity);
super.placeCover(aSide, aCover, aTileEntity);
}
@@ -122,14 +145,33 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior {
//Logger.INFO("Unmapping key "+aKey+".");
return true;
}
-
+
+ public static boolean getConnectionState(int aCoverVar) {
+ return aCoverVar == VALUE_ON;
+ }
+
+ private static final void trySetState(byte aSide, int aState, ICoverable aTile) {
+ //Try set cover state directly
+ if (aTile instanceof IGregTechTileEntity) {
+ IGregTechTileEntity gTileEntity = (IGregTechTileEntity) aTile;
+ if (gTileEntity != null) {
+ gTileEntity.setCoverDataAtSide(aSide, aState);
+ }
+ }
+ }
+
+
public static boolean getConnectionState(byte aSide, ICoverable aTile) {
String aKey = generateUniqueKey(aSide, aTile);
- boolean b = sConnectionStateForEntityMap.get(aKey);
- //Logger.INFO("Get State: "+b+" | "+aKey);
- return b;
+ return getConnectionState(aKey);
}
+ public static boolean getConnectionState(String aKey) {
+ Integer b = sConnectionStateForEntityMap.get(aKey);
+ //Logger.INFO("Get State: "+b+" | "+aKey);
+ return b != null ? b == VALUE_ON : false;
+ }
+
public static final boolean getCoverConnections(final ItemStack aStack) {
NBTTagCompound aNBT = aStack.getTagCompound();
if (aNBT != null) {