aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/GT_Network.java2
-rw-r--r--src/main/java/gregtech/common/GT_Pollution.java341
-rw-r--r--src/main/java/gregtech/common/GT_Proxy.java81
-rw-r--r--src/main/java/gregtech/common/GT_RecipeAdder.java15
-rw-r--r--src/main/java/gregtech/common/GT_UndergroundOil.java291
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Block_Machines.java36
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Item_Machines.java29
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_Arm.java11
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java13
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java256
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java215
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java18
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java19
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java24
-rw-r--r--src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java2
-rw-r--r--src/main/java/gregtech/common/items/GT_FluidDisplayItem.java2
-rw-r--r--src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java6
-rw-r--r--src/main/java/gregtech/common/misc/GT_Command.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java97
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java21
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java206
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java131
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java89
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java45
-rw-r--r--src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java3
-rw-r--r--src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java50
-rw-r--r--src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java14
-rw-r--r--src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java28
-rw-r--r--src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java14
31 files changed, 1291 insertions, 774 deletions
diff --git a/src/main/java/gregtech/common/GT_Network.java b/src/main/java/gregtech/common/GT_Network.java
index c9c57676ad..97e511aba4 100644
--- a/src/main/java/gregtech/common/GT_Network.java
+++ b/src/main/java/gregtech/common/GT_Network.java
@@ -36,7 +36,7 @@ public class GT_Network extends MessageToMessageCodec<FMLProxyPacket, GT_Packet>
public GT_Network() {
this.mChannel = NetworkRegistry.INSTANCE.newChannel("GregTech", this, new HandlerShared());
- this.mSubChannels = new GT_Packet[]{new GT_Packet_TileEntity(), new GT_Packet_Sound(), new GT_Packet_Block_Event(), new GT_Packet_Ores(), new GT_Packet_Pollution(), new MessageSetFlaskCapacity(), new GT_Packet_TileEntityCover(), new GT_Packet_TileEntityCoverGUI(), new MessageUpdateFluidDisplayItem(), new GT_Packet_ClientPreference(), new GT_Packet_WirelessRedstoneCover()};
+ this.mSubChannels = new GT_Packet[]{new GT_Packet_TileEntity(), new GT_Packet_Sound(), new GT_Packet_Block_Event(), new GT_Packet_Ores(), new GT_Packet_Pollution(), new MessageSetFlaskCapacity(), new GT_Packet_TileEntityCover(), new GT_Packet_TileEntityCoverGUI(), new MessageUpdateFluidDisplayItem(), new GT_Packet_ClientPreference(), new GT_Packet_WirelessRedstoneCover(), new GT_Packet_TileEntityCoverNew()};
}
@Override
diff --git a/src/main/java/gregtech/common/GT_Pollution.java b/src/main/java/gregtech/common/GT_Pollution.java
index 7b1ad90d52..865fa83f7e 100644
--- a/src/main/java/gregtech/common/GT_Pollution.java
+++ b/src/main/java/gregtech/common/GT_Pollution.java
@@ -7,6 +7,7 @@ import gregtech.GT_Mod;
import gregtech.api.enums.GT_Values;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.net.GT_Packet_Pollution;
+import gregtech.api.util.GT_ChunkAssociatedData;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@@ -20,30 +21,34 @@ import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
+import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
+import net.minecraftforge.event.world.WorldEvent;
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
-import static gregtech.common.GT_Proxy.GTPOLLUTION;
-import static gregtech.common.GT_Proxy.dimensionWiseChunkData;
import static gregtech.common.GT_Proxy.dimensionWisePollution;
-import static gregtech.common.GT_Proxy.getDefaultChunkDataOnCreation;
public class GT_Pollution {
+ private static final Storage STORAGE = new Storage();
/**
* Pollution dispersion until effects start:
* Calculation: ((Limit * 0.01) + 2000) * (4 <- spreading rate)
- *
+ * <p>
* SMOG(500k) 466.7 pollution/sec
* Poison(750k) 633,3 pollution/sec
* Dying Plants(1mio) 800 pollution/sec
* Sour Rain(1.5mio) 1133.3 pollution/sec
- *
+ * <p>
* Pollution producers (pollution/sec)
* Bronze Boiler(20)
* Lava Boiler(20)
@@ -52,7 +57,7 @@ public class GT_Pollution {
* Diesel Generator(40/80/160)
* Gas Turbine(20/40/80)
* Charcoal Pile(100)
- *
+ * <p>
* Large Diesel Engine(320)
* Electric Blast Furnace(100)
* Implosion Compressor(2000)
@@ -60,33 +65,27 @@ public class GT_Pollution {
* Large Gas Turbine(160)
* Multi Smelter(100)
* Pyrolyse Oven(400)
- *
+ * <p>
* Machine Explosion(100,000)
- *
+ * <p>
* Other Random Shit: lots and lots
- *
+ * <p>
* Muffler Hatch Pollution reduction: ** inaccurate **
* LV (0%), MV (30%), HV (52%), EV (66%), IV (76%), LuV (84%), ZPM (89%), UV (92%), MAX (95%)
*/
private List<ChunkCoordIntPair> pollutionList = new ArrayList<>();//chunks left to process
- private HashMap<ChunkCoordIntPair,int[]> chunkData;//link to chunk data that is saved/loaded
- private int operationsPerTick=0;//how much chunks should be processed in each cycle
- private static final short cycleLen=1200;
- private final World aWorld;
+ private final List<ChunkCoordIntPair> chunkData = new ArrayList<>();//link to chunk data that is saved/loaded
+ private int operationsPerTick = 0;//how much chunks should be processed in each cycle
+ private static final short cycleLen = 1200;
+ private final World world;
public static int mPlayerPollution;
private static int POLLUTIONPACKET_MINVALUE = 1000;
private static GT_PollutionEventHandler EVENT_HANDLER;
- public GT_Pollution(World world){
- aWorld=world;
- chunkData=dimensionWiseChunkData.get(aWorld.provider.dimensionId);
- if(chunkData==null){
- chunkData=new HashMap<>(1024);
- dimensionWiseChunkData.put(world.provider.dimensionId,chunkData);
- }
- dimensionWisePollution.put(aWorld.provider.dimensionId,this);
+ public GT_Pollution(World world) {
+ this.world = world;
if (EVENT_HANDLER == null) {
EVENT_HANDLER = new GT_PollutionEventHandler();
@@ -94,61 +93,61 @@ public class GT_Pollution {
}
}
- public static void onWorldTick(TickEvent.WorldTickEvent aEvent){//called from proxy
+ public static void onWorldTick(TickEvent.WorldTickEvent aEvent) {//called from proxy
//return if pollution disabled
- if(!GT_Mod.gregtechproxy.mPollution) return;
+ if (!GT_Mod.gregtechproxy.mPollution) return;
final GT_Pollution pollutionInstance = dimensionWisePollution.get(aEvent.world.provider.dimensionId);
- if(pollutionInstance==null)return;
- pollutionInstance.tickPollutionInWorld((int)(aEvent.world.getTotalWorldTime()%cycleLen));
+ if (pollutionInstance == null) return;
+ pollutionInstance.tickPollutionInWorld((int) (aEvent.world.getTotalWorldTime() % cycleLen));
}
- private void tickPollutionInWorld(int aTickID){//called from method above
+ private void tickPollutionInWorld(int aTickID) {//called from method above
//gen data set
- if(aTickID==0){
- pollutionList = new ArrayList<>(chunkData.keySet());
+ if (aTickID == 0) {
+ // make a snapshot of what to work on
+ // counterintuitive as it seems, but this is the fastest way java collections framework offers us.
+ pollutionList = new ArrayList<>(chunkData);
//set operations per tick
- if(pollutionList.size()>0) operationsPerTick =(pollutionList.size()/cycleLen);
- else operationsPerTick=0;//SANity
+ if (pollutionList.size() > 0) operationsPerTick = (pollutionList.size() / cycleLen);
+ else operationsPerTick = 0;//SANity
}
- for(int chunksProcessed=0;chunksProcessed<=operationsPerTick;chunksProcessed++){
- if(pollutionList.size()==0)break;//no more stuff to do
- ChunkCoordIntPair actualPos=pollutionList.remove(pollutionList.size()-1);//faster
- //add default data if missing
- if(!chunkData.containsKey(actualPos)) chunkData.put(actualPos,getDefaultChunkDataOnCreation());
+ for (int chunksProcessed = 0; chunksProcessed <= operationsPerTick; chunksProcessed++) {
+ if (pollutionList.size() == 0) break;//no more stuff to do
+ ChunkCoordIntPair actualPos = pollutionList.remove(pollutionList.size() - 1);//faster
//get pollution
- int tPollution = chunkData.get(actualPos)[GTPOLLUTION];
+ ChunkData currentData = STORAGE.get(world, actualPos);
+ int tPollution = currentData.getAmount();
//remove some
- tPollution = (int)(0.9945f*tPollution);
+ tPollution = (int) (0.9945f * tPollution);
//tPollution -= 2000;//This does not really matter...
- if(tPollution<=0) tPollution = 0;//SANity check
- else if(tPollution>400000){//Spread Pollution
+ if (tPollution <= 0) tPollution = 0;//SANity check
+ else if (tPollution > 400000) {//Spread Pollution
ChunkCoordIntPair[] tNeighbors = new ChunkCoordIntPair[4];//array is faster
- tNeighbors[0]=(new ChunkCoordIntPair(actualPos.chunkXPos+1,actualPos.chunkZPos));
- tNeighbors[1]=(new ChunkCoordIntPair(actualPos.chunkXPos-1,actualPos.chunkZPos));
- tNeighbors[2]=(new ChunkCoordIntPair(actualPos.chunkXPos,actualPos.chunkZPos+1));
- tNeighbors[3]=(new ChunkCoordIntPair(actualPos.chunkXPos,actualPos.chunkZPos-1));
- for(ChunkCoordIntPair neighborPosition : tNeighbors){
- if(!chunkData.containsKey(neighborPosition)) chunkData.put(neighborPosition,getDefaultChunkDataOnCreation());
-
- int neighborPollution = chunkData.get(neighborPosition)[GTPOLLUTION];
- if(neighborPollution*6 < tPollution*5){//METHEMATICS...
+ tNeighbors[0] = (new ChunkCoordIntPair(actualPos.chunkXPos + 1, actualPos.chunkZPos));
+ tNeighbors[1] = (new ChunkCoordIntPair(actualPos.chunkXPos - 1, actualPos.chunkZPos));
+ tNeighbors[2] = (new ChunkCoordIntPair(actualPos.chunkXPos, actualPos.chunkZPos + 1));
+ tNeighbors[3] = (new ChunkCoordIntPair(actualPos.chunkXPos, actualPos.chunkZPos - 1));
+ for (ChunkCoordIntPair neighborPosition : tNeighbors) {
+ ChunkData neighbor = STORAGE.get(world, neighborPosition);
+ int neighborPollution = neighbor.getAmount();
+ if (neighborPollution * 6 < tPollution * 5) {//MATHEMATICS...
int tDiff = tPollution - neighborPollution;
- tDiff = tDiff/20;
- neighborPollution = GT_Utility.safeInt((long)neighborPollution+tDiff);//tNPol += tDiff;
+ tDiff = tDiff / 20;
+ neighborPollution = GT_Utility.safeInt((long) neighborPollution + tDiff);//tNPol += tDiff;
tPollution -= tDiff;
- chunkData.get(neighborPosition)[GTPOLLUTION] = neighborPollution;
+ neighbor.setAmount(neighborPollution);
}
}
//Create Pollution effects
//Smog filter TODO
- if(tPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit) {
+ if (tPollution > GT_Mod.gregtechproxy.mPollutionSmogLimit) {
AxisAlignedBB chunk = AxisAlignedBB.getBoundingBox(actualPos.chunkXPos << 4, 0, actualPos.chunkZPos << 4, (actualPos.chunkXPos << 4) + 16, 256, (actualPos.chunkZPos << 4) + 16);
- List<EntityLivingBase> tEntitys = aWorld.getEntitiesWithinAABB(EntityLivingBase.class, chunk);
+ List<EntityLivingBase> tEntitys = world.getEntitiesWithinAABB(EntityLivingBase.class, chunk);
for (EntityLivingBase tEnt : tEntitys) {
if (tEnt instanceof EntityPlayerMP && ((EntityPlayerMP) tEnt).capabilities.isCreativeMode)
continue;
@@ -194,131 +193,211 @@ public class GT_Pollution {
int x = (actualPos.chunkXPos << 4) + XSTR_INSTANCE.nextInt(16);
int y = 60 + (-f + XSTR_INSTANCE.nextInt(f * 2 + 1));
int z = (actualPos.chunkZPos << 4) + XSTR_INSTANCE.nextInt(16);
- damageBlock(aWorld, x, y, z, tPollution > GT_Mod.gregtechproxy.mPollutionSourRainLimit);
+ damageBlock(world, x, y, z, tPollution > GT_Mod.gregtechproxy.mPollutionSourRainLimit);
}
}
}
}
}
//Write new pollution to Hashmap !!!
- chunkData.get(actualPos)[GTPOLLUTION] = tPollution;
+ currentData.setAmount(tPollution);
//Send new value to players nearby
if (tPollution > POLLUTIONPACKET_MINVALUE) {
- NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(aWorld.provider.dimensionId, (actualPos.chunkXPos << 4), 64, (actualPos.chunkZPos << 4), 256);
+ NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, (actualPos.chunkXPos << 4), 64, (actualPos.chunkZPos << 4), 256);
GT_Values.NW.sendToAllAround(new GT_Packet_Pollution(actualPos, tPollution), point);
}
}
}
- private static void damageBlock(World world, int x, int y, int z, boolean sourRain){
- if (world.isRemote) return;
+ private static void damageBlock(World world, int x, int y, int z, boolean sourRain) {
+ if (world.isRemote) return;
Block tBlock = world.getBlock(x, y, z);
int tMeta = world.getBlockMetadata(x, y, z);
- if (tBlock == Blocks.air || tBlock == Blocks.stone || tBlock == Blocks.sand|| tBlock == Blocks.deadbush)return;
-
- if (tBlock == Blocks.leaves || tBlock == Blocks.leaves2 || tBlock.getMaterial() == Material.leaves)
- world.setBlockToAir(x, y, z);
- if (tBlock == Blocks.reeds) {
- tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
- world.setBlockToAir(x, y, z);
- }
- if (tBlock == Blocks.tallgrass)
- world.setBlock(x, y, z, Blocks.deadbush);
- if (tBlock == Blocks.vine) {
- tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
- world.setBlockToAir(x, y, z);
- }
- if (tBlock == Blocks.waterlily || tBlock == Blocks.wheat || tBlock == Blocks.cactus ||
+ if (tBlock == Blocks.air || tBlock == Blocks.stone || tBlock == Blocks.sand || tBlock == Blocks.deadbush)
+ return;
+
+ if (tBlock == Blocks.leaves || tBlock == Blocks.leaves2 || tBlock.getMaterial() == Material.leaves)
+ world.setBlockToAir(x, y, z);
+ if (tBlock == Blocks.reeds) {
+ tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
+ world.setBlockToAir(x, y, z);
+ }
+ if (tBlock == Blocks.tallgrass)
+ world.setBlock(x, y, z, Blocks.deadbush);
+ if (tBlock == Blocks.vine) {
+ tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
+ world.setBlockToAir(x, y, z);
+ }
+ if (tBlock == Blocks.waterlily || tBlock == Blocks.wheat || tBlock == Blocks.cactus ||
tBlock.getMaterial() == Material.cactus || tBlock == Blocks.melon_block || tBlock == Blocks.melon_stem) {
- tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
- world.setBlockToAir(x, y, z);
- }
- if (tBlock == Blocks.red_flower || tBlock == Blocks.yellow_flower || tBlock == Blocks.carrots ||
+ tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
+ world.setBlockToAir(x, y, z);
+ }
+ if (tBlock == Blocks.red_flower || tBlock == Blocks.yellow_flower || tBlock == Blocks.carrots ||
tBlock == Blocks.potatoes || tBlock == Blocks.pumpkin || tBlock == Blocks.pumpkin_stem) {
- tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
- world.setBlockToAir(x, y, z);
- }
- if (tBlock == Blocks.sapling || tBlock.getMaterial() == Material.plants)
- world.setBlock(x, y, z, Blocks.deadbush);
- if (tBlock == Blocks.cocoa) {
- tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
- world.setBlockToAir(x, y, z);
- }
- if (tBlock == Blocks.mossy_cobblestone)
+ tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
+ world.setBlockToAir(x, y, z);
+ }
+ if (tBlock == Blocks.sapling || tBlock.getMaterial() == Material.plants)
+ world.setBlock(x, y, z, Blocks.deadbush);
+ if (tBlock == Blocks.cocoa) {
+ tBlock.dropBlockAsItem(world, x, y, z, tMeta, 0);
+ world.setBlockToAir(x, y, z);
+ }
+ if (tBlock == Blocks.mossy_cobblestone)
+ world.setBlock(x, y, z, Blocks.cobblestone);
+ if (tBlock == Blocks.grass || tBlock.getMaterial() == Material.grass)
+ world.setBlock(x, y, z, Blocks.dirt);
+ if (tBlock == Blocks.farmland || tBlock == Blocks.dirt) {
+ world.setBlock(x, y, z, Blocks.sand);
+ }
+
+ if (sourRain && world.isRaining() && (tBlock == Blocks.stone || tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) &&
+ world.getBlock(x, y + 1, z) == Blocks.air && world.canBlockSeeTheSky(x, y, z)) {
+ if (tBlock == Blocks.stone) {
world.setBlock(x, y, z, Blocks.cobblestone);
- if (tBlock == Blocks.grass || tBlock.getMaterial() == Material.grass )
- world.setBlock(x, y, z, Blocks.dirt);
- if(tBlock == Blocks.farmland || tBlock == Blocks.dirt){
+ } else if (tBlock == Blocks.cobblestone) {
+ world.setBlock(x, y, z, Blocks.gravel);
+ } else if (tBlock == Blocks.gravel) {
world.setBlock(x, y, z, Blocks.sand);
}
-
- if(sourRain && world.isRaining() && (tBlock == Blocks.stone || tBlock == Blocks.gravel || tBlock == Blocks.cobblestone) &&
- world.getBlock(x, y+1, z) == Blocks.air && world.canBlockSeeTheSky(x, y, z)){
- if(tBlock == Blocks.stone){world.setBlock(x, y, z, Blocks.cobblestone); }
- else if(tBlock == Blocks.cobblestone){world.setBlock(x, y, z, Blocks.gravel); }
- else if(tBlock == Blocks.gravel){world.setBlock(x, y, z, Blocks.sand); }
- }
+ }
}
- public static void addPollution(IGregTechTileEntity te, int aPollution){
- addPollution(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()), aPollution);
+ public static void addPollution(IGregTechTileEntity te, int aPollution) {
+ addPollution(te.getWorld().getChunkFromBlockCoords(te.getXCoord(), te.getZCoord()), aPollution);
}
- public static void addPollution(Chunk ch, int aPollution){
- if(!GT_Mod.gregtechproxy.mPollution)return;
- HashMap<ChunkCoordIntPair,int[]> dataMap=dimensionWiseChunkData.get(ch.worldObj.provider.dimensionId);
- if(dataMap==null){
- dataMap=new HashMap<>(1024);
- dimensionWiseChunkData.put(ch.worldObj.provider.dimensionId,dataMap);
- }
- int[] dataArr=dataMap.get(ch.getChunkCoordIntPair());
- if(dataArr==null){
- dataArr=getDefaultChunkDataOnCreation();
- dataMap.put(ch.getChunkCoordIntPair(),dataArr);
- }
- dataArr[GTPOLLUTION]+=aPollution;
- if(dataArr[GTPOLLUTION]<0)dataArr[GTPOLLUTION]=0;
+ public static void addPollution(Chunk ch, int aPollution) {
+ if (!GT_Mod.gregtechproxy.mPollution || aPollution == 0) return;
+ STORAGE.get(ch).changeAmount(aPollution);
}
- public static int getPollution(IGregTechTileEntity te){
- return getPollution(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()));
+ public static int getPollution(IGregTechTileEntity te) {
+ return getPollution(te.getWorld().getChunkFromBlockCoords(te.getXCoord(), te.getZCoord()));
}
- public static int getPollution(Chunk ch){
- if(!GT_Mod.gregtechproxy.mPollution)
+ public static int getPollution(Chunk ch) {
+ if (!GT_Mod.gregtechproxy.mPollution)
return 0;
- HashMap<ChunkCoordIntPair,int[]> dataMap=dimensionWiseChunkData.get(ch.worldObj.provider.dimensionId);
- if(dataMap==null || dataMap.get(ch.getChunkCoordIntPair())==null) return 0;
- return dataMap.get(ch.getChunkCoordIntPair())[GTPOLLUTION];
+ return STORAGE.get(ch).getAmount();
+ }
+
+ public static boolean hasPollution(Chunk ch) {
+ if (!GT_Mod.gregtechproxy.mPollution)
+ return false;
+ return STORAGE.isCreated(ch.worldObj, ch.getChunkCoordIntPair()) && STORAGE.get(ch).getAmount() > 0;
}
public static int getPollution(ChunkCoordIntPair aCh, int aDim) {
if (!GT_Mod.gregtechproxy.mPollution)
return 0;
- HashMap<ChunkCoordIntPair, int[]> dataMap = dimensionWiseChunkData.get(aDim);
- if (dataMap == null || dataMap.get(aCh) == null)
- return 0;
- return dataMap.get(aCh)[GTPOLLUTION];
+ return STORAGE.get(DimensionManager.getWorld(aDim), aCh.chunkXPos, aCh.chunkZPos).getAmount();
}
//Add compatibility with old code
@Deprecated /*Don't use it... too weird way of passing position*/
- public static void addPollution(World aWorld, ChunkPosition aPos, int aPollution){
+ public static void addPollution(World aWorld, ChunkPosition aPos, int aPollution) {
//The abuse of ChunkPosition to store block position and dim...
//is just bad especially when that is both used to store ChunkPos and BlockPos depending on context
- addPollution(aWorld.getChunkFromBlockCoords(aPos.chunkPosX,aPos.chunkPosZ),aPollution);
+ addPollution(aWorld.getChunkFromBlockCoords(aPos.chunkPosX, aPos.chunkPosZ), aPollution);
+ }
+
+ static void migrate(ChunkDataEvent.Load e) {
+ addPollution(e.getChunk(), e.getData().getInteger("GTPOLLUTION"));
}
- public class GT_PollutionEventHandler {
+ public static class GT_PollutionEventHandler {
@SubscribeEvent
public void chunkWatch(ChunkWatchEvent.Watch event) {
- if(!GT_Mod.gregtechproxy.mPollution) return;
- if (chunkData.containsKey(event.chunk)) {
- int pollution = chunkData.get(event.chunk)[GTPOLLUTION];
+ if (!GT_Mod.gregtechproxy.mPollution) return;
+ World world = event.player.worldObj;
+ if (STORAGE.isCreated(world, event.chunk)) {
+ int pollution = STORAGE.get(world, event.chunk).getAmount();
if (pollution > POLLUTIONPACKET_MINVALUE)
GT_Values.NW.sendToPlayer(new GT_Packet_Pollution(event.chunk, pollution), event.player);
}
}
+
+ @SubscribeEvent
+ public void onWorldLoad(WorldEvent.Load e) {
+ // super class loads everything lazily. We force it to load them all.
+ STORAGE.loadAll(e.world);
+ }
+ }
+
+ @ParametersAreNonnullByDefault
+ private static final class Storage extends GT_ChunkAssociatedData<ChunkData> {
+ private Storage() {
+ super("Pollution", ChunkData.class, 64, (byte) 0, false);
+ }
+
+ @Override
+ protected void writeElement(DataOutput output, ChunkData element, World world, int chunkX, int chunkZ) throws IOException {
+ output.writeInt(element.getAmount());
+ }
+
+ @Override
+ protected ChunkData readElement(DataInput input, int version, World world, int chunkX, int chunkZ) throws IOException {
+ ChunkData data = new ChunkData(input.readInt());
+ getChunkData(world).add(new ChunkCoordIntPair(chunkX, chunkZ));
+ return data;
+ }
+
+ private List<ChunkCoordIntPair> getChunkData(World world) {
+ return dimensionWisePollution.computeIfAbsent(world.provider.dimensionId, i -> new GT_Pollution(world)).chunkData;
+ }
+
+ @Override
+ protected ChunkData createElement(World world, int chunkX, int chunkZ) {
+ return new ChunkData();
+ }
+
+ @Override
+ public void loadAll(World w) {
+ super.loadAll(w);
+ }
+
+ public void set(World world, ChunkCoordIntPair coord, ChunkData data) {
+ set(world, coord.chunkXPos, coord.chunkZPos, data);
+ getChunkData(world).add(coord);
+ }
+
+ public boolean isCreated(World world, ChunkCoordIntPair coord) {
+ return isCreated(world.provider.dimensionId, coord.chunkXPos, coord.chunkZPos);
+ }
+ }
+
+ private static final class ChunkData implements GT_ChunkAssociatedData.IData {
+ public int amount;
+
+ private ChunkData() {
+ this(0);
+ }
+
+ private ChunkData(int amount) {
+ this.amount = amount;
+ }
+
+ /**
+ * Current pollution amount.
+ */
+ public int getAmount() {
+ return amount;
+ }
+
+ public void setAmount(int amount) {
+ this.amount = Math.max(amount, 0);
+ }
+
+ public void changeAmount(int delta) {
+ this.amount = Math.max(amount + delta, 0);
+ }
+
+ @Override
+ public boolean isSameAsDefault() {
+ return amount == 0;
+ }
}
}
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java
index ed99c1e3c0..40716a2fa6 100644
--- a/src/main/java/gregtech/common/GT_Proxy.java
+++ b/src/main/java/gregtech/common/GT_Proxy.java
@@ -632,6 +632,12 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_leggings, 1, W));
GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_boots, 1, W));
+ //Infinity Hazmat
+ addFullHazmatToGeneralItem("Avaritia", "Infinity_Helm", 1L);
+ addFullHazmatToGeneralItem("Avaritia", "Infinity_Chest", 1L);
+ addFullHazmatToGeneralItem("Avaritia", "Infinity_Pants", 1L);
+ addFullHazmatToGeneralItem("Avaritia", "Infinity_Shoes", 1L);
+
GregTech_API.sLoadStarted = true;
for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if ((tData.filledContainer.getItem() == Items.potionitem) && (tData.filledContainer.getItemDamage() == 0)) {
@@ -709,8 +715,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
}
public void onServerAboutToStart(){
- dimensionWiseChunkData.clear();//!!! IMPORTANT for map switching...
dimensionWisePollution.clear();//!!! IMPORTANT for map switching...
+ GT_ChunkAssociatedData.clearAll();
}
public void onServerStarting() {
@@ -776,6 +782,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
} catch (Throwable e) {e.printStackTrace(GT_Log.err);}
}
this.mUniverse = null;
+ //GT_ChunkAssociatedData.saveAll(); todo: figure out if this is needed
}
@SubscribeEvent
@@ -1981,87 +1988,25 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
}
+ @Deprecated
public static final HashMap<Integer,HashMap<ChunkCoordIntPair,int []>> dimensionWiseChunkData = new HashMap<>(16);//stores chunk data that is loaded/saved
public static final HashMap<Integer,GT_Pollution> dimensionWisePollution = new HashMap<>(16);//stores GT_Polluttors objects
public static final byte GTOIL=3,GTOILFLUID=2,GTPOLLUTION=1,GTMETADATA=0,NOT_LOADED=0,LOADED=1;//consts
- //@Deprecated
- //public static final HashMap<ChunkPosition, int[]> chunkData = new HashMap<>(0);
-
- private static final byte oilVer=(byte)20;//non zero plz
//TO get default's fast
+ @Deprecated
public static int[] getDefaultChunkDataOnCreation(){
return new int[]{NOT_LOADED,0,-1,-1};
}
+ @Deprecated
public static int[] getDefaultChunkDataOnLoad(){
return new int[]{LOADED,0,-1,-1};
}
@SubscribeEvent
- public void handleChunkSaveEvent(ChunkDataEvent.Save event) {//ALWAYS SAVE FROM THE HASH MAP DATA
- HashMap<ChunkCoordIntPair,int []> chunkData=dimensionWiseChunkData.get(event.world.provider.dimensionId);
- if(chunkData==null) return;//no dim info stored
-
- int[] tInts = chunkData.get(event.getChunk().getChunkCoordIntPair());
- if(tInts==null) return;//no chunk data stored
- //assuming len of this array 4
- if(tInts[3]>=0)event.getData().setInteger("GTOIL", tInts[GTOIL]);
- else event.getData().removeTag("GTOIL");
- if(tInts[2]>=0)event.getData().setInteger("GTOILFLUID", tInts[GTOILFLUID]);
- else event.getData().removeTag("GTOILFLUID");
- if(tInts[1]>0)event.getData().setInteger("GTPOLLUTION", tInts[GTPOLLUTION]);
- else event.getData().removeTag("GTPOLLUTION");
- event.getData().setByte("GTOILVER", oilVer);//version mark
- }
-
- @SubscribeEvent
public void handleChunkLoadEvent(ChunkDataEvent.Load event) {
- final int worldID=event.world.provider.dimensionId;
- HashMap<ChunkCoordIntPair, int[]> chunkData = dimensionWiseChunkData.computeIfAbsent(worldID, k -> new HashMap<>(1024));
- if (dimensionWisePollution.get(worldID) == null)
- dimensionWisePollution.put(worldID, new GT_Pollution(event.world));
-
- int[] tInts = chunkData.get(event.getChunk().getChunkCoordIntPair());
- if (tInts == null) {
- //NOT LOADED and NOT PROCESSED by pollution algorithms
- //regular load
- tInts = getDefaultChunkDataOnLoad();
-
- if (event.getData().getByte("GTOILVER") == oilVer) {
- if (event.getData().hasKey("GTOIL"))
- tInts[GTOIL] = event.getData().getInteger("GTOIL");
- if (event.getData().hasKey("GTOILFLUID"))
- tInts[GTOILFLUID] = event.getData().getInteger("GTOILFLUID");
- }
-
- tInts[GTPOLLUTION] = event.getData().getInteger("GTPOLLUTION");//Defaults to 0
-
- //store in HASH MAP if has useful data
- if (tInts[GTPOLLUTION] > 0 || tInts[GTOIL] >= 0 || tInts[GTOILFLUID] >= 0)
- chunkData.put(event.getChunk().getChunkCoordIntPair(), tInts);
- } else if (tInts[GTMETADATA] == NOT_LOADED) {//was NOT loaded from chunk save game data
- //NOT LOADED but generated
- //append load
- if (event.getData().getByte("GTOILVER") == oilVer) {
- if (tInts[GTOIL] < 0 && event.getData().hasKey("GTOIL"))//if was not yet initialized
- tInts[GTOIL] = event.getData().getInteger("GTOIL");
-
- if (tInts[GTOILFLUID] < 0 && event.getData().hasKey("GTOILFLUID"))//if was not yet initialized
- tInts[GTOILFLUID] = event.getData().getInteger("GTOILFLUID");
- } else {
- tInts[GTOIL] = -1;
- tInts[GTOILFLUID] = -1;
- }
-
- tInts[GTPOLLUTION] += event.getData().getInteger("GTPOLLUTION");//Defaults to 0, add stored pollution to data
- tInts[GTMETADATA] = LOADED;//mark as = loaded
- //store in HASHMAP
-
- chunkData.put(event.getChunk().getChunkCoordIntPair(), tInts);
- }//else if(tInts[0]==1){
- ////Already loaded chunk data
- ////DO NOTHING - this chunk data was already loaded and stored in hash map
- //}
+ GT_UndergroundOil.migrate(event);
+ GT_Pollution.migrate(event);
}
@SubscribeEvent
diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java
index 23f539952f..1571ef7b46 100644
--- a/src/main/java/gregtech/common/GT_RecipeAdder.java
+++ b/src/main/java/gregtech/common/GT_RecipeAdder.java
@@ -1149,6 +1149,21 @@ public class GT_RecipeAdder implements IGT_RecipeAdder {
}
@Override
+ public boolean addMixerRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aInput3, ItemStack aInput4, ItemStack aInput5, ItemStack aInput6, ItemStack aInput7, ItemStack aInput8, ItemStack aInput9, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt) {
+ if (((aInput1 == null) && (aFluidInput == null)) || ((aOutput1 == null) && (aFluidOutput == null))) {
+ return false;
+ }
+ if ((aOutput1 != null) && ((aDuration = GregTech_API.sRecipeFile.get("mixer", aOutput1, aDuration)) <= 0)) {
+ return false;
+ }
+ if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("mixer", aFluidOutput.getFluid().getName(), aDuration)) <= 0)) {
+ return false;
+ }
+ GT_Recipe.GT_Recipe_Map.sMixerRecipes.addRecipe(true, new ItemStack[]{aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0);
+ return true;
+ }
+
+ @Override
public boolean addLaserEngraverRecipe(ItemStack aItemToEngrave, ItemStack aLens, ItemStack aEngravedItem, int aDuration, int aEUt) {
return addLaserEngraverRecipe( aItemToEngrave, aLens, aEngravedItem, aDuration, aEUt, false);
}
diff --git a/src/main/java/gregtech/common/GT_UndergroundOil.java b/src/main/java/gregtech/common/GT_UndergroundOil.java
index 1f45b5fca9..21b681de4a 100644
--- a/src/main/java/gregtech/common/GT_UndergroundOil.java
+++ b/src/main/java/gregtech/common/GT_UndergroundOil.java
@@ -5,22 +5,31 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_UO_Dimension;
import gregtech.api.objects.GT_UO_Fluid;
import gregtech.api.objects.XSTR;
-import net.minecraft.world.ChunkCoordIntPair;
+import gregtech.api.util.GT_ChunkAssociatedData;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
-import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.event.world.ChunkDataEvent;
+import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
+import org.apache.commons.lang3.tuple.Pair;
-import java.util.HashMap;
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.WeakHashMap;
import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
-import static gregtech.common.GT_Proxy.*;
/**
* Created by Tec on 29.04.2017.
*/
public class GT_UndergroundOil {
public static final short DIVIDER=5000;
+ private static final GT_UndergroundOilStore STORAGE = new GT_UndergroundOilStore();
+ private static final ChunkData NIL_FLUID_STACK = new ChunkData(-1, null, null, false);
public static FluidStack undergroundOilReadInformation(IGregTechTileEntity te){
return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),-1);
@@ -37,81 +46,233 @@ public class GT_UndergroundOil {
//Returns whole content for information purposes -> when drainSpeedCoefficient < 0
//Else returns extracted fluidStack if amount > 0, or null otherwise
public static FluidStack undergroundOil(Chunk chunk, float readOrDrainCoefficient) {
- World aWorld = chunk.worldObj;
- int dimensionId=aWorld.provider.dimensionId;
- GT_UO_Dimension dimension=GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(dimensionId);
- if(dimension==null) return null;
-
- //Read hash map
- HashMap<ChunkCoordIntPair, int[]> chunkData = dimensionWiseChunkData.get(dimensionId);
- if(chunkData==null){
- chunkData=new HashMap<>(1024);
- dimensionWiseChunkData.put(dimensionId,chunkData);
- }
-
- int[] tInts = chunkData.get(chunk.getChunkCoordIntPair());
-
- if(tInts==null) tInts=getDefaultChunkDataOnCreation();//init if null
- else if(tInts[GTOIL]==0){//FAST stop
- //can return 0 amount stack for info :D
- return readOrDrainCoefficient>=0 ? null : new FluidStack(FluidRegistry.getFluid(tInts[GTOILFLUID]),0);
- }
-
- //GEN IT TO GET OBJECT...
- final XSTR tRandom = new XSTR(aWorld.getSeed() + dimensionId * 2 +
- (chunk.getChunkCoordIntPair().chunkXPos>>3) +
- 8267 * (chunk.getChunkCoordIntPair().chunkZPos>>3));
-
- GT_UO_Fluid uoFluid = dimension.getRandomFluid(tRandom);
-
- //Fluid stack holder
- FluidStack fluidInChunk;
-
- //Set fluid stack from uoFluid
- if (uoFluid == null || uoFluid.getFluid()==null){
- tInts[GTOILFLUID]=Integer.MAX_VALUE;//null fluid pointer... kind of
- tInts[GTOIL]=0;
- chunkData.put(chunk.getChunkCoordIntPair(),tInts);//update hash map
+ ChunkData chunkData = STORAGE.get(chunk);
+ if (chunkData.getVein() == null || chunkData.getFluid() == null) // nothing here...
return null;
- } else {
- if(tInts[GTOILFLUID]== uoFluid.getFluid().getID()){//if stored fluid matches uoFluid
- fluidInChunk = new FluidStack(uoFluid.getFluid(),tInts[GTOIL]);
- }else{
- fluidInChunk = new FluidStack(uoFluid.getFluid(), uoFluid.getRandomAmount(tRandom));
- fluidInChunk.amount=(int)((float)fluidInChunk.amount*(0.75f+(XSTR_INSTANCE.nextFloat()/2f)));//Randomly change amounts by +/- 25%
- }
- tInts[GTOIL]=fluidInChunk.amount;
- tInts[GTOILFLUID]=fluidInChunk.getFluidID();
- }
-
//do stuff on it if needed
+ FluidStack fluidInChunk = new FluidStack(chunkData.getFluid(), 0);
if(readOrDrainCoefficient>=0){
- int fluidExtracted=(int)Math.floor(fluidInChunk.amount * (double) readOrDrainCoefficient / DIVIDER);
- double averageDecrease=uoFluid.DecreasePerOperationAmount * (double)readOrDrainCoefficient;
+ int fluidExtracted = (int) Math.floor(chunkData.getAmount() * (double) readOrDrainCoefficient / DIVIDER);
+ double averageDecrease = chunkData.getVein().DecreasePerOperationAmount * (double) readOrDrainCoefficient;
int decrease=(int)Math.ceil(averageDecrease);
- if(fluidExtracted<=0 || fluidInChunk.amount<=decrease){//decrease - here it is max value of extraction for easy check
- fluidInChunk=null;
- tInts[GTOIL]=0;//so in next access it will stop way above
+ if (fluidExtracted <= 0 || chunkData.amount <= decrease) {//decrease - here it is max value of extraction for easy check
+ chunkData.setAmount(0);
}else{
fluidInChunk.amount = fluidExtracted;//give appropriate amount
- if(XSTR_INSTANCE.nextFloat()<(decrease-averageDecrease)) decrease--;//use XSTR_INSTANCE to "subtract double from int"
+ if (XSTR_INSTANCE.nextFloat() < (decrease - averageDecrease))
+ decrease--;//use XSTR_INSTANCE to "subtract double from int"
//ex.
// averageDecrease=3.9
// decrease= ceil from 3.9 = 4
// decrease-averageDecrease=0.1 -> chance to subtract 1
// if XSTR_INSTANCE is < chance then subtract 1
- tInts[GTOIL]-=decrease;//diminish amount, "randomly" adjusted to double value (averageDecrease)
+ chunkData.changeAmount(-decrease);//diminish amount, "randomly" adjusted to double value (averageDecrease)
}
- }else{//just get info
- if(fluidInChunk.amount<=DIVIDER){
- fluidInChunk.amount=0;//return informative stack
- tInts[GTOIL]=0;//so in next access it will stop way above
- }else{
- fluidInChunk.amount=fluidInChunk.amount/DIVIDER;//give moderate extraction speed
+ } else {//just get info
+ if (chunkData.amount <= DIVIDER) {
+ chunkData.setAmount(0);
+ } else {
+ fluidInChunk.amount = chunkData.amount / DIVIDER;//give moderate extraction speed
}
}
-
- chunkData.put(chunk.getChunkCoordIntPair(),tInts);//update hash map
return fluidInChunk;
}
+
+ /**
+ * Get the deposit as if it is never exploited
+ * @return UO fluid kind and amount, or null if nothing here.
+ */
+ public static Pair<GT_UO_Fluid, Integer> getPristineAmount(World world, int chunkX, int chunkZ) {
+ int dimensionId = world.provider.dimensionId;
+ GT_UO_Dimension dimension = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(dimensionId);
+ if (dimension == null) return null;
+ // prepare RNG 🙏 🙏 🙏
+ final XSTR tVeinRNG = new XSTR(world.getSeed() + dimensionId * 2L + (chunkX >> 3) + 8267L * (chunkZ >> 3));
+ final XSTR tChunkRNG = new XSTR(world.getSeed() + dimensionId * 2L + chunkX + 8267L * chunkZ);
+ GT_UO_Fluid uoFluid = dimension.getRandomFluid(tVeinRNG);
+ // nothing here :(
+ if (uoFluid == null || uoFluid.getFluid() == null) return null;
+ // offset each chunk's fluid amount by +-25%
+ int amount = (int) ((float) uoFluid.getRandomAmount(tVeinRNG) * (0.75f + (tChunkRNG.nextFloat() / 2f)));
+ return Pair.of(uoFluid, amount);
+ }
+
+ static void migrate(ChunkDataEvent.Load e) {
+ if (e.getData().hasKey("GTOIL") && e.getData().hasKey("GTOILFLUID")) {
+ ChunkData chunkData = STORAGE.get(e.getChunk());
+ Fluid fluid = chunkData.getFluid();
+ if (fluid != null && fluid.getID() == e.getData().getInteger("GTOILFLUID"))
+ chunkData.setAmount(Math.min(0, Math.min(chunkData.getAmount(), e.getData().getInteger("GTOIL"))));
+ }
+ }
+
+ /**
+ * Revamped UO store.
+ * <p>
+ * Primary functionality:
+ *
+ * <ul>
+ * <li>Decouple data storage with chunk, making it possible to pump oil from unloaded chunks</li>
+ * <li>Regen detection. If fluid generation config is changed, chunk fluid will be regenerated.</li>
+ * </ul>
+ *
+ * <h2>Serialized form</h2>
+ * <p>
+ * Since the exact file layout is controlled by the super class, here we only concern how each chunk's data is written.
+ * <h3>Form A: Empty Chunk</h3>
+ * <ol>
+ * <li>4 bytes of 0 </li>
+ * </ol>
+ *
+ * <h3>Form B: Normal Chunk</h3>
+ * <ol>
+ * <li>4 bytes unsigned integer. Vein Hash.</li>
+ * <li>UTF string. Vein Key.</li>
+ * <li>4 bytes signed integer. Fluid amount.</li>
+ * </ol>
+ *
+ * @author glease
+ */
+ @ParametersAreNonnullByDefault
+ private static class GT_UndergroundOilStore extends GT_ChunkAssociatedData<ChunkData> {
+ private static final WeakHashMap<GT_UO_Fluid, Integer> hashes = new WeakHashMap<>();
+
+ private GT_UndergroundOilStore() {
+ super("UO", GT_UndergroundOil.ChunkData.class, 64, (byte) 0, false);
+ }
+
+ @Override
+ protected void writeElement(DataOutput output, ChunkData element, World world, int chunkX, int chunkZ) throws IOException {
+ /* see class javadoc for explanation */
+ output.writeInt(element.getVeinHash());
+ if (element.getVeinKey() == null) return;
+ output.writeUTF(element.getVeinKey());
+ if (element.getAmount() > 0 && element.getFluid() != null) {
+ output.writeInt(element.getAmount());
+ } else {
+ output.writeInt(-1);
+ }
+ }
+
+ @Override
+ protected GT_UndergroundOil.ChunkData readElement(DataInput input, int version, World world, int chunkX, int chunkZ) throws IOException {
+ /* see class javadoc for explanation */
+ if (version != 0)
+ throw new IOException("Region file corrupted");
+ GT_UndergroundOil.ChunkData pristine = createElement(world, chunkX, chunkZ);
+ int hash = input.readInt();
+ String veinKey = hash != 0 ? input.readUTF() : null;
+ int amount = hash != 0 ? input.readInt() : -1;
+ if (hash != pristine.veinHash || !Objects.equals(veinKey, pristine.getVeinKey())) {
+ // vein config changed. use regen-ed data.
+ return pristine;
+ }
+ if (hash == 0)
+ return NIL_FLUID_STACK;
+ return new GT_UndergroundOil.ChunkData(amount, GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(world.provider.dimensionId).getUOFluid(veinKey), veinKey);
+ }
+
+ @Override
+ protected GT_UndergroundOil.ChunkData createElement(World world, int chunkX, int chunkZ) {
+ Pair<GT_UO_Fluid, Integer> pristine = getPristineAmount(world, chunkX, chunkZ);
+ if (pristine == null)
+ return NIL_FLUID_STACK;
+ int dimensionId = world.provider.dimensionId;
+ GT_UO_Dimension dimension = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(dimensionId);
+ return new GT_UndergroundOil.ChunkData(pristine.getRight(), pristine.getLeft(), dimension.getUOFluidKey(pristine.getLeft()), false);
+ }
+
+ private static int hash(@Nullable GT_UO_Fluid fluid) {
+ if (fluid == null)
+ return 0;
+ int result = fluid.Registry.hashCode();
+ result = 31 * result + fluid.MaxAmount;
+ result = 31 * result + fluid.MinAmount;
+ result = 31 * result + fluid.Chance;
+ result = 31 * result + fluid.DecreasePerOperationAmount;
+ return result == 0 ? 1 : result;
+ }
+
+ }
+
+ /**
+ * Represent the amount of fluid in a given chunk.
+ */
+ private static final class ChunkData implements GT_ChunkAssociatedData.IData {
+ private final Fluid fluid;
+ @Nullable
+ private final GT_UO_Fluid vein;
+ private final String veinKey;
+ private final int veinHash;
+ private int amount;
+ private boolean dirty;
+
+ private ChunkData(int amount, GT_UO_Fluid veinKey, String veinID) {
+ this(amount, veinKey, veinID, true);
+ }
+
+ private ChunkData(int amount, @Nullable GT_UO_Fluid vein, @Nullable String veinKey, boolean dirty) {
+ this.amount = amount;
+ this.vein = vein;
+ this.dirty = dirty;
+ if (vein == null) {
+ fluid = null;
+ this.veinKey = null;
+ veinHash = 0;
+ } else {
+ fluid = vein.getFluid();
+ this.veinKey = veinKey;
+ veinHash = GT_UndergroundOilStore.hashes.computeIfAbsent(vein, GT_UndergroundOilStore::hash);
+ }
+ }
+
+ /**
+ * The current fluid type. {@code null} if vein is generated to be empty.
+ */
+ @Nullable
+ public Fluid getFluid() {
+ return fluid;
+ }
+
+ /**
+ * Current fluid amount. Might be 0 if empty. Cannot be negative
+ */
+ public int getAmount() {
+ return amount;
+ }
+
+ public void setAmount(int amount) {
+ if (this.amount != amount)
+ dirty = true;
+ this.amount = Math.max(0, amount);
+ }
+
+ public void changeAmount(int delta) {
+ if (delta != 0)
+ dirty = true;
+ this.amount = Math.max(0, amount - delta);
+ }
+
+ @Nullable
+ public GT_UO_Fluid getVein() {
+ return vein;
+ }
+
+ /**
+ * The vein ID. Might be null if generated to be empty.
+ */
+ @Nullable
+ public String getVeinKey() {
+ return veinKey;
+ }
+
+ public int getVeinHash() {
+ return veinHash;
+ }
+
+ @Override
+ public boolean isSameAsDefault() {
+ return dirty;
+ }
+ }
}
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java
index 0d673a020e..2c9254bf28 100644
--- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java
+++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java
@@ -16,6 +16,8 @@ import gregtech.api.util.GT_BaseCrop;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
import gregtech.common.render.GT_Renderer_Block;
+import gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest;
+import gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperChest;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -396,23 +398,25 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
if (tTileEntity instanceof IGregTechTileEntity) {
IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity;
mTemporaryTileEntity.set(tGregTechTileEntity);
- for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) {
- ItemStack tItem = tGregTechTileEntity.getStackInSlot(i);
- if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) {
- EntityItem tItemEntity = new EntityItem(aWorld,
- aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
- aY + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
- aZ + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
- new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage()));
- if (tItem.hasTagCompound()) {
- tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy());
+ if (!(tGregTechTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_SuperChest || tGregTechTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest)) {
+ for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) {
+ ItemStack tItem = tGregTechTileEntity.getStackInSlot(i);
+ if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) {
+ EntityItem tItemEntity = new EntityItem(aWorld,
+ aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
+ aY + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
+ aZ + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
+ new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage()));
+ if (tItem.hasTagCompound()) {
+ tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy());
+ }
+ tItemEntity.motionX = (XSTR_INSTANCE.nextGaussian() * 0.05D);
+ tItemEntity.motionY = (XSTR_INSTANCE.nextGaussian() * 0.25D);
+ tItemEntity.motionZ = (XSTR_INSTANCE.nextGaussian() * 0.05D);
+ aWorld.spawnEntityInWorld(tItemEntity);
+ tItem.stackSize = 0;
+ tGregTechTileEntity.setInventorySlotContents(i, null);
}
- tItemEntity.motionX = (XSTR_INSTANCE.nextGaussian() * 0.05D);
- tItemEntity.motionY = (XSTR_INSTANCE.nextGaussian() * 0.25D);
- tItemEntity.motionZ = (XSTR_INSTANCE.nextGaussian() * 0.05D);
- aWorld.spawnEntityInWorld(tItemEntity);
- tItem.stackSize = 0;
- tGregTechTileEntity.setInventorySlotContents(i, null);
}
}
}
diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
index 74e3e3653d..55743f445d 100644
--- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
+++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
@@ -15,11 +15,19 @@ import gregtech.api.util.GT_ItsNotMyFaultException;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest;
+import gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumTank;
+import gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperChest;
+import gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperTank;
import net.minecraft.block.Block;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
@@ -211,4 +219,25 @@ public class GT_Item_Machines extends ItemBlock {
}
return true;
}
+
+ @Override
+ public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) {
+ super.onUpdate(aStack, aWorld, aPlayer, aTimer, aIsInHand);
+ short tDamage = (short) getDamage(aStack);
+ EntityLivingBase tPlayer = (EntityPlayer) aPlayer;
+ if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_SuperChest ||
+ GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_QuantumChest ||
+ GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_SuperTank ||
+ GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_QuantumTank) {
+ NBTTagCompound tNBT = aStack.stackTagCompound;
+ if (tNBT == null) return;
+ if ((tNBT.hasKey("mItemCount") && tNBT.getInteger("mItemCount") > 0) ||
+ tNBT.hasKey("mFluid")) {
+ tPlayer.addPotionEffect(new PotionEffect(Potion.hunger.id, 12000, 4));
+ tPlayer.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 12000, 4));
+ tPlayer.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 12000, 4));
+ tPlayer.addPotionEffect(new PotionEffect(Potion.weakness.id, 12000, 4));
+ }
+ }
+ }
}
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java
index ed60929719..c64aaa16a1 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java
@@ -11,6 +11,7 @@ import gregtech.api.interfaces.tileentity.IMachineProgress;
import gregtech.api.net.GT_Packet_TileEntityCover;
import gregtech.api.util.GT_CoverBehavior;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@@ -111,6 +112,16 @@ public class GT_Cover_Arm extends GT_CoverBehavior {
}
@Override
+ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ int step = (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) ? 1 : -1;
+ int tCoverVariable = getNewVar(aCoverVariable.get(), step);
+ sendMessageToPlayer(aPlayer, tCoverVariable);
+ aCoverVariable.set(tCoverVariable);
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings("deprecation")
public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
int step = (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) ? 1 : -1;
aCoverVariable = getNewVar(aCoverVariable, step);
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java
index a53545802a..83a8f20ea9 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java
@@ -9,6 +9,7 @@ import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.net.GT_Packet_TileEntityCover;
import gregtech.api.util.GT_CoverBehavior;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.util.ForgeDirection;
@@ -136,6 +137,18 @@ public class GT_Cover_FluidRegulator extends GT_CoverBehavior {
}
@Override
+ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) {
+ aCoverVariable.set(adjustSpeed(aPlayer, aCoverVariable.get(), 1));
+ } else {
+ aCoverVariable.set(adjustSpeed(aPlayer, aCoverVariable.get(), -1));
+ }
+ aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings("deprecation")
public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
EntityPlayer aPlayer, float aX, float aY, float aZ) {
if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) {
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java
index 7aab35ddaa..99836c1d99 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java
@@ -1,22 +1,33 @@
package gregtech.common.covers;
+import com.google.common.io.ByteArrayDataInput;
import gregtech.api.enums.GT_Values;
import gregtech.api.gui.GT_GUICover;
import gregtech.api.gui.widgets.GT_GuiFakeItemButton;
import gregtech.api.gui.widgets.GT_GuiIcon;
import gregtech.api.gui.widgets.GT_GuiIconButton;
import gregtech.api.interfaces.tileentity.ICoverable;
-import gregtech.api.net.GT_Packet_TileEntityCover;
-import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.net.GT_Packet_TileEntityCoverNew;
+import gregtech.api.util.GT_CoverBehaviorBase;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
+import io.netty.buffer.ByteBuf;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.*;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+import javax.annotation.Nonnull;
import static gregtech.api.enums.GT_Values.E;
-public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
+public class GT_Cover_Fluidfilter extends GT_CoverBehaviorBase<GT_Cover_Fluidfilter.FluidFilterData> {
// Uses the lower 3 bits of the cover variable, so we have 8 options to work with (0-7)
private final int FILTER_INPUT_DENY_OUTPUT = 0; // 000
@@ -28,99 +39,115 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
private final int ANY_INPUT_FILTER_OUTPUT = 6; // 110
private final int ANY_INPUT_INVERT_OUTPUT = 7; // 111
+ public GT_Cover_Fluidfilter() {
+ super(FluidFilterData.class);
+ }
+
+ @Override
+ public FluidFilterData createDataObject() {
+ return new FluidFilterData(-1, 0);
+ }
+
+ @Override
+ public FluidFilterData createDataObject(int aLegacyData) {
+ return new FluidFilterData(aLegacyData >>> 3, aLegacyData & 0x7);
+ }
+
@Override
- public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- int aFilterMode = aCoverVariable & 7;
- int aFilterFluid = aCoverVariable >>> 3;
- final Fluid fluid = FluidRegistry.getFluid(aFilterFluid);
- if(fluid == null) return E;
-
+ protected String getDescriptionImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) {
+ final Fluid fluid = FluidRegistry.getFluid(aCoverVariable.mFluidID);
+ if (fluid == null) return E;
+
final FluidStack sFluid = new FluidStack(fluid, 1000);
- return(String.format("Filtering Fluid: %s Mode: %s", sFluid.getLocalizedName(), getFilterMode(aFilterMode)));
+ return (String.format("Filtering Fluid: %s Mode: %s", sFluid.getLocalizedName(), getFilterMode(aCoverVariable.mFilterMode)));
}
@Override
- public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity, long aTimer) {
return false;
}
@Override
- public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ protected FluidFilterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity, long aTimer) {
return aCoverVariable;
}
public String getFilterMode(int aFilterMode) {
- switch(aFilterMode) {
- case FILTER_INPUT_DENY_OUTPUT: return(trans("043", "Filter input, Deny output"));
- case INVERT_INPUT_DENY_OUTPUT: return(trans("044", "Invert input, Deny output"));
- case FILTER_INPUT_ANY_OUTPUT: return(trans("045", "Filter input, Permit any output"));
- case INVERT_INPUT_ANY_OUTPUT: return(trans("046", "Invert input, Permit any output"));
- case DENY_INPUT_FILTER_OUTPUT: return(trans("219", "Deny input, Filter output"));
- case DENY_INPUT_INVERT_OUTPUT: return(trans("220", "Deny input, Invert output"));
- case ANY_INPUT_FILTER_OUTPUT: return(trans("221", "Permit any input, Filter output"));
- case ANY_INPUT_INVERT_OUTPUT: return(trans("222", "Permit any input, Invert output"));
- default: return("UNKNOWN");
+ switch (aFilterMode) {
+ case FILTER_INPUT_DENY_OUTPUT:
+ return (trans("043", "Filter input, Deny output"));
+ case INVERT_INPUT_DENY_OUTPUT:
+ return (trans("044", "Invert input, Deny output"));
+ case FILTER_INPUT_ANY_OUTPUT:
+ return (trans("045", "Filter input, Permit any output"));
+ case INVERT_INPUT_ANY_OUTPUT:
+ return (trans("046", "Invert input, Permit any output"));
+ case DENY_INPUT_FILTER_OUTPUT:
+ return (trans("219", "Deny input, Filter output"));
+ case DENY_INPUT_INVERT_OUTPUT:
+ return (trans("220", "Deny input, Invert output"));
+ case ANY_INPUT_FILTER_OUTPUT:
+ return (trans("221", "Permit any input, Filter output"));
+ case ANY_INPUT_INVERT_OUTPUT:
+ return (trans("222", "Permit any input, Invert output"));
+ default:
+ return ("UNKNOWN");
}
}
@Override
- public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- int aFilterMode = aCoverVariable & 7;
- aCoverVariable ^= aFilterMode;
- aFilterMode = (aFilterMode + (aPlayer.isSneaking()? -1 : 1)) % 8;
- if (aFilterMode < 0) {
- aFilterMode = 7;
+ protected FluidFilterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ aCoverVariable.mFilterMode = (aCoverVariable.mFilterMode + (aPlayer.isSneaking() ? -1 : 1)) % 8;
+ if (aCoverVariable.mFilterMode < 0) {
+ aCoverVariable.mFilterMode = 7;
}
- GT_Utility.sendChatToPlayer(aPlayer, getFilterMode(aFilterMode));
-
- aCoverVariable|=aFilterMode;
+ GT_Utility.sendChatToPlayer(aPlayer, getFilterMode(aCoverVariable.mFilterMode));
return aCoverVariable;
}
@Override
- public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- //GT_FML_LOGGER.info("rightclick");
+ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
if (
((aX > 0.375D) && (aX < 0.625D)) ||
- ((aSide > 3) && ((aY > 0.375D) && (aY < 0.625D))) ||
- ((aSide < 2) && ((aZ > 0.375D) && (aZ < 0.625D))) ||
- (aSide == 2) ||
- (aSide == 3)
+ ((aSide > 3) && ((aY > 0.375D) && (aY < 0.625D))) ||
+ ((aSide < 2) && ((aZ > 0.375D) && (aZ < 0.625D))) ||
+ (aSide == 2) ||
+ (aSide == 3)
) {
ItemStack tStack = aPlayer.inventory.getCurrentItem();
if (tStack == null) return true;
- FluidStack tFluid = FluidContainerRegistry.getFluidForFilledItem(tStack);
+ FluidStack tFluid = GT_Utility.getFluidForFilledItem(tStack, true);
if (tFluid != null) {
int aFluid = tFluid.getFluidID();
- aCoverVariable = (aCoverVariable & 7) | (aFluid << 3);
+ aCoverVariable.mFluidID = aFluid;
aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
FluidStack sFluid = new FluidStack(FluidRegistry.getFluid(aFluid), 1000);
GT_Utility.sendChatToPlayer(aPlayer, trans("047", "Filter Fluid: ") + sFluid.getLocalizedName());
- } else if (tStack.getItem() instanceof IFluidContainerItem) {
- IFluidContainerItem tContainer = (IFluidContainerItem) tStack.getItem();
- if (tContainer.getFluid(tStack) != null) {
- int aFluid = tContainer.getFluid(tStack).getFluidID();
- aCoverVariable = (aCoverVariable & 7) | (aFluid << 3);
- aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
- FluidStack sFluid = new FluidStack(FluidRegistry.getFluid(aFluid), 1000);
- GT_Utility.sendChatToPlayer(aPlayer, trans("047", "Filter Fluid: ") + sFluid.getLocalizedName());
- }
}
return true;
}
return false;
}
-
+
+ @Override
+ protected boolean letsFluidInImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return isFluidAllowed(aCoverVariable, aFluid);
+ }
+
@Override
- public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ protected boolean letsFluidOutImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return isFluidAllowed(aCoverVariable, aFluid);
+ }
+
+ protected boolean isFluidAllowed(FluidFilterData aCoverVariable, Fluid aFluid) {
if (aFluid == null) return true;
- int aFilterMode = aCoverVariable & 7;
- int aFilterFluid = aCoverVariable >>> 3;
+ int aFilterMode = aCoverVariable.mFilterMode;
+ int aFilterFluid = aCoverVariable.mFluidID;
if (aFilterMode == DENY_INPUT_FILTER_OUTPUT || aFilterMode == DENY_INPUT_INVERT_OUTPUT)
return false;
@@ -130,36 +157,18 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
return aFilterMode == FILTER_INPUT_DENY_OUTPUT || aFilterMode == FILTER_INPUT_ANY_OUTPUT;
else
return aFilterMode == INVERT_INPUT_DENY_OUTPUT || aFilterMode == INVERT_INPUT_ANY_OUTPUT;
-
}
-
- @Override
- public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
- if (aFluid == null) return true;
- int aFilterMode = aCoverVariable & 7;
- int aFilterFluid = aCoverVariable >>> 3;
-
- if (aFilterMode == FILTER_INPUT_DENY_OUTPUT || aFilterMode == INVERT_INPUT_DENY_OUTPUT)
- return false;
- else if (aFilterMode == FILTER_INPUT_ANY_OUTPUT || aFilterMode == INVERT_INPUT_ANY_OUTPUT)
- return true;
- else if (aFluid.getID() == aFilterFluid)
- return aFilterMode == DENY_INPUT_FILTER_OUTPUT || aFilterMode == ANY_INPUT_FILTER_OUTPUT;
- else
- return aFilterMode == DENY_INPUT_INVERT_OUTPUT || aFilterMode == ANY_INPUT_INVERT_OUTPUT;
-
- }
-
@Override
- public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) {
return true;
}
@Override
- public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ protected int getTickRateImpl(byte aSide, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) {
return 0;
}
+
/**
* GUI Stuff
*/
@@ -170,14 +179,14 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
}
@Override
- public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) {
+ protected Object getClientGUIImpl(byte aSide, int aCoverID, FluidFilterData coverData, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) {
return new GT_FluidFilterGUICover(aSide, aCoverID, coverData, aTileEntity);
}
private class GT_FluidFilterGUICover extends GT_GUICover {
private final byte side;
private final int coverID;
- private int coverVariable;
+ private final FluidFilterData coverVariable;
private final GT_GuiFakeItemButton fluidFilterButton;
protected String fluidFilterName;
@@ -186,8 +195,7 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
private static final int spaceX = 18;
private static final int spaceY = 18;
- public GT_FluidFilterGUICover(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity)
- {
+ public GT_FluidFilterGUICover(byte aSide, int aCoverID, FluidFilterData aCoverVariable, ICoverable aTileEntity) {
super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID));
this.side = aSide;
this.coverID = aCoverID;
@@ -201,35 +209,38 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
b = new GT_GuiIconButton(this, 4, startX + spaceX*0, startY+spaceY*1, GT_GuiIcon.WHITELIST).setTooltipText(trans("236","Whitelist Fluid"));
b = new GT_GuiIconButton(this, 5, startX + spaceX*1, startY+spaceY*1, GT_GuiIcon.BLACKLIST).setTooltipText(trans("237","Blacklist Fluid"));
- fluidFilterButton = new GT_GuiFakeItemButton(this, startX, startY+spaceY*3+2, GT_GuiIcon.SLOT_DARKGRAY);
+ fluidFilterButton = new GT_GuiFakeItemButton(this, startX, startY + spaceY * 3 + 2, GT_GuiIcon.SLOT_DARKGRAY);
}
- private int getNewCoverVariable(int id) {
+ private int getNewFilterMode(int id) {
switch (id) {
case 0:
- return (coverVariable & ~0x7) | (coverVariable & 0x3);
+ return (coverVariable.mFilterMode & 0x3);
case 1:
- return (coverVariable & ~0x7) | (coverVariable | 0x4);
+ return (coverVariable.mFilterMode | 0x4);
case 2:
- return (coverVariable & ~0x7) | (coverVariable & 0x5);
+ return (coverVariable.mFilterMode & 0x5);
case 3:
- return (coverVariable & ~0x7) | (coverVariable | 0x2);
+ return (coverVariable.mFilterMode | 0x2);
case 4:
- return (coverVariable & ~0x7) | (coverVariable & 0x6);
+ return (coverVariable.mFilterMode & 0x6);
case 5:
- return (coverVariable & ~0x7) | (coverVariable | 0x1);
+ return (coverVariable.mFilterMode | 0x1);
}
- return coverVariable;
+ return coverVariable.mFilterMode;
}
private boolean getClickable(int id) {
switch (id) {
- case 0: case 1:
- return (coverVariable>>2 & 0x1) != (id & 0x1);
- case 2: case 3:
- return (coverVariable>>1 & 0x1) != (id & 0x1);
- case 4: case 5:
- return (coverVariable & 0x1) != (id & 0x1);
+ case 0:
+ case 1:
+ return (coverVariable.mFilterMode >> 2 & 0x1) != (id & 0x1);
+ case 2:
+ case 3:
+ return (coverVariable.mFilterMode >> 1 & 0x1) != (id & 0x1);
+ case 4:
+ case 5:
+ return (coverVariable.mFilterMode & 0x1) != (id & 0x1);
}
return false;
}
@@ -250,15 +261,15 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
}
@Override
- public void buttonClicked(GuiButton btn){
- if (getClickable(btn.id)){
- coverVariable = getNewCoverVariable(btn.id);
- GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile));
+ public void buttonClicked(GuiButton btn) {
+ if (getClickable(btn.id)) {
+ coverVariable.mFilterMode = (byte) getNewFilterMode(btn.id);
+ GT_Values.NW.sendToServer(new GT_Packet_TileEntityCoverNew(side, coverID, coverVariable, tile));
}
updateButtons();
}
- private void updateButtons(){
+ private void updateButtons() {
GT_GuiIconButton b;
for (Object o : buttonList) {
if (o instanceof GT_GuiIconButton) {
@@ -277,7 +288,7 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
}
}
}
- Fluid f = FluidRegistry.getFluid(coverVariable >>> 3);
+ Fluid f = FluidRegistry.getFluid(coverVariable.mFluidID);
if (f != null) {
ItemStack item = GT_Utility.getFluidDisplayStack(f);
if (item != null) {
@@ -290,4 +301,51 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior {
fluidFilterName = trans("224", "Filter Empty");
}
}
+
+ public static class FluidFilterData implements ISerializableObject {
+ private int mFluidID;
+ private int mFilterMode;
+
+ public FluidFilterData(int mFluidID, int mFilterMode) {
+ this.mFluidID = mFluidID;
+ this.mFilterMode = mFilterMode;
+ }
+
+ @Override
+ @Nonnull
+ public ISerializableObject copy() {
+ return new FluidFilterData(mFluidID, mFilterMode);
+ }
+
+ @Override
+ @Nonnull
+ public NBTBase saveDataToNBT() {
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setInteger("mFilterMode", mFilterMode);
+ tNBT.setString("mFluid", FluidRegistry.getFluid(mFluidID).getName());
+ return tNBT;
+ }
+
+ @Override
+ public void writeToByteBuf(ByteBuf aBuf) {
+ aBuf.writeByte(mFilterMode).writeInt(mFluidID);
+ }
+
+ @Override
+ public void loadDataFromNBT(NBTBase aNBT) {
+ if (aNBT instanceof NBTTagCompound) {
+ NBTTagCompound tNBT = (NBTTagCompound) aNBT;
+ mFilterMode = tNBT.getByte("mFilterMod");
+ mFluidID = FluidRegistry.getFluidID(tNBT.getString("mFluid"));
+ }
+ }
+
+ @Override
+ @Nonnull
+ public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) {
+ mFilterMode = aBuf.readByte();
+ mFluidID = aBuf.readInt();
+ return this;
+ }
+ }
}
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java b/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java
index 99003e18e0..88ef51dd01 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java
@@ -1,134 +1,142 @@
package gregtech.common.covers;
+import com.google.common.io.ByteArrayDataInput;
+import cpw.mods.fml.common.network.ByteBufUtils;
import gregtech.api.enums.GT_Values;
import gregtech.api.gui.GT_GUICover;
import gregtech.api.gui.widgets.GT_GuiFakeItemButton;
import gregtech.api.gui.widgets.GT_GuiIcon;
-import gregtech.api.gui.widgets.GT_GuiIconButton;
+import gregtech.api.gui.widgets.GT_GuiIconCheckButton;
import gregtech.api.interfaces.tileentity.ICoverable;
-import gregtech.api.net.GT_Packet_TileEntityCover;
-import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.net.GT_Packet_TileEntityCoverNew;
+import gregtech.api.util.GT_CoverBehaviorBase;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
+import io.netty.buffer.ByteBuf;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid;
+import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
-import static gregtech.api.util.GT_Utility.*;
+import static gregtech.api.util.GT_Utility.intToStack;
+import static gregtech.api.util.GT_Utility.moveMultipleItemStacks;
-public class GT_Cover_ItemFilter extends GT_CoverBehavior {
+public class GT_Cover_ItemFilter extends GT_CoverBehaviorBase<GT_Cover_ItemFilter.ItemFilterData> {
private final boolean mExport;
- public GT_Cover_ItemFilter(boolean isExport){
+ public GT_Cover_ItemFilter(boolean isExport) {
+ super(ItemFilterData.class);
this.mExport = isExport;
}
@Override
- public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ public ItemFilterData createDataObject(int aLegacyData) {
+ return new ItemFilterData((aLegacyData & 0x1) == 0, intToStack(aLegacyData >>> 1));
+ }
+
+ @Override
+ public ItemFilterData createDataObject() {
+ return new ItemFilterData();
+ }
+
+ @Override
+ protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity, long aTimer) {
return false;
}
@Override
- public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ protected ItemFilterData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity, long aTimer) {
TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide);
Object fromEntity = mExport ? aTileEntity : tTileEntity,
toEntity = !mExport ? aTileEntity : tTileEntity;
byte fromSide = !mExport ? GT_Utility.getOppositeSide(aSide) : aSide,
toSide = mExport ? GT_Utility.getOppositeSide(aSide) : aSide;
- int FilterId = aCoverVariable >>> 1;
- List<ItemStack> Filter = Collections.singletonList(intToStack(FilterId));
+ List<ItemStack> Filter = Collections.singletonList(aCoverVariable.mFilter);
- boolean isWhiteList = (aCoverVariable & 1) != 0;
-
- moveMultipleItemStacks(fromEntity, toEntity, fromSide , toSide, Filter, isWhiteList, (byte) 64, (byte) 1, (byte) 64, (byte) 1,64);
+ moveMultipleItemStacks(fromEntity, toEntity, fromSide, toSide, Filter, aCoverVariable.mWhitelist, (byte) 64, (byte) 1, (byte) 64, (byte) 1, 64);
return aCoverVariable;
}
@Override
- public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ){
- ItemStack tStack = aPlayer.inventory.getCurrentItem();
- if (tStack != null){
- aCoverVariable = (stackToInt(tStack) << 1) + (aCoverVariable & 1);
- aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
- GT_Utility.sendChatToPlayer(aPlayer, trans("301", "Item Filter: ") + tStack.getDisplayName());
- }
- else{
- aCoverVariable = aCoverVariable & 1;
- aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
- GT_Utility.sendChatToPlayer(aPlayer, trans("300", "Filter Cleared!"));
- }
- return true;
+ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ ItemStack tStack = aPlayer.inventory.getCurrentItem();
+ if (tStack != null) {
+ aCoverVariable.mFilter = tStack;
+ GT_Utility.sendChatToPlayer(aPlayer, trans("301", "Item Filter: ") + tStack.getDisplayName());
+ } else {
+ aCoverVariable.mFilter = null;
+ GT_Utility.sendChatToPlayer(aPlayer, trans("300", "Filter Cleared!"));
+ }
+ return true;
}
@Override
- public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- int mode = aCoverVariable & 1;
- if (mode == 1) mode = 0;
- else mode = 1;
- if (mode == 1){
- GT_Utility.sendChatToPlayer(aPlayer, trans("124", "Blacklist Mode"));
- }
- else{
- GT_Utility.sendChatToPlayer(aPlayer, trans("125", "Whitelist Mode"));
- }
- aCoverVariable = (aCoverVariable & ~0x1) + mode;
+ protected ItemFilterData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ aCoverVariable.mWhitelist = !aCoverVariable.mWhitelist;
+ GT_Utility.sendChatToPlayer(aPlayer, aCoverVariable.mWhitelist ? trans("125", "Whitelist Mode") : trans("124", "Blacklist Mode"));
return aCoverVariable;
}
@Override
- public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) {
return true;
}
@Override
- public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) {
return true;
}
@Override
- public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ protected boolean letsEnergyInImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) {
return true;
}
@Override
- public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) {
return true;
}
@Override
- public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ protected boolean letsFluidInImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
return false;
}
@Override
- public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ protected boolean letsFluidOutImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
return false;
}
@Override
- public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ protected boolean letsItemsInImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, int aSlot, ICoverable aTileEntity) {
return true;
}
@Override
- public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ protected boolean letsItemsOutImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, int aSlot, ICoverable aTileEntity) {
return true;
}
@Override
- public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) {
return true;
}
@Override
- public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ protected int getTickRateImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) {
return 1;
}
@@ -142,14 +150,68 @@ public class GT_Cover_ItemFilter extends GT_CoverBehavior {
}
@Override
- public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) {
- return new GT_Cover_ItemFilter.GUI(aSide, aCoverID, coverData, aTileEntity);
+ protected Object getClientGUIImpl(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) {
+ return new GT_Cover_ItemFilter.GUI(aSide, aCoverID, aCoverVariable, aTileEntity);
+ }
+
+ public static class ItemFilterData implements ISerializableObject {
+ private boolean mWhitelist;
+ private ItemStack mFilter;
+
+ public ItemFilterData() {
+ }
+
+ public ItemFilterData(boolean mWhitelist, ItemStack mFilter) {
+ this.mWhitelist = mWhitelist;
+ this.mFilter = mFilter;
+ }
+
+ @Nonnull
+ @Override
+ public ISerializableObject copy() {
+ return new ItemFilterData(mWhitelist, mFilter);
+ }
+
+ @Nonnull
+ @Override
+ public NBTBase saveDataToNBT() {
+ NBTTagCompound tag = new NBTTagCompound();
+ tag.setBoolean("mWhitelist", mWhitelist);
+ if (mFilter != null)
+ tag.setTag("mFilter", mFilter.writeToNBT(new NBTTagCompound()));
+ return tag;
+ }
+
+ @Override
+ public void writeToByteBuf(ByteBuf aBuf) {
+ aBuf.writeBoolean(mWhitelist);
+ ByteBufUtils.writeItemStack(aBuf, mFilter);
+ }
+
+ @Override
+ public void loadDataFromNBT(NBTBase aNBT) {
+ NBTTagCompound tag = (NBTTagCompound) aNBT;
+ mWhitelist = tag.getBoolean("mWhitelist");
+ if (tag.hasKey("mFilter", Constants.NBT.TAG_COMPOUND))
+ mFilter = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("mFilter"));
+ else
+ mFilter = null;
+ }
+
+ @Nonnull
+ @Override
+ public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) {
+ mWhitelist = aBuf.readBoolean();
+ mFilter = ISerializableObject.readItemStackFromGreggyByteBuf(aBuf);
+ return this;
+ }
}
private class GUI extends GT_GUICover {
private final byte side;
private final int coverID;
- private int coverVariable;
+ private final GT_GuiIconCheckButton btnMode;
+ private final ItemFilterData coverVariable;
private final GT_GuiFakeItemButton itemFilterButtons;
private static final int startX = 10;
@@ -157,17 +219,15 @@ public class GT_Cover_ItemFilter extends GT_CoverBehavior {
private static final int spaceX = 18;
private static final int spaceY = 18;
- public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ public GUI(byte aSide, int aCoverID, ItemFilterData aCoverVariable, ICoverable aTileEntity) {
super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID));
this.side = aSide;
this.coverID = aCoverID;
this.coverVariable = aCoverVariable;
- GT_GuiIconButton b;
- b = new GT_GuiIconButton(this, 0, startX + spaceX*0, startY+spaceY*0, GT_GuiIcon.WHITELIST).setTooltipText(trans("125","Whitelist Mode"));
- b = new GT_GuiIconButton(this, 1, startX + spaceX*1, startY+spaceY*0, GT_GuiIcon.BLACKLIST).setTooltipText(trans("124","Blacklist Mode"));
+ btnMode = new GT_GuiIconCheckButton(this, 0, startX + spaceX * 0, startY + spaceY * 0, GT_GuiIcon.WHITELIST, GT_GuiIcon.BLACKLIST, trans("125", "Whitelist Mode"), trans("124", "Blacklist Mode"));
- itemFilterButtons = new GT_GuiFakeItemButton(this ,startX + spaceX*0, startY+spaceY*2, GT_GuiIcon.SLOT_GRAY);
+ itemFilterButtons = new GT_GuiFakeItemButton(this, startX + spaceX * 0, startY + spaceY * 2, GT_GuiIcon.SLOT_GRAY);
}
@Override
@@ -183,46 +243,19 @@ public class GT_Cover_ItemFilter extends GT_CoverBehavior {
}
@Override
- public void buttonClicked(GuiButton btn){
- if (getClickable(btn.id)){
- coverVariable = getNewCoverVariable(btn.id);
- GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile));
+ public void buttonClicked(GuiButton btn) {
+ if (btn == btnMode) {
+ if (coverVariable.mWhitelist != btnMode.isChecked()) {
+ coverVariable.mWhitelist = btnMode.isChecked();
+ GT_Values.NW.sendToServer(new GT_Packet_TileEntityCoverNew(side, coverID, coverVariable, tile));
+ }
}
updateButtons();
}
- private void updateButtons(){
- GuiButton b;
- for (Object o : buttonList) {
- b = (GuiButton) o;
- b.enabled = getClickable(b.id);
- }
- ItemStack tItemStack = intToStack(coverVariable >>> 1);
- if (tItemStack != null){
- itemFilterButtons.setItem(tItemStack);
- return;
- }
- itemFilterButtons.setItem(null);
- }
-
- private int getNewCoverVariable(int id) {
- switch (id) {
- case 0:
- return coverVariable & ~0x1;
- case 1:
- return coverVariable | 0x1;
- }
- return coverVariable;
- }
-
- private boolean getClickable(int id) {
- switch (id) {
- case 0:
- return (0x1 & coverVariable) != 0;
- case 1:
- return (0x1 & coverVariable) == 0;
- }
- return false;
+ private void updateButtons() {
+ btnMode.setChecked(coverVariable.mWhitelist);
+ itemFilterButtons.setItem(coverVariable.mFilter);
}
}
}
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java
index f1c1bc7df7..74e5438bde 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java
@@ -14,7 +14,6 @@ import gregtech.api.util.GT_CoverBehavior;
import gregtech.api.util.GT_Utility;
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME;
import gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalChestBase;
-
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -46,25 +45,22 @@ public class GT_Cover_ItemMeter extends GT_CoverBehavior {
long tMax = 0;
long tUsed = 0;
- IMetaTileEntity mte = ((IGregTechTileEntity)aTileEntity).getMetaTileEntity();
+ IMetaTileEntity mte = ((IGregTechTileEntity) aTileEntity).getMetaTileEntity();
if (mte instanceof GT_MetaTileEntity_DigitalChestBase) {
- GT_MetaTileEntity_DigitalChestBase dc = (GT_MetaTileEntity_DigitalChestBase)mte;
+ GT_MetaTileEntity_DigitalChestBase dc = (GT_MetaTileEntity_DigitalChestBase) mte;
tMax = dc.getMaxItemCount(); // currently it is limited by int, but there is not much reason for that
ItemStack[] inv = dc.getStoredItemData();
if (inv != null && inv.length > 1 && inv[1] != null)
tUsed = inv[1].stackSize;
- }
- else if (mte instanceof GT_MetaTileEntity_Hatch_OutputBus_ME) {
- if (((GT_MetaTileEntity_Hatch_OutputBus_ME)mte).isLastOutputFailed())
- {
+ } else if (mte instanceof GT_MetaTileEntity_Hatch_OutputBus_ME) {
+ if (((GT_MetaTileEntity_Hatch_OutputBus_ME) mte).isLastOutputFailed()) {
tMax = 64;
tUsed = 64;
}
- }
- else {
+ } else {
int[] tSlots = (aCoverVariable & SLOT_MASK) > 0 ?
- new int[] {(aCoverVariable & SLOT_MASK) - 1} :
- aTileEntity.getAccessibleSlotsFromSide(aSide);
+ new int[]{(aCoverVariable & SLOT_MASK) - 1} :
+ aTileEntity.getAccessibleSlotsFromSide(aSide);
for (int i : tSlots) {
if (i >= 0 && i < aTileEntity.getSizeInventory()) {
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java
index 577cff3d7a..62f8d3550b 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneWirelessBase.java
@@ -12,6 +12,7 @@ import gregtech.api.net.GT_Packet_TileEntityCover;
import gregtech.api.net.GT_Packet_WirelessRedstoneCover;
import gregtech.api.util.GT_CoverBehavior;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fluids.Fluid;
@@ -25,14 +26,26 @@ public abstract class GT_Cover_RedstoneWirelessBase extends GT_CoverBehavior {
@Override
public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) {
- GregTech_API.sWirelessRedstone.put(Integer.valueOf(aCoverVariable), Byte.valueOf((byte) 0));
+ GregTech_API.sWirelessRedstone.put(aCoverVariable, (byte) 0);
return true;
}
@Override
+ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (((aX > 0.375D) && (aX < 0.625D)) || ((aSide > 3) && ((aY > 0.375D) && (aY < 0.625D)))) {
+ GregTech_API.sWirelessRedstone.put(aCoverVariable.get(), (byte) 0);
+ aCoverVariable.set((aCoverVariable.get() & (PRIVATE_MASK | CHECKBOX_MASK)) | (((Integer)GT_Utility.stackToInt(aPlayer.inventory.getCurrentItem())).hashCode() & PUBLIC_MASK));
+ GT_Utility.sendChatToPlayer(aPlayer, trans("081", "Frequency: ") + aCoverVariable);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ @SuppressWarnings("deprecation")
public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
if (((aX > 0.375D) && (aX < 0.625D)) || ((aSide > 3) && ((aY > 0.375D) && (aY < 0.625D)))) {
- GregTech_API.sWirelessRedstone.put(Integer.valueOf(aCoverVariable), Byte.valueOf((byte) 0));
+ GregTech_API.sWirelessRedstone.put(aCoverVariable, (byte) 0);
int val = GT_Utility.stackToInt(aPlayer.inventory.getCurrentItem()) * (1 + aPlayer.inventory.getCurrentItem().getItemDamage());
@@ -48,7 +61,7 @@ public abstract class GT_Cover_RedstoneWirelessBase extends GT_CoverBehavior {
@Override
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
if (((aX > 0.375D) && (aX < 0.625D)) || ((aSide <= 3) || (((aY > 0.375D) && (aY < 0.625D)) || ((((aZ <= 0.375D) || (aZ >= 0.625D))))))) {
- GregTech_API.sWirelessRedstone.put(Integer.valueOf(aCoverVariable), Byte.valueOf((byte) 0));
+ GregTech_API.sWirelessRedstone.put(aCoverVariable, (byte) 0);
float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ);
short tAdjustVal = 0;
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java b/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java
index ae1b73b8cb..09a9d5ab69 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java
@@ -3,6 +3,7 @@ package gregtech.common.covers;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.util.GT_CoverBehavior;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.ISerializableObject;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -58,6 +59,29 @@ public class GT_Cover_SolarPanel extends GT_CoverBehavior {
}
@Override
+ protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if(aPlayer.capabilities.isCreativeMode){
+ GT_Utility.sendChatToPlayer(aPlayer,"Cleaned solar panel from "+(aCoverVariable.get()>>2)+"% dirt");
+ aCoverVariable.set(aCoverVariable.get() & 0x3);
+ return true;
+ }
+ for(int i=0;i<aPlayer.inventory.mainInventory.length;i++){
+ ItemStack is=aPlayer.inventory.mainInventory[i];
+ if(is==null) continue;
+ if(is.getUnlocalizedName().equals(new ItemStack(Items.water_bucket).getUnlocalizedName())){
+ aPlayer.inventory.mainInventory[i]=new ItemStack(Items.bucket);
+ if (aPlayer.inventoryContainer != null) aPlayer.inventoryContainer.detectAndSendChanges();
+ GT_Utility.sendChatToPlayer(aPlayer,"Cleaned solar panel from "+(aCoverVariable.get()>>2)+"% dirt");
+ aCoverVariable.set(aCoverVariable.get() & 0x3);
+ return true;
+ }
+ }
+ GT_Utility.sendChatToPlayer(aPlayer,"You need water bucket in inventory to clean the panel.");
+ return false;
+ }
+
+ @Override
+ @SuppressWarnings("deprecation")
public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
if(aPlayer.capabilities.isCreativeMode){
GT_Utility.sendChatToPlayer(aPlayer,"Cleaned solar panel from "+(aCoverVariable>>2)+"% dirt");
diff --git a/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java b/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java
index 1006acebf1..2e217f6b1e 100644
--- a/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java
+++ b/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java
@@ -116,7 +116,7 @@ public class GT_Container_OutputHatch extends GT_Container_BasicTank {
}
byte mode = buffer.get(Integer.BYTES);
FluidStack tFluid = FluidRegistry.getFluidStack(sb.toString().replace("fluid.", "")
- .replace(".name", "").replace("ic2.fluid", "ic2").toLowerCase(), 1);
+ .replace("tile.", "").replace(".name", "").replace("ic2.fluid", "ic2").toLowerCase(), 1);
if (tFluid == null || mode < 8) return "Empty";
else return tFluid.getLocalizedName().replace("fluid.", "");
}
diff --git a/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java b/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java
index ad4e1f6bdd..43186b9621 100644
--- a/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java
+++ b/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java
@@ -40,7 +40,7 @@ public class GT_FluidDisplayItem extends GT_Generic_Item {
protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) {
if (FluidRegistry.getFluid(aStack.getItemDamage()) != null) {
String tChemicalFormula = getChemicalFormula(new FluidStack(FluidRegistry.getFluid(aStack.getItemDamage()), 1));
- if (!tChemicalFormula.isEmpty()) aList.add(EnumChatFormatting.GRAY + tChemicalFormula + EnumChatFormatting.GRAY);
+ if (!tChemicalFormula.isEmpty()) aList.add(EnumChatFormatting.YELLOW + tChemicalFormula + EnumChatFormatting.RESET);
}
NBTTagCompound aNBT = aStack.getTagCompound();
if (GT_Values.D1) {
diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java
index 2e9a0c3f6d..e7f846d9b0 100644
--- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java
+++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java
@@ -407,8 +407,8 @@ public class GT_MetaGenerated_Item_01 extends GT_MetaGenerated_Item_X32 {
ItemList.Battery_Hull_MV.set(addItem(501, "Medium Battery Hull", "An empty MV Battery Hull", new ItemData(Materials.BatteryAlloy, OrePrefixes.plate.mMaterialAmount * 3L), new TC_Aspects.TC_AspectStack(TC_Aspects.ELECTRUM, 2L), new TC_Aspects.TC_AspectStack(TC_Aspects.METALLUM, 2L), new TC_Aspects.TC_AspectStack(TC_Aspects.VACUOS, 1L)));
ItemList.Battery_Hull_HV.set(addItem(502, "Large Battery Hull", "An empty HV Battery Hull", new ItemData(Materials.BatteryAlloy, OrePrefixes.plate.mMaterialAmount * 9L), new TC_Aspects.TC_AspectStack(TC_Aspects.ELECTRUM, 4L), new TC_Aspects.TC_AspectStack(TC_Aspects.METALLUM, 4L), new TC_Aspects.TC_AspectStack(TC_Aspects.VACUOS, 1L)));
- GT_ModHandler.addCraftingRecipe(ItemList.Battery_Hull_LV.get(1L), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"C", "P", "P", 'P', OrePrefixes.plate.get(Materials.BatteryAlloy), 'C', OreDictNames.craftingWireTin});
- GT_ModHandler.addCraftingRecipe(ItemList.Battery_Hull_MV.get(1L), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"C C", "PPP", "PPP", 'P', OrePrefixes.plate.get(Materials.BatteryAlloy), 'C', OreDictNames.craftingWireCopper});
+ GT_ModHandler.addCraftingRecipe(ItemList.Battery_Hull_LV.get(1L), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"Cf ", "Ph ", "Ps ", 'P', OrePrefixes.plate.get(Materials.BatteryAlloy), 'C', OreDictNames.craftingWireTin});
+ //GT_ModHandler.addCraftingRecipe(ItemList.Battery_Hull_MV.get(1L), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"C C", "PPP", "PPP", 'P', OrePrefixes.plate.get(Materials.BatteryAlloy), 'C', OreDictNames.craftingWireCopper});
ItemList.Battery_RE_ULV_Tantalum.set(addItem(tLastID = 499, "Tantalum Capacitor", "Reusable", new TC_Aspects.TC_AspectStack(TC_Aspects.ELECTRUM, 1L), new TC_Aspects.TC_AspectStack(TC_Aspects.METALLUM, 1L), new TC_Aspects.TC_AspectStack(TC_Aspects.POTENTIA, 1L)));
setElectricStats(32000 + tLastID, 1000L, GT_Values.V[0], 0L, -3L, false);
@@ -516,7 +516,7 @@ public class GT_MetaGenerated_Item_01 extends GT_MetaGenerated_Item_X32 {
GT_ModHandler.addCraftingRecipe(ItemList.Electric_Motor_LV.get(1L), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", 'I', OrePrefixes.stick.get(Materials.SteelMagnetic), 'R', OrePrefixes.stick.get(Materials.Steel), 'W', OrePrefixes.wireGt01.get(Materials.AnyCopper), 'C', OrePrefixes.cableGt01.get(Materials.Tin)});
GT_ModHandler.addCraftingRecipe(ItemList.Electric_Motor_MV.get(1L), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", 'I', OrePrefixes.stick.get(Materials.SteelMagnetic), 'R', OrePrefixes.stick.get(Materials.Aluminium), 'W', OrePrefixes.wireGt02.get(Materials.Cupronickel), 'C', OrePrefixes.cableGt01.get(Materials.AnyCopper)});
GT_ModHandler.addCraftingRecipe(ItemList.Electric_Motor_HV.get(1L), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", 'I', OrePrefixes.stick.get(Materials.SteelMagnetic), 'R', OrePrefixes.stick.get(Materials.StainlessSteel), 'W', OrePrefixes.wireGt04.get(Materials.Electrum), 'C', OrePrefixes.cableGt02.get(Materials.Silver)});
- GT_ModHandler.addCraftingRecipe(ItemList.Electric_Motor_EV.get(1L), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", 'I', OrePrefixes.stick.get(Materials.NeodymiumMagnetic), 'R', OrePrefixes.stick.get(Materials.Titanium), 'W', OrePrefixes.wireGt04.get(Materials.AnnealedCopper), 'C', OrePrefixes.cableGt02.get(Materials.Aluminium)});
+ GT_ModHandler.addCraftingRecipe(ItemList.Electric_Motor_EV.get(1L), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", 'I', OrePrefixes.stick.get(Materials.NeodymiumMagnetic), 'R', OrePrefixes.stick.get(Materials.Titanium), 'W', OrePrefixes.wireGt04.get(Materials.BlackSteel), 'C', OrePrefixes.cableGt02.get(Materials.Aluminium)});
GT_ModHandler.addCraftingRecipe(ItemList.Electric_Motor_IV.get(1L), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", 'I', OrePrefixes.stick.get(Materials.NeodymiumMagnetic), 'R', OrePrefixes.stick.get(Materials.TungstenSteel), 'W', OrePrefixes.wireGt04.get(Materials.Graphene), 'C', OrePrefixes.cableGt02.get(Materials.Tungsten)});
ItemList.Electric_Piston_LV.set(addItem(640, "Electric Piston (LV)", "", new TC_Aspects.TC_AspectStack(TC_Aspects.ELECTRUM, 1L), new TC_Aspects.TC_AspectStack(TC_Aspects.MACHINA, 2L), new TC_Aspects.TC_AspectStack(TC_Aspects.MOTUS, 1L)));
diff --git a/src/main/java/gregtech/common/misc/GT_Command.java b/src/main/java/gregtech/common/misc/GT_Command.java
index 13e26353d8..4f6f77ea70 100644
--- a/src/main/java/gregtech/common/misc/GT_Command.java
+++ b/src/main/java/gregtech/common/misc/GT_Command.java
@@ -61,7 +61,7 @@ public final class GT_Command extends CommandBase {
} else if (test.equals("toggle")) {
String test1 = ss[1].trim();
Stream.of("D1", "D2", "debugCleanroom", "debugDriller", "debugBlockPump", "debugBlockMiner", "debugWorldGen", "debugEntityCramming",
- "debugOrevein", "debugSmallOres", "debugStones", "debugChunkloaders", "debugMulti")
+ "debugOrevein", "debugSmallOres", "debugStones", "debugChunkloaders", "debugMulti", "debugWorldData")
.filter(s -> test1.isEmpty() || s.startsWith(test1))
.forEach(l::add);
diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java
index 4fb9deb5b4..96b991e767 100644
--- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java
+++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java
@@ -175,7 +175,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa
@Override
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) {
- return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover();
+ return GregTech_API.getCoverBehaviorNew(aCover.toStack()).isSimpleCover();
}
@Override
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
index eba61ad1b1..1573c951eb 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java
@@ -15,6 +15,7 @@ import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtech.api.objects.ItemData;
import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_AssemblyLineUtils;
import gregtech.api.util.GT_Assemblyline_Server;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_ModHandler;
@@ -253,6 +254,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
if (failScanner) {
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
}
+
String s = tRecipe.mOutput.getDisplayName();
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
@@ -261,92 +263,19 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
s = tRecipe.mOutput.getDisplayName();
}
this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot());
- //remove possible old NBTTagCompound
- this.mOutputItems[0].setTagCompound(new NBTTagCompound());
- GT_Utility.ItemNBT.setBookTitle(this.mOutputItems[0], s + " Construction Data");
+
- NBTTagCompound tNBT = this.mOutputItems[0].getTagCompound();
- if (tNBT == null) {
- tNBT = new NBTTagCompound();
- }
-
- tNBT.setTag("output", tRecipe.mOutput.writeToNBT(new NBTTagCompound()));
- tNBT.setInteger("time", tRecipe.mDuration);
- tNBT.setInteger("eu", tRecipe.mEUt);
- for (int i = 0; i < tRecipe.mInputs.length; i++) {
- tNBT.setTag("" + i, tRecipe.mInputs[i].writeToNBT(new NBTTagCompound()));
- }
- for (int i = 0; i < tRecipe.mOreDictAlt.length; i++) {
- if (tRecipe.mOreDictAlt[i] != null && tRecipe.mOreDictAlt[i].length > 0) {
- tNBT.setInteger("a" + i, tRecipe.mOreDictAlt[i].length);
- for (int j = 0; j < tRecipe.mOreDictAlt[i].length; j++) {
- tNBT.setTag("a" + i + ":" + j, tRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound()));
- }
- }
- }
- for (int i = 0; i < tRecipe.mFluidInputs.length; i++) {
- tNBT.setTag("f" + i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound()));
- }
- tNBT.setString("author", "Assembling Line Recipe Generator");
- NBTTagList tNBTList = new NBTTagList();
- s = tRecipe.mOutput.getDisplayName();
- if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
- s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mOutput.getDisplayName());
- if (s == null)
- s = tRecipe.mOutput.getDisplayName();
- }
- tNBTList.appendTag(new NBTTagString("Construction plan for " + tRecipe.mOutput.stackSize + " " + s + ". Needed EU/t: " + tRecipe.mEUt + " Production time: " + (tRecipe.mDuration / 20)));
- for (int i = 0; i < tRecipe.mInputs.length; i++) {
- if (tRecipe.mOreDictAlt[i] != null) {
- int count = 0;
- StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": ");
- for (ItemStack tStack : tRecipe.mOreDictAlt[i]) {
- if (tStack != null) {
- s = tStack.getDisplayName();
- if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
- s = GT_Assemblyline_Server.lServerNames.get(tStack.getDisplayName());
- if (s == null)
- s = tStack.getDisplayName();
- }
-
-
- tBuilder.append(count == 0 ? "" : "\nOr ").append(tStack.stackSize).append(" ").append(s);
- count++;
- }
- }
- if (count > 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString()));
- } else if (tRecipe.mInputs[i] != null) {
- s = tRecipe.mInputs[i].getDisplayName();
- if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
- s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mInputs[i].getDisplayName());
- if (s == null)
- s = tRecipe.mInputs[i].getDisplayName();
- }
- tNBTList.appendTag(new NBTTagString("Input Bus " + (i + 1) + ": " + tRecipe.mInputs[i].stackSize + " " + s));
- }
- }
- for (int i = 0; i < tRecipe.mFluidInputs.length; i++) {
- if (tRecipe.mFluidInputs[i] != null) {
- s = tRecipe.mFluidInputs[i].getLocalizedName();
- if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
- s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mFluidInputs[i].getLocalizedName());
- if (s == null)
- s = tRecipe.mFluidInputs[i].getLocalizedName();
- }
- tNBTList.appendTag(new NBTTagString("Input Hatch " + (i + 1) + ": " + tRecipe.mFluidInputs[i].amount + "L " + s));
- }
+ // Use Assline Utils
+ if (GT_AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(this.mOutputItems[0], tRecipe)) {
+ aStack.stackSize -= 1;
+ calculateOverclockedNess(30, tRecipe.mResearchTime);
+ //In case recipe is too OP for that machine
+ if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
+ return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
+ getSpecialSlot().stackSize -= 1;
+ return 2;
}
- tNBT.setTag("pages", tNBTList);
-
- this.mOutputItems[0].setTagCompound(tNBT);
-
- aStack.stackSize -= 1;
- calculateOverclockedNess(30, tRecipe.mResearchTime);
- //In case recipe is too OP for that machine
- if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
- return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
- getSpecialSlot().stackSize -= 1;
- return 2;
+
}
}
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java
index 64651a3fc4..14663f7d68 100644
--- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java
+++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java
@@ -46,6 +46,7 @@ import java.util.LinkedList;
import java.util.Queue;
public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_MetaTileEntity_BasicHull_NonElectric {
+ public static int minimalDistancePoints = 64;
protected GT_MetaTileEntity_LongDistancePipelineBase mTarget = null, mSender = null;
protected ChunkCoordinates mTargetPos = null;
@@ -77,6 +78,8 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta
aNBT.getInteger("target.y"),
aNBT.getInteger("target.z")
);
+ if (getDistanceToSelf(mTargetPos) < minimalDistancePoints)
+ mTargetPos = null;
}
}
@@ -210,9 +213,13 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta
tGtTile.getFacingOffset((BaseMetaTileEntity)tTileEntity, ((BaseMetaTileEntity) tTileEntity).getFrontFacing())
)) {
// If it's the same class, and we've scanned a wire in front of it (the input side), we've found our target
- mTarget = tGtTile;
- mTargetPos = tGtTile.getCoords();
- return;
+ // still need to check if it's distant enough
+ int distance = getDistanceToSelf(aCoords);
+ if (distance > minimalDistancePoints) {
+ mTarget = tGtTile;
+ mTargetPos = tGtTile.getCoords();
+ return;
+ }
}
// Remove this block from the visited because we might end up back here from another wire that IS connected to the
@@ -224,7 +231,13 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta
}
}
-
+
+ protected int getDistanceToSelf(ChunkCoordinates aCoords) {
+ return Math.abs(getBaseMetaTileEntity().getXCoord() - aCoords.posX) +
+ Math.abs(getBaseMetaTileEntity().getYCoord() - aCoords.posY) / 2 +
+ Math.abs(getBaseMetaTileEntity().getZCoord() - aCoords.posZ);
+ }
+
public ChunkCoordinates getFacingOffset(IGregTechTileEntity gt_tile, byte aSide) {
return new ChunkCoordinates(
gt_tile.getOffsetX(aSide, 1), gt_tile.getOffsetY(aSide, 1), gt_tile.getOffsetZ(aSide, 1)
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java
index 0a19536bf1..c2460213c8 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java
@@ -17,8 +17,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_AssemblyLineUtils;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -156,117 +158,111 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu
@Override
public boolean checkRecipe(ItemStack aStack) {
- if (GT_Values.D1)
- GT_FML_LOGGER.info("Start ALine recipe check");
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Start ALine recipe check");
+ }
ArrayList<ItemStack> tDataStickList = getDataItems(2);
- if (tDataStickList.isEmpty()) return false;
- if (GT_Values.D1)
- GT_FML_LOGGER.info("Stick accepted, " + tDataStickList.size() + " Data Sticks found");
+ if (tDataStickList.isEmpty()) {
+ return false;
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Stick accepted, " + tDataStickList.size() + " Data Sticks found");
+ }
- ItemStack[] tStack = new ItemStack[15];
- FluidStack[] tFluids = new FluidStack[4];
+ ItemStack[] tStack = null;
+ FluidStack[] tFluids = null;
boolean findRecipe = false;
- nextDS:
+
+ nextDataStick:
for (ItemStack tDataStick : tDataStickList) {
- NBTTagCompound tTag = tDataStick.getTagCompound();
- if (tTag == null)
- continue;
+ GT_Recipe_AssemblyLine aFoundRecipe = GT_AssemblyLineUtils.findAssemblyLineRecipeFromDataStick(tDataStick);
+
+ // Check if the recipe on the data stick is the current recipe for it's given output, if not we update it and continue to next.
+ if (!GT_AssemblyLineUtils.processDataStick(tDataStick)) {
+ continue;
+ }
+
+ tStack = aFoundRecipe.mInputs;
+ tFluids = aFoundRecipe.mFluidInputs;
+
+ // So here we check against the recipe found on the data stick.
+ // If we run into missing buses/hatches or bad inputs, we go to the next data stick.
+ // This check only happens if we have a valid up to date data stick.
+
+ // Check Inputs allign
+ int aItemCount = aFoundRecipe.mInputs.length;
for (int i = 0; i < 15; i++) {
- int count = tTag.getInteger("a" + i);
- if (!tTag.hasKey("" + i) && count <= 0)
- continue;
- if (mInputBusses.get(i) == null) {
- continue nextDS;
- }
-
- ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
- boolean flag = true;
- if (count > 0) {
- for (int j = 0; j < count; j++) {
- tStack[i] = GT_Utility.loadItem(tTag, "a" + i + ":" + j);
- if (tStack[i] == null) continue;
- if (GT_Values.D1)
- GT_FML_LOGGER.info("Item " + i + " : " + tStack[i].getUnlocalizedName());
- if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) {
- flag = false;
- break;
- }
- }
- }
- if (flag) {
- tStack[i] = GT_Utility.loadItem(tTag, "" + i);
- if (tStack[i] == null) {
- flag = false;
- continue;
- }
- if (GT_Values.D1)
- GT_FML_LOGGER.info("Item " + i + " : " + tStack[i].getUnlocalizedName());
- if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) {
- flag = false;
+ if (i >= aItemCount) {
+ continue;
+ }
+ else {
+ if (mInputBusses.get(i) == null) {
+ continue nextDataStick;
}
- }
- if (GT_Values.D1)
- GT_FML_LOGGER.info(i + (flag ? " not accepted" : " accepted"));
- if (flag)
- continue nextDS;
- }
-
- if (GT_Values.D1) GT_FML_LOGGER.info("All Items done, start fluid check");
- for (int i = 0; i < 4; i++) {
- if (!tTag.hasKey("f" + i)) continue;
- tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i);
- if (tFluids[i] == null) continue;
- if (GT_Values.D1)
- GT_FML_LOGGER.info("Fluid " + i + " " + tFluids[i].getUnlocalizedName());
- if (mInputHatches.get(i) == null) {
- continue nextDS;
- }
- FluidStack fluidInHatch = mInputHatches.get(i).mFluid;
- if (!GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) {
- if (GT_Values.D1)
- GT_FML_LOGGER.info(i + " not accepted");
- continue nextDS;
- }
- if (GT_Values.D1)
- GT_FML_LOGGER.info(i + " accepted");
+ else {
+ ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
+ if (!GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) || tStack[i].stackSize <= stackInSlot.stackSize) {
+ continue nextDataStick;
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Item: " + i + " accepted");
+ }
+ }
+ }
}
-
- if (GT_Values.D1)
- GT_FML_LOGGER.info("Input accepted, check other values");
- if (!tTag.hasKey("output"))
- continue;
- mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")};
- if (mOutputItems[0] == null || !GT_Utility.isStackValid(mOutputItems[0]))
- continue;
-
- if (!tTag.hasKey("time"))
- continue;
- int tMaxProgressTime = tTag.getInteger("time");
- if (tMaxProgressTime <= 0)
- continue;
-
- if (!tTag.hasKey("eu"))
- continue;
-
- if (GT_Values.D1) GT_FML_LOGGER.info("Check overclock");
-
- calculateOverclockedNessMulti(tTag.getInteger("eu"), tMaxProgressTime, 1, getMaxInputVoltage());
- //In case recipe is too OP for that machine
- if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) {
- if (GT_Values.D1) GT_FML_LOGGER.info("Recipe too OP");
- continue;
+
+ // Check Fluid Inputs allign
+ int aFluidCount = aFoundRecipe.mFluidInputs.length;
+ for (int i = 0; i < 4; i++){
+ if (i >= aFluidCount) {
+ continue;
+ }
+ else {
+ if (mInputHatches.get(i) == null) {
+ continue nextDataStick;
+ }
+ else {
+ FluidStack fluidInHatch = mInputHatches.get(i).mFluid;
+ if (!GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) {
+ continue nextDataStick;
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Fluid:" + i + " accepted");
+ }
+ }
+ }
}
-
- if (GT_Values.D1) GT_FML_LOGGER.info("Find avaiable recipe");
- findRecipe = true;
- break;
+
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Check overclock");
+ }
+ calculateOverclockedNessMulti(aFoundRecipe.mEUt, aFoundRecipe.mDuration, 1, getMaxInputVoltage());
+ //In case recipe is too OP for that machine
+ if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) {
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Recipe too OP");
+ }
+ continue;
+ }
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Find available recipe");
+ }
+ findRecipe = true;
}
- if (!findRecipe) return false;
+
+ // Best not to run this recipe.
+ if (!findRecipe || tStack == null || tStack.length <= 0 || tFluids == null || tFluids.length <= 0) {
+ return false;
+ }
+
- if (GT_Values.D1) GT_FML_LOGGER.info("All checked start consuming inputs");
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("All checked start consuming inputs");
+ }
for (int i = 0; i < 15; i++) {
- if (tStack[i] == null)
- continue;
+ if (tStack[i] == null) {
+ continue;
+ }
ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
stackInSlot.stackSize -= tStack[i].stackSize;
}
@@ -280,13 +276,15 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu
}
}
- if (this.mEUt > 0)
- this.mEUt = -this.mEUt;
+ if (this.mEUt > 0) {
+ this.mEUt = -this.mEUt;
+ }
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
updateSlots();
- if (GT_Values.D1)
- GT_FML_LOGGER.info("Recipe sucessfull");
+ if (GT_Values.D1) {
+ GT_FML_LOGGER.info("Recipe sucessfull");
+ }
return true;
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
index 63b536fc72..87eddb7e13 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
@@ -11,6 +11,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMul
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Single_Recipe_Check;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -123,68 +124,98 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_En
}
@Override
+ public boolean supportsSingleRecipeLocking() {
+ return true;
+ }
+
+ @Override
public boolean checkRecipe(ItemStack aStack) {
- ArrayList<ItemStack> tInputList = getStoredInputs();
- int tInputList_sS = tInputList.size();
- for (int i = 0; i < tInputList_sS - 1; i++) {
- for (int j = i + 1; j < tInputList_sS; j++) {
- if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) {
- if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) {
- tInputList.remove(j--);
- tInputList_sS = tInputList.size();
- } else {
- tInputList.remove(i--);
- tInputList_sS = tInputList.size();
- break;
+ long tVoltage = getMaxInputVoltage();
+ byte tier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ GT_Recipe tRecipe;
+
+ if (mLockedToSingleRecipe && mSingleRecipeCheck != null) {
+ if (!mSingleRecipeCheck.checkRecipeInputsSingleStack(true)) {
+ return false;
+ }
+
+ tRecipe = mSingleRecipeCheck.getRecipe();
+ } else {
+ ArrayList<ItemStack> tInputList = getStoredInputs();
+ int tInputList_sS = tInputList.size();
+ for (int i = 0; i < tInputList_sS - 1; i++) {
+ for (int j = i + 1; j < tInputList_sS; j++) {
+ if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) {
+ if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) {
+ tInputList.remove(j--);
+ tInputList_sS = tInputList.size();
+ } else {
+ tInputList.remove(i--);
+ tInputList_sS = tInputList.size();
+ break;
+ }
}
}
}
- }
- tInputList.add(mInventory[1]);
- ItemStack[] inputs = tInputList.toArray(new ItemStack[0]);
-
- ArrayList<FluidStack> tFluidList = getStoredFluids();
- int tFluidList_sS = tFluidList.size();
- for (int i = 0; i < tFluidList_sS - 1; i++) {
- for (int j = i + 1; j < tFluidList_sS; j++) {
- if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) {
- if (tFluidList.get(i).amount >= tFluidList.get(j).amount) {
- tFluidList.remove(j--);
- tFluidList_sS = tFluidList.size();
- } else {
- tFluidList.remove(i--);
- tFluidList_sS = tFluidList.size();
- break;
+ tInputList.add(mInventory[1]);
+ ItemStack[] inputs = tInputList.toArray(new ItemStack[0]);
+
+ ArrayList<FluidStack> tFluidList = getStoredFluids();
+ int tFluidList_sS = tFluidList.size();
+ for (int i = 0; i < tFluidList_sS - 1; i++) {
+ for (int j = i + 1; j < tFluidList_sS; j++) {
+ if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) {
+ if (tFluidList.get(i).amount >= tFluidList.get(j).amount) {
+ tFluidList.remove(j--);
+ tFluidList_sS = tFluidList.size();
+ } else {
+ tFluidList.remove(i--);
+ tFluidList_sS = tFluidList.size();
+ break;
+ }
}
}
}
- }
- FluidStack[] fluids = tFluidList.toArray(new FluidStack[0]);
+ FluidStack[] fluids = tFluidList.toArray(new FluidStack[0]);
+
+ if (inputs.length == 0 && fluids.length == 0) {
+ return false;
+ }
- if (inputs.length > 0 || fluids.length > 0) {
- long tVoltage = getMaxInputVoltage();
- byte tier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
- GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.findRecipe(getBaseMetaTileEntity(), false,
+ GT_Single_Recipe_Check.Builder tSingleRecipeCheckBuilder = null;
+ if (mLockedToSingleRecipe) {
+ // We're locked to a single recipe, but haven't built the recipe checker yet.
+ // Build the checker on next successful recipe.
+ tSingleRecipeCheckBuilder = GT_Single_Recipe_Check.builder(this).setBefore();
+ }
+
+ tRecipe = GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.findRecipe(getBaseMetaTileEntity(), false,
false, gregtech.api.enums.GT_Values.V[tier], fluids, inputs);
- if (tRecipe != null && tRecipe.isRecipeInputEqual(true, fluids, inputs)) {
- this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
- this.mEfficiencyIncrease = 10000;
-
- calculatePerfectOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage);
- //In case recipe is too OP for that machine
- if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
- return false;
- if (this.mEUt > 0) {
- this.mEUt = (-this.mEUt);
- }
- this.mOutputItems = tRecipe.mOutputs;
- this.mOutputFluids = tRecipe.mFluidOutputs;
- this.updateSlots();
- return true;
+ if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, fluids, inputs)) {
+ return false;
+ }
+
+ if (mLockedToSingleRecipe) {
+ mSingleRecipeCheck = tSingleRecipeCheckBuilder.setAfter().setRecipe(tRecipe).build();
}
}
- return false;
+
+ this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+
+ calculatePerfectOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage);
+ //In case recipe is too OP for that machine
+ if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
+ return false;
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
+ }
+
+ this.mOutputItems = tRecipe.mOutputs;
+ this.mOutputFluids = tRecipe.mFluidOutputs;
+ this.updateSlots();
+ return true;
}
@Override
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java
index eab4e9c896..61fb394841 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java
@@ -114,7 +114,7 @@ public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEn
@Override
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
- return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID));
+ return (GregTech_API.getCoverBehaviorNew(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID));
}
@Override
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java
index ad0f5bd7f8..a48f63c60a 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java
@@ -19,6 +19,7 @@ import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_ProcessingArray_Manager;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.GT_Single_Recipe_Check_Processing_Array;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -145,7 +146,16 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu
}
@Override
+ public boolean supportsSingleRecipeLocking() {
+ return true;
+ }
+
+ @Override
public boolean checkRecipe(ItemStack aStack) {
+ if (mLockedToSingleRecipe && mSingleRecipeCheck != null) {
+ return processLockedRecipe();
+ }
+
if (!isCorrectMachinePart(mInventory[1])) {
return false;
}
@@ -228,6 +238,15 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu
return false;
}
+ public boolean processLockedRecipe() {
+ GT_Single_Recipe_Check_Processing_Array tSingleRecipeCheck = (GT_Single_Recipe_Check_Processing_Array) mSingleRecipeCheck;
+
+ int machines = Math.min(64, mInventory[1].stackSize << mMult); //Upped max Cap to 64
+ int parallel = tSingleRecipeCheck.checkRecipeInputs(true, machines);
+
+ return processRecipeOutputs(tSingleRecipeCheck.getRecipe(), tSingleRecipeCheck.getRecipeAmperage(), parallel);
+ }
+
public boolean processRecipe(ItemStack[] tInputs, FluidStack[] tFluids, GT_Recipe.GT_Recipe_Map map) {
if (tInputs.length <= 0 && tFluids.length <= 0) return false;
GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
@@ -236,54 +255,77 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu
!isValidForLowGravity(tRecipe, getBaseMetaTileEntity().getWorld().provider.dimensionId))
return false;
+ GT_Single_Recipe_Check_Processing_Array.Builder tSingleRecipeCheckBuilder = null;
+ if (mLockedToSingleRecipe) {
+ // We're locked to a single recipe, but haven't built the recipe checker yet.
+ // Build the checker on next successful recipe.
+ tSingleRecipeCheckBuilder = GT_Single_Recipe_Check_Processing_Array.processingArrayBuilder(this).setBefore();
+ }
+
+ boolean recipeLocked = false;
mLastRecipe = tRecipe;
- this.mEUt = 0;
- this.mOutputItems = null;
- this.mOutputFluids = null;
int machines = Math.min(64, mInventory[1].stackSize << mMult); //Upped max Cap to 64
int i = 0;
for (; i < machines; i++) {
if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) {
- if (i == 0) {
- return false;
- }
break;
+ } else if (mLockedToSingleRecipe && !recipeLocked) {
+ // We want to lock to a single run of the recipe.
+ mSingleRecipeCheck =
+ tSingleRecipeCheckBuilder
+ .setAfter()
+ .setRecipe(tRecipe)
+ .setRecipeAmperage(map.mAmperage)
+ .build();
+ recipeLocked = true;
}
}
- this.mMaxProgresstime = tRecipe.mDuration;
+
+ return processRecipeOutputs(tRecipe, map.mAmperage, i);
+ }
+
+ public boolean processRecipeOutputs(GT_Recipe aRecipe, int aAmperage, int parallel) {
+ this.mEUt = 0;
+ this.mOutputItems = null;
+ this.mOutputFluids = null;
+ if (parallel == 0) {
+ return false;
+ }
+
+ this.mMaxProgresstime = aRecipe.mDuration;
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
- calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, map.mAmperage, GT_Values.V[tTier]);
+ calculateOverclockedNessMulti(aRecipe.mEUt, aRecipe.mDuration, aAmperage, GT_Values.V[tTier]);
//In case recipe is too OP for that machine
if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
return false;
- this.mEUt = GT_Utility.safeInt(((long) this.mEUt * i) >> mMult, 1);
+ this.mEUt = GT_Utility.safeInt(((long) this.mEUt * parallel) >> mMult, 1);
if (mEUt == Integer.MAX_VALUE - 1)
return false;
if (this.mEUt > 0) {
this.mEUt = (-this.mEUt);
}
- ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length];
- for (int h = 0; h < tRecipe.mOutputs.length; h++) {
- if (tRecipe.getOutput(h) != null) {
- tOut[h] = tRecipe.getOutput(h).copy();
+ ItemStack[] tOut = new ItemStack[aRecipe.mOutputs.length];
+ for (int h = 0; h < aRecipe.mOutputs.length; h++) {
+ if (aRecipe.getOutput(h) != null) {
+ tOut[h] = aRecipe.getOutput(h).copy();
tOut[h].stackSize = 0;
}
}
FluidStack tFOut = null;
- if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy();
+ if (aRecipe.getFluidOutput(0) != null) tFOut = aRecipe.getFluidOutput(0).copy();
for (int f = 0; f < tOut.length; f++) {
- if (tRecipe.mOutputs[f] != null && tOut[f] != null) {
- for (int g = 0; g < i; g++) {
- if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f))
- tOut[f].stackSize += tRecipe.mOutputs[f].stackSize;
+ if (aRecipe.mOutputs[f] != null && tOut[f] != null) {
+ for (int g = 0; g < parallel; g++) {
+ if (getBaseMetaTileEntity().getRandomNumber(10000) < aRecipe.getOutputChance(f))
+ tOut[f].stackSize += aRecipe.mOutputs[f].stackSize;
}
}
}
if (tFOut != null) {
int tSize = tFOut.amount;
- tFOut.amount = tSize * i;
+ tFOut.amount = tSize * parallel;
}
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
this.mOutputItems = Arrays.stream(tOut)
@@ -353,8 +395,13 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu
@Override
public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- mSeparate = !mSeparate;
- GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + mSeparate);
+ if (aPlayer.isSneaking()) {
+ // Lock to single recipe
+ super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
+ } else {
+ mSeparate = !mSeparate;
+ GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + mSeparate);
+ }
}
@Override
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
index ae96b82a23..9542c54ce0 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java
@@ -16,6 +16,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMul
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Single_Recipe_Check;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -129,19 +130,45 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu
}
@Override
- public boolean checkRecipe(ItemStack aStack) {
- ItemStack[] tInputs = getCompactedInputs();
- FluidStack[] tFluids = getCompactedFluids();
-
- if (tInputs.length <= 0)
- return false;
+ public boolean supportsSingleRecipeLocking() {
+ return true;
+ }
+ @Override
+ public boolean checkRecipe(ItemStack aStack) {
long tVoltage = getMaxInputVoltage();
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
- GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
+ GT_Recipe tRecipe;
- if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs))
- return false;
+ if (mLockedToSingleRecipe && mSingleRecipeCheck != null) {
+ if (!mSingleRecipeCheck.checkRecipeInputsSingleStack(true)) {
+ return false;
+ }
+
+ tRecipe = mSingleRecipeCheck.getRecipe();
+ } else {
+ ItemStack[] tInputs = getCompactedInputs();
+ FluidStack[] tFluids = getCompactedFluids();
+
+ if (tInputs.length <= 0)
+ return false;
+
+ GT_Single_Recipe_Check.Builder tSingleRecipeCheckBuilder = null;
+ if (mLockedToSingleRecipe) {
+ // We're locked to a single recipe, but haven't built the recipe checker yet.
+ // Build the checker on next successful recipe.
+ tSingleRecipeCheckBuilder = GT_Single_Recipe_Check.builder(this).setBefore();
+ }
+
+ tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
+
+ if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs))
+ return false;
+
+ if (mLockedToSingleRecipe) {
+ mSingleRecipeCheck = tSingleRecipeCheckBuilder.setAfter().setRecipe(tRecipe).build();
+ }
+ }
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java
index 7110ed20f9..c7bd5d0029 100644
--- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java
+++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java
@@ -34,7 +34,8 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti
super(aID, aName, aNameRegional, aTier, 3, new String[]{
"This Chest stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + " Blocks",
"Use a screwdriver to enable",
- "voiding items on overflow"
+ "voiding items on overflow",
+ "Can keep its contents when harvested"
});
}
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java
index 20d333783e..ca3289e218 100644
--- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java
+++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java
@@ -3,11 +3,16 @@ package gregtech.common.tileentities.storage;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
public class GT_MetaTileEntity_QuantumChest extends GT_MetaTileEntity_DigitalChestBase {
public int mItemCount = 0;
public ItemStack mItemStack = null;
+ NBTTagList mInvData = null;
+
public GT_MetaTileEntity_QuantumChest(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier);
}
@@ -24,16 +29,53 @@ public class GT_MetaTileEntity_QuantumChest extends GT_MetaTileEntity_DigitalChe
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_QuantumChest(mName, mTier, mDescriptionArray, mTextures);
}
+
@Override
- protected String chestName(){ return "Quantum Chest"; }
+ public void setItemNBT(NBTTagCompound aNBT) {
+ mInvData = new NBTTagList();
+ for (int i = 0; i < 3; i++) {
+ if (mInventory[i] != null) {
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setByte("Count", (byte) mInventory[i].stackSize);
+ tNBT.setShort("Damage", (short) mInventory[i].getItemDamage());
+ tNBT.setShort("id", (short) Item.getIdFromItem(mInventory[i].getItem()));
+ tNBT.setInteger("IntSlot", i);
+ if (mInventory[i].hasTagCompound()) {
+ tNBT.setTag("tag", mInventory[i].getTagCompound());
+ }
+ mInvData.appendTag(tNBT);
+ }
+ }
+ if (mItemStack != null)
+ aNBT.setTag("mItemStack", getItemStack().writeToNBT(new NBTTagCompound()));
+ aNBT.setTag("Inventory", mInvData);
+ aNBT.setInteger("mItemCount", getItemCount());
+ aNBT.setBoolean("mVoidOverflow", mVoidOverflow);
+ super.setItemNBT(aNBT);
+ }
+
@Override
- protected int getItemCount() { return mItemCount; }
+ protected String chestName() {
+ return "Quantum Chest";
+ }
+
+ @Override
+ protected int getItemCount() {
+ return mItemCount;
+ }
+
@Override
public void setItemCount(int aCount) {
mItemCount = aCount;
}
+
@Override
- protected ItemStack getItemStack(){ return mItemStack; }
+ protected ItemStack getItemStack() {
+ return mItemStack;
+ }
+
@Override
- protected void setItemStack(ItemStack s){ mItemStack = s; }
+ protected void setItemStack(ItemStack s) {
+ mItemStack = s;
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java
index ea935f1360..1637a126e4 100644
--- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java
+++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java
@@ -7,6 +7,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
@@ -16,8 +17,10 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW;
public class GT_MetaTileEntity_QuantumTank extends GT_MetaTileEntity_BasicTank {
public GT_MetaTileEntity_QuantumTank(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, 3,
- "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid");
+ super(aID, aName, aNameRegional, aTier, 3, new String[]{
+ "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid",
+ "Can keep its contents when harvested"
+ });
}
private static int commonSizeCompute(int tier) {
@@ -51,6 +54,13 @@ public class GT_MetaTileEntity_QuantumTank extends GT_MetaTileEntity_BasicTank {
}
@Override
+ public void setItemNBT(NBTTagCompound aNBT) {
+ if (mFluid != null && mFluid.amount > 0)
+ aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound()));
+ super.setItemNBT(aNBT);
+ }
+
+ @Override
public boolean isSimpleMachine() {
return true;
}
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java
index e566ba9ed5..4614cc409e 100644
--- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java
+++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java
@@ -3,11 +3,15 @@ package gregtech.common.tileentities.storage;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
public class GT_MetaTileEntity_SuperChest extends GT_MetaTileEntity_DigitalChestBase {
public int mItemCount = 0;
public ItemStack mItemStack = null;
+ NBTTagList mInvData = null;
public GT_MetaTileEntity_SuperChest(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier);
@@ -22,6 +26,30 @@ public class GT_MetaTileEntity_SuperChest extends GT_MetaTileEntity_DigitalChest
}
@Override
+ public void setItemNBT(NBTTagCompound aNBT) {
+ mInvData = new NBTTagList();
+ for (int i = 0; i < 3; i++) {
+ if (mInventory[i] != null) {
+ NBTTagCompound tNBT = new NBTTagCompound();
+ tNBT.setByte("Count", (byte) mInventory[i].stackSize);
+ tNBT.setShort("Damage", (short) mInventory[i].getItemDamage());
+ tNBT.setShort("id", (short) Item.getIdFromItem(mInventory[i].getItem()));
+ tNBT.setInteger("IntSlot", i);
+ if (mInventory[i].hasTagCompound()) {
+ tNBT.setTag("tag", mInventory[i].getTagCompound());
+ }
+ mInvData.appendTag(tNBT);
+ }
+ }
+ if (mItemStack != null)
+ aNBT.setTag("mItemStack", getItemStack().writeToNBT(new NBTTagCompound()));
+ aNBT.setTag("Inventory", mInvData);
+ aNBT.setInteger("mItemCount", getItemCount());
+ aNBT.setBoolean("mVoidOverflow", mVoidOverflow);
+ super.setItemNBT(aNBT);
+ }
+
+ @Override
protected ItemStack getItemStack() {
return mItemStack;
}
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java
index edb69abb20..1aa9f98d82 100644
--- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java
+++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java
@@ -7,6 +7,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
@@ -16,8 +17,10 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW;
public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank {
public GT_MetaTileEntity_SuperTank(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, 3,
- "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid");
+ super(aID, aName, aNameRegional, aTier, 3, new String[]{
+ "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid",
+ "Can keep its contents when harvested"
+ });
}
private static int commonSizeCompute(int tier) {
@@ -51,6 +54,13 @@ public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank {
}
@Override
+ public void setItemNBT(NBTTagCompound aNBT) {
+ if (mFluid != null && mFluid.amount > 0)
+ aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound()));
+ super.setItemNBT(aNBT);
+ }
+
+ @Override
public boolean isSimpleMachine() {
return true;
}