From b8abcd143a3efe84141aebc22fee55449b1ad5f1 Mon Sep 17 00:00:00 2001 From: Tec Date: Sun, 11 Mar 2018 10:03:57 +0100 Subject: add eu reader for gt --- src/main/java/com/github/technus/tectech/Util.java | 2 + .../technus/tectech/loader/RecipeLoader.java | 17 ++++- .../technus/tectech/loader/ThingsLoader.java | 1 + .../technus/tectech/thing/item/EuMeterGT.java | 79 ++++++++++++++++++++++ 4 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java (limited to 'src/main/java/com') diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index 9d53689517..fe623d7135 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -69,6 +69,7 @@ public final class Util { return result.toString(); } + //region junk /* //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller //This only checks for REGULAR BLOCKS! @@ -355,6 +356,7 @@ public final class Util { return true; } */ + //endregion //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller //This only checks for REGULAR BLOCKS! diff --git a/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java index 0299f96849..0b44eacca5 100644 --- a/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java @@ -5,8 +5,10 @@ import com.github.technus.tectech.elementalMatter.definitions.complex.atom.dAtom import com.github.technus.tectech.elementalMatter.definitions.complex.hadron.dHadronDefinition; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.item.ConstructableTriggerItem; +import com.github.technus.tectech.thing.item.EuMeterGT; import cpw.mods.fml.common.Loader; import gregtech.api.enums.Dyes; +import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; @@ -38,12 +40,23 @@ public class RecipeLoader implements Runnable { GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{Dyes.dyeBlue, OrePrefixes.plate.get(Materials.Paper), Dyes.dyeBlue, Dyes.dyeWhite}); + //GT EU reader + GT_ModHandler.addCraftingRecipe(new ItemStack(EuMeterGT.INSTANCE,1), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{"PGW", "SCW", "BRN", + 'P', OrePrefixes.plateDouble.get(Materials.Steel), + 'G', OrePrefixes.plate.get(Materials.Glass), + 'W', OrePrefixes.cableGt01.get(Materials.Copper), + 'S', OrePrefixes.stick.get(Materials.Brass), + 'C', ItemList.Casing_Coil_Cupronickel.get(1), + 'B', Dyes.dyeBlue, + 'R', Dyes.dyeRed, + 'N', Dyes.dyeBlack,}); + if (Loader.isModLoaded("dreamcraft")) { new DreamCraftRecipeLoader().run();//init recipes for GTNH version } else { new BloodyRecipeLoader().run();//init recipes for NON-GTNH version } - - } } diff --git a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java index 3cd285a858..84d1a8ab0c 100644 --- a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java @@ -51,6 +51,7 @@ public class ThingsLoader implements Runnable { FrontRotationTriggerItem.run(); ParametrizerMemoryCard.run(); ElementalDefinitionScanStorage_EM.run(); + EuMeterGT.run(); TecTech.Logger.info("Useful Items registered"); ElementalDefinitionContainer_EM.run(); 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 new file mode 100644 index 0000000000..84c43aad8f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java @@ -0,0 +1,79 @@ +package com.github.technus.tectech.thing.item; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.auxiliary.Reference; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; +import gregtech.api.util.GT_Utility; +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.ArrayList; +import java.util.List; + +import static com.github.technus.tectech.auxiliary.Reference.MODID; + +public class EuMeterGT extends Item { + public static EuMeterGT INSTANCE; + + private EuMeterGT() { + setUnlocalizedName("em.EuMeterGT"); + setTextureName(MODID + ":itemEuMeterGT"); + setMaxStackSize(1); + } + + @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 && !aPlayer.isSneaking() && tTileEntity instanceof IGregTechTileEntity) { + if (tTileEntity instanceof BaseMetaTileEntity) { + GT_Utility.sendChatToPlayer(aPlayer, EnumChatFormatting.AQUA+"----- X:"+aX+" Y:"+aY+" Z:"+aZ+" D:"+aWorld.provider.dimensionId+" S:"+aSide + " -----"); + GT_Utility.sendChatToPlayer(aPlayer, "Stored energy: "+EnumChatFormatting.YELLOW+(((BaseMetaTileEntity) tTileEntity).getUniversalEnergyStored())+EnumChatFormatting.RESET+'/'+EnumChatFormatting.GREEN+(((BaseMetaTileEntity) tTileEntity).getUniversalEnergyCapacity())); + GT_Utility.sendChatToPlayer(aPlayer, "Stored EU: "+EnumChatFormatting.YELLOW+(((BaseMetaTileEntity) tTileEntity).getStoredEU())+EnumChatFormatting.RESET+'/'+EnumChatFormatting.GREEN+(((BaseMetaTileEntity) tTileEntity).getEUCapacity())); + GT_Utility.sendChatToPlayer(aPlayer, "Average I/O: "+EnumChatFormatting.YELLOW+(((BaseMetaTileEntity) tTileEntity).getAverageElectricInput())+EnumChatFormatting.RESET+'/'+EnumChatFormatting.YELLOW+(((BaseMetaTileEntity) tTileEntity).getAverageElectricOutput())); + GT_Utility.sendChatToPlayer(aPlayer, "Voltage I/O (max): "+EnumChatFormatting.GOLD+(((BaseMetaTileEntity) tTileEntity).getInputVoltage())+EnumChatFormatting.RESET+'/'+EnumChatFormatting.GOLD+(((BaseMetaTileEntity) tTileEntity).getOutputVoltage())); + GT_Utility.sendChatToPlayer(aPlayer, "Voltage I/O max: "+EnumChatFormatting.RED+(((BaseMetaTileEntity) tTileEntity).getMaxSafeInput())+EnumChatFormatting.RESET+'/'+EnumChatFormatting.RED+(((BaseMetaTileEntity) tTileEntity).getMaxEnergyOutput())); + GT_Utility.sendChatToPlayer(aPlayer, "Amperage I/O (max): "+EnumChatFormatting.GOLD+(((BaseMetaTileEntity) tTileEntity).getInputAmperage())+EnumChatFormatting.RESET+'/'+EnumChatFormatting.GOLD+(((BaseMetaTileEntity) tTileEntity).getOutputAmperage())); + GT_Utility.sendChatToPlayer(aPlayer, "Side capabilities: "+(((BaseMetaTileEntity) tTileEntity).inputEnergyFrom((byte) aSide)?"input ":"")+(((BaseMetaTileEntity) tTileEntity).outputsEnergyTo((byte) aSide)?"output ":"")); + return true; + } else if (tTileEntity instanceof BaseMetaPipeEntity) { + if(((BaseMetaPipeEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable){ + ArrayList tList = new ArrayList<>(); + GT_Utility.getCoordinateScan(tList, aPlayer, aWorld, 1, aX, aY, aZ, aSide, hitX, hitY, hitZ); + for(String str:tList){ + GT_Utility.sendChatToPlayer(aPlayer,str); + } + } + return true; + } + } + if(!(aPlayer instanceof EntityPlayerMP)){ + GT_Utility.doSoundAtClient(Reference.MODID+":fx_scan", 1, 1.0F, (double)aX, (double)aY, (double)aZ); + } + return false; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.TEC_MARK_GENERAL); + aList.add("Measures basic EU related stuff"); + aList.add(EnumChatFormatting.BLUE + "Just right click on blocks."); + } + + public static void run() { + INSTANCE = new EuMeterGT(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + } +} -- cgit