diff options
| author | Tec <daniel112092@gmail.com> | 2020-05-01 10:47:04 +0200 |
|---|---|---|
| committer | Tec <daniel112092@gmail.com> | 2020-05-01 10:47:04 +0200 |
| commit | 31f7fc89f41e430494bb6e03415f58049f85da51 (patch) | |
| tree | e31200c15642d30cdda99d9e8381904e1a4ad30e /src/main/java/com | |
| parent | 9099a93e902cd29f5312f4691e00be91c2dbe554 (diff) | |
| download | GT5-Unofficial-31f7fc89f41e430494bb6e03415f58049f85da51.tar.gz GT5-Unofficial-31f7fc89f41e430494bb6e03415f58049f85da51.tar.bz2 GT5-Unofficial-31f7fc89f41e430494bb6e03415f58049f85da51.zip | |
Fix navigation, move handles to util
Diffstat (limited to 'src/main/java/com')
8 files changed, 468 insertions, 357 deletions
diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentUtility.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentUtility.java new file mode 100644 index 0000000000..68e11b77af --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentUtility.java @@ -0,0 +1,45 @@ +package com.github.technus.tectech.mechanics.alignment; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; + +public class AlignmentUtility { + private AlignmentUtility(){ + + } + + public static boolean handle(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ){ + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if(tTileEntity==null || aPlayer instanceof FakePlayer) { + return aPlayer instanceof EntityPlayerMP; + } + if (aPlayer instanceof EntityPlayerMP) { + if (tTileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + if (metaTE instanceof IAlignmentProvider) { + IAlignment alignment = ((IAlignmentProvider) metaTE).getAlignment(); + if(aPlayer.isSneaking()){ + alignment.toolSetFlip(null); + }else { + alignment.toolSetRotation(null); + } + return true; + } + } else if (tTileEntity instanceof IAlignmentProvider) { + IAlignment alignment = ((IAlignmentProvider) tTileEntity).getAlignment(); + if(aPlayer.isSneaking()){ + alignment.toolSetFlip(null); + }else { + alignment.toolSetRotation(null); + } + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/constructable/ConstructableUtility.java b/src/main/java/com/github/technus/tectech/mechanics/constructable/ConstructableUtility.java new file mode 100644 index 0000000000..2dc74330f9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/constructable/ConstructableUtility.java @@ -0,0 +1,114 @@ +package com.github.technus.tectech.mechanics.constructable; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.alignment.IAlignment; +import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.ForgeDirection; + +public class ConstructableUtility { + private ConstructableUtility(){ + + } + + public static boolean handle(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if(tTileEntity==null || aPlayer instanceof FakePlayer) { + return aPlayer instanceof EntityPlayerMP; + } + if (aPlayer instanceof EntityPlayerMP) { + //struct gen + if (aPlayer.isSneaking() && aPlayer.capabilities.isCreativeMode) { + if (tTileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + if (metaTE instanceof IConstructable) { + ((IConstructable) metaTE).construct(aStack, false); + } else if (IMultiblockInfoContainer.contains(metaTE.getClass())) { + IMultiblockInfoContainer<IMetaTileEntity> iMultiblockInfoContainer =IMultiblockInfoContainer.get(metaTE.getClass()); + if(metaTE instanceof IAlignment){ + iMultiblockInfoContainer.construct(aStack, false, metaTE, ( + (IAlignment) metaTE).getExtendedFacing()); + }else { + iMultiblockInfoContainer.construct(aStack, false, metaTE, + ExtendedFacing.of(ForgeDirection.getOrientation(((IGregTechTileEntity) tTileEntity).getFrontFacing()))); + } + } + } else if (tTileEntity instanceof IConstructable) { + ((IConstructable) tTileEntity).construct(aStack, false); + } else if (IMultiblockInfoContainer.contains(tTileEntity.getClass())) { + IMultiblockInfoContainer<TileEntity> iMultiblockInfoContainer =IMultiblockInfoContainer.get(tTileEntity.getClass()); + if(tTileEntity instanceof IAlignment){ + iMultiblockInfoContainer.construct(aStack, false, tTileEntity, + ((IAlignment) tTileEntity).getExtendedFacing()); + }else { + iMultiblockInfoContainer.construct(aStack, false, tTileEntity, + ExtendedFacing.of(ForgeDirection.getOrientation(aSide))); + } + } + } + return true; + }else if (TecTech.proxy.isThePlayer(aPlayer)){//particles and text client side + //if ((!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode)) { + if(tTileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + if (metaTE instanceof IConstructable) { + ((IConstructable) metaTE).construct(aStack, true); + TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack)); + return false; + } else if(IMultiblockInfoContainer.contains(metaTE.getClass())){ + IMultiblockInfoContainer<IMetaTileEntity> iMultiblockInfoContainer =IMultiblockInfoContainer.get(metaTE.getClass()); + if(metaTE instanceof IAlignment){ + iMultiblockInfoContainer.construct(aStack, true, metaTE, + ((IAlignment) metaTE).getExtendedFacing()); + }else { + iMultiblockInfoContainer.construct(aStack, true, metaTE, + ExtendedFacing.of(ForgeDirection.getOrientation(((IGregTechTileEntity) tTileEntity).getFrontFacing()))); + } + TecTech.proxy.printInchat(IMultiblockInfoContainer.get(metaTE.getClass()).getDescription(aStack)); + return false; + } + } else if(tTileEntity instanceof IConstructable){ + ((IConstructable) tTileEntity).construct(aStack,true); + TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack)); + return false; + } else if(IMultiblockInfoContainer.contains(tTileEntity.getClass())){ + IMultiblockInfoContainer<TileEntity> iMultiblockInfoContainer = IMultiblockInfoContainer.get(tTileEntity.getClass()); + if(tTileEntity instanceof IAlignment){ + iMultiblockInfoContainer.construct(aStack, true, tTileEntity, + ((IAlignment) tTileEntity).getExtendedFacing()); + }else { + iMultiblockInfoContainer.construct(aStack, true, tTileEntity, + ExtendedFacing.of(ForgeDirection.getOrientation(aSide))); + } + TecTech.proxy.printInchat(IMultiblockInfoContainer.get(tTileEntity.getClass()).getDescription(aStack)); + return false; + } + //} else { + // if(tTileEntity instanceof IGregTechTileEntity) { + // IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + // if (metaTE instanceof IConstructable) { + // TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize)); + // return false; + // } else if(multiblockMap.containsKey(metaTE.getClass().getCanonicalName())){ + // TecTech.proxy.printInchat(multiblockMap.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize)); + // return false; + // } + // } else if(tTileEntity instanceof IConstructable){ + // TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize)); + // return false; + // } else if(multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())){ + // TecTech.proxy.printInchat(multiblockMap.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize)); + // return false; + // } + //} + } + return false; + } +} 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 71305ebd92..542d13a7cd 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 @@ -115,9 +115,8 @@ public interface IStructureDefinition<T> { xyz[1] += basePositionY; xyz[2] += basePositionZ; - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - element.spawnHint(object, world, xyz[0], xyz[1], xyz[2], trigger); - } + element.spawnHint(object, world, xyz[0], xyz[1], xyz[2], trigger); + abc[0]+=1; } } 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 9cc82699b9..29114647ac 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 @@ -1,5 +1,6 @@ package com.github.technus.tectech.mechanics.structure; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.util.Vec3Impl; import java.util.*; @@ -29,7 +30,7 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { private static final char A='\uA000'; private static final char B='\uB000'; private static final char C='\uC000'; - private static final char D='\uD000'; + private char d ='\uD000'; private final Map<Vec3Impl,Character> navigates; private final Map<Character, IStructureElement<T>> elements; private final Map<String, String> shapes; @@ -61,8 +62,12 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { StringBuilder builder = new StringBuilder(); if (structurePiece.length > 0) { for (String[] strings : structurePiece) { + + if (strings.length > 0) { for (String string : strings) { + + for (int i = 0; i < string.length(); i++) { char ch = string.charAt(i); if(ch<' '){ @@ -77,16 +82,29 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { builder.append(ch); } } + + builder.append(B); } builder.setLength(builder.length() - 1); } + + builder.append(C); } builder.setLength(builder.length() - 1); } + if(DEBUG_MODE){ + Exception exception = new Exception(); + exception.getStackTrace(); + + TecTech.LOGGER.info("Structure shape normal:"); + + + TecTech.LOGGER.info("Structure shape transposed:"); + + } int a=0,b=0,c=0; - char d=D; for (int i = 0; i < builder.length(); i++) { char ch = builder.charAt(i); if(ch =='.'){ @@ -106,7 +124,7 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { Vec3Impl vec3 = new Vec3Impl(a, b, c); Character navigate = navigates.get(vec3); if(navigate==null){ - navigate=d++; + navigate= d++; navigates.put(vec3,navigate); addElement(navigate,step(vec3)); } @@ -137,8 +155,8 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { * rest needs to be defined * * next char is next block(a) - * next string is next line(a,b) - * next string[] is next slice(a,b,c) + * next string is next line(b) + * next string[] is next slice(c) * * char A000-FFFF range is reserved for generated skips * @param name unlocalized/code name @@ -160,7 +178,6 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { builder.setLength(builder.length() - 1); } int a=0,b=0,c=0; - char d=D; for (int i = 0; i < builder.length(); i++) { char ch = builder.charAt(i); if(ch ==' ' || ch =='.'){ @@ -188,7 +205,6 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { a=0; b=0; c=0; - d++; } } @@ -220,14 +236,14 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { @SuppressWarnings("unchecked") private Map<String, IStructureElement<T>[]> compileElementSetMap() { - Set<Integer> mising = new HashSet<>(); + Set<Integer> missing = new HashSet<>(); shapes.values().stream().map(CharSequence::chars).forEach(intStream -> intStream.forEach(c -> { IStructureElement<T> iStructureElement = elements.get((char) c); if (iStructureElement == null) { - mising.add(c); + missing.add(c); } })); - if (mising.isEmpty()) { + if (missing.isEmpty()) { Map<String, IStructureElement<T>[]> map = new HashMap<>(); shapes.forEach((key, value) -> { Set<Character> chars=new HashSet<>(); @@ -244,7 +260,7 @@ public class StructureDefinition<T> implements IStructureDefinition<T> { return map; } else { throw new RuntimeException("Missing Structure Element bindings for (chars as integers): " + - Arrays.toString(mising.toArray())); + Arrays.toString(missing.toArray())); } } 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 1f8beaa240..868bfec181 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 @@ -24,11 +24,11 @@ import java.util.function.Supplier; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sHintCasingsTT; public class StructureUtility { - private static final String NICE_CHARS ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_=|[]{};:'<>,./?"; + private static final String NICE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_=|[]{};:'<>,./?"; @SuppressWarnings("rawtypes") - private static final Map<Vec3Impl,IStructureNavigate> STEP = new HashMap<>(); + private static final Map<Vec3Impl, IStructureNavigate> STEP = new HashMap<>(); @SuppressWarnings("rawtypes") - private static final IStructureElement AIR= new IStructureElement() { + private static final IStructureElement AIR = new IStructureElement() { @Override public boolean check(Object t, World world, int x, int y, int z) { return world.getBlock(x, y, z).getMaterial() == Material.air; @@ -36,18 +36,18 @@ public class StructureUtility { @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 13); return true; } @Override public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x,y,z,Blocks.air,0,2); + world.setBlock(x, y, z, Blocks.air, 0, 2); return false; } }; @SuppressWarnings("rawtypes") - private static final IStructureElement NOT_AIR= new IStructureElement() { + private static final IStructureElement NOT_AIR = new IStructureElement() { @Override public boolean check(Object t, World world, int x, int y, int z) { return world.getBlock(x, y, z).getMaterial() != Material.air; @@ -55,18 +55,18 @@ public class StructureUtility { @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 14); return true; } @Override public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x,y,z,sHintCasingsTT,14,2); + world.setBlock(x, y, z, sHintCasingsTT, 14, 2); return true; } }; @SuppressWarnings("rawtypes") - private static final IStructureElement ERROR= new IStructureElement() { + private static final IStructureElement ERROR = new IStructureElement() { @Override public boolean check(Object t, World world, int x, int y, int z) { return false; @@ -74,7 +74,7 @@ public class StructureUtility { @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 15); return true; } @@ -84,17 +84,17 @@ public class StructureUtility { } }; - private StructureUtility(){ + private StructureUtility() { } @SuppressWarnings("unchecked") - public static <T> IStructureElement<T> isAir(){ + public static <T> IStructureElement<T> isAir() { return AIR; } @SuppressWarnings("unchecked") - public static <T> IStructureElement<T> notAir(){ + public static <T> IStructureElement<T> notAir() { return NOT_AIR; } @@ -102,22 +102,24 @@ public class StructureUtility { * Check returns false. * Placement is always handled by this and does nothing. * Makes little to no use it in fallback chain. + * * @param <T> * @return */ @SuppressWarnings("unchecked") - public static <T> IStructureElement<T> error(){ + public static <T> IStructureElement<T> error() { return ERROR; } /** * Check always returns: true. + * * @param dots * @param <T> * @return */ - public static <T> IStructureElementNoPlacement<T> ofHint(int dots){ - int meta=dots-1; + public static <T> IStructureElementNoPlacement<T> ofHint(int dots) { + int meta = dots - 1; return new IStructureElementNoPlacement<T>() { @Override public boolean check(T t, World world, int x, int y, int z) { @@ -135,8 +137,8 @@ public class StructureUtility { /** * Does not allow Block duplicates (with different meta) */ - public static <T> IStructureElementNoPlacement<T> ofBlocksFlatHint(Map<Block, Integer> blocsMap, Block hintBlock, int hintMeta){ - if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ + public static <T> IStructureElementNoPlacement<T> ofBlocksFlatHint(Map<Block, Integer> blocsMap, Block hintBlock, int hintMeta) { + if (blocsMap == null || blocsMap.isEmpty() || hintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElementNoPlacement<T>() { @@ -147,7 +149,7 @@ public class StructureUtility { @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; @@ -156,12 +158,12 @@ public class StructureUtility { /** * Allows block duplicates (with different meta) */ - public static <T> IStructureElementNoPlacement<T> ofBlocksMapHint(Map<Block, Set<Integer>> blocsMap, Block hintBlock, int hintMeta){ - if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ + public static <T> IStructureElementNoPlacement<T> ofBlocksMapHint(Map<Block, Set<Integer>> blocsMap, Block hintBlock, int hintMeta) { + if (blocsMap == null || blocsMap.isEmpty() || hintBlock == null) { throw new IllegalArgumentException(); } for (Set<Integer> value : blocsMap.values()) { - if(value.isEmpty()){ + if (value.isEmpty()) { throw new IllegalArgumentException(); } } @@ -173,14 +175,14 @@ public class StructureUtility { @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static <T> IStructureElementNoPlacement<T> ofBlockHint(Block block, int meta,Block hintBlock,int hintMeta){ - if(block==null || hintBlock==null){ + public static <T> IStructureElementNoPlacement<T> ofBlockHint(Block block, int meta, Block hintBlock, int hintMeta) { + if (block == null || hintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElementNoPlacement<T>() { @@ -191,29 +193,29 @@ public class StructureUtility { @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static <T> IStructureElementNoPlacement<T> ofBlockHint(Block block, int meta){ - return ofBlockHint(block, meta,block,meta); + public static <T> IStructureElementNoPlacement<T> ofBlockHint(Block block, int meta) { + return ofBlockHint(block, meta, block, meta); } - public static <T> IStructureElementNoPlacement<T> ofBlockAdderHint(IBlockAdder<T> iBlockAdder, Block hintBlock, int hintMeta){ - if(iBlockAdder==null ||hintBlock==null){ + public static <T> IStructureElementNoPlacement<T> ofBlockAdderHint(IBlockAdder<T> iBlockAdder, Block hintBlock, int hintMeta) { + if (iBlockAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElementNoPlacement<T>() { @Override public boolean check(T t, World world, int x, int y, int z) { - return iBlockAdder.apply(t,world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)); + return iBlockAdder.apply(t, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)); } @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; @@ -222,8 +224,8 @@ public class StructureUtility { /** * Does not allow Block duplicates (with different meta) */ - public static <T> IStructureElement<T> ofBlocksFlat(Map<Block, Integer> blocsMap,Block defaultBlock,int defaultMeta){ - if(blocsMap==null || blocsMap.isEmpty() || defaultBlock==null){ + public static <T> IStructureElement<T> ofBlocksFlat(Map<Block, Integer> blocsMap, Block defaultBlock, int defaultMeta) { + if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { throw new IllegalArgumentException(); } return new IStructureElement<T>() { @@ -234,13 +236,13 @@ public class StructureUtility { @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x,y,z,defaultBlock,defaultMeta,2); + world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; @@ -249,12 +251,12 @@ public class StructureUtility { /** * Allows block duplicates (with different meta) */ - public static <T> IStructureElement<T> ofBlocksMap(Map<Block, Set<Integer>> blocsMap, Block defaultBlock, int defaultMeta){ - if(blocsMap==null || blocsMap.isEmpty() || defaultBlock==null){ + public static <T> IStructureElement<T> ofBlocksMap(Map<Block, Set<Integer>> blocsMap, Block defaultBlock, int defaultMeta) { + if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { throw new IllegalArgumentException(); } for (Set<Integer> value : blocsMap.values()) { - if(value.isEmpty()){ + if (value.isEmpty()) { throw new IllegalArgumentException(); } } @@ -266,20 +268,20 @@ public class StructureUtility { @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x,y,z,defaultBlock,defaultMeta,2); + world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; } - public static <T> IStructureElement<T> ofBlock(Block block, int meta,Block defaultBlock,int defaultMeta){ - if(block==null || defaultBlock==null){ + public static <T> IStructureElement<T> ofBlock(Block block, int meta, Block defaultBlock, int defaultMeta) { + if (block == null || defaultBlock == null) { throw new IllegalArgumentException(); } return new IStructureElement<T>() { @@ -290,98 +292,98 @@ public class StructureUtility { @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x,y,z,defaultBlock,defaultMeta,2); + world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; } - public static <T> IStructureElement<T> ofBlock(Block block, int meta){ - return ofBlock(block, meta,block,meta); + public static <T> IStructureElement<T> ofBlock(Block block, int meta) { + return ofBlock(block, meta, block, meta); } - public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder<T> iBlockAdder,Block defaultBlock,int defaultMeta){ - if(iBlockAdder==null ||defaultBlock==null){ + public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder<T> iBlockAdder, Block defaultBlock, int defaultMeta) { + if (iBlockAdder == null || defaultBlock == null) { throw new IllegalArgumentException(); } return new IStructureElement<T>() { @Override public boolean check(T t, World world, int x, int y, int z) { - return iBlockAdder.apply(t,world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)); + return iBlockAdder.apply(t, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)); } @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x,y,z,defaultBlock,defaultMeta,2); + world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; } - public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder<T> iBlockAdder,int dots){ - return ofBlockAdder(iBlockAdder,sHintCasingsTT,dots-1); + public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder<T> iBlockAdder, int dots) { + return ofBlockAdder(iBlockAdder, sHintCasingsTT, dots - 1); } - public static <T> IStructureElementNoPlacement<T> ofTileAdder(ITileAdder<T> iTileAdder, Block hintBlock, int hintMeta){ - if(iTileAdder==null ||hintBlock==null){ + public static <T> IStructureElementNoPlacement<T> ofTileAdder(ITileAdder<T> iTileAdder, Block hintBlock, int hintMeta) { + if (iTileAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElementNoPlacement<T>() { @Override 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(t,tileEntity); + return tileEntity instanceof IGregTechTileEntity && iTileAdder.apply(t, tileEntity); } @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IHatchAdder<T> iHatchAdder, int textureIndex, int dots){ - return ofHatchAdder(iHatchAdder, textureIndex,sHintCasingsTT, dots-1); + public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IHatchAdder<T> iHatchAdder, int textureIndex, int dots) { + return ofHatchAdder(iHatchAdder, textureIndex, sHintCasingsTT, dots - 1); } - public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IHatchAdder<T> iHatchAdder, int textureIndex, Block hintBlock, int hintMeta){ - if(iHatchAdder==null ||hintBlock==null){ + public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IHatchAdder<T> iHatchAdder, int textureIndex, Block hintBlock, int hintMeta) { + if (iHatchAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElementNoPlacement<T>() { @Override 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(t,(IGregTechTileEntity) tileEntity, (short)textureIndex); + return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex); } @Override 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); + TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static <T> IStructureElement<T> ofHatchAdderOptional(IHatchAdder<T> iHatchAdder, int textureIndex, int dots, Block placeCasing,int placeCasingMeta){ - return ofHatchAdderOptional(iHatchAdder, textureIndex, sHintCasingsTT, dots-1, placeCasing, placeCasingMeta); + public static <T> IStructureElement<T> ofHatchAdderOptional(IHatchAdder<T> iHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { + return ofHatchAdderOptional(iHatchAdder, textureIndex, sHintCasingsTT, dots - 1, placeCasing, placeCasingMeta); } - public static <T> IStructureElement<T> ofHatchAdderOptional(IHatchAdder<T> iHatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing,int placeCasingMeta){ - if(iHatchAdder==null ||hintBlock==null){ + public static <T> IStructureElement<T> ofHatchAdderOptional(IHatchAdder<T> iHatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { + if (iHatchAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElement<T>() { @@ -389,30 +391,30 @@ public class StructureUtility { public boolean check(T t, World |
