From 281015aaf5a3b65dece68f12b559926b8f41d3c9 Mon Sep 17 00:00:00 2001 From: Tec Date: Sun, 19 Apr 2020 22:53:04 +0200 Subject: Fix pipes, implement ExtendedFacing, bump version --- .../com/github/technus/tectech/CommonValues.java | 43 - .../java/com/github/technus/tectech/Converter.java | 59 - .../java/com/github/technus/tectech/TecTech.java | 1 + src/main/java/com/github/technus/tectech/Util.java | 1640 -------------------- .../java/com/github/technus/tectech/Vec3pos.java | 50 - src/main/java/com/github/technus/tectech/XSTR.java | 278 ---- .../dreamcraft/NoDreamCraftMachineLoader.java | 2 +- .../openComputers/AvrArchitecture.java | 2 +- .../blocks/turretbases/TurretBaseItemEM.java | 2 +- .../blocks/turretheads/TurretHeadItemEM.java | 2 +- .../definitions/dComplexAspectDefinition.java | 2 +- .../GT_MetaTileEntity_EM_essentiaDequantizer.java | 10 +- .../GT_MetaTileEntity_EM_essentiaQuantizer.java | 10 +- .../github/technus/tectech/loader/MainLoader.java | 4 +- .../technus/tectech/loader/NetworkDispatcher.java | 8 +- .../tectech/loader/recipe/BloodyRecipeLoader.java | 34 +- .../tectech/loader/thing/MachineLoader.java | 2 +- .../technus/tectech/loader/thing/ThingsLoader.java | 4 +- .../mechanics/alignment/AlignmentLimits.java | 183 +++ .../mechanics/alignment/AlignmentMessage.java | 140 ++ .../tectech/mechanics/alignment/IAlignment.java | 173 +++ .../mechanics/alignment/IAlignmentLimits.java | 19 + .../mechanics/alignment/IntegerAxisSwap.java | 67 + .../mechanics/alignment/enumerable/Direction.java | 34 + .../alignment/enumerable/ExtendedFacing.java | 324 ++++ .../mechanics/alignment/enumerable/Flip.java | 76 + .../mechanics/alignment/enumerable/Rotation.java | 76 + .../tectech/mechanics/anomaly/AnomalyHandler.java | 2 +- .../tectech/mechanics/commands/ConvertFloat.java | 2 +- .../tectech/mechanics/commands/ConvertInteger.java | 2 +- .../mechanics/constructible/IConstructable.java | 15 + .../tectech/mechanics/data/ChunkDataMessage.java | 2 +- .../tectech/mechanics/data/PlayerPersistence.java | 2 +- .../mechanics/dataTransport/DataPacket.java | 22 +- .../mechanics/dataTransport/QuantumDataPacket.java | 4 +- .../core/stacks/cElementalInstanceStack.java | 2 +- .../core/templates/cElementalPrimitive.java | 2 +- .../definitions/complex/dAtomDefinition.java | 6 +- .../definitions/complex/dHadronDefinition.java | 2 +- .../definitions/complex/iaeaNuclide.java | 2 +- .../tectech/mechanics/pipe/IActivePipe.java | 9 + .../mechanics/pipe/IConnectsToDataPipe.java | 14 + .../mechanics/pipe/IConnectsToElementalPipe.java | 8 + .../mechanics/pipe/IConnectsToEnergyTunnel.java | 8 + .../mechanics/pipe/PipeActivityMessage.java | 133 ++ .../tectech/thing/block/QuantumGlassItem.java | 2 +- .../tectech/thing/block/ReactorSimItem.java | 2 +- .../tectech/thing/casing/GT_Item_CasingsBA0.java | 2 +- .../tectech/thing/casing/GT_Item_CasingsTT.java | 4 +- .../tectech/thing/casing/GT_Item_HintTT.java | 2 +- .../thing/item/ConstructableTriggerItem.java | 6 +- .../item/DebugElementalInstanceContainer_EM.java | 4 +- .../item/ElementalDefinitionContainer_EM.java | 4 +- .../item/ElementalDefinitionScanStorage_EM.java | 4 +- .../technus/tectech/thing/item/EuMeterGT.java | 2 +- .../thing/item/FrontRotationTriggerItem.java | 20 +- .../tectech/thing/item/ParametrizerMemoryCard.java | 4 +- .../tectech/thing/item/TeslaCoilCapacitor.java | 4 +- .../tectech/thing/item/TeslaCoilComponent.java | 2 +- .../technus/tectech/thing/item/TeslaCoilCover.java | 2 +- .../technus/tectech/thing/item/TeslaStaff.java | 2 +- .../thing/metaTileEntity/IConstructable.java | 15 - .../thing/metaTileEntity/IFrontRotation.java | 11 - .../thing/metaTileEntity/RotationMessage.java | 139 -- .../hatch/GT_MetaTileEntity_Hatch_Capacitor.java | 8 +- .../GT_MetaTileEntity_Hatch_CreativeData.java | 8 +- ...T_MetaTileEntity_Hatch_CreativeMaintenance.java | 4 +- .../GT_MetaTileEntity_Hatch_DataConnector.java | 8 +- .../hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java | 6 +- .../GT_MetaTileEntity_Hatch_DynamoTunnel.java | 10 +- ...GT_MetaTileEntity_Hatch_ElementalContainer.java | 6 +- .../hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java | 6 +- .../GT_MetaTileEntity_Hatch_EnergyTunnel.java | 21 +- .../hatch/GT_MetaTileEntity_Hatch_Holder.java | 4 +- .../hatch/GT_MetaTileEntity_Hatch_InputData.java | 6 +- .../GT_MetaTileEntity_Hatch_InputDataItems.java | 8 +- .../GT_MetaTileEntity_Hatch_InputElemental.java | 2 +- .../hatch/GT_MetaTileEntity_Hatch_OutputData.java | 6 +- .../GT_MetaTileEntity_Hatch_OutputDataItems.java | 6 +- .../GT_MetaTileEntity_Hatch_OutputElemental.java | 2 +- .../GT_MetaTileEntity_Hatch_OverflowElemental.java | 8 +- .../hatch/GT_MetaTileEntity_Hatch_Param.java | 4 +- .../hatch/GT_MetaTileEntity_Hatch_ParamText.java | 2 +- .../hatch/GT_MetaTileEntity_Hatch_Rack.java | 8 +- .../hatch/GT_MetaTileEntity_Hatch_Uncertainty.java | 4 +- .../hatch/TextParametersMessage.java | 2 +- .../hatch/gui/GT_Container_Param.java | 2 +- .../hatch/gui/GT_Container_ParamAdv.java | 2 +- .../hatch/gui/GT_Container_ParamText.java | 2 +- .../hatch/gui/GT_GUIContainer_Param.java | 2 +- .../hatch/gui/GT_GUIContainer_ParamAdv.java | 2 +- .../hatch/gui/GT_GUIContainer_ParamText.java | 2 +- .../multi/GT_MetaTileEntity_EM_annihilation.java | 12 +- .../multi/GT_MetaTileEntity_EM_bhg.java | 14 +- .../multi/GT_MetaTileEntity_EM_collider.java | 16 +- .../multi/GT_MetaTileEntity_EM_computer.java | 28 +- .../multi/GT_MetaTileEntity_EM_crafting.java | 12 +- .../multi/GT_MetaTileEntity_EM_dataBank.java | 14 +- .../multi/GT_MetaTileEntity_EM_decay.java | 14 +- .../multi/GT_MetaTileEntity_EM_dequantizer.java | 10 +- .../multi/GT_MetaTileEntity_EM_infuser.java | 8 +- .../multi/GT_MetaTileEntity_EM_junction.java | 10 +- .../multi/GT_MetaTileEntity_EM_quantizer.java | 12 +- .../multi/GT_MetaTileEntity_EM_research.java | 16 +- .../multi/GT_MetaTileEntity_EM_scanner.java | 14 +- .../multi/GT_MetaTileEntity_EM_stabilizer.java | 8 +- .../multi/GT_MetaTileEntity_EM_switch.java | 18 +- .../multi/GT_MetaTileEntity_EM_transformer.java | 12 +- .../multi/GT_MetaTileEntity_EM_wormhole.java | 12 +- .../multi/GT_MetaTileEntity_TM_microwave.java | 36 +- .../GT_MetaTileEntity_TM_proccessingStack.java | 8 +- .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 114 +- .../multi/base/GT_Container_MultiMachineEM.java | 2 +- .../base/GT_MetaTileEntity_MultiblockBase_EM.java | 429 +---- .../render/TT_RenderedExtendedFacingTexture.java | 893 +++++++++++ .../multi/base/render/TT_RenderedTexture.java | 769 --------- .../multi/em_machine/Behaviour_Centrifuge.java | 2 +- .../Behaviour_ElectromagneticSeparator.java | 2 +- .../multi/em_machine/Behaviour_Recycler.java | 2 +- .../em_machine/GT_MetaTileEntity_EM_machine.java | 10 +- .../pipe/GT_MetaTileEntity_Pipe_Data.java | 40 +- .../pipe/GT_MetaTileEntity_Pipe_EM.java | 40 +- .../pipe/GT_MetaTileEntity_Pipe_Energy.java | 40 +- .../thing/metaTileEntity/pipe/IActivePipe.java | 9 - .../metaTileEntity/pipe/IConnectsToDataPipe.java | 14 - .../pipe/IConnectsToElementalPipe.java | 8 - .../pipe/IConnectsToEnergyTunnel.java | 8 - .../metaTileEntity/pipe/PipeActivityMessage.java | 133 -- .../single/GT_MetaTileEntity_BuckConverter.java | 4 +- .../single/GT_MetaTileEntity_DataReader.java | 6 +- .../single/GT_MetaTileEntity_DebugPollutor.java | 4 +- .../GT_MetaTileEntity_DebugPowerGenerator.java | 4 +- .../GT_MetaTileEntity_DebugStructureWriter.java | 6 +- .../single/GT_MetaTileEntity_MicroController.java | 2 +- .../single/GT_MetaTileEntity_OwnerDetector.java | 6 +- .../single/GT_MetaTileEntity_TT_Transformer.java | 4 +- .../single/GT_MetaTileEntity_TeslaCoil.java | 16 +- .../single/GT_MetaTileEntity_WetTransformer.java | 4 +- .../single/gui/GT_Container_DebugPollutor.java | 2 +- .../single/gui/GT_GUIContainer_BuckConverter.java | 4 +- .../single/gui/GT_GUIContainer_DataReader.java | 2 +- .../gui/GT_GUIContainer_DebugPowerGenerator.java | 4 +- .../github/technus/tectech/util/CommonValues.java | 43 + .../com/github/technus/tectech/util/Converter.java | 59 + .../java/com/github/technus/tectech/util/Util.java | 1104 +++++++++++++ .../com/github/technus/tectech/util/Vec3Impl.java | 146 ++ .../java/com/github/technus/tectech/util/XSTR.java | 278 ++++ 147 files changed, 4316 insertions(+), 4035 deletions(-) delete mode 100644 src/main/java/com/github/technus/tectech/CommonValues.java delete mode 100644 src/main/java/com/github/technus/tectech/Converter.java delete mode 100644 src/main/java/com/github/technus/tectech/Util.java delete mode 100644 src/main/java/com/github/technus/tectech/Vec3pos.java delete mode 100644 src/main/java/com/github/technus/tectech/XSTR.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentLimits.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentMessage.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignment.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignmentLimits.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Direction.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Flip.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Rotation.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/constructible/IConstructable.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/IActivePipe.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToDataPipe.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToElementalPipe.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/IConnectsToEnergyTunnel.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/pipe/PipeActivityMessage.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/IConstructable.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/IFrontRotation.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/RotationMessage.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedTexture.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/IActivePipe.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/IConnectsToDataPipe.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/IConnectsToElementalPipe.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/IConnectsToEnergyTunnel.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/PipeActivityMessage.java create mode 100644 src/main/java/com/github/technus/tectech/util/CommonValues.java create mode 100644 src/main/java/com/github/technus/tectech/util/Converter.java create mode 100644 src/main/java/com/github/technus/tectech/util/Util.java create mode 100644 src/main/java/com/github/technus/tectech/util/Vec3Impl.java create mode 100644 src/main/java/com/github/technus/tectech/util/XSTR.java (limited to 'src/main/java') diff --git a/src/main/java/com/github/technus/tectech/CommonValues.java b/src/main/java/com/github/technus/tectech/CommonValues.java deleted file mode 100644 index 9564643fbe..0000000000 --- a/src/main/java/com/github/technus/tectech/CommonValues.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.github.technus.tectech; - -import net.minecraft.util.EnumChatFormatting; - -/** - * Created by danie_000 on 11.01.2017. - */ -public final class CommonValues { - public static final String TEC_MARK_GENERAL = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Interdimensional"; - public static final String TEC_MARK_EM = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Elemental Matter"; - public static final String BASS_MARK = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Theta Movement"; - public static final String COSMIC_MARK = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Cosmic";//TODO get a better name than cosmic for *UNDEFINED* thing - - public static final byte DECAY_AT = 0;// hatches compute decays - public static final byte MULTI_PURGE_1_AT = 2;// multiblocks clean their hatches 1 - public static final byte MOVE_AT = 4;// move stuff around - public static final byte RECIPE_AT = 6;// move stuff around - public static final byte MULTI_PURGE_2_AT = 8;// multiblocks clean their hatches 2 - public static final byte OVERFLOW_AT = 10;// then hatches clean themselves - // - in case some hatches are not in multiblock structure - public static final byte MULTI_CHECK_AT = 12;// multiblock checks it's state - public static final byte DISPERSE_AT = 14;// overflow hatches perform disperse - public static final byte TRANSFER_AT = 16; - - public static final long[] AatV = new long[]{268435455,67108863,16777215,4194303,1048575,262143,65535,16383,4095,1023,255,63,15,3,1,1}; - public static final String[] VOLTAGE_NAMES = new String[]{"Ultra Low Voltage", "Low Voltage", "Medium Voltage", "High Voltage", "Extreme Voltage", "Insane Voltage", "Ludicrous Voltage", "ZPM Voltage", "Ultimate Voltage", "Ultimate High Voltage", "Ultimate Extreme Voltage", "Ultimate Insane Voltage", "Ultimate Mega Voltage", "Ultimate Extended Mega Voltage", "Overpowered Voltage", "Maximum Voltage"}; - public static final String[] VN = new String[]{"ULV", "LV", "MV", "HV", "EV", "IV", "LuV", "ZPM", "UV", "UHV", "UEV", "UIV", "UMV", "UXV", "OpV", "MAX"}; - public static final long[] V = new long[]{8L, 32L, 128L, 512L, 2048L, 8192L, 32768L, 131072L, 524288L, 2097152L, 8388608L, 33554432L, 134217728L, 536870912L, 1073741824L, Integer.MAX_VALUE - 7}; - - private CommonValues() {} -} diff --git a/src/main/java/com/github/technus/tectech/Converter.java b/src/main/java/com/github/technus/tectech/Converter.java deleted file mode 100644 index 5d1f5c802e..0000000000 --- a/src/main/java/com/github/technus/tectech/Converter.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.github.technus.tectech; - -import java.io.*; - -public final class Converter { - private Converter() {} - - public static void writeInts(int [] array,ByteArrayOutputStream byteArrayOutputStream) { - try { - DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream); - for (int i = 0; i < array.length; i++) { - dataOutputStream.writeInt(array[i]); - } - dataOutputStream.flush(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static void readInts(ByteArrayInputStream byteArrayInputStream,int[] array) { - try { - DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream); - for (int i = 0; i < array.length; i++) { - array[i] = dataInputStream.readInt(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static byte[] writeInts(int[] array) { - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(array.length * 4); - DataOutputStream dos = new DataOutputStream(bos); - for (int i = 0; i < array.length; i++) { - dos.writeInt(array[i]); - } - - return bos.toByteArray(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static int[] readInts(byte[] array) { - try { - ByteArrayInputStream bis = new ByteArrayInputStream(array); - DataInputStream dataInputStream = new DataInputStream(bis); - int size = array.length / Integer.BYTES; - int[] res = new int[size]; - for (int i = 0; i < size; i++) { - res[i] = dataInputStream.readInt(); - } - return res; - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 9694dadfd3..47a3b576b1 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -12,6 +12,7 @@ import com.github.technus.tectech.mechanics.data.PlayerPersistence; import com.github.technus.tectech.mechanics.elementalMatter.core.commands.GiveEM; import com.github.technus.tectech.mechanics.elementalMatter.core.commands.ListEM; import com.github.technus.tectech.proxy.CommonProxy; +import com.github.technus.tectech.util.XSTR; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java deleted file mode 100644 index 5bd3ff59a9..0000000000 --- a/src/main/java/com/github/technus/tectech/Util.java +++ /dev/null @@ -1,1640 +0,0 @@ -package com.github.technus.tectech; - -import com.github.technus.tectech.thing.casing.TT_Container_Casings; -import com.github.technus.tectech.thing.metaTileEntity.IFrontRotation; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.ObfuscationReflectionHelper; -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.ChunkCoordIntPair; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.storage.IPlayerFileData; -import net.minecraft.world.storage.SaveHandler; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.StringUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.lang.reflect.Field; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static gregtech.api.enums.GT_Values.E; -import static java.nio.charset.Charset.forName; - -/** - * Created by Tec on 21.03.2017. - */ -public final class Util { - private Util() { - } - - @SuppressWarnings("ComparatorMethodParameterNotUsed") - public static > SortedSet> entriesSortedByValues(Map map) { - SortedSet> sortedEntries = new TreeSet<>( - (e1, e2) -> { - int res = e1.getValue().compareTo(e2.getValue()); - return res != 0 ? res : 1; // Special fix to preserve items with equal values - } - ); - sortedEntries.addAll(map.entrySet()); - return sortedEntries; - } - - public static int bitStringToInt(String bits){ - if(bits==null){ - return 0; - } - if(bits.length() > 32){ - throw new NumberFormatException("Too long!"); - } - return Integer.parseInt(bits,2); - } - - public static int hexStringToInt(String hex){ - if(hex==null){ - return 0; - } - if(hex.length()>8){ - throw new NumberFormatException("Too long!"); - } - return Integer.parseInt(hex,16); - } - - public static double stringToDouble(String str){ - if(str==null){ - return 0; - } - return Double.parseDouble(str); - } - - public static double getValue(String in1) { - String str = in1.toLowerCase(); - double val; - try { - if (str.contains("b")) { - String[] split = str.split("b"); - val = Util.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); - } else if (str.contains("x")) { - String[] split = str.split("x"); - val = Util.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); - } else { - val = Util.stringToDouble(str); - } - return val; - } catch (Exception e) { - return 0; - } - } - - - public static String intBitsToString(int number) { - StringBuilder result = new StringBuilder(16); - - for (int i = 31; i >= 0; i--) { - int mask = 1 << i; - result.append((number & mask) != 0 ? "1" : "0"); - - if (i % 8 == 0) { - result.append(' '); - } - } - result.replace(result.length() - 1, result.length(), ""); - - return result.toString(); - } - - public static String intBitsToShortString(int number) { - StringBuilder result = new StringBuilder(35); - - for (int i = 31; i >= 0; i--) { - int mask = 1 << i; - result.append((number & mask) != 0 ? ":" : "."); - - if (i % 8 == 0) { - result.append('|'); - } - } - result.replace(result.length() - 1, result.length(), ""); - - return result.toString(); - } - - public static String longBitsToShortString(long number) { - StringBuilder result = new StringBuilder(71); - - for (int i = 63; i >= 0; i--) { - long mask = 1L << i; - result.append((number & mask) != 0 ? ":" : "."); - - if (i % 8 == 0) { - result.append('|'); - } - } - result.replace(result.length() - 1, result.length(), ""); - - return result.toString(); - } - - public static float map(float x, float in_min, float in_max, float out_min, float out_max) { - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; - } - - //region junk - /* - //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller - //This only checks for REGULAR BLOCKS! - public static boolean StructureChecker(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR-1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - IGregTechTileEntity aBaseMetaTileEntity, - boolean forceCheck) { - World world = aBaseMetaTileEntity.getWorld(); - if (world.isRemote) { - return false; - } - //TE Rotation - byte facing = aBaseMetaTileEntity.getFrontFacing(); - - int x, y, z, a, b, c, pointer; - int - baseX=aBaseMetaTileEntity.getXCoord(), - baseZ=aBaseMetaTileEntity.getZCoord(), - baseY=aBaseMetaTileEntity.getYCoord(); - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - //yPos - absolute height of checked block - - //perform your duties - c = -depthOffset; - for (String[] _structure : structure) {//front to back - b = verticalOffset; - for (String __structure : _structure) {//top to bottom - a = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block < ' ') {//Control chars allow skipping - b -= block; - break; - } if (block > '@')//characters allow to skip check a-1 skip, b-2 skips etc. - { - a += block - '@'; - } else if (block < '+')//used to mark THINGS - { - a++; - } else if (block=='.') { - a++; - } else { - //get x y z from rotation - switch (facing) {//translation - case 4: - x = baseX + c; - z = baseZ + a; - y = baseY + b; - break; - case 3: - x = baseX + a; - z = baseZ - c; - y = baseY + b; - break; - case 5: - x = baseX - c; - z = baseZ - a; - y = baseY + b; - break; - case 2: - x = baseX - a; - z = baseZ + c; - y = baseY + b; - break; - //Things get odd if the block faces up or down... - case 1: - x = baseX + a; - z = baseZ + b; - y = baseY - c; - break;//similar to 3 - case 0: - x = baseX - a; - z = baseZ - b; - y = baseY + c; - break;//similar to 2 - default: - return false; - } - - //that must be here since in some cases other axis (b,c) controls y - if (y < 0 || y >= 256) { - return false; - } - - //Check block - if (world.blockExists(x, y, z)) {//this actually checks if the chunk is loaded at this pos - switch (block) { - case '-'://must be air - if (world.getBlock(x, y, z).getMaterial() != Material.air) { - return false; - } - break; - case '+'://must not be air - if (world.getBlock(x, y, z).getMaterial() == Material.air) { - return false; - } - break; - default: //check for block (countable) - pointer = block - '0'; - //countable air -> net.minecraft.block.BlockAir - if (world.getBlock(x, y, z) != blockType[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + blockType[pointer].getUnlocalizedName()); - } - return false; - } - if (world.getBlockMetadata(x, y, z) != blockMeta[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMeta[pointer]); - } - return false; - } - } - } else if (forceCheck) { - return false; - } - a++;//block in horizontal layer - } - } - b--;//horizontal layer - } - c++;//depth - } - return true; - } - - //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller - //This only checks for REGULAR BLOCKS! - public static boolean StructureCheckerAdvanced( - String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR-1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - Method adder, - String[] addingMethods, - short[] casingTextures, - Block[] blockTypeFallback,//use numbers 0-9 for casing types - byte[] blockMetaFallback,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - IGregTechTileEntity aBaseMetaTileEntity, - boolean forceCheck) { - World world = aBaseMetaTileEntity.getWorld(); - if (world.isRemote) { - return false; - } - //TE Rotation - byte facing = aBaseMetaTileEntity.getFrontFacing(); - - IGregTechTileEntity igt; - IMetaTileEntity imt = aBaseMetaTileEntity.getMetaTileEntity(); - - int x, y, z, a, b, c, pointer; - int baseX=aBaseMetaTileEntity.getXCoord(), - baseZ=aBaseMetaTileEntity.getZCoord(), - baseY=aBaseMetaTileEntity.getYCoord(); - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - //yPos - absolute height of checked block - - //perform your duties - c = -depthOffset; - for (String[] _structure : structure) {//front to back - b = verticalOffset; - for (String __structure : _structure) {//top to bottom - a = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block < ' ') {//Control chars allow skipping - b -= block; - break; - } else if (block > '@') //characters allow to skip check A-1 skip, B-2 skips etc. - { - a += block - '@'; - }//else if (block < '+')//used to mark THINGS - // a++; - else if (block=='.') { - a++; - } else { - //get x y z from rotation - switch (facing) {//translation - case 4: - x = baseX + c; - z = baseZ + a; - y = baseY + b; - break; - case 3: - x = baseX + a; - z = baseZ - c; - y = baseY + b; - break; - case 5: - x = baseX - c; - z = baseZ - a; - y = baseY + b; - break; - case 2: - x = baseX - a; - z = baseZ + c; - y = baseY + b; - break; - //Things get odd if the block faces up or down... - case 1: - x = baseX + a; - z = baseZ + b; - y = baseY - c; - break;//similar to 3 - case 0: - x = baseX - a; - z = baseZ - b; - y = baseY + c; - break;//similar to 2 - default: - return false; - } - - //that must be here since in some cases other axis (b,c) controls y - if (y < 0 || y >= 256) { - return false; - } - - //Check block - if (world.blockExists(x, y, z)) {//this actually checks if the chunk is loaded at this pos - switch (block) { - case '-'://must be air - if (world.getBlock(x, y, z).getMaterial() != Material.air) { - return false; - } - break; - case '+'://must not be air - if (world.getBlock(x, y, z).getMaterial() == Material.air) { - return false; - } - break; - default://check for block (countable) - if ((pointer = block - '0') >= 0) { - //countable air -> net.minecraft.block.BlockAir - if (world.getBlock(x, y, z) != blockType[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + blockType[pointer].getUnlocalizedName()); - } - return false; - } - if (world.getBlockMetadata(x, y, z) != blockMeta[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMeta[pointer]); - } - return false; - } - } else if ((pointer = block - ' ') >= 0) { - igt = aBaseMetaTileEntity.getIGregTechTileEntity(x, y, z); - try { - if (igt == null || !(boolean) adder.invoke(imt, addingMethods[pointer], igt, casingTextures[pointer])) { - if (world.getBlock(x, y, z) != blockTypeFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + (blockTypeFallback[pointer] == null ? "null" : blockTypeFallback[pointer].getUnlocalizedName())); - } - return false; - } - if (world.getBlockMetadata(x, y, z) != blockMetaFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMetaFallback[pointer]); - } - return false; - } - } - } catch (InvocationTargetException | IllegalAccessException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return false; - } - } - } - } else if (forceCheck) { - return false; - } - a++;//block in horizontal layer - } - } - b--;//horizontal layer - } - c++;//depth - } - return true; - } - */ - //endregion - - //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller - //This only checks for REGULAR BLOCKS! - public static boolean StructureCheckerExtreme( - String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR-1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - IHatchAdder[] addingMethods, - short[] casingTextures, - Block[] blockTypeFallback,//use numbers 0-9 for casing types - byte[] blockMetaFallback,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - IGregTechTileEntity aBaseMetaTileEntity, - IFrontRotation frontRotation, - boolean forceCheck) { - World world = aBaseMetaTileEntity.getWorld(); - if (world.isRemote) { - return false; - } - //TE Rotation - int facingAndRotation = aBaseMetaTileEntity.getFrontFacing() + (frontRotation == null ? 0 : (frontRotation.getFrontRotation() << 3)); - - IGregTechTileEntity igt; - IMetaTileEntity imt = aBaseMetaTileEntity.getMetaTileEntity(); - - int x, y, z, a, b, c, pointer; - int baseX = aBaseMetaTileEntity.getXCoord(), - baseZ = aBaseMetaTileEntity.getZCoord(), - baseY = aBaseMetaTileEntity.getYCoord(); - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - //yPos - absolute height of checked block - - //perform your duties - c = -depthOffset; - for (String[] _structure : structure) {//front to back - b = verticalOffset; - for (String __structure : _structure) {//top to bottom - a = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block < ' ') {//Control chars allow skipping - b -= block; - break; - } else if (block > '@') {//characters allow to skip check A-1 skip, B-2 skips etc. - a += block - '@'; - }//else if (block < '+')//used to mark THINGS - // a++; - else if (block == '.') { - a++; - } else { - //get x y z from rotation - switch (facingAndRotation) {//translation - case 4: - x = baseX + c; - z = baseZ + a; - y = baseY + b; - break; - case 12: - x = baseX + c; - y = baseY - a; - z = baseZ + b; - break; - case 20: - x = baseX + c; - z = baseZ - a; - y = baseY - b; - break; - case 28: - x = baseX + c; - y = baseY + a; - z = baseZ - b; - break; - - case 3: - x = baseX + a; - z = baseZ - c; - y = baseY + b; - break; - case 11: - y = baseY - a; - z = baseZ - c; - x = baseX + b; - break; - case 19: - x = baseX - a; - z = baseZ - c; - y = baseY - b; - break; - case 27: - y = baseY + a; - z = baseZ - c; - x = baseX - b; - break; - - case 5: - x = baseX - c; - z = baseZ - a; - y = baseY + b; - break; - case 13: - x = baseX - c; - y = baseY - a; - z = baseZ - b; - break; - case 21: - x = baseX - c; - z = baseZ + a; - y = baseY - b; - break; - case 29: - x = baseX - c; - y = baseY + a; - z = baseZ + b; - break; - - case 2: - x = baseX - a; - z = baseZ + c; - y = baseY + b; - break; - case 10: - y = baseY - a; - z = baseZ + c; - x = baseX - b; - break; - case 18: - x = baseX + a; - z = baseZ + c; - y = baseY - b; - break; - case 26: - y = baseY + a; - z = baseZ + c; - x = baseX + b; - break; - //Things get odd if the block faces up or down... - case 1: - x = baseX + a; - z = baseZ - b; - y = baseY - c; - break;//similar to 3 - case 9: - z = baseZ + a; - x = baseX + b; - y = baseY - c; - break;//similar to 3 - case 17: - x = baseX - a; - z = baseZ + b; - y = baseY - c; - break;//similar to 3 - case 25: - z = baseZ - a; - x = baseX - b; - y = baseY - c; - break;//similar to 3 - - case 0: - x = baseX - a; - z = baseZ - b; - y = baseY + c; - break;//similar to 2 - case 8: - z = baseZ + a; - x = baseX - b; - y = baseY + c; - break; - case 16: - x = baseX + a; - z = baseZ + b; - y = baseY + c; - break; - case 24: - z = baseZ - a; - x = baseX + b; - y = baseY + c; - break; - default: - if (DEBUG_MODE) { - TecTech.LOGGER.info("facing = " + facingAndRotation); - } - return false; - } - - //that must be here since in some cases other axis (b,c) controls y - if (y < 0 || y >= 256) { - return false; - } - - //Check block - if (world.blockExists(x, y, z)) {//this actually checks if the chunk is loaded at this pos - switch (block) { - case '-'://must be air - if (world.getBlock(x, y, z).getMaterial() != Material.air) { - return false; - } - break; - case '+'://must not be air - if (world.getBlock(x, y, z).getMaterial() == Material.air) { - return false; - } - break; - default://check for block (countable) - if ((pointer = block - '0') >= 0) { - //countable air -> net.minecraft.block.BlockAir - if (world.getBlock(x, y, z) != blockType[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + blockType[pointer].getUnlocalizedName()); - } - return false; - } - if (world.getBlockMetadata(x, y, z) != blockMeta[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMeta[pointer]); - } - return false; - } - } else //noinspection ConstantConditions - if ((pointer = block - ' ') >= 0) { - igt = aBaseMetaTileEntity.getIGregTechTileEntity(x, y, z); - if (igt == null || !addingMethods[pointer].apply(igt, casingTextures[pointer])) { - if (world.getBlock(x, y, z) != blockTypeFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + (blockTypeFallback[pointer] == null ? "null" : blockTypeFallback[pointer].getUnlocalizedName())); - } - return false; - } - if (world.getBlockMetadata(x, y, z) != blockMetaFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMetaFallback[pointer]); - } - return false; - } - } - } - } - } else if (forceCheck) { - return false; - } - a++;//block in horizontal layer - } - } - b--;//horizontal layer - } - c++;//depth - } - return true; - } - - public static boolean StructureBuilder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - IGregTechTileEntity aBaseMetaTileEntity, boolean hintsOnly) { - byte facing = aBaseMetaTileEntity.getFrontFacing(); - return StructureBuilderExtreme(structure, blockType, blockMeta, - horizontalOffset, verticalOffset, depthOffset, - aBaseMetaTileEntity.getWorld().getTileEntity(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()), null, - facing, hintsOnly); - } - - public static boolean StructureBuilderExtreme(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - IGregTechTileEntity aBaseMetaTileEntity, IFrontRotation frontRotation, boolean hintsOnly) { - byte facing = aBaseMetaTileEntity.getFrontFacing(); - return StructureBuilderExtreme(structure, blockType, blockMeta, - horizontalOffset, verticalOffset, depthOffset, - aBaseMetaTileEntity.getWorld().getTileEntity(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()), frontRotation, - facing, hintsOnly); - } - - public static boolean StructureBuilder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - TileEntity tileEntity, int facing, boolean hintsOnly) { - return StructureBuilderExtreme(structure, blockType, blockMeta, horizontalOffset, verticalOffset, depthOffset, tileEntity, null, facing, hintsOnly); - } - - public static boolean StructureBuilderExtreme(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - TileEntity tileEntity, IFrontRotation frontRotation, int facing, boolean hintsOnly) { - if (!tileEntity.hasWorldObj()) { - return false; - } - World world = tileEntity.getWorldObj(); - if (!world.isRemote && hintsOnly) { - return false; - } - - //TE Rotation - - int x, y, z, a, b, c, pointer; - int - baseX = tileEntity.xCoord, - baseZ = tileEntity.zCoord, - baseY = tileEntity.yCoord; - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - if (frontRotation != null) { - facing += frontRotation.getFrontRotation() << 3; - } - - //perform your duties - c = -depthOffset; - for (String[] _structure : structure) {//front to back - b = verticalOffset; - for (String __structure : _structure) {//top to bottom - a = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block < ' ') {//Control chars allow skipping - b -= block; - break; - } - if (block > '@')//characters allow to skip check a-1 skip, b-2 skips etc. - { - a += block - '@'; - }//else if (block < '+')//used to mark THINGS - // a++; - else if (block == '.')// this TE - { - a++; - } else { - //get x y z from rotation - switch (facing) { - case 4: - x = baseX + c; - z = baseZ + a; - y = baseY + b; - break; - case 12: - x = baseX + c; - y = baseY - a; - z = baseZ + b; - break; - case 20: - x = baseX + c; - z = baseZ - a; - y = baseY - b; - break; - case 28: - x = baseX + c; - y = baseY + a; - z = baseZ - b; - break; - - case 3: - x = baseX + a; - z = baseZ - c; - y = baseY + b; - break; - case 11: - y = baseY - a; - z = baseZ - c; - x = baseX + b; - break; - case 19: - x = baseX - a; - z = baseZ - c; - y = baseY - b; - break; - case 27: - y = baseY + a; - z = baseZ - c; - x = baseX - b; - break; - - case 5: - x = baseX - c; - z = baseZ - a; - y = baseY + b; - break; - case 13: - x = baseX - c; - y = baseY - a; - z = baseZ - b; - break; - case 21: - x = baseX - c; - z = baseZ + a; - y = baseY - b; - break; - case 29: - x = baseX - c; - y = baseY + a; - z = baseZ + b; - break; - - case 2: - x = baseX - a; - z = baseZ + c; - y = baseY + b; - break; - case 10: - y = baseY - a; - z = baseZ + c; - x = baseX - b; - break; - case 18: - x = baseX + a; - z = baseZ + c; - y = baseY - b; - break; - case 26: - y = baseY + a; - z = baseZ + c; - x = baseX + b; - break; - //Things get odd if the block faces up or down... - case 1: - x = baseX + a; - z = baseZ - b; - y = baseY - c; - break;//similar to 3 - case 9: - z = baseZ + a; - x = baseX + b; - y = baseY - c; - break;//similar to 3 - case 17: - x = baseX - a; - z = baseZ + b; - y = baseY - c; - break;//similar to 3 - case 25: - z = baseZ - a; - x = baseX - b; - y = baseY - c; - break;//similar to 3 - - case 0: - x = baseX - a; - z = baseZ - b; - y = baseY + c; - break;//similar to 2 - case 8: - z = baseZ + a; - x = baseX - b; - y = baseY + c; - break; - case 16: - x = baseX + a; - z = baseZ + b; - y = baseY + c; - break; - case 24: - z = baseZ - a; - x = baseX + b; - y = baseY + c; - break; - default: - if (DEBUG_MODE) { - TecTech.LOGGER.info("facing = " + facing); - } - return false; - } - - //that must be here since in some cases other axis (b,c) controls y - if (y < 0 || y >= 256) { - return false; - } - - //Check block - if (world.blockExists(x, y, z)) {//this actually checks if the chunk is loaded - if (hintsOnly) { - switch (block) { - case '-'://must be air - TecTech.proxy.hint_particle(world, x, y, z, TT_Container_Casings.sHintCasingsTT, 13); - break; - case '+'://must not be air - TecTech.proxy.hint_particle(world, x, y, z, TT_Container_Casings.sHintCasingsTT, 14); - break; - default: //check for block - if ((pointer = block - '0') >= 0) { - if (world.getBlock(x, y, z) != blockType[pointer] || world.getBlockMetadata(x, y, z) != blockMeta[pointer]) { - TecTech.proxy.hint_particle(world, x, y, z, blockType[pointer], blockMeta[pointer]); - } - } else if ((pointer = block - ' ') >= 0) { - if (p