aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentUtility.java45
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/constructable/ConstructableUtility.java114
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java5
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java38
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java481
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java104
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java36
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 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) ||
- (world.getBlock(x,y,z)==placeCasing&&world.getBlockMetadata(x,y,z)==placeCasingMeta));
+ (iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex) ||
+ (world.getBlock(x, y, z) == placeCasing && world.getBlockMetadata(x, y, z) == placeCasingMeta));
}
@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;
}
@Override
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
- world.setBlock(x,y,z,placeCasing,placeCasingMeta,2);
+ world.setBlock(x, y, z, placeCasing, placeCasingMeta, 2);
return true;
}
};
}
- public static <B extends IStructureElement<T>,T> IStructureElement<T> onElementPass(Consumer<T> onCheckPass, B element){
+ public static <B extends IStructureElement<T>, T> IStructureElement<T> onElementPass(Consumer<T> onCheckPass, B element) {
return new IStructureElement<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
boolean check = element.check(t, world, x, y, z);
- if(check){
+ if (check) {
onCheckPass.accept(t);
}
return check;
@@ -430,12 +432,12 @@ public class StructureUtility {
};
}
- public static <B extends IStructureElement<T>,T> IStructureElement<T> onElementFail(Consumer<T> onFail, B element){
+ public static <B extends IStructureElement<T>, T> IStructureElement<T> onElementFail(Consumer<T> onFail, B element) {
return new IStructureElement<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
boolean check = element.check(t, world, x, y, z);
- if(!check){
+ if (!check) {
onFail.accept(t);
}
return check;
@@ -457,17 +459,18 @@ public class StructureUtility {
/**
* Take care while chaining, as it will try to call every structure element until it returns true.
* If none does it will finally return false.
+ *
* @param elementChain
* @param <T>
* @return
*/
@SafeVarargs
- public static <T> IStructureElementChain<T> ofChain(IStructureElement<T>... elementChain){
- if(elementChain==null || elementChain.length==0){
+ public static <T> IStructureElementChain<T> ofChain(IStructureElement<T>... elementChain) {
+ if (elementChain == null || elementChain.length == 0) {
throw new IllegalArgumentException();
}
for (IStructureElement<T> iStructureElement : elementChain) {
- if(iStructureElement==null){
+ if (iStructureElement == null) {
throw new IllegalArgumentException();
}
}
@@ -477,17 +480,18 @@ public class StructureUtility {
/**
* Take care while chaining, as it will try to call every structure element until it returns true.
* If none does it will finally return false.
+ *
* @param elementChain
* @param <T>
* @return
*/
@SuppressWarnings("unchecked")
- public static <T> IStructureElementChain<T> ofChain(List<IStructureElement<T>> elementChain){
+ public static <T> IStructureElementChain<T> ofChain(List<IStructureElement<T>> elementChain) {
return ofChain(elementChain.toArray(new IStructureElement[0]));
}
- public static <T> IStructureElementDeferred<T> defer(Supplier<IStructureElement<T>> to){
- if(to==null){
+ public static <T> IStructureElementDeferred<T> defer(Supplier<IStructureElement<T>> to) {
+ if (to == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@@ -508,8 +512,8 @@ public class StructureUtility {
};
}
- public static <T> IStructureElementDeferred<T> defer(Function<T,IStructureElement<T>> to){
- if(to==null){
+ public static <T> IStructureElementDeferred<T> defer(Function<T, IStructureElement<T>> to) {
+ if (to == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@@ -530,8 +534,8 @@ public class StructureUtility {
};
}
- public static <T,K> IStructureElementDeferred<T> defer(Function<T,K> keyExtractor,Map<K,IStructureElement<T>> map){
- if(keyExtractor==null||map==null){
+ public static <T, K> IStructureElementDeferred<T> defer(Function<T, K> keyExtractor, Map<K, IStructureElement<T>> map) {
+ if (keyExtractor == null || map == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@@ -552,31 +556,31 @@ public class StructureUtility {
};
}
- public static <T,K> IStructureElementDeferred<T> defer(Function<T,K> keyExtractor,Map<K,IStructureElement<T>> map,IStructureElement<T> defaultElem){
- if(keyExtractor==null||map==null){
+ public static <T, K> IStructureElementDeferred<T> defer(Function<T, K> keyExtractor, Map<K, IStructureElement<T>> map, IStructureElement<T> defaultElem) {
+ if (keyExtractor == null || map == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@Override
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);
+ return map.getOrDefault(keyExtractor.apply(t), defaultElem).check(t, world, x, y, z);
}
@Override
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);
+ return map.getOrDefault(keyExtractor.apply(t), defaultElem).placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return map.getOrDefault(keyExtractor.apply(t), defaultElem).spawnHint(t, world, x, y, z, trigger);
}
};
}
@SafeVarargs
- public static <T> IStructureElementDeferred<T> defer(Function<T,Integer> keyExtractor, IStructureElement<T>... array){
- if(keyExtractor==null||array==null){
+ public static <T> IStructureElementDeferred<T> defer(Function<T, Integer> keyExtractor, IStructureElement<T>... array) {
+ if (keyExtractor == null || array == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@@ -598,106 +602,106 @@ public class StructureUtility {
}
@SuppressWarnings("unchecked")
- public static <T> IStructureElementDeferred<T> defer(Function<T,Integer> keyExtractor,List<IStructureElement<T>> array){
+ public static <T> IStructureElementDeferred<T> defer(Function<T, Integer> keyExtractor, List<IStructureElement<T>> array) {
return defer(keyExtractor, array.toArray(new IStructureElement[0]));
}
- public static <T> IStructureElementDeferred<T> defer(BiFunction<T,ItemStack,IStructureElement<T>> to){
- if(to==null){
+ public static <T> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, IStructureElement<T>> to) {
+ if (to == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
- return to.apply(t,null).check(t, world, x, y, z);
+ return to.apply(t, null).check(t, world, x, y, z);
}
@Override
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);
+ return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return to.apply(t, trigger).spawnHint(t, world, x, y, z, trigger);
}
};
}
- public static <T,K> IStructureElementDeferred<T> defer(BiFunction<T,ItemStack,K> keyExtractor,Map<K,IStructureElement<T>> map){
- if(keyExtractor==null||map==null){
+ public static <T, K> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, K> keyExtractor, Map<K, IStructureElement<T>> map) {
+ if (keyExtractor == null || map == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@Override
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);
+ return map.get(keyExtractor.apply(t, null)).check(t, world, x, y, z);
}
@Override
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);
+ return map.get(keyExtractor.apply(t, trigger)).placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return map.get(keyExtractor.apply(t, trigger)).spawnHint(t, world, x, y, z, trigger);
}
};
}
- public static <T,K> IStructureElementDeferred<T> defer(BiFunction<T,ItemStack,K> keyExtractor,Map<K,IStructureElement<T>> map,IStructureElement<T> defaultElem){
- if(keyExtractor==null||map==null){
+ public static <T, K> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, K> keyExtractor, Map<K, IStructureElement<T>> map, IStructureElement<T> defaultElem) {
+ if (keyExtractor == null || map == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@Override
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);
+ return map.getOrDefault(keyExtractor.apply(t, null), defaultElem).check(t, world, x, y, z);
}
@Override
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);
+ return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).spawnHint(t, world, x, y, z, trigger);
}
};
}
@SafeVarargs
- public static <T> IStructureElementDeferred<T> defer(BiFunction<T,ItemStack,Integer> keyExtractor, IStructureElement<T>... array){
- if(keyExtractor==null||array==null){
+ public static <T> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, Integer> keyExtractor, IStructureElement<T>... array) {
+ if (keyExtractor == null || array == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@Override
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);
+ return array[keyExtractor.apply(t, null)].check(t, world, x, y, z);
}
@Override
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);
+ return array[keyExtractor.apply(t, trigger)].placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return array[keyExtractor.apply(t, trigger)].spawnHint(t, world, x, y, z, trigger);
}
};
}
@SuppressWarnings("unchecked")
- public static <T> IStructureElementDeferred<T> defer(BiFunction<T,ItemStack,Integer> keyExtractor, List<IStructureElement<T>> array){
+ public static <T> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, Integer> keyExtractor, List<IStructureElement<T>> array) {
return defer(keyExtractor, array.toArray(new IStructureElement[0]));
}
- public static <T> IStructureElementDeferred<T> defer(Function<T,IStructureElement<T>> toCheck, BiFunction<T,ItemStack,IStructureElement<T>> to){
- if(to==null){
+ public static <T> IStructureElementDeferred<T> defer(Function<T, IStructureElement<T>> toCheck, BiFunction<T, ItemStack, IStructureElement<T>> to) {
+ if (to == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@@ -708,18 +712,18 @@ public class StructureUtility {
@Override
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);
+ return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return to.apply(t, trigger).spawnHint(t, world, x, y, z, trigger);
}
};
}
- public static <T,K> IStructureElementDeferred<T> defer(Function<T,K> keyExtractorCheck,BiFunction<T,ItemStack,K> keyExtractor,Map<K,IStructureElement<T>> map){
- if(keyExtractor==null||map==null){
+ public static <T, K> IStructureElementDeferred<T> defer(Function<T, K> keyExtractorCheck, BiFunction<T, ItemStack, K> keyExtractor, Map<K, IStructureElement<T>> map) {
+ if (keyExtractor == null || map == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@@ -730,41 +734,41 @@ public class StructureUtility {
@Override
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);
+ return map.get(keyExtractor.apply(t, trigger)).placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return map.get(keyExtractor.apply(t, trigger)).spawnHint(t, world, x, y, z, trigger);
}
};
}
- public static <T,K> IStructureElementDeferred<T> defer(Function<T,K> keyExtractorCheck,BiFunction<T,ItemStack,K> keyExtractor,Map<K,IStructureElement<T>> map,IStructureElement<T> defaultElem){
- if(keyExtractor==null||map==null){
+ public static <T, K> IStructureElementDeferred<T> defer(Function<T, K> keyExtractorCheck, BiFunction<T, ItemStack, K> keyExtractor, Map<K, IStructureElement<T>> map, IStructureElement<T> defaultElem) {
+ if (keyExtractor == null || map == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@Override
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);
+ return map.getOrDefault(keyExtractorCheck.apply(t), defaultElem).check(t, world, x, y, z);
}
@Override
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);
+ return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).spawnHint(t, world, x, y, z, trigger);
}
};
}
@SafeVarargs
- public static <T> IStructureElementDeferred<T> defer(Function<T,Integer> keyExtractorCheck,BiFunction<T,ItemStack,Integer> keyExtractor, IStructureElement<T>... array){
- if(keyExtractor==null||array==null){
+ public static <T> IStructureElementDeferred<T> defer(Function<T, Integer> keyExtractorCheck, BiFunction<T, ItemStack, Integer> keyExtractor, IStructureElement<T>... array) {
+ if (keyExtractor == null || array == null) {
throw new IllegalArgumentException();
}
return new IStructureElementDeferred<T>() {
@@ -775,42 +779,42 @@ public class StructureUtility {
@Override
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);
+ return array[keyExtractor.apply(t, trigger)].placeBlock(t, world, x, y, z, trigger);
}
@Override
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);
+ return array[keyExtractor.apply(t, trigger)].spawnHint(t, world, x, y, z, trigger);
}
};
}
@SuppressWarnings("unchecked")
- public static <T> IStructureElementDeferred<T> defer(Function<T,Integer> keyExtractorCheck,BiFunction<T,ItemStack,Integer> keyExtractor, List<IStructureElement<T>> array){
+ public static <T> IStructureElementDeferred<T> defer(Function<T, Integer> keyExtractorCheck, BiFunction<T, ItemStack, Integer> keyExtractor, List<IStructureElement<T>> array) {
return defer(keyExtractorCheck, keyExtractor, array.toArray(new IStructureElement[0]));
}
- public static <T> IStructureNavigate<T> step(int a,int b, int c){
- return step(new Vec3Impl(a,b,c));
+ public static <T> IStructureNavigate<T> step(int a, int b, int c) {
+ return step(new Vec3Impl(a, b, c));
}
@SuppressWarnings("unchecked")
- public static <T> IStructureNavigate<T> step(Vec3Impl step){
- if(step==null || step.get0()<0 || step.get1()<0 || step.get2()<0){
+ public static <T> IStructureNavigate<T> step(Vec3Impl step) {
+ if (step == null || step.get0() < 0 || step.get1() < 0 || step.get2() < 0) {
throw new IllegalArgumentException();
}
return STEP.computeIfAbsent(step, vec3 -> {
- if(vec3.get2()>0){
+ if (vec3.get2() > 0) {
return stepC(vec3.get0(), vec3.get1(), vec3.get2());
- }else if(vec3.get1()>0){
+ } else if (vec3.get1() > 0) {
return stepB(vec3.get0(), vec3.get1(), vec3.get2());
- }else {
+ } else {
return stepA(vec3.get0(), vec3.get1(), vec3.get2());
}
});
}
- private static <T> IStructureNavigate<T> stepA(int a,int b, int c){
+ private static <T> IStructureNavigate<T> stepA(int a, int b, int c) {
return new IStructureNavigate<T>() {
@Override
public int getStepA() {
@@ -829,7 +833,7 @@ public class StructureUtility {
};
}
- private static <T> IStructureNavigate<T> stepB(int a,int b, int c){
+ private static <T> IStructureNavigate<T> stepB(int a, int b, int c) {
return new IStructureNavigate<T>() {
@Override
public int getStepA() {
@@ -853,7 +857,7 @@ public class StructureUtility {
};
}
- private static <T> IStructureNavigate<T> stepC(int a,int b, int c){
+ private static <T> IStructureNavigate<T> stepC(int a, int b, int c) {
return new IStructureNavigate<T>() {
@Override
public int getStepA() {
@@ -884,13 +888,14 @@ public class StructureUtility {
/**
* Used only to get pseudo code in structure writer...
+ *
* @param world
* @return
*/
public static String getPseudoJavaCode(World world, ExtendedFacing extendedFacing,
int basePositionX, int basePositionY, int basePositionZ,
int basePositionA, int basePositionB, int basePositionC,
- int sizeA,int sizeB, int sizeC) {
+ int sizeA, int sizeB, int sizeC, boolean transpose) {
Map<Block, Set<Integer>> blocks = new TreeMap<>(Comparator.comparing(Block::getUnlocalizedName));
Set<Class<? extends TileEntity>> tiles = new TreeSet<>(Comparator.comparing(Class::getCanonicalName));
Set<Class<? extends IMetaTileEntity>> gtTiles = new TreeSet<>(Comparator.comparing(Class::getCanonicalName));
@@ -934,7 +939,7 @@ public class StructureUtility {
Set<Integer> set = entry.getValue();
for (Integer meta : set) {
c = NICE_CHARS.charAt(i++);
- if(i>NICE_CHARS.length()){
+ if (i > NICE_CHARS.length()) {
return "Too complicated for nice chars";
}
map.put(block.getUnlocalizedName() + '\0' + meta, c);
@@ -945,7 +950,7 @@ public class StructureUtility {
builder.append("\nTiles:\n");
for (Class<? extends TileEntity> tile : tiles) {
c = NICE_CHARS.charAt(i++);
- if(i>NICE_CHARS.length()){
+ if (i > NICE_CHARS.length()) {
return "Too complicated for nice chars";
}
map.put(tile.getCanonicalName(), c);
@@ -955,7 +960,7 @@ public class StructureUtility {
builder.append("\nMeta:\n");
for (Class<? extends IMetaTileEntity> gtTile : gtTiles) {
c = NICE_CHARS.charAt(i++);
- if(i>NICE_CHARS.length()){
+ if (i > NICE_CHARS.length()) {
return "Too complicated for nice chars";
}
map.put(gtTile.getCanonicalName(), c);
@@ -965,61 +970,97 @@ public class StructureUtility {
}
builder.append("\nOffsets:\n")
.append(basePositionA).append(' ').append(basePositionB).append(' ').append(basePositionC).append('\n');
- builder.append("\nScan:\n")
- .append("new String[][]{{\n")
- .append(" \"");
-
- iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ,
- basePositionA, basePositionB, basePositionC,
- sizeA, sizeB, sizeC, ((w, x, y, z) -> {
- TileEntity tileEntity = w.getTileEntity(x, y, z);
- if (tileEntity == null) {
- Block block = w.getBlock(x, y, z);
- if (block != null && block != Blocks.air) {
- builder.append(map.get(block.getUnlocalizedName() + '\0' + world.getBlockMetadata(x, y, z)));
- }else {
- builder.append(' ');
- }
- } else {
- if (tileEntity instanceof IGregTechTileEntity) {
- IMetaTileEntity meta = ((IGregTechTileEntity) tileEntity).getMetaTileEntity();
- if (meta != null) {
- builder.append(map.get(meta.getClass().getCanonicalName()));
+ if (transpose) {
+ builder.append("\nTransposed Scan:\n")
+ .append("new String[][]{\n")
+ .append(" {\"");
+ iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ,
+ basePositionA, basePositionB, basePositionC, true,
+ sizeA, sizeB, sizeC, ((w, x, y, z) -> {
+ TileEntity tileEntity = w.getTileEntity(x, y, z);
+ if (tileEntity == null) {
+ Block block = w.getBlock(x, y, z);
+ if (block != null && block != Blocks.air) {
+ builder.append(map.get(block.getUnlocalizedName() + '\0' + world.getBlockMetadata(x, y, z)));
+ } else {
+ builder.append(' ');
+ }
+ } else {
+ if (tileEntity instanceof IGregTechTileEntity) {
+ IMetaTileEntity meta = ((IGregTechTileEntity) tileEntity).getMetaTileEntity();
+ if (meta != null) {
+ builder.append(map.get(meta.getClass().getCanonicalName()));
+ } else {
+ builder.append(map.get(tileEntity.getClass().getCanonicalName()));
+ }
} else {
builder.append(map.get(tileEntity.getClass().getCanonicalName()));
}
+ }
+ }),
+ () -> builder.append("\",\""),
+ () -> {
+ builder.setLength(builder.length() - 2);
+ builder.append("},\n {\"");
+ });
+ builder.setLength(builder.length() - 8);
+ builder.append("\n}\n\n");
+ } else {
+ builder.append("\nNormal Scan:\n")
+ .append("new String[][]{{\n")
+ .append(" \"");
+ iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ,
+ basePositionA, basePositionB, basePositionC, false,
+ sizeA, sizeB, sizeC, ((w, x, y, z) -> {
+ TileEntity tileEntity = w.getTileEntity(x, y, z);
+ if (tileEntity == null) {
+ Block block = w.getBlock(x, y, z);
+ if (block != null && block != Blocks.air) {
+ builder.append(map.get(block.getUnlocalizedName() + '\0' + world.getBlockMetadata(x, y, z)));
+ } else {
+ builder.append(' ');
+ }
} else {
- builder.append(map.get(tileEntity.getClass().getCanonicalName()));
+ if (tileEntity instanceof IGregTechTileEntity) {
+ IMetaTileEntity meta = ((IGregTechTileEntity) tileEntity).getMetaTileEntity();
+ if (meta != null) {
+ builder.append(map.get(meta.getClass().getCanonicalName()));
+ } else {
+ builder.append(map.get(tileEntity.getClass().getCanonicalName()));
+ }
+ } else {
+ builder.append(map.get(tileEntity.getClass().getCanonicalName()));
+ }
}
- }
- }),
- () -> builder.append("\",\n").append(" \""),
- () -> {
- builder.setLength(builder.length()-7);
- builder.append("\n").append("},{\n").append(" \"");
- });
- builder.setLength(builder.length()-8);
- builder.append("};\n\n");
- return(builder.toString().replaceAll("\"\"","E"));
+ }),
+ () -> builder.append("\",\n").append(" \""),
+ () -> {
+ builder.setLength(builder.length() - 7);
+ builder.append("\n").append("},{\n").append(" \"");
+ });
+ builder.setLength(builder.length() - 8);
+ builder.append("}\n\n");
+ }
+ return (builder.toString().replaceAll("\"\"", "E"));
}
public static void iterate(World world, ExtendedFacing extendedFacing,
- int basePositionX, int basePositionY, int basePositionZ,
- int basePositionA, int basePositionB, int basePositionC,
- int sizeA,int sizeB, int sizeC,
- IBlockPosConsumer iBlockPosConsumer){
- sizeA-=basePositionA;
- sizeB-=basePositionB;
- sizeC-=basePositionC;
+ int basePositionX, int basePositionY, int basePositionZ,
+ int basePositionA, int basePositionB, int basePositionC,
+ int sizeA, int sizeB, int sizeC,
+ IBlockPosConsumer iBlockPosConsumer) {
+ sizeA -= basePositionA;
+ sizeB -= basePositionB;
+ sizeC -= basePositionC;
int[] abc = new int[3];
int[] xyz = new int[3];
- for (abc[2]=-basePositionC ; abc[2] < sizeC; abc[2]++) {
- for (abc[1]=-basePositionB; abc[1] < sizeB; abc[1]++) {
- for (abc[0]=-basePositionA ; abc[0] < sizeA; abc[0]++) {
+ for (abc[2] = -basePositionC; abc[2] < sizeC; abc[2]++) {
+ for (abc[1] = -basePositionB; abc[1] < sizeB; abc[1]++) {
+ for (abc[0] = -basePositionA; abc[0] < sizeA; abc[0]++) {
extendedFacing.getWorldOffset(abc, xyz);
- iBlockPosConsumer.consume(world, xyz[0]+basePositionX,xyz[1]+basePositionY,xyz[2]+basePositionZ);
+ iBlockPosConsumer.consume(world, xyz[0] + basePositionX, xyz[1] + basePositionY, xyz[2] + basePositionZ);
}
}
@@ -1027,28 +1068,56 @@ public class StructureUtility {
}
public static void iterate(World world, ExtendedFacing extendedFacing,
- int basePositionX, int basePositionY, int basePositionZ,
- int basePositionA, int basePositionB, int basePositionC,
- int sizeA, int sizeB, int sizeC,
- IBlockPosConsumer iBlockPosConsumer,
- Runnable nextB,
- Runnable nextC){
- sizeA-=basePositionA;
- sizeB-=basePositionB;
- sizeC-=basePositionC;
+ int basePositionX, int basePositionY, int basePositionZ,
+ int basePositionA, int basePositionB, int basePositionC,
+ boolean transpose, int sizeA, int sizeB, int sizeC,
+ IBlockPosConsumer iBlockPosConsumer,
+ Runnable nextB,
+ Runnable nextC) {
+ sizeA -= basePositionA;
+ sizeB -= basePositionB;
+ sizeC -= basePositionC;
int[] abc = new int[3];
int[] xyz = new int[3];
-
- for (abc[2]=-basePositionC ; abc[2] < sizeC; abc[2]++) {
- for (abc[1]=-basePositionB; abc[1] < sizeB; abc[1]++) {
- for (abc[0]=-basePositionA ; abc[0] < sizeA; abc[0]++) {
- extendedFacing.getWorldOffset(abc, xyz);
- iBlockPosConsumer.consume(world, xyz[0]+basePositionX,xyz[1]+basePositionY,xyz[2]+basePositionZ);
+ if (transpose) {
+ for (abc[1] = -basePositionB; abc[1] < sizeB; abc[1]++) {
+ for (abc[2] = -basePositionC; abc[2] < sizeC; abc[2]++) {
+ for (abc[0] = -basePositionA; abc[0] < sizeA; abc[0]++) {
+ extendedFacing.getWorldOffset(abc, xyz);
+ iBlockPosConsumer.consume(world, xyz[0] + basePositionX, xyz[1] + basePositionY, xyz[2] + basePositionZ);
+ }
+ nextB.run();
+ }
+ nextC.run();
+ }
+ } else {
+ for (abc[2] = -basePositionC; abc[2] < sizeC; abc[2]++) {
+ for (abc[1] = -basePositionB; abc[1] < sizeB; abc[1]++) {
+ for (abc[0] = -basePositionA; abc[0] < sizeA; abc[0]++) {
+ extendedFacing.getWorldOffset(abc, xyz);
+ iBlockPosConsumer.consume(world, xyz[0] + basePositionX, xyz[1] + basePositionY, xyz[2] + basePositionZ);
+ }
+ nextB.run();
}
- nextB.run();
+ nextC.run();
+ }
+ }
+ }
+
+ /**
+ * Transposes shape (swaps B and C axis, can be used to un-transpose transposed shape)
+ * WARNING! Do not use on old api...
+ * @param structurePiece shape (transposed shape)
+ * @return transposed shape (untransposed shape)
+ */
+ public static String[][] transpose(String[][] structurePiece){
+ String[][] shape=new String[structurePiece[0].length][structurePiece.length];
+ for (int i = 0; i < structurePiece.length; i++) {
+ for (int j = 0; j < structurePiece[i].length; j++) {
+ shape[j][i]=structurePiece[i][j];
}
- nextC.run();
}
+ return shape;
}
}
diff --git a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java
index c24b35f8d5..752f2d1bcc 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java
@@ -1,23 +1,13 @@
package com.github.technus.tectech.thing.item;
-import com.github.technus.tectech.TecTech;
-import com.github.technus.tectech.mechanics.alignment.IAlignment;
-import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing;
-import com.github.technus.tectech.mechanics.constructable.IConstructable;
-import com.github.technus.tectech.mechanics.constructable.IMultiblockInfoContainer;
+import com.github.technus.tectech.mechanics.constructable.ConstructableUtility;
import com.github.technus.tectech.util.CommonValues;
import cpw.mods.fml.common.registry.GameRegistry;
-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.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
-import net.minecraftforge.common.util.FakePlayer;
-import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
@@ -39,97 +29,7 @@ public final class ConstructableTriggerItem extends Item {
@Override
public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) {
- 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;
+ return ConstructableUtility.handle(aStack, aPlayer, aWorld, aX, aY, aZ, aSide);
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java
index 8e3d770da1..f4531a248b 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java
@@ -73,7 +73,7 @@ public class EuMeterGT extends Item {
}
}
if (!(aPlayer instanceof EntityPlayerMP)) {
- GT_Utility.doSoundAtClient(Reference.MODID + ":fx_scan", 1, 1.0F, (double) aX, (double) aY, (double) aZ);
+ GT_Utility.doSoundAtClient(Reference.MODID + ":fx_scan", 1, 1.0F, aX, aY, aZ);
}
return false;
}
diff --git a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java
index 5edc238a91..d71abb34b7 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java
@@ -1,19 +1,13 @@
package com.github.technus.tectech.thing.item;
-import com.github.technus.tectech.mechanics.alignment.IAlignment;
-import com.github.technus.tectech.mechanics.alignment.IAlignmentProvider;
+import com.github.technus.tectech.mechanics.alignment.AlignmentUtility;
import com.github.technus.tectech.util.CommonValues;
import cpw.mods.fml.common.registry.GameRegistry;
-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.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
-import net.minecraftforge.common.util.FakePlayer;
import java.util.List;
@@ -36,33 +30,7 @@ public final class FrontRotationTriggerItem extends Item {
@Override
public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) {
- 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;
+ return AlignmentUtility.handle(aPlayer,aWorld,aX,aY,aZ);
}
@Override