From 4a9a1df6dfff83fc84c4b0b2660632d3b01b2cdb Mon Sep 17 00:00:00 2001 From: Technus Date: Sat, 12 Aug 2017 16:19:30 +0200 Subject: Compatiblity solutions --- .../thing/item/ConstructibleTriggerItem.java | 9 ++-- .../multi/GT_MetaTileEntity_EM_switch.java | 60 ++++++++++++---------- .../multi/GT_MetaTileEntity_EM_transformer.java | 56 +++++++++++--------- .../multi/GT_MetaTileEntity_MultiblockBase_EM.java | 3 +- 4 files changed, 73 insertions(+), 55 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/github/technus/tectech/thing/item/ConstructibleTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/ConstructibleTriggerItem.java index 404d5ae4f8..15462838d9 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ConstructibleTriggerItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ConstructibleTriggerItem.java @@ -10,6 +10,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ElectricBlastFurnace; import net.minecraft.block.Block; +import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -17,6 +18,7 @@ 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.HashMap; import java.util.List; @@ -43,7 +45,7 @@ public class ConstructibleTriggerItem 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) return aPlayer instanceof EntityPlayerMP; + if(tTileEntity==null || aPlayer instanceof FakePlayer) return aPlayer instanceof EntityPlayerMP; if (aPlayer instanceof EntityPlayerMP) { //struct gen if (aPlayer.isSneaking() && aPlayer.capabilities.isCreativeMode) { @@ -54,6 +56,7 @@ public class ConstructibleTriggerItem extends Item { return true; } else if (multiblockMap.containsKey(metaTE.getClass())) { multiblockMap.get(metaTE.getClass()).construct(aStack.stackSize, false, tTileEntity, ((IGregTechTileEntity) tTileEntity).getFrontFacing()); + return true; } } else if (tTileEntity instanceof IConstructable) { ((IConstructable) tTileEntity).construct(aStack.stackSize, false); @@ -63,9 +66,7 @@ public class ConstructibleTriggerItem extends Item { return true; } } - } - //particles and text client side - if(aWorld.isRemote){ + }else if (aPlayer instanceof EntityClientPlayerMP){//particles and text client side if ((!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode)) { if(tTileEntity instanceof IGregTechTileEntity) { IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java index b87cc72d26..be1299860d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java @@ -1,19 +1,21 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.Vec3pos; import com.github.technus.tectech.dataFramework.QuantumDataPacket; +import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; -import com.github.technus.tectech.Vec3pos; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; +import static com.github.technus.tectech.Util.StructureBuilder; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; @@ -22,7 +24,25 @@ import static gregtech.api.enums.GT_Values.V; /** * Created by danie_000 on 17.12.2016. */ -public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBase_EM { +public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable{ + //region Structure + private static final String[][] shape = new String[][]{ + {" "," . "," ",}, + {" "," 0 "," ",}, + {" "," "," ",}, + }; + private static final Block[] blockType = new Block[]{sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{3}; + private static final String[] addingMethods = new String[]{"addClassicToMachineList"}; + private static final short[] casingTextures = new short[]{textureOffset}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{1}; + private static final String[] description = new String[]{ + EnumChatFormatting.AQUA+"Hint Details:", + "1 - Classic/Data Hatches or Computer casing", + }; + //endregion + public GT_MetaTileEntity_EM_switch(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -45,29 +65,17 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; - int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; - if (iGregTechTileEntity.getBlockOffset(xDir, yDir, zDir) != sBlockCasingsTT || iGregTechTileEntity.getMetaIDOffset(xDir, yDir, zDir) != 3) - return false; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((i != 0 || j != 0 || h != 0)/*exclude center*/ && (xDir + i != 0 || yDir + h != 0 || zDir + j != 0)/*exclude this*/) { - IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, yDir + h, zDir + j); - if (!addEnergyIOToMachineList(tTileEntity, textureOffset + 1) && - (!addDataConnectorToMachineList(tTileEntity, textureOffset + 1)) && - (!addMaintenanceToMachineList(tTileEntity, textureOffset + 1))) { - if (iGregTechTileEntity.getBlockOffset(xDir + i, yDir + h, zDir + j) != sBlockCasingsTT || - iGregTechTileEntity.getMetaIDOffset(xDir + i, yDir + h, zDir + j) != 1) { - return false; - } - } - } - } - } - } - return true; + return EM_StructureCheckAdvanced(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 1, 0); + } + + @Override + public void construct(int stackSize, boolean hintsOnly) { + StructureBuilder(shape, blockType, blockMeta,1, 1, 0, getBaseMetaTileEntity(),hintsOnly); + } + + @Override + public String[] getStructureDescription(int stackSize) { + return description; } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java index c08765e4fe..ebe1ff3de4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java @@ -1,15 +1,17 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; +import static com.github.technus.tectech.Util.StructureBuilder; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; @@ -18,7 +20,25 @@ import static gregtech.api.GregTech_API.sBlockCasings1; /** * Created by danie_000 on 17.12.2016. */ -public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_MultiblockBase_EM { +public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable{ + //region Structure + private static final String[][] shape = new String[][]{ + {" "," . "," ",}, + {" "," 0 "," ",}, + {" "," "," ",}, + }; + private static final Block[] blockType = new Block[]{sBlockCasings1}; + private static final byte[] blockMeta = new byte[]{15}; + private static final String[] addingMethods = new String[]{"addEnergyIOToMachineList"}; + private static final short[] casingTextures = new short[]{textureOffset}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{0}; + private static final String[] description = new String[]{ + EnumChatFormatting.AQUA+"Hint Details:", + "1 - Energy IO Hatches or High Power Casing", + }; + //endregion + public GT_MetaTileEntity_EM_transformer(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); mWrench = true; @@ -45,27 +65,17 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; - int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; - if (iGregTechTileEntity.getBlockOffset(xDir, yDir, zDir) != sBlockCasings1 || iGregTechTileEntity.getMetaIDOffset(xDir, yDir, zDir) != 15) - return false;//Not superconducting coil in middle - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((i != 0 || j != 0 || h != 0)/*exclude center*/ && (xDir + i != 0 || yDir + h != 0 || zDir + j != 0)/*exclude this*/) { - IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, yDir + h, zDir + j); - if (!addEnergyIOToMachineList(tTileEntity, textureOffset)) { - if (iGregTechTileEntity.getBlockOffset(xDir + i, yDir + h, zDir + j) != sBlockCasingsTT || - iGregTechTileEntity.getMetaIDOffset(xDir + i, yDir + h, zDir + j) != 0) { - return false; - } - } - } - } - } - } - return true; + return EM_StructureCheckAdvanced(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 1, 0); + } + + @Override + public void construct(int stackSize, boolean hintsOnly) { + StructureBuilder(shape, blockType, blockMeta,1, 1, 0, getBaseMetaTileEntity(),hintsOnly); + } + + @Override + public String[] getStructureDescription(int stackSize) { + return description; } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java index d4cd958204..56af7e045d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java @@ -512,8 +512,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mSolderingTool = true; mCrowbar = true; } else { - if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) - tHatch.isRecipeInputEqual(true); + if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) tHatch.autoMaintainance(); if (tHatch.mWrench) mWrench = true; if (tHatch.mScrewdriver) mScrewdriver = true; if (tHatch.mSoftHammer) mSoftHammer = true; -- cgit