diff options
Diffstat (limited to 'src')
8 files changed, 437 insertions, 54 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java index 42eeada394..471373e3dd 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java @@ -397,8 +397,9 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { this.getBaseMetaTileEntity().setActive(true); long finishedTime = System.nanoTime(); + //System.out.println("LESU LookUp: "+((finishedTime - startingTime) / 1000000)+"ms"); if (finishedTime - startingTime > 5000000) - MainMod.LOGGER.warn("LESU LookUp took longer than 5ms!(" + (finishedTime - startingTime) + "ns / " + ((finishedTime - startingTime) / 1000000) + "ms) Check at x:" + this.getBaseMetaTileEntity().getXCoord() + " y:" + this.getBaseMetaTileEntity().getYCoord() + " z:" + this.getBaseMetaTileEntity().getZCoord() + " DIM-ID: " + this.getBaseMetaTileEntity().getWorld().provider.dimensionId); + MainMod.LOGGER.warn("LESU LookUp took longer than 5ms!(" + (finishedTime - startingTime) + "ns / " + ((finishedTime - startingTime) / 1000000) + "ms) Owner:"+this.getBaseMetaTileEntity().getOwnerName()+" Check at x:" + this.getBaseMetaTileEntity().getXCoord() + " y:" + this.getBaseMetaTileEntity().getYCoord() + " z:" + this.getBaseMetaTileEntity().getZCoord() + " DIM-ID: " + this.getBaseMetaTileEntity().getWorld().provider.dimensionId); return true; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java index 501069b25d..193a1ffacb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java @@ -41,6 +41,7 @@ import gregtech.api.objects.XSTR; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; @@ -57,6 +58,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { private int HeliumSupply; private int BISOPeletSupply; private int TRISOPeletSupply; + private boolean empty; public GT_TileEntity_THTR(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -77,6 +79,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { HeliumSupply=aNBT.getInteger("HeliumSupply"); BISOPeletSupply=aNBT.getInteger("BISOPeletSupply"); TRISOPeletSupply=aNBT.getInteger("TRISOPeletSupply"); + empty=aNBT.getBoolean("EmptyMode"); } @Override @@ -85,6 +88,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { aNBT.setInteger("HeliumSupply",HeliumSupply); aNBT.setInteger("BISOPeletSupply",BISOPeletSupply); aNBT.setInteger("TRISOPeletSupply",TRISOPeletSupply); + aNBT.setBoolean("EmptyMode",empty); } @Override @@ -155,6 +159,17 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { @Override public boolean onRunningTick(ItemStack aStack) { + + if (empty){ + this.addOutput(Materials.Helium.getGas(HeliumSupply)); + this.addOutput(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, TRISOPeletSupply, 3)); + this.addOutput(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, BISOPeletSupply, 1)); + this.HeliumSupply = 0; + this.TRISOPeletSupply = 0; + this.BISOPeletSupply = 0; + return true; + } + long accessibleCoolant = 0; long toProduce=0; for (FluidStack fluidStack : this.getStoredFluids()) { @@ -198,16 +213,17 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 4; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 4; - for (int x = -4; x <= 4; x++) { - for (int z = -4; z <= 4; z++) { + final byte xz = 5; + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * xz; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * xz; + for (int x = -xz; x <= xz; x++) { + for (int z = -xz; z <= xz; z++) { for (int y = 0; y < 12; y++) { if (y == 0 || y == 11) { if ( - !((Math.abs(z) == 3 && Math.abs(x) == 4)) && - !((Math.abs(z) == 4 && Math.abs(x) == 3)) && - !((Math.abs(x) == Math.abs(z) && Math.abs(x) == 4)) + !((Math.abs(z) == xz-1 && Math.abs(x) == xz)) && + !((Math.abs(z) == xz && Math.abs(x) == xz-1)) && + !((Math.abs(x) == Math.abs(z) && Math.abs(x) == xz)) ) { if (x + xDir == 0 && y == 0 && z + zDir == 0) continue; @@ -223,10 +239,18 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { } } } - else if (!((Math.abs(x) == 4 && Math.abs(z) == 4) || (Math.abs(x) == 3 && Math.abs(z) == 3)) && !(Math.abs(x) < 3 || Math.abs(z) < 3) && !((Math.abs(x) == Math.abs(z) && Math.abs(x) == 3) || Math.abs(x) == 4 || Math.abs(z) == 4)) { - if (!(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 12)) { + + +// else if (!((Math.abs(x) == 4 && Math.abs(z) == 4) || (Math.abs(x) == 3 && Math.abs(z) == 3)) && !(Math.abs(x) < 3 || Math.abs(z) < 3) && !((Math.abs(x) == Math.abs(z) && Math.abs(x) == 3) || Math.abs(x) == 4 || Math.abs(z) == 4)) { + else if (!((Math.abs(z) == xz-1 && Math.abs(x) == xz))) + if (!((Math.abs(z) == xz && Math.abs(x) == xz-1))) + if (!((Math.abs(x) == Math.abs(z) && Math.abs(x) == xz))) + if (!(Math.abs(x) < xz && Math.abs(z) != xz)) + + { + if (!(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 12)) { if ( - !this.addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), BASECASINGINDEX)) + !this.addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), BASECASINGINDEX)) { return false; } @@ -237,10 +261,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { } - if (this.mMaintenanceHatches.size() != 1) - return false; - - return true; + return this.mMaintenanceHatches.size() == 1; } @Override @@ -276,7 +297,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { "BISO-Pebbles:", this.BISOPeletSupply + "pcs.", "TRISO-Pebbles:", this.TRISOPeletSupply + "pcs.", "Helium-Level:", this.HeliumSupply+"L / "+HELIUM_NEEDED+"L", - "Coolant/sec:", this.BISOPeletSupply+this.TRISOPeletSupply >= 100000 ? (long) ((0.03471*(float)this.TRISOPeletSupply + 0.0267*(float)this.BISOPeletSupply))+"L/t" : "0L/t", + "Coolant/t:", this.BISOPeletSupply+this.TRISOPeletSupply >= 100000 ? (long) ((0.03471*(float)this.TRISOPeletSupply + 0.0267*(float)this.BISOPeletSupply))+"L/t" : "0L/t", "Problems:", String.valueOf(this.getIdealStatus() - this.getRepairStatus()) }; } @@ -297,6 +318,11 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { return aSide == aFacing ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[BASECASINGINDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)} : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[BASECASINGINDEX]}; } + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + empty = !empty; + GT_Utility.sendChatToPlayer(aPlayer,empty ? "THTR will now empty itself." : "THTR is back in normal Operation"); + } public static class THTRMaterials{ static final SimpleSubItemClass aTHTR_Materials = new SimpleSubItemClass("BISOPelletCompound","BISOPellet","TRISOPelletCompound","TRISOPellet","BISOPelletBall","TRISOPelletBall"); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java index e1502041ed..1a0f189fd7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java @@ -29,22 +29,17 @@ import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; import java.util.HashSet; +import java.util.LinkedHashSet; public class ConnectedBlocksChecker { - public final HashSet<Coords> hashset = new HashSet<Coords>(); + public final HashSet<Coords> hashset = new HashSet<Coords>(2048); public static byte check_sourroundings(Coords C, Block b) { byte ret = 0; World w = DimensionManager.getWorld(C.wID); int x = C.x, y = C.y, z = C.z; - if (w.getBlock(x, y + 1, z).equals(b)) - ret = (byte) (ret | 0b000001); - - if (w.getBlock(x, y - 1, z).equals(b)) - ret = (byte) (ret | 0b000010); - if (w.getBlock(x + 1, y, z).equals(b)) ret = (byte) (ret | 0b000100); @@ -57,6 +52,13 @@ public class ConnectedBlocksChecker { if (w.getBlock(x, y, z - 1).equals(b)) ret = (byte) (ret | 0b100000); + if (w.getBlock(x, y + 1, z).equals(b)) + ret = (byte) (ret | 0b000001); + + if (w.getBlock(x, y - 1, z).equals(b)) + ret = (byte) (ret | 0b000010); + + return ret; } @@ -67,16 +69,6 @@ public class ConnectedBlocksChecker { byte sides = check_sourroundings(w, x, y, z, b); - if (((sides | 0b111110) == 0b111111) && !hashset.contains(new Coords(x, y + 1, z, wID))) { - ret++; - ret += get_connected(w, x, y + 1, z, b); - } - - if (((sides | 0b111101) == 0b111111) && !hashset.contains(new Coords(x, y - 1, z, wID))) { - ret++; - ret += get_connected(w, x, y - 1, z, b); - } - if (((sides | 0b111011) == 0b111111) && !hashset.contains(new Coords(x + 1, y, z, wID))) { ret++; ret += get_connected(w, x + 1, y, z, b); @@ -97,6 +89,17 @@ public class ConnectedBlocksChecker { ret += get_connected(w, x, y, z - 1, b); } + + if (((sides | 0b111110) == 0b111111) && !hashset.contains(new Coords(x, y + 1, z, wID))) { + ret++; + ret += get_connected(w, x, y + 1, z, b); + } + + if (((sides | 0b111101) == 0b111111) && !hashset.contains(new Coords(x, y - 1, z, wID))) { + ret++; + ret += get_connected(w, x, y - 1, z, b); + } + return ret; } @@ -110,12 +113,6 @@ public class ConnectedBlocksChecker { hashset.add(new Coords(x, y, z, wID)); - if (w.getBlock(x, y + 1, z).equals(b)) - ret = (byte) (ret | 0b000001); - - if (w.getBlock(x, y - 1, z).equals(b)) - ret = (byte) (ret | 0b000010); - if (w.getBlock(x + 1, y, z).equals(b)) ret = (byte) (ret | 0b000100); @@ -128,6 +125,12 @@ public class ConnectedBlocksChecker { if (w.getBlock(x, y, z - 1).equals(b)) ret = (byte) (ret | 0b100000); + if (w.getBlock(x, y + 1, z).equals(b)) + ret = (byte) (ret | 0b000001); + + if (w.getBlock(x, y - 1, z).equals(b)) + ret = (byte) (ret | 0b000010); + return ret; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java new file mode 100644 index 0000000000..707b374888 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksCheckerIteration.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Queue; + + +/** + * This implementation is for some reason slower than the Recursive Check.... + * For ~3400 blocks this takes 8ms, the Recursive Check 5ms. + */ +public class ConnectedBlocksCheckerIteration { + + public final HashSet<Coords> hashset = new HashSet<Coords>(2048); + public final HashSet<Coords> checked = new HashSet<Coords>(4096); + private final Queue<Coords> kwoe = new LinkedList<Coords>(); + + public long get_connected(World w, int x, int y, int z, Block b){ + kwoe.add(new Coords(x,y,z,w.provider.dimensionId)); + hashset.add(new Coords(x,y,z,w.provider.dimensionId)); + while (!kwoe.isEmpty()){ + Coords tocheck = kwoe.poll(); + int wID = w.provider.dimensionId; + checked.add(tocheck); + Coords c; + if (!checked.contains(c = new Coords(tocheck.x + 1, tocheck.y, tocheck.z, wID)) && w.getBlock(tocheck.x + 1, tocheck.y, tocheck.z).equals(b)) { + kwoe.add(c); + hashset.add(c); + } + if (!checked.contains(c = new Coords(tocheck.x - 1, tocheck.y, tocheck.z, wID)) && w.getBlock(tocheck.x - 1, tocheck.y, tocheck.z).equals(b)) { + kwoe.add(c); + hashset.add(c); + } + if (!checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z + 1, wID)) && w.getBlock(tocheck.x, tocheck.y, tocheck.z + 1).equals(b)) { + kwoe.add(c); + hashset.add(c); + } + if (!checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z - 1, wID)) && w.getBlock(tocheck.x, tocheck.y, tocheck.z - 1).equals(b)) { + kwoe.add(c); + hashset.add(c); + } + if (!checked.contains(c = new Coords(tocheck.x, tocheck.y + 1, tocheck.z, wID)) && w.getBlock(tocheck.x, tocheck.y + 1, tocheck.z).equals(b)) { + kwoe.add(c); + hashset.add(c); + } + if (!checked.contains(c = new Coords(tocheck.x, tocheck.y - 1, tocheck.z, wID)) && w.getBlock(tocheck.x, tocheck.y - 1, tocheck.z).equals(b)) { + kwoe.add(c); + hashset.add(c); + } + } + return hashset.size(); + } + + public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { + + int wID = w.provider.dimensionId; + Coords Controller = new Coords(xyz[0], xyz[1], xyz[2], wID); + + for (Coords C : hashset) { + if (GT) { + TileEntity t; + t = w.getTileEntity(C.x, C.y + 1, C.z); + if (t != null && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) { + if (t instanceof IGregTechTileEntity) + if (((IGregTechTileEntity) t).getMetaTileID() == n) + return true; + } + t = w.getTileEntity(C.x, C.y - 1, C.z); + if (t != null && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { + if (t instanceof IGregTechTileEntity) + if (((IGregTechTileEntity) t).getMetaTileID() == n) + return true; + } + t = w.getTileEntity(C.x + 1, C.y, C.z); + if (t != null && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { + if (t instanceof IGregTechTileEntity) + if (((IGregTechTileEntity) t).getMetaTileID() == n) + return true; + } + t = w.getTileEntity(C.x - 1, C.y, C.z); + if (t != null && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { + if (t instanceof IGregTechTileEntity) + if (((IGregTechTileEntity) t).getMetaTileID() == n) + return true; + } + t = w.getTileEntity(C.x, C.y, C.z + 1); + if (t != null && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { + if (t instanceof IGregTechTileEntity) + if (((IGregTechTileEntity) t).getMetaTileID() == n) + return true; + } + t = w.getTileEntity(C.x, C.y, C.z - 1); + if (t != null && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { + if (t instanceof IGregTechTileEntity) + if (((IGregTechTileEntity) t).getMetaTileID() == n) + return true; + } + } else { + if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) + return true; + if (n == w.getBlockMetadata(C.x, C.y - 1, C.z) && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) + return true; + if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) + return true; + if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) + return true; + if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) + return true; + if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) + return true; + } + } + return false; + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java index f285b7b6e2..c27054eb01 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java @@ -55,20 +55,20 @@ public class Coords { @Override public int hashCode() { byte[] data = new byte[14]; - data[0] = (byte) (this.x & 0b1111); - data[1] = (byte) (this.x >> 4 & 0b1111); - data[2] = (byte) (this.x >> 8 & 0b1111); - data[3] = (byte) (this.x >> 12 & 0b1111); - data[4] = (byte) (this.y & 0b1111); - data[5] = (byte) (this.y >> 4 & 0b1111); - data[6] = (byte) (this.z & 0b1111); - data[7] = (byte) (this.z >> 4 & 0b1111); - data[8] = (byte) (this.z >> 8 & 0b1111); - data[9] = (byte) (this.z >> 12 & 0b1111); - data[10] = (byte) (this.wID & 0b1111); - data[11] = (byte) (this.wID >> 4 & 0b1111); - data[12] = (byte) (this.wID >> 8 & 0b1111); - data[13] = (byte) (this.wID >> 12 & 0b1111); + data[0] = (byte) (this.x & 0xff); + data[1] = (byte) (this.x >> 4 & 0xff); + data[2] = (byte) (this.x >> 8 & 0xff); + data[3] = (byte) (this.x >> 12 & 0xff); + data[4] = (byte) (this.y & 0xff); + data[5] = (byte) (this.y >> 4 & 0xff); + data[6] = (byte) (this.z & 0xff); + data[7] = (byte) (this.z >> 4 & 0xff); + data[8] = (byte) (this.z >> 8 & 0xff); + data[9] = (byte) (this.z >> 12 & 0xff); + data[10] = (byte) (this.wID & 0xff); + data[11] = (byte) (this.wID >> 4 & 0xff); + data[12] = (byte) (this.wID >> 8 & 0xff); + data[13] = (byte) (this.wID >> 12 & 0xff); return MurmurHash3.murmurhash3_x86_32(data, 0, 14, 31); } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java new file mode 100644 index 0000000000..4974a5725d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.openComputers; + +import net.minecraft.nbt.NBTTagCompound; + +import java.util.HashMap; + +public class GT_NBT_DataBase { + + private static HashMap<NBTTagCompound, Long> tagToIdMap = new HashMap<>(); + + private static long maxID = Long.MIN_VALUE+1; + + private final NBTTagCompound tagCompound; + + private final String mDataName; + private final String mDataTitle; + private long id; + + GT_NBT_DataBase(String mDataName, String mDataTitle, NBTTagCompound tagCompound) { + this.mDataName = mDataName; + this.mDataTitle = mDataTitle; + this.tagCompound = tagCompound; + this.id = GT_NBT_DataBase.maxID; + GT_NBT_DataBase.tagToIdMap.put(tagCompound,id); + ++GT_NBT_DataBase.maxID; + } + + static Long getIdFromTag(NBTTagCompound tagCompound){ + return GT_NBT_DataBase.tagToIdMap.get(tagCompound); + } + + public NBTTagCompound getTagCompound() { + return this.tagCompound; + } + + public String getmDataName() { + return this.mDataName; + } + + static long getMaxID() { + return GT_NBT_DataBase.maxID; + } + + public String getmDataTitle() { + return this.mDataTitle; + } + + public long getId() { + return this.id; + } + + public void setId(long id) { + this.id = id; + } + + private GT_NBT_DataBase(NBTTagCompound tagCompound, String mDataName, String mDataTitle, long id) { + this.tagCompound = tagCompound; + this.mDataName = mDataName; + this.mDataTitle = mDataTitle; + this.id = id; + } + + public static GT_NBT_DataBase makeNewWithoutRegister(String mDataName, String mDataTitle, NBTTagCompound tagCompound){ + return new GT_NBT_DataBase(tagCompound,mDataName,mDataTitle,Long.MIN_VALUE); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java new file mode 100644 index 0000000000..635ceb9fee --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.openComputers; + +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; +import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import java.util.HashMap; + +//@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers") +public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, ITileAddsInformation, ITileHasDifferentTextureSides/*, SimpleComponent*/ { + + private static HashMap<Long,GT_NBT_DataBase> OrbDataBase = new HashMap<>(); + + private ItemStack[] mItems = new ItemStack[2]; + + + private byte TickTimer = 0; + + public String getComponentName() { + return "GT-Data Server"; + } + +// @Callback +// @Optional.Method(modid = "OpenComputers") +// public Object[] listData(Context context, Arguments args) { +// return new String[] +// } + + private boolean isServerSide(){ + return !this.worldObj.isRemote || FMLCommonHandler.instance().getSide().isServer(); + } + + + @Override + public void updateEntity() { + if (this.TickTimer++ % 20 != 0) + return; + + if (this.isServerSide()) { + if (GT_Utility.areStacksEqual(this.mItems[0],ItemList.Tool_DataOrb.get(1))) { + if (this.mItems[0].hasTagCompound()) { + if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { + TileEntity_GTDataServer.OrbDataBase.put( + GT_NBT_DataBase.getMaxID(), + new GT_NBT_DataBase( + Behaviour_DataOrb.getDataName(this.mItems[0]), + Behaviour_DataOrb.getDataTitle(this.mItems[0]), + this.mItems[0].getTagCompound() + ) + ); + } + } + } + if (GT_Utility.areStacksEqual(this.mItems[0],ItemList.Tool_DataStick.get(1))) { + if (this.mItems[0].hasTagCompound()) { + + String bookTitle = GT_Utility.ItemNBT.getBookTitle(this.mItems[0]); + String punchcardData = GT_Utility.ItemNBT.getPunchCardData(this.mItems[0]); + short mapID = GT_Utility.ItemNBT.getMapID(this.mItems[0]); + byte data = (byte) (bookTitle.isEmpty() ? punchcardData.isEmpty() ? mapID != -1 ? 3 : -1 : 2 : 1); + + String title = data == 1 ? bookTitle : data == 2 ? punchcardData : data == 3 ? ""+mapID : "Custom Data"; + String name = data == 1 ? "eBook" : data == 2 ? "Punch Card Data" : data == 3 ? "Map Data" : "Custom Data"; + if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { + TileEntity_GTDataServer.OrbDataBase.put( + GT_NBT_DataBase.getMaxID(), + new GT_NBT_DataBase( + name, + title, + this.mItems[0].getTagCompound() + ) + ); + } + } + } + } + } + + @Override + public String[] getInfoData() { + return new String[0]; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + + } + + @Override + public int getGUIID() { + return 0; + } +} diff --git a/src/main/resources/assets/bartworks/lang/en_US.lang b/src/main/resources/assets/bartworks/lang/en_US.lang index 73a58a4c64..0388c0cb46 100644 --- a/src/main/resources/assets/bartworks/lang/en_US.lang +++ b/src/main/resources/assets/bartworks/lang/en_US.lang @@ -144,7 +144,7 @@ tile.radiohatch.name=Radio Hatch tile.bw.windmill.name=Windmill tile.manutrafo.name=Manual Trafo -tooltip.tile.htr.0.name=Controller Block for the Thorium High Temperature Reactor;Size(WxHxD): 9x12x9 (Hollow);Corners and the 2 touching blocks are air;Once build, Helium is inserted into the Fluid Input Hatch until it doesnt accept any more;1+ Output Hatch (Any Bottom casing);1+ Input Hatch (Any Top casing);1+ Input Bus (Any Top casing);1x Maintenance Hatch (Any casing);Raidation Proof Casings for the Rest;Needs a constant supply of coolant or will shut down;Needs at least 100k Fuel pebbles to start operation (can hold up to 675k pebbles);Consumes 1 Fuel Pellet per Operation;TRISO pebbles provide 30% more Energy;Each pebble increases the amount of converted coolant;One Operation takes 27 Ingame Days +tooltip.tile.htr.0.name=Controller Block for the Thorium High Temperature Reactor;Size(WxHxD): 11x12x11 (Hollow);Controller: Front Center, Lowest Layer;Corners and the 2 touching blocks are air;Once build, Helium is inserted into the Fluid Input Hatch until it doesnt accept any more;1+ Output Hatch (Any Bottom casing);1+ Input Hatch (Any Top casing);1+ Input Bus (Any Top casing);1x Maintenance Hatch (Any casing);Raidation Proof Casings for the Rest;Needs a constant supply of coolant while running, will output after complete Operation;Needs at least 100k Fuel pebbles to start operation (can hold up to 675k pebbles);Consumes 1 Fuel Pellet per Operation;TRISO pebbles provide 30% more Energy;Each pebble increases the amount of converted coolant;One Operation takes 27 Ingame Days item.TRISOPellet.name=TRISO pebble item.TRISOPelletBall.name=TRISO pebble ball item.BISOPelletBall.name=BISO pebble ball |