From 5de583bf34003095ff286aa132aa0e005020cab7 Mon Sep 17 00:00:00 2001 From: basdxz Date: Wed, 4 Nov 2020 09:06:13 +0000 Subject: Revert "Merge branch 'master' into BassAddons" This reverts commit 95993fb3d937b8dcfc9c945c18a754ce4ac11f88. --- .../dreamcraft/DreamCraftRecipeLoader.java | 12 +- .../mechanics/structure/IStructureDefinition.java | 146 ++++- .../mechanics/structure/IStructureElement.java | 8 +- .../structure/IStructureElementChain.java | 22 +- .../structure/IStructureElementCheckOnly.java | 6 +- .../structure/IStructureElementDeferred.java | 2 +- .../structure/IStructureElementNoPlacement.java | 4 +- .../mechanics/structure/IStructureNavigate.java | 8 +- .../mechanics/structure/StructureDefinition.java | 50 +- .../structure/StructureIterationType.java | 8 - .../mechanics/structure/StructureUtility.java | 646 ++++++++------------- .../mechanics/structure/adders/IBlockAdder.java | 4 +- .../mechanics/structure/adders/IHatchAdder.java | 6 +- .../mechanics/structure/adders/ITileAdder.java | 4 +- .../java/com/github/technus/tectech/util/Util.java | 1 + 15 files changed, 453 insertions(+), 474 deletions(-) delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/structure/StructureIterationType.java diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index d58a6e7686..df5c11e67b 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java @@ -933,8 +933,6 @@ public class DreamCraftRecipeLoader implements Runnable { 48000, 64, 200000, 8, new Object[]{ GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.CosmicNeutronium, 1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.CosmicNeutronium, 6L), - ItemList.Gravistar.get(4L), - ItemList.Emitter_UHV.get(4L), new Object[]{OrePrefixes.circuit.get(Materials.Bio), 4L}, GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), @@ -954,9 +952,7 @@ public class DreamCraftRecipeLoader implements Runnable { 96000, 128, 400000, 16, new Object[]{ GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Infinity, 1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Infinity, 6L), - ItemList.Gravistar.get(8L), - ItemList.Emitter_UEV.get(4L), - new Object[]{OrePrefixes.circuit.get(Materials.Nano), 4}, + new Object[]{OrePrefixes.circuit.get(Materials.Bio), 8L}, GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), @@ -1088,7 +1084,7 @@ public class DreamCraftRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 64), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Polybenzimidazole, 64) }, new FluidStack[]{ - Materials.SolderingAlloy.getMolten(3744L), + Materials.SolderingAlloy.getMolten(3760L), Materials.Naquadria.getMolten(4032L), new FluidStack(FluidRegistry.getFluid("ic2coolant"), 20000) }, getItemContainer("NanoCircuit").get(1L), 8000, 8000000); @@ -1109,7 +1105,7 @@ public class DreamCraftRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.bolt, Materials.Neutronium, 16), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Lanthanum, 64) }, new FluidStack[]{ - Materials.SolderingAlloy.getMolten(4032L), + Materials.SolderingAlloy.getMolten(3760L), Materials.UUMatter.getFluid(8000L), Materials.Osmium.getMolten(1152L) }, getItemContainer("PikoCircuit").get(1L), 10000, 8000000); @@ -1128,7 +1124,7 @@ public class DreamCraftRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Bedrockium, 8), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Lanthanum, 64) }, new FluidStack[]{ - Materials.SolderingAlloy.getMolten(4608L), + Materials.SolderingAlloy.getMolten(3760L), Materials.UUMatter.getFluid(24000L), Materials.Osmium.getMolten(2304L) }, getItemContainer("QuantumCircuit").get(1L), 20000, 32000000); diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java index ca9712df04..c8488d5cea 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java @@ -1,47 +1,167 @@ package com.github.technus.tectech.mechanics.structure; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import static com.github.technus.tectech.mechanics.structure.StructureIterationType.*; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.iterate; +import java.util.Arrays; -public interface IStructureDefinition { +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; + +public interface IStructureDefinition { /** * Used internally * @param name same name as for other methods here * @return the array of elements to process */ - IStructureElement[] getStructureFor(String name); + IStructureElement[] getStructureFor(String name); - default boolean check(MultiBlock object, String piece, World world, ExtendedFacing extendedFacing, + default boolean check(T object,String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, boolean forceCheckAllBlocks){ return iterate(object, null, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,forceCheckAllBlocks? CHECK_FULLY:CHECK); + basePositionA, basePositionB, basePositionC,false,forceCheckAllBlocks); } - default boolean hints(MultiBlock object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, + default boolean hints(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC) { return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,SPAWN_HINTS); + basePositionA, basePositionB, basePositionC,true,null); } - default boolean build(MultiBlock object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, + default boolean build(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC) { return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,BUILD_TEMPLATE); + basePositionA, basePositionB, basePositionC,false,null); } - default boolean buildOrHints(MultiBlock object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, + default boolean buildOrHints(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, - boolean hints){ + boolean hintsOnly){ return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,hints?SPAWN_HINTS:BUILD_TEMPLATE); + basePositionA, basePositionB, basePositionC,hintsOnly,null); + } + + static boolean iterate(T object, ItemStack trigger, IStructureElement[] elements, World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC, + boolean hintsOnly, Boolean checkBlocksIfNotNullForceCheckAllIfTrue){ + if(world.isRemote ^ hintsOnly){ + return false; + } + + //change base position to base offset + basePositionA=-basePositionA; + basePositionB=-basePositionB; + basePositionC=-basePositionC; + + int[] abc = new int[]{basePositionA,basePositionB,basePositionC}; + int[] xyz = new int[3]; + + if(checkBlocksIfNotNullForceCheckAllIfTrue!=null){ + if(checkBlocksIfNotNullForceCheckAllIfTrue){ + for (IStructureElement element : elements) { + if(element.isNavigating()) { + abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); + abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); + abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); + }else { + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + if(!element.check(object, world, xyz[0], xyz[1], xyz[2])){ + if(DEBUG_MODE){ + TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] failed @ "+ + Arrays.toString(xyz)+" "+Arrays.toString(abc)); + } + return false; + } + } else { + if(DEBUG_MODE){ + TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] !blockExists @ "+ + Arrays.toString(xyz)+" "+Arrays.toString(abc)); + } + return false; + } + abc[0]+=1; + } + } + } else { + for (IStructureElement element : elements) { + if(element.isNavigating()) { + abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); + abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); + abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); + }else { + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + if(!element.check(object, world, xyz[0], xyz[1], xyz[2])){ + if(DEBUG_MODE){ + TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] failed @ "+ + Arrays.toString(xyz)+" "+Arrays.toString(abc)); + } + return false; + } + } else { + if(DEBUG_MODE){ + TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] !blockExists @ "+ + Arrays.toString(xyz)+" "+Arrays.toString(abc)); + } + } + abc[0]+=1; + } + } + } + }else { + if(hintsOnly) { + for (IStructureElement element : elements) { + if(element.isNavigating()) { + abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); + abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); + abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); + }else { + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + element.spawnHint(object, world, xyz[0], xyz[1], xyz[2], trigger); + + abc[0]+=1; + } + } + } else { + for (IStructureElement element : elements) { + if(element.isNavigating()) { + abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); + abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); + abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); + }else { + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + element.placeBlock(object, world, xyz[0], xyz[1], xyz[2], trigger); + } + abc[0]+=1; + } + } + } + } + return true; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java index 436c7ce203..f946e71f91 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java @@ -6,12 +6,12 @@ import net.minecraft.world.World; /** * Use StructureUtility to instantiate */ -public interface IStructureElement { - boolean check(MultiBlock multiBlock, World world, int x, int y, int z); +public interface IStructureElement { + boolean check(T t,World world,int x,int y,int z); - boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger); + boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger); - boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger); + boolean placeBlock(T t,World world,int x,int y,int z, ItemStack trigger); default int getStepA(){ return 1; diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java index 4c7059dd81..f9593ee1c5 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java @@ -6,13 +6,13 @@ import net.minecraft.world.World; /** * Use StructureUtility to instantiate */ -public interface IStructureElementChain extends IStructureElement { - IStructureElement[] fallbacks(); +public interface IStructureElementChain extends IStructureElement { + IStructureElement[] fallbacks(); @Override - default boolean check(MultiBlock multiBlock, World world, int x, int y, int z){ - for (IStructureElement fallback : fallbacks()) { - if (fallback.check(multiBlock, world, x, y, z)) { + default boolean check(T t, World world, int x, int y, int z){ + for (IStructureElement fallback : fallbacks()) { + if (fallback.check(t, world, x, y, z)) { return true; } } @@ -20,9 +20,9 @@ public interface IStructureElementChain extends IStructureElement fallback : fallbacks()) { - if (fallback.spawnHint(multiBlock, world, x, y, z, trigger)) { + default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + for (IStructureElement fallback : fallbacks()) { + if (fallback.spawnHint(t, world, x, y, z, trigger)) { return true; } } @@ -30,9 +30,9 @@ public interface IStructureElementChain extends IStructureElement fallback : fallbacks()) { - if (fallback.placeBlock(multiBlock, world, x, y, z, trigger)) { + default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + for (IStructureElement fallback : fallbacks()) { + if (fallback.placeBlock(t, world, x, y, z, trigger)) { return true; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java index c6492a5ed6..ec15aea53b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java @@ -3,14 +3,14 @@ package com.github.technus.tectech.mechanics.structure; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IStructureElementCheckOnly extends IStructureElement { +public interface IStructureElementCheckOnly extends IStructureElement { @Override - default boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger){ + default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger){ return false; } @Override - default boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger){ + default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger){ return false; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java index c0e39bb2ad..dbb74312a8 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java @@ -3,5 +3,5 @@ package com.github.technus.tectech.mechanics.structure; /** * Use StructureUtility to instantiate */ -public interface IStructureElementDeferred extends IStructureElement { +public interface IStructureElementDeferred extends IStructureElement { } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java index 12cf2141ae..47e6060878 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java @@ -3,9 +3,9 @@ package com.github.technus.tectech.mechanics.structure; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IStructureElementNoPlacement extends IStructureElement { +public interface IStructureElementNoPlacement extends IStructureElement { @Override - default boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger){ + default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger){ return false; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java index 8c7c837a94..d3f4134cea 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java @@ -6,19 +6,19 @@ import net.minecraft.world.World; /** * Use StructureUtility to instantiate */ -interface IStructureNavigate extends IStructureElement { +interface IStructureNavigate extends IStructureElement { @Override - default boolean check(MultiBlock multiBlock, World world, int x, int y, int z){ + default boolean check(T t, World world, int x, int y, int z){ return true; } @Override - default boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { return true; } @Override - default boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { return true; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java index f42cbd35d1..9a1e94d98a 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java @@ -7,31 +7,31 @@ import java.util.*; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; -public class StructureDefinition implements IStructureDefinition { - private final Map> elements; +public class StructureDefinition implements IStructureDefinition { + private final Map> elements; private final Map shapes; - private final Map[]> structures; + private final Map[]> structures; - public static Builder builder() { + public static Builder builder() { return new Builder<>(); } private StructureDefinition( - Map> elements, + Map> elements, Map shapes, - Map[]> structures) { + Map[]> structures) { this.elements =elements; this.shapes=shapes; this.structures = structures; } - public static class Builder { + public static class Builder { private static final char A='\uA000'; private static final char B='\uB000'; private static final char C='\uC000'; private char d ='\uD000'; private final Map navigates; - private final Map> elements; + private final Map> elements; private final Map shapes; private Builder() { @@ -40,7 +40,7 @@ public class StructureDefinition implements IStructureDefinition(); } - public Map> getElements() { + public Map> getElements() { return elements; } @@ -57,7 +57,7 @@ public class StructureDefinition implements IStructureDefinition addShapeOldApi(String name, String[][] structurePiece) { + public Builder addShapeOldApi(String name, String[][] structurePiece) { StringBuilder builder = new StringBuilder(); if (structurePiece.length > 0) { for (String[] strings : structurePiece) { @@ -142,7 +142,7 @@ public class StructureDefinition implements IStructureDefinition addShape(String name, String[][] structurePiece) { + public Builder addShape(String name, String[][] structurePiece) { StringBuilder builder = new StringBuilder(); if (structurePiece.length > 0) { for (String[] strings : structurePiece) { @@ -199,13 +199,13 @@ public class StructureDefinition implements IStructureDefinition addElement(Character name, IStructureElement structurePiece) { + public Builder addElement(Character name, IStructureElement structurePiece) { elements.putIfAbsent(name, structurePiece); return this; } - public IStructureDefinition build() { - Map[]> structures = compileStructureMap(); + public IStructureDefinition build() { + Map[]> structures = compileStructureMap(); if(DEBUG_MODE){ return new StructureDefinition<>(new HashMap<>(elements), new HashMap<>(shapes), structures); }else { @@ -214,22 +214,22 @@ public class StructureDefinition implements IStructureDefinition[]> compileElementSetMap() { + private Map[]> compileElementSetMap() { Set missing = new HashSet<>(); shapes.values().stream().map(CharSequence::chars).forEach(intStream -> intStream.forEach(c -> { - IStructureElement iStructureElement = elements.get((char) c); + IStructureElement iStructureElement = elements.get((char) c); if (iStructureElement == null) { missing.add(c); } })); if (missing.isEmpty()) { - Map[]> map = new HashMap<>(); + Map[]> map = new HashMap<>(); shapes.forEach((key, value) -> { Set chars=new HashSet<>(); for (char c : value.toCharArray()) { chars.add(c); } - IStructureElement[] compiled = new IStructureElement[chars.size()]; + IStructureElement[] compiled = new IStructureElement[chars.size()]; int i=0; for (Character aChar : chars) { compiled[i++]=elements.get(aChar); @@ -244,18 +244,18 @@ public class StructureDefinition implements IStructureDefinition[]> compileStructureMap() { + private Map[]> compileStructureMap() { Set mising = new HashSet<>(); shapes.values().stream().map(CharSequence::chars).forEach(intStream -> intStream.forEach(c -> { - IStructureElement iStructureElement = elements.get((char) c); + IStructureElement iStructureElement = elements.get((char) c); if (iStructureElement == null) { mising.add(c); } })); if (mising.isEmpty()) { - Map[]> map = new HashMap<>(); + Map[]> map = new HashMap<>(); shapes.forEach((key, value) -> { - IStructureElement[] compiled = new IStructureElement[value.length()]; + IStructureElement[] compiled = new IStructureElement[value.length()]; for (int i = 0; i < value.length(); i++) { compiled[i] = elements.get(value.charAt(i)); } @@ -269,7 +269,7 @@ public class StructureDefinition implements IStructureDefinition> getElements(){ + public Map> getElements(){ return elements; } @@ -277,12 +277,12 @@ public class StructureDefinition implements IStructureDefinition[]> getStructures() { + public Map[]> getStructures() { return structures; } @Override - public IStructureElement[] getStructureFor(String name) { + public IStructureElement[] getStructureFor(String name) { return structures.get(name); } } \ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureIterationType.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureIterationType.java deleted file mode 100644 index 618c07f970..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureIterationType.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -public enum StructureIterationType { - SPAWN_HINTS, //only spawn hint particles - BUILD_TEMPLATE, //only builds template - CHECK, //checks the structure skipping all unloaded chunks (for machines that were validated already) - CHECK_FULLY, //checks the structure failing on unloaded chunks (for machines that are not valid currently) -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java index 87ab275d39..521b0e7645 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java @@ -22,8 +22,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.structure.StructureIterationType.SPAWN_HINTS; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sHintCasingsTT; import static java.lang.Integer.MIN_VALUE; @@ -39,18 +37,18 @@ public class StructureUtility { @SuppressWarnings("rawtypes") private static final IStructureElement AIR = new IStructureElement() { @Override - public boolean check(Object multiBlock, World world, int x, int y, int z) { + public boolean check(Object t, World world, int x, int y, int z) { return world.getBlock(x, y, z).getMaterial() == Material.air; } @Override - public boolean spawnHint(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 13); return true; } @Override - public boolean placeBlock(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, Blocks.air, 0, 2); return false; } @@ -58,18 +56,18 @@ public class StructureUtility { @SuppressWarnings("rawtypes") private static final IStructureElement NOT_AIR = new IStructureElement() { @Override - public boolean check(Object multiBlock, World world, int x, int y, int z) { + public boolean check(Object t, World world, int x, int y, int z) { return world.getBlock(x, y, z).getMaterial() != Material.air; } @Override - public boolean spawnHint(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 14); return true; } @Override - public boolean placeBlock(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, sHintCasingsTT, 14, 2); return true; } @@ -77,18 +75,18 @@ public class StructureUtility { @SuppressWarnings("rawtypes") private static final IStructureElement ERROR = new IStructureElement() { @Override - public boolean check(Object multiBlock, World world, int x, int y, int z) { + public boolean check(Object t, World world, int x, int y, int z) { return false; } @Override - public boolean spawnHint(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 15); return true; } @Override - public boolean placeBlock(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { return true; } }; @@ -98,12 +96,12 @@ public class StructureUtility { } @SuppressWarnings("unchecked") - public static IStructureElement isAir() { + public static IStructureElement isAir() { return AIR; } @SuppressWarnings("unchecked") - public static IStructureElement notAir() { + public static IStructureElement notAir() { return NOT_AIR; } @@ -112,11 +110,11 @@ public class StructureUtility { * Placement is always handled by this and does nothing. * Makes little to no use it in fallback chain. * - * @param + * @param * @return */ @SuppressWarnings("unchecked") - public static IStructureElement error() { + public static IStructureElement error() { return ERROR; } @@ -126,19 +124,19 @@ public class StructureUtility { * Check always returns: true. * * @param dots - * @param + * @param * @return */ - public static IStructureElementNoPlacement ofHint(int dots) { + public static IStructureElementNoPlacement ofHint(int dots) { int meta = dots - 1; - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, meta); return false; } @@ -149,18 +147,18 @@ public class StructureUtility { * Check always returns: true. * * @param icons - * @param + * @param * @return */ - public static IStructureElementNoPlacement ofHintDeferred(Supplier icons) { - return new IStructureElementNoPlacement() { + public static IStructureElementNoPlacement ofHintDeferred(Supplier icons) { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, icons.get()); return false; } @@ -172,18 +170,18 @@ public class StructureUtility { * * @param icons * @param RGBa - * @param + * @param * @return */ - public static IStructureElementNoPlacement ofHintDeferred(Supplier icons, short[] RGBa) { - return new IStructureElementNoPlacement() { + public static IStructureElementNoPlacement ofHintDeferred(Supplier icons, short[] RGBa) { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle_tinted(world, x, y, z, icons.get(), RGBa); return false; } @@ -197,19 +195,19 @@ public class StructureUtility { /** * Does not allow Block duplicates (with different meta) */ - public static IStructureElementNoPlacement ofBlocksFlatHint(Map blocsMap, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofBlocksFlatHint(Map blocsMap, Block hintBlock, int hintMeta) { if (blocsMap == null || blocsMap.isEmpty() || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } @@ -228,57 +226,57 @@ public class StructureUtility { throw new IllegalArgumentException(); } } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static IStructureElementNoPlacement ofBlockHint(Block block, int meta, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofBlockHint(Block block, int meta, Block hintBlock, int hintMeta) { if (block == null || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static IStructureElementNoPlacement ofBlockHint(Block block, int meta) { + public static IStructureElementNoPlacement ofBlockHint(Block block, int meta) { return ofBlockHint(block, meta, block, meta); } - public static IStructureElementNoPlacement ofBlockAdderHint(IBlockAdder iBlockAdder, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofBlockAdderHint(IBlockAdder iBlockAdder, Block hintBlock, int hintMeta) { if (iBlockAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(multiBlock, worldBlock, worldBlock.getDamageValue(world, x, y, z)); + return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } @@ -288,46 +286,46 @@ public class StructureUtility { /** * Does not allow Block duplicates (with different meta) */ - public static IStructureElement ofBlocksFlat(Map blocsMap, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlocksFlat(Map blocsMap, Block defaultBlock, int defaultMeta) { if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { throw new IllegalArgumentException(); } if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; }else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -348,41 +346,41 @@ public class StructureUtility { } } if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; }else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -390,46 +388,46 @@ public class StructureUtility { } } - public static IStructureElement ofBlock(Block block, int meta, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlock(Block block, int meta, Block defaultBlock, int defaultMeta) { if (block == null || defaultBlock == null) { throw new IllegalArgumentException(); } if(block instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; } else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -440,44 +438,44 @@ public class StructureUtility { /** * Same as above but ignores target meta id */ - public static IStructureElement ofBlockAnyMeta(Block block, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlockAnyMeta(Block block, Block defaultBlock, int defaultMeta) { if (block == null || defaultBlock == null) { throw new IllegalArgumentException(); } if(block instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return block == world.getBlock(x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; } else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return block == world.getBlock(x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -485,21 +483,21 @@ public class StructureUtility { } } - public static IStructureElement ofBlock(Block block, int meta) { + public static IStructureElement ofBlock(Block block, int meta) { return ofBlock(block, meta, block, meta); } /** * Same as above but ignores target meta id */ - public static IStructureElement ofBlockAnyMeta(Block block) { + public static IStructureElement ofBlockAnyMeta(Block block) { return ofBlockAnyMeta(block, block, 0); } /** * Same as above but allows to set hint particle render */ - public static IStructureElement ofBlockAnyMeta(Block block,int defaultMeta) { + public static IStructureElement ofBlockAnyMeta(Block block,int defaultMeta) { return ofBlockAnyMeta(block, block, defaultMeta); } @@ -507,46 +505,46 @@ public class StructureUtility { //region adders - public static IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, Block defaultBlock, int defaultMeta) { if (iBlockAdder == null || defaultBlock == null) { throw new IllegalArgumentException(); } if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(multiBlock, worldBlock, worldBlock.getDamageValue(world, x, y, z)); + return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; }else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(multiBlock, worldBlock, worldBlock.getDamageValue(world, x, y, z)); + return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -554,102 +552,102 @@ public class StructureUtility { } } - public static IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, int dots) { + public static IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, int dots) { return ofBlockAdder(iBlockAdder, sHintCasingsTT, dots - 1); } - public static IStructureElementNoPlacement ofTileAdder(ITileAdder iTileAdder, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofTileAdder(ITileAdder iTileAdder, Block hintBlock, int hintMeta) { if (iTileAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && iTileAdder.apply(multiBlock, tileEntity); + return tileEntity instanceof IGregTechTileEntity && iTileAdder.apply(t, tileEntity); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static IStructureElementNoPlacement ofHatchAdder(IHatchAdder iHatchAdder, int textureIndex, int dots) { + public static IStructureElementNoPlacement ofHatchAdder(IHatchAdder iHatchAdder, int textureIndex, int dots) { return ofHatchAdder(iHatchAdder, textureIndex, sHintCasingsTT, dots - 1); } - public static IStructureElementNoPlacement ofHatchAdder(IHatchAdder iHatchAdder, int textureIndex, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofHatchAdder(IHatchAdder iHatchAdder, int textureIndex, Block hintBlock, int hintMeta) { if (iHatchAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(multiBlock, (IGregTechTileEntity) tileEntity, (short) textureIndex); + return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static IStructureElement ofHatchAdderOptional(IHatchAdder iHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { + public static IStructureElement ofHatchAdderOptional(IHatchAdder iHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { return ofHatchAdderOptional(iHatchAdder, textureIndex, sHintCasingsTT, dots - 1, placeCasing, placeCasingMeta); } - public static IStructureElement ofHatchAdderOptional(IHatchAdder iHatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { + public static IStructureElement ofHatchAdderOptional(IHatchAdder iHatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { if (iHatchAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } if(placeCasing instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); Block worldBlock = world.getBlock(x, y, z); return (tileEntity instanceof IGregTechTileEntity && - iHatchAdder.apply(multiBlock, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || + iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) placeCasing).setBlock(world, x, y, z, placeCasingMeta); return true; } }; }else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); Block worldBlock = world.getBlock(x, y, z); return (tileEntity instanceof IGregTechTileEntity && - iHatchAdder.apply(multiBlock, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || + iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, placeCasing, placeCasingMeta, 2); return true; } @@ -661,48 +659,48 @@ public class StructureUtility { //region side effects - public static IStructureElement onElementPass(Consumer onCheckPass, IStructureElement element) { - return new IStructureElement() { + public static , T> IStructureElement onElementPass(Consumer onCheckPass, B element) { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - boolean check = element.check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + boolean check = element.check(t, world, x, y, z); if (check) { - onCheckPass.accept(multiBlock); + onCheckPass.accept(t); } return check; } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return element.placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return element.placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return element.spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return element.spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElement onElementFail(Consumer onFail, IStructureElement element) { - return new IStructureElement() { + public static , T> IStructureElement onElementFail(Consumer onFail, B element) { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - boolean check = element.check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + boolean check = element.check(t, world, x, y, z); if (!check) { - onFail.accept(multiBlock); + onFail.accept(t); } return check; } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return element.placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return element.placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return element.spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return element.spawnHint(t, world, x, y, z, trigger); } }; } @@ -714,15 +712,15 @@ public class StructureUtility { * If none does it will finally return false. * * @param elementChain - * @param + * @param * @return */ @SafeVarargs - public static IStructureElementChain ofChain(IStructureElement... elementChain) { + public static IStructureElementChain ofChain(IStructureElement... elementChain) { if (elementChain == null || elementChain.length == 0) { throw new IllegalArgumentException(); } - for (IStructureElement iStructureElement : elementChain) { + for (IStructureElement iStructureElement : elementChain) { if (iStructureElement == null) { throw new IllegalArgumentException(); } @@ -735,317 +733,317 @@ public class StructureUtility { * If none does it will finally return false. * * @param elementChain - * @param + * @param * @return */ @SuppressWarnings("unchecked") - public static IStructureElementChain ofChain(List> elementChain) { + public static IStructureElementChain ofChain(List> elementChain) { return ofChain(elementChain.toArray(new IStructureElement[0])); } //region defer - public static IStructureElementDeferred defer(Supplier> to) { + public static IStructureElementDeferred defer(Supplier> to) { if (to == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return to.get().check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return to.get().check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.get().placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.get().placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.get().spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.get().spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function> to) { + public static IStructureElementDeferred defer(Function> to) { if (to == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return to.apply(multiBlock).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return to.apply(t).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function keyExtractor, Map> map) { + public static IStructureElementDeferred defer(Function keyExtractor, Map> map) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.get(keyExtractor.apply(multiBlock)).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.get(keyExtractor.apply(t)).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock)).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t)).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock)).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t)).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function keyExtractor, Map> map, IStructureElement defaultElem) { + public static IStructureElementDeferred defer(Function keyExtractor, Map> map, IStructureElement defaultElem) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractor.apply(multiBlock), defaultElem).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.getOrDefault(keyExtractor.apply(t), defaultElem).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock), defaultElem).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t), defaultElem).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock), defaultElem).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t), defaultElem).spawnHint(t, world, x, y, z, trigger); } }; } @SafeVarargs - public static IStructureElementDeferred defer(Function keyExtractor, IStructureElement... array) { + public static IStructureElementDeferred defer(Function keyExtractor, IStructureElement... array) { if (keyExtractor == null || array == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return array[keyExtractor.apply(multiBlock)].check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return array[keyExtractor.apply(t)].check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock)].placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t)].placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock)].spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t)].spawnHint(t, world, x, y, z, trigger); } }; } @SuppressWarnings("unchecked") - public static IStructureElementDeferred defer(Function keyExtractor, List> array) { + public static IStructureElementDeferred defer(Function keyExtractor, List> array) { return defer(keyExtractor, array.toArray(new IStructureElement[0])); } - public static IStructureElementDeferred defer(BiFunction> to) { + public static IStructureElementDeferred defer(BiFunction> to) { if (to == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return to.apply(multiBlock, null).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return to.apply(t, null).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock, trigger).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock, trigger).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t, trigger).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(BiFunction keyExtractor, Map> map) { + public static IStructureElementDeferred defer(BiFunction keyExtractor, Map> map) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.get(keyExtractor.apply(multiBlock, null)).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.get(keyExtractor.apply(t, null)).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock, trigger)).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t, trigger)).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock, trigger)).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t, trigger)).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { + public static IStructureElementDeferred defer(BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractor.apply(multiBlock, null), defaultElem).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.getOrDefault(keyExtractor.apply(t, null), defaultElem).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock, trigger), defaultElem).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock, trigger), defaultElem).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).spawnHint(t, world, x, y, z, trigger); } }; } @SafeVarargs - public static IStructureElementDeferred defer(BiFunction keyExtractor, IStructureElement... array) { + public static IStructureElementDeferred defer(BiFunction keyExtractor, IStructureElement... array) { if (keyExtractor == null || array == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return array[keyExtractor.apply(multiBlock, null)].check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return array[keyExtractor.apply(t, null)].check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock, trigger)].placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t, trigger)].placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock, trigger)].spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t, trigger)].spawnHint(t, world, x, y, z, trigger); } }; } @SuppressWarnings("unchecked") - public static IStructureElementDeferred defer(BiFunction keyExtractor, List> array) { + public static IStructureElementDeferred defer(BiFunction keyExtractor, List> array) { return defer(keyExtractor, array.toArray(new IStructureElement[0])); } - public static IStructureElementDeferred defer(Function> toCheck, BiFunction> to) { + public static IStructureElementDeferred defer(Function> toCheck, BiFunction> to) { if (to == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return toCheck.apply(multiBlock).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return toCheck.apply(t).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock, trigger).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock, trigger).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t, trigger).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, Map> map) { + public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, Map> map) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.get(keyExtractorCheck.apply(multiBlock)).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.get(keyExtractorCheck.apply(t)).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock, trigger)).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t, trigger)).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock, trigger)).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t, trigger)).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { + public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractorCheck.apply(multiBlock), defaultElem).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.getOrDefault(keyExtractorCheck.apply(t), defaultElem).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock, trigger), defaultElem).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock, trigger), defaultElem).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).spawnHint(t, world, x, y, z, trigger); } }; } @SafeVarargs - public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, IStructureElement... array) { + public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, IStructureElement... array) { if (keyExtractor == null || array == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return array[keyExtractorCheck.apply(multiBlock)].check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return array[keyExtractorCheck.apply(t)].check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock, trigger)].placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t, trigger)].placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock, trigger)].spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t, trigger)].spawnHint(t, world, x, y, z, trigger); } }; } @SuppressWarnings("unchecked") - public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, List> array) { + public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, List> array) { return defer(keyExtractorCheck, keyExtractor, array.toArray(new IStructureElement[0])); } @@ -1057,10 +1055,10 @@ public class StructureUtility { * @param a * @param b * @param c - * @param + * @param * @return */ - public static IStructureNavigate step(int a, int b, int c) { + public static IStructureNavigate step(int a, int b, int c) { return step(new Vec3Impl(a, b, c)); } @@ -1068,11 +1066,11 @@ public class StructureUtility { * Used internally, to generate skips for structure definitions * * @param step - * @param + * @param * @return */ @SuppressWarnings("unchecked") - public static IStructureNavigate step(Vec3Impl step) { + public static IStructureNavigate step(Vec3Impl step) { if (step == null || step.get0() < 0 || step.get1() < 0 || step.get2() < 0) { throw new IllegalArgumentException(); } @@ -1087,8 +1085,8 @@ public class StructureUtility { }); } - private static IStructureNavigate stepA(int a, int b, int c) { - return new IStructureNavigate() { + private static IStructureNavigate stepA(int a, int b, int c) { + return new IStructureNavigate() { @Override public int getStepA() { return a; @@ -1106,8 +1104,8 @@ public class StructureUtility { }; } - private static IStructureNavigate stepB(int a, int b, int c) { - return new IStructureNavigate() { + private static IStructureNavigate stepB(int a, int b, int c) { + return new IStructureNavigate() { @Override public int getStepA() { return a; @@ -1130,8 +1128,8 @@ public class StructureUtility { }; } - private static IStructureNavigate stepC(int a, int b, int c) { - return new IStructureNavigate() { + private static IStructureNavigate stepC(int a, int b, int c) { + return new IStructureNavigate() { @Override public int getStepA() { return a; @@ -1378,134 +1376,6 @@ public class StructureUtility { } } - public static boolean iterate(MultiBlock object, - ItemStack trigger, - IStructureElement[] elements, - World world, - ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC, - StructureIterationType iterationType) { - if (world.isRemote ^ (iterationType == SPAWN_HINTS)) { - return false; - } - - //change base position to base offset - basePositionA = -basePositionA; - basePositionB = -basePositionB; - basePositionC = -basePositionC; - - int[] abc = new int[]{basePositionA, basePositionB, basePositionC}; - int[] xyz = new int[3]; - - switch (iterationType) { - case SPAWN_HINTS: { - for (IStructureElement element : elements) { - if (element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - } else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - element.spawnHint(object, world, xyz[0], xyz[1], xyz[2], trigger); - - abc[0] += 1; - } - } - break; - } - case BUILD_TEMPLATE: { - for (IStructureElement element : elements) { - if (element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - } else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - element.placeBlock(object, world, xyz[0], xyz[1], xyz[2], trigger); - } - abc[0] += 1; - } - } - break; - } - case CHECK: { - for (IStructureElement element : elements) { - if (element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - } else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - if (!element.check(object, world, xyz[0], xyz[1], xyz[2])) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] failed @ " + - Arrays.toString(xyz) + " " + Arrays.toString(abc)); - } - return false; - } - } else { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] !blockExists @ " + - Arrays.toString(xyz) + " " + Arrays.toString(abc)); - } - } - abc[0] += 1; - } - break; - } - } - case CHECK_FULLY: { - for (IStructureElement element : elements) { - if (element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - } else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - if (!element.check(object, world, xyz[0], xyz[1], xyz[2])) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] failed @ " + - Arrays.toString(xyz) + " " + Arrays.toString(abc)); - } - return false; - } - } else { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] !blockExists @ " + - Arrays.toString(xyz) + " " + Arrays.toString(abc)); - } - return false; - } - abc[0] += 1; - } - } - break; - } - default: return false; - } - return true; - } - /** * Transposes shape (swaps B and C axis, can be used to un-transpose transposed shape) * WARNING! Do not use on old api... diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java index 36ebfb3d21..908c4c4aca 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java @@ -3,12 +3,12 @@ package com.github.technus.tectech.mechanics.structure.adders; import net.minecraft.block.Block; -public interface IBlockAdder { +public interface IBlockAdder { /** * Callback on block added, needs to check if block is valid (and add it) * @param block block attempted to add * @param meta meta of block attempted to add * @return is structure still valid */ - boolean apply(MultiBlock multiBlock, Block block, int meta); + boolean apply(T t,Block block, Integer meta); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java index 0545a83d9e..a47befc2e8 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java @@ -3,12 +3,12 @@ package com.github.technus.tectech.mechanics.structure.adders; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -public interface IHatchAdder { +public interface IHatchAdder { /** * Callback to add hatch, needs to check if hatch is valid (and add it) * @param iGregTechTileEntity hatch - * @param textureIndex requested texture index, or null if not... + * @param aShort requested texture index, or null if not... * @return managed to add hatch (structure still valid) */ - boolean apply(MultiBlock multiBlock, IGregTechTileEntity iGregTechTileEntity, int textureIndex); + boolean apply(T t,IGregTechTileEntity iGregTechTileEntity, Short aShort); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java index 72d08751b5..cc3c7dbb7a 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java @@ -2,11 +2,11 @@ package com.github.technus.tectech.mechanics.structure.adders; import net.minecraft.tileentity.TileEntity; -public interface ITileAdder { +public interface ITileAdder { /** * Callback to add hatch, needs to check if tile is valid (and add it) * @param tileEntity tile * @return managed to add hatch (structure still valid) */ - boolean apply(MultiBlock multiBlock, TileEntity tileEntity); + boolean apply(T t,TileEntity tileEntity); } diff --git a/src/main/java/com/github/technus/tectech/util/Util.java b/src/main/java/com/github/technus/tectech/util/Util.java index 8c693620b6..1843770e3a 100644 --- a/src/main/java/com/github/technus/tectech/util/Util.java +++ b/src/main/java/com/github/technus/tectech/util/Util.java @@ -40,6 +40,7 @@ public final class Util { private Util() { } + @SuppressWarnings("ComparatorMethodParameterNotUsed") public static > SortedSet> entriesSortedByValues(Map map) { SortedSet> sortedEntries = new TreeSet<>( (e1, e2) -> { -- cgit