From 85c804fa112fd1f19c91e45d150a787cfbf0f7a8 Mon Sep 17 00:00:00 2001 From: Shawn Buckley Date: Sun, 18 Oct 2015 23:04:39 -0400 Subject: Move source directory --- .../basic/GT_MetaTileEntity_Boxinator.java | 109 ++++++ .../basic/GT_MetaTileEntity_Disassembler.java | 65 ++++ .../basic/GT_MetaTileEntity_Massfabricator.java | 77 +++++ .../basic/GT_MetaTileEntity_MonsterRepellent.java | 79 +++++ .../basic/GT_MetaTileEntity_PotionBrewer.java | 159 +++++++++ .../machines/basic/GT_MetaTileEntity_Printer.java | 65 ++++ .../machines/basic/GT_MetaTileEntity_Pump.java | 380 +++++++++++++++++++++ .../basic/GT_MetaTileEntity_Replicator.java | 119 +++++++ .../basic/GT_MetaTileEntity_RockBreaker.java | 82 +++++ .../machines/basic/GT_MetaTileEntity_Scanner.java | 215 ++++++++++++ .../basic/GT_MetaTileEntity_Teleporter.java | 340 ++++++++++++++++++ 11 files changed, 1690 insertions(+) create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Massfabricator.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MonsterRepellent.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Printer.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java (limited to 'src/main/java/gregtech/common/tileentities/machines/basic') diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java new file mode 100644 index 0000000000..bf498a22d1 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java @@ -0,0 +1,109 @@ +package gregtech.common.tileentities.machines.basic; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; + +public class GT_MetaTileEntity_Boxinator + extends GT_MetaTileEntity_BasicMachine +{ + public GT_MetaTileEntity_Boxinator(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier, 1, "Puts things into Boxes", 2, 1, "Packager.png", "", new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_BOXINATOR_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_BOXINATOR), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_BOXINATOR_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_BOXINATOR), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_BOXINATOR_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_BOXINATOR), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_BOXINATOR_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_BOXINATOR) }); + } + + public GT_MetaTileEntity_Boxinator(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) + { + super(aName, aTier, 1, aDescription, aTextures, 2, 1, aGUIName, aNEIName); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_Boxinator(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public GT_Recipe.GT_Recipe_Map getRecipeList() + { + return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes; + } + + public int checkRecipe() + { + int tCheck = super.checkRecipe(); + if (tCheck != 0) { + return tCheck; + } + if ((GT_Utility.isStackValid(getInputAt(0))) && (GT_Utility.isStackValid(getInputAt(1))) && (GT_Utility.getContainerItem(getInputAt(0), true) == null)) + { + if ((ItemList.Schematic_1by1.isStackEqual(getInputAt(1))) && (getInputAt(0).stackSize >= 1)) + { + this.mOutputItems[0] = GT_ModHandler.getRecipeOutput(new ItemStack[] { getInputAt(0) }); + if (this.mOutputItems[0] != null) { + if (canOutput(new ItemStack[] { this.mOutputItems[0] })) + { + getInputAt(0).stackSize -= 1; + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + this.mMaxProgresstime = (16 / (1 << this.mTier - 1)); + return 2; + } + } + return 0; + } + if ((ItemList.Schematic_2by2.isStackEqual(getInputAt(1))) && (getInputAt(0).stackSize >= 4)) + { + this.mOutputItems[0] = GT_ModHandler.getRecipeOutput(new ItemStack[] { getInputAt(0), getInputAt(0), null, getInputAt(0), getInputAt(0) }); + if (this.mOutputItems[0] != null) { + if (canOutput(new ItemStack[] { this.mOutputItems[0] })) + { + getInputAt(0).stackSize -= 4; + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + this.mMaxProgresstime = (32 / (1 << this.mTier - 1)); + return 2; + } + } + return 0; + } + if ((ItemList.Schematic_3by3.isStackEqual(getInputAt(1))) && (getInputAt(0).stackSize >= 9)) + { + this.mOutputItems[0] = GT_ModHandler.getRecipeOutput(new ItemStack[] { getInputAt(0), getInputAt(0), getInputAt(0), getInputAt(0), getInputAt(0), getInputAt(0), getInputAt(0), getInputAt(0), getInputAt(0) }); + if (this.mOutputItems[0] != null) { + if (canOutput(new ItemStack[] { this.mOutputItems[0] })) + { + getInputAt(0).stackSize -= 9; + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + this.mMaxProgresstime = (64 / (1 << this.mTier - 1)); + return 2; + } + } + return 0; + } + } + return 0; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) + { + if (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + { + if ((ItemList.Schematic_1by1.isStackEqual(getInputAt(1))) || (ItemList.Schematic_2by2.isStackEqual(getInputAt(1))) || (ItemList.Schematic_3by3.isStackEqual(getInputAt(1)))) { + if(GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe(getBaseMetaTileEntity(), true, gregtech.api.enums.GT_Values.V[this.mTier], null, new ItemStack[] { GT_Utility.copyAmount(64L, new Object[] { aStack }), getInputAt(1) }) != null){return true;} + if(ItemList.Schematic_1by1.isStackEqual(getInputAt(1))&>_ModHandler.getRecipeOutput(new ItemStack[] { aStack })!=null)return true; + if(ItemList.Schematic_2by2.isStackEqual(getInputAt(1))&>_ModHandler.getRecipeOutput(new ItemStack[] { aStack, aStack, null, aStack, aStack })!=null){return true;} + if(ItemList.Schematic_3by3.isStackEqual(getInputAt(1))&&(GT_ModHandler.getRecipeOutput(new ItemStack[] { aStack,aStack,aStack,aStack,aStack,aStack,aStack,aStack,aStack })!=null)){return true;} + }else{return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack);} + } + return false; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java new file mode 100644 index 0000000000..8be43c1b94 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -0,0 +1,65 @@ +package gregtech.common.tileentities.machines.basic; + +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_Disassembler + extends GT_MetaTileEntity_BasicMachine +{ + public GT_MetaTileEntity_Disassembler(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier, 1, "Disassembles Machines at " + (50 + 10 * aTier) + "% Efficiency", 1, 9, "Disassembler.png", "", new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_DISASSEMBLER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_DISASSEMBLER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_DISASSEMBLER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_DISASSEMBLER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_DISASSEMBLER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_DISASSEMBLER) }); + } + + public GT_MetaTileEntity_Disassembler(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) + { + super(aName, aTier, 1, aDescription, aTextures, 1, 9, aGUIName, aNEIName); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_Disassembler(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public int checkRecipe() + { + if ((getInputAt(0) != null) && (isOutputEmpty())) + { + NBTTagCompound tNBT = getInputAt(0).getTagCompound(); + if (tNBT != null) + { + tNBT = tNBT.getCompoundTag("GT.CraftingComponents"); + if (tNBT != null) + { + getInputAt(0).stackSize -= 1; + this.mEUt = (16 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + this.mMaxProgresstime = 80; + for (int i = 0; i < this.mOutputItems.length; i++) { + if (getBaseMetaTileEntity().getRandomNumber(100) < 50 + 10 * this.mTier) + { + this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i); + if (this.mOutputItems[i] != null) { + this.mMaxProgresstime *= 1.7; + } + } + } + return 2; + } + } + } + return 0; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) + { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (aStack.getTagCompound() != null) && (aStack.getTagCompound().getCompoundTag("GT.CraftingComponents") != null); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Massfabricator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Massfabricator.java new file mode 100644 index 0000000000..1932ad49f3 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Massfabricator.java @@ -0,0 +1,77 @@ +package gregtech.common.tileentities.machines.basic; + +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_Massfabricator + extends GT_MetaTileEntity_BasicMachine +{ + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3215; + public static boolean sRequiresUUA = false; + + public GT_MetaTileEntity_Massfabricator(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier, 1, "UUM = Matter * Fabrication Squared", 1, 1, "Massfabricator.png", "", new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_MASSFAB_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_MASSFAB), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB) }); + } + + public GT_MetaTileEntity_Massfabricator(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) + { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_Massfabricator(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public void onConfigLoad(GT_Config aConfig) + { + super.onConfigLoad(aConfig); + sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUM_Duration_Multiplier", sDurationMultiplier); + sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_per_UUM", sUUAperUUM); + sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Speed_Bonus", sUUASpeedBonus); + sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Requirement", sRequiresUUA); + Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); + } + + public int checkRecipe() + { + FluidStack tFluid = getDrainableStack(); + if ((tFluid == null) || (tFluid.amount < getCapacity())) + { + this.mOutputFluid = Materials.UUMatter.getFluid(1L); + this.mEUt = ((int)gregtech.api.enums.GT_Values.V[this.mTier]); + this.mMaxProgresstime = (sDurationMultiplier / (1 << this.mTier - 1)); + if (((tFluid = getFillableStack()) != null) && (tFluid.amount >= sUUAperUUM) && (tFluid.isFluidEqual(Materials.UUAmplifier.getFluid(1L)))) + { + tFluid.amount -= sUUAperUUM; + this.mMaxProgresstime /= sUUASpeedBonus; + return 2; + } + return (sRequiresUUA) || (ItemList.Circuit_Integrated.isStackEqual(getInputAt(0), true, true)) ? 1 : 2; + } + return 0; + } + + public boolean isFluidInputAllowed(FluidStack aFluid) + { + return aFluid.isFluidEqual(Materials.UUAmplifier.getFluid(1L)); + } + + public int getCapacity() + { + return Math.max(sUUAperUUM, 1000); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MonsterRepellent.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MonsterRepellent.java new file mode 100644 index 0000000000..871835020d --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MonsterRepellent.java @@ -0,0 +1,79 @@ +package gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GT_Values.V; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingSpawnEvent; +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.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_SpawnEventHandler; + +public class GT_MetaTileEntity_MonsterRepellent extends GT_MetaTileEntity_TieredMachineBlock { + + public int mRange = 16; + + public GT_MetaTileEntity_MonsterRepellent(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 0, "Reprells nasty Creatures. Range: "+(4 + (12*aTier))+" unpowered / "+(16 + (48*aTier))+" powered"); + } + + public GT_MetaTileEntity_MonsterRepellent(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_MonsterRepellent(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1], (aSide != 1) ? null : aActive ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER) }; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide()) { + int[] tCoords = new int[]{aBaseMetaTileEntity.getXCoord(),aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord(),aBaseMetaTileEntity.getWorld().provider.dimensionId}; + if((aTimer%600 == 0)&&!GT_SpawnEventHandler.mobReps.contains(tCoords)){ + GT_SpawnEventHandler.mobReps.add(tCoords); + } + if(aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && aBaseMetaTileEntity.decreaseStoredEnergyUnits(1 << (this.mTier*2), false)){ + mRange = 16 + (48*mTier); + }else{ + mRange = 4 + (12*mTier); + }} + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + int[] tCoords = new int[]{aBaseMetaTileEntity.getXCoord(),aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord(),aBaseMetaTileEntity.getWorld().provider.dimensionId}; + GT_SpawnEventHandler.mobReps.add(tCoords); + } + + @Override + public void onRemoval() { + int[] tCoords = new int[]{this.getBaseMetaTileEntity().getXCoord(),this.getBaseMetaTileEntity().getYCoord(),this.getBaseMetaTileEntity().getZCoord(),this.getBaseMetaTileEntity().getWorld().provider.dimensionId}; + GT_SpawnEventHandler.mobReps.remove(tCoords); + } + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isFacingValid(byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isInputFacing(byte aSide) {return true;} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 512;} + @Override public long maxEUStore() {return 512+V[mTier]*50;} + @Override public long maxEUInput() {return V[mTier];} + @Override public long maxAmperesIn() {return 2;} + @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {return false;} + @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {return false;} + @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) {return null;} + @Override public void saveNBTData(NBTTagCompound aNBT) {} + @Override public void loadNBTData(NBTTagCompound aNBT) {} + } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java new file mode 100644 index 0000000000..35110b6adf --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java @@ -0,0 +1,159 @@ +package gregtech.common.tileentities.machines.basic; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_PotionBrewer + extends GT_MetaTileEntity_BasicMachine +{ + public GT_MetaTileEntity_PotionBrewer(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier, 1, "Brewing your Drinks", 1, 0, "PotionBrewer.png", "", new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_POTIONBREWER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_POTIONBREWER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_POTIONBREWER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_POTIONBREWER) }); + } + + public GT_MetaTileEntity_PotionBrewer(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) + { + super(aName, aTier, 1, aDescription, aTextures, 1, 0, aGUIName, aNEIName); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_PotionBrewer(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public GT_Recipe.GT_Recipe_Map getRecipeList() + { + return GT_Recipe.GT_Recipe_Map.sBrewingRecipes; + } + + public int checkRecipe() + { + int tCheck = super.checkRecipe(); + if (tCheck != 0) { + return tCheck; + } + FluidStack aFluid = getFillableStack(); + if ((getDrainableStack() == null) && (aFluid != null) && (getInputAt(0) != null)) + { + String tInputName = aFluid.getFluid().getName(); + if (tInputName.startsWith("potion.")) + { + tInputName = tInputName.replaceFirst("potion.", ""); + int tFirstDot = tInputName.indexOf('.') + 1; + String tModifier = tFirstDot <= 0 ? "" : tInputName.substring(tFirstDot); + if (!tModifier.isEmpty()) { + tInputName = tInputName.replaceFirst("." + tModifier, ""); + } + if (GT_Utility.areStacksEqual(new ItemStack(Items.fermented_spider_eye, 1, 0), getInputAt(0))) + { + if (tInputName.equals("poison")) { + return setOutput("potion.damage" + tModifier); + } + if (tInputName.equals("health")) { + return setOutput("potion.damage" + tModifier); + } + if (tInputName.equals("waterbreathing")) { + return setOutput("potion.damage" + tModifier); + } + if (tInputName.equals("nightvision")) { + return setOutput("potion.invisibility" + tModifier); + } + if (tInputName.equals("fireresistance")) { + return setOutput("potion.slowness" + tModifier); + } + if (tInputName.equals("speed")) { + return setOutput("potion.slowness" + tModifier); + } + if (tInputName.equals("strength")) { + return setOutput("potion.weakness" + tModifier); + } + if (tInputName.equals("regen")) { + return setOutput("potion.poison" + tModifier); + } + return setOutput("potion.weakness"); + } + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Glowstone, 1L), getInputAt(0))) + { + if (!tModifier.startsWith("strong")) { + return setOutput("potion." + tInputName + ".strong" + (tModifier.isEmpty() ? "" : new StringBuilder().append(".").append(tModifier).toString())); + } + if (tModifier.startsWith("long")) { + return setOutput("potion." + tInputName + tModifier.replaceFirst("long", "")); + } + return setOutput("potion.thick"); + } + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L), getInputAt(0))) + { + if (!tModifier.startsWith("long")) { + return setOutput("potion." + tInputName + ".long" + (tModifier.isEmpty() ? "" : new StringBuilder().append(".").append(tModifier).toString())); + } + if (tModifier.startsWith("strong")) { + return setOutput("potion." + tInputName + tModifier.replaceFirst("strong", "")); + } + return setOutput("potion.mundane"); + } + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Gunpowder, 1L), getInputAt(0))) + { + if (!tInputName.endsWith(".splash")) { + return setOutput("potion." + tInputName + ".splash"); + } + return setOutput("potion.mundane"); + } + } + } + return 0; + } + + private final int setOutput(String aFluidName) + { + this.mOutputFluid = FluidRegistry.getFluidStack(aFluidName, 750); + if (this.mOutputFluid == null) + { + this.mOutputFluid = FluidRegistry.getFluidStack("potion.mundane", getFillableStack().amount); + getInputAt(0).stackSize -= 1; + getFillableStack().amount = 0; + this.mEUt = (4 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + this.mMaxProgresstime = (128 / (1 << this.mTier - 1)); + return 2; + } + if (getFillableStack().amount < 750) { + return 0; + } + getInputAt(0).stackSize -= 1; + getFillableStack().amount -= 750; + this.mEUt = (4 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + this.mMaxProgresstime = (128 / (1 << this.mTier - 1)); + return 2; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) + { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); + } + + public boolean isFluidInputAllowed(FluidStack aFluid) + { + return (aFluid.getFluid().getName().startsWith("potion.")) || (super.isFluidInputAllowed(aFluid)); + } + + public int getCapacity() + { + return 750; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Printer.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Printer.java new file mode 100644 index 0000000000..b4058f8830 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Printer.java @@ -0,0 +1,65 @@ +package gregtech.common.tileentities.machines.basic; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Printer + extends GT_MetaTileEntity_BasicMachine +{ + public GT_MetaTileEntity_Printer(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier, 1, "It can copy Books and paint Stuff", 1, 1, "Printer.png", GT_Recipe.GT_Recipe_Map.sPrinterRecipes.mNEIName, new ITexture[0]); + } + + public GT_MetaTileEntity_Printer(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) + { + super(aName, aTier, 1, aDescription, aTextures, 2, 2, aGUIName, aNEIName); + } + + public int checkRecipe() + { + if (getOutputAt(0) != null) + { + this.mOutputBlocked += 1; + } + else if ((GT_Utility.isStackValid(getInputAt(0))) && (getInputAt(0).stackSize > 0) && + (GT_Utility.isStackInvalid(getSpecialSlot())) && + (OrePrefixes.block.contains(getInputAt(0)))) + { + ArrayList tList = GT_OreDictUnificator.getOres(GT_OreDictUnificator.getAssociation(getInputAt(0))); + if (tList.size() > 1) + { + tList.add(tList.get(0)); + int i = 0; + for (int j = tList.size() - 1; i < j; i++) { + if (GT_Utility.areStacksEqual(getInputAt(0), (ItemStack)tList.get(i))) + { + this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[] { tList.get(i + 1) }); + this.mEUt = (1 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + this.mMaxProgresstime = (32 / (1 << this.mTier - 1)); + getInputAt(0).stackSize -= 1; + return 2; + } + } + } + } + this.mMaxProgresstime = 0; + return 0; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return null; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java new file mode 100644 index 0000000000..40020ef435 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -0,0 +1,380 @@ +package gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GT_Values.V; + +import java.util.ArrayList; +import java.util.Iterator; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.ChunkPosition; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidBlock; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_BasicTank; +import gregtech.api.gui.GT_GUIContainer_BasicTank; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; + +public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { + + public ArrayList mPumpList = new ArrayList(); + public int mPumpTimer = 0; + public int mPumpCountBelow = 0; + public Block mPumpedBlock1 = null; + public Block mPumpedBlock2 = null; + + public GT_MetaTileEntity_Pump(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "The best way of emptying Oceans!"); + } + + public GT_MetaTileEntity_Pump(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription,aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Pump(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setString("mPumpedBlock1", this.mPumpedBlock1 == null ? "" : this.mPumpedBlock1.getUnlocalizedName()); + aNBT.setString("mPumpedBlock2", this.mPumpedBlock2 == null ? "" : this.mPumpedBlock2.getUnlocalizedName()); + } + + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mPumpedBlock1 = Block.getBlockFromName(aNBT.getString("mPumpedBlock1")); + this.mPumpedBlock2 = Block.getBlockFromName(aNBT.getString("mPumpedBlock2")); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + @Override + public boolean doesFillContainers() { + return true; + } + @Override + public boolean doesEmptyContainers() { + return false; + } + @Override + public boolean canTankBeFilled() { + return false; + } + @Override + public boolean canTankBeEmptied() { + return true; + } + @Override + public boolean displaysItemStack() { + return true; + } + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isServerSide()) { + this.mPumpTimer -= 1; + if ((getBaseMetaTileEntity() instanceof BaseTileEntity)) { + ((BaseTileEntity) getBaseMetaTileEntity()).ignoreUnloadedChunks = false; + } + this.doTickProfilingInThisTick = true; + this.mPumpCountBelow = 0; + IGregTechTileEntity tTileEntity; + for (int i = 1; (i < 21) && ((tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance((byte) 0, i)) != null) + && (tTileEntity.getMetaTileEntity() != null) && ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Pump)); i++) { + getBaseMetaTileEntity().setActive(tTileEntity.isActive()); + this.mPumpCountBelow += 1; + ((GT_MetaTileEntity_Pump) tTileEntity.getMetaTileEntity()).mPumpTimer -= 1; + } + if (this.mPumpCountBelow <= 0) { + if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().isUniversalEnergyStored(16*((int)Math.pow(4, this.mTier)))) + && ((this.mFluid == null) || (this.mFluid.amount + 1000 <= getCapacity()))) { + boolean tMovedOneDown = false; + if ((this.mPumpList.isEmpty()) && (getBaseMetaTileEntity().getTimer() % 100L == 0L)) { + tMovedOneDown = moveOneDown(); + } + if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { + getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead() - 1, getBaseMetaTileEntity().getZCoord()); + if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { + getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead(), getBaseMetaTileEntity().getZCoord() + 1); + } + if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { + getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead(), getBaseMetaTileEntity().getZCoord() - 1); + } + if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { + getFluidAt(getBaseMetaTileEntity().getXCoord() + 1, getYOfPumpHead(), getBaseMetaTileEntity().getZCoord()); + } + if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) { + getFluidAt(getBaseMetaTileEntity().getXCoord() - 1, getYOfPumpHead(), getBaseMetaTileEntity().getZCoord()); + } + } else if (getYOfPumpHead() < getBaseMetaTileEntity().getYCoord()) { + if ((tMovedOneDown) || ((this.mPumpList.isEmpty()) && (getBaseMetaTileEntity().getTimer() % 200L == 100L)) || (getBaseMetaTileEntity().getTimer() % 72000L == 100L)) { + this.mPumpList.clear(); + int y = getBaseMetaTileEntity().getYCoord() - 1; + for (int yHead = getYOfPumpHead(); (this.mPumpList.isEmpty()) && (y >= yHead); y--) { + scanForFluid(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), this.mPumpList, getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord(), 10*((int)Math.pow(1.6, this.mTier))); + } + } + if ((!tMovedOneDown) && (this.mPumpTimer <= 0)) { + while ((!this.mPumpList.isEmpty()) + && (!consumeFluid(((ChunkPosition) this.mPumpList.get(this.mPumpList.size() - 1)).chunkPosX, + ((ChunkPosition) this.mPumpList.get(this.mPumpList.size() - 1)).chunkPosY, + ((ChunkPosition) this.mPumpList.remove(this.mPumpList.size() - 1)).chunkPosZ))) { + } + this.mPumpTimer = 160/((int)Math.pow(2, this.mTier)); + } + } + } + getBaseMetaTileEntity().setActive(!this.mPumpList.isEmpty()); + } + } + } + + private boolean moveOneDown() { + if ((this.mInventory[0] == null) || (this.mInventory[0].stackSize < 1) + || (!GT_Utility.areStacksEqual(this.mInventory[0], GT_ModHandler.getIC2Item("miningPipe", 1L)))) { + return false; + } + int yHead = getYOfPumpHead(); + if (yHead <= 0) { + return false; + } + if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))&& (!getBaseMetaTileEntity().getAir(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) { + + return false; + } + if (!(getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(),GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))))) { + return false; + } + if (yHead != getBaseMetaTileEntity().getYCoord()) { + getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead, getBaseMetaTileEntity().getZCoord(),GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L))); + } + getBaseMetaTileEntity().decrStackSize(0, 1); + return true; + } + + private int getYOfPumpHead() { + int y = getBaseMetaTileEntity().getYCoord() - 1; + while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) == GT_Utility + .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L))) { + y--; + } + if (y == getBaseMetaTileEntity().getYCoord() - 1) { + if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != GT_Utility + .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))) { + return y + 1; + } + } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != GT_Utility + .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))&&this.mInventory[0] != null&&this.mInventory[0].stackSize>0&>_Utility.areStacksEqual(this.mInventory[0], GT_ModHandler.getIC2Item("miningPipe", 1L))) { + getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), + GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))); + getBaseMetaTileEntity().decrStackSize(0, 1); + + } + return y; + } + + private void scanForFluid(int aX, int aY, int aZ, ArrayList aList, int mX, int mZ, int mDist) { + doTickProfilingInThisTick = false; + ArrayList tList1 = new ArrayList(); + ArrayList tList2 = new ArrayList(); + tList1.add(new ChunkPosition(aX, aY, aZ)); + while(!tList1.isEmpty()) + { + Iterator i$ = tList1.iterator(); + do + { + if(!i$.hasNext()) + break; + ChunkPosition tPos = (ChunkPosition)i$.next(); + if(tPos.chunkPosX < mX + mDist) + addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX + 1, tPos.chunkPosY, tPos.chunkPosZ, tList2, aList); + if(tPos.chunkPosX > mX - mDist) + addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX - 1, tPos.chunkPosY, tPos.chunkPosZ, tList2, aList); + if(tPos.chunkPosZ < mZ + mDist) + addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ + 1, tList2, aList); + if(tPos.chunkPosZ > mZ - mDist) + addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ - 1, tList2, aList); + addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY + 1, tPos.chunkPosZ, tList2, aList); + ChunkPosition tCoordinate = new ChunkPosition(aX, aY + 1, aZ); + if(tPos.chunkPosX == mX && tPos.chunkPosZ == mZ && tPos.chunkPosY < getBaseMetaTileEntity().getYCoord() && !aList.contains(tCoordinate) && !tList2.contains(tCoordinate)) + tList2.add(tCoordinate); + } while(true); + aList.addAll(tList2); + tList1 = tList2; + tList2 = new ArrayList(); + } + for(int y = getBaseMetaTileEntity().getYCoord(); y >= aY; y--) + aList.remove(new ChunkPosition(aX, y, aZ)); + } + + private boolean addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(int aX, int aY, int aZ, ArrayList aList1, + ArrayList aList2) { + ChunkPosition tCoordinate = new ChunkPosition(aX, aY, aZ); + if ((!aList1.contains(tCoordinate)) && (!aList2.contains(tCoordinate))) { + Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); + if ((this.mPumpedBlock1 == aBlock) || (this.mPumpedBlock2 == aBlock)) { + aList1.add(tCoordinate); + return true; + } + } + return false; + } + + private void getFluidAt(int aX, int aY, int aZ) { + Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); + if (GT_Utility.isBlockValid(aBlock)) { + if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) { + this.mPumpedBlock1 = Blocks.water; + this.mPumpedBlock2 = Blocks.flowing_water; + return; + } + if ((aBlock == Blocks.lava) || (aBlock == Blocks.flowing_lava)) { + this.mPumpedBlock1 = Blocks.lava; + this.mPumpedBlock2 = Blocks.flowing_lava; + return; + } + if ((aBlock instanceof IFluidBlock)) { + this.mPumpedBlock1 = aBlock; + this.mPumpedBlock2 = aBlock; + return; + } + } + this.mPumpedBlock1 = null; + this.mPumpedBlock2 = null; + } + + private boolean consumeFluid(int aX, int aY, int aZ) { + Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); + int aMeta = getBaseMetaTileEntity().getMetaID(aX, aY, aZ); + if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPumpedBlock1 == aBlock) || (this.mPumpedBlock2 == aBlock))) { + if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) { + if (aMeta == 0) { + if (this.mFluid == null) { + getBaseMetaTileEntity().decreaseStoredEnergyUnits(16*((int)Math.pow(4, this.mTier)), true); + this.mFluid = GT_ModHandler.getWater(1000L); + } else if (GT_ModHandler.isWater(this.mFluid)) { + getBaseMetaTileEntity().decreaseStoredEnergyUnits(16*((int)Math.pow(4, this.mTier)), true); + this.mFluid.amount += 1000; + } else { + return false; + } + } else { + getBaseMetaTileEntity().decreaseStoredEnergyUnits(4*((int)Math.pow(4, this.mTier)), true); + } + } + if ((aBlock == Blocks.lava) || (aBlock == Blocks.flowing_lava)) { + if (aMeta == 0) { + if (this.mFluid == null) { + getBaseMetaTileEntity().decreaseStoredEnergyUnits(16*((int)Math.pow(4, this.mTier)), true); + this.mFluid = GT_ModHandler.getLava(1000L); + } else if (GT_ModHandler.isLava(this.mFluid)) { + getBaseMetaTileEntity().decreaseStoredEnergyUnits(16*((int)Math.pow(4, this.mTier)), true); + this.mFluid.amount += 1000; + } else { + return false; + } + } else { + getBaseMetaTileEntity().decreaseStoredEnergyUnits(4*((int)Math.pow(4, this.mTier)), true); + } + } + if ((aBlock instanceof IFluidBlock)) { + if (this.mFluid == null) { + this.mFluid = ((IFluidBlock) aBlock).drain(getBaseMetaTileEntity().getWorld(), aX, aY, aZ, true); + getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mFluid == null ? 1000 : this.mFluid.amount, true); + }else if(this.mFluid.isFluidEqual(((IFluidBlock) aBlock).drain(getBaseMetaTileEntity().getWorld(), aX, aY, aZ, false))){ + this.getBaseMetaTileEntity().getWorld().setBlockToAir( aX, aY, aZ); + this.mFluid.amount += 1000; + getBaseMetaTileEntity().decreaseStoredEnergyUnits(16*((int)Math.pow(4, this.mTier)), true); + }else { + return false; + } + } + getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ,Blocks.air,0,2); + return true; + } + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isOverclockerUpgradable() {return false;} + @Override public boolean isTransformerUpgradable() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isFacingValid(byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isInputFacing(byte aSide) {return true;} + @Override public boolean isOutputFacing(byte aSide) {return false;} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return V[mTier]*16;} + @Override public long maxEUStore() {return V[mTier]*64;} + @Override public long maxEUInput() {return V[mTier];} + @Override public long maxSteamStore() {return maxEUStore();} + @Override public long maxAmperesIn() {return 2;} + @Override public int getStackDisplaySlot() {return 2;} + @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} + + + @Override + public int getCapacity() { + return 16000*this.mTier; + } + @Override + public int getTankPressure() { + return 100; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1], (aSide == 0||aSide ==1) ? null : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP) }; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return getTexturesInactive(aBaseTexture); + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP),new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP),new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP),}; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java new file mode 100644 index 0000000000..c5a0ecfc92 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java @@ -0,0 +1,119 @@ +package gregtech.common.tileentities.machines.basic; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Element; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_Replicator + extends GT_MetaTileEntity_BasicMachine +{ + private static int sHeaviestElementMass = 0; + + public GT_MetaTileEntity_Replicator(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier, 1, "Producing Elemental Matter", 1, 1, "Replicator.png", "", new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_REPLICATOR_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_REPLICATOR), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_REPLICATOR_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_REPLICATOR), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_REPLICATOR_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_REPLICATOR) }); + } + + public GT_MetaTileEntity_Replicator(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) + { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_Replicator(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public int checkRecipe() + { + FluidStack tFluid = getFillableStack(); + if ((tFluid != null) && (tFluid.isFluidEqual(Materials.UUMatter.getFluid(1L)))) + { + ItemStack tDataOrb = getSpecialSlot(); + if ((ItemList.Tool_DataOrb.isStackEqual(tDataOrb, false, true)) && (Behaviour_DataOrb.getDataTitle(tDataOrb).equals("Elemental-Scan"))) + { + Materials tMaterial = (Materials)Element.get(Behaviour_DataOrb.getDataName(tDataOrb)).mLinkedMaterials.get(0); + long tMass = tMaterial.getMass(); + if ((tFluid.amount >= tMass) && (tMass > 0L)) + { + this.mEUt = ((int)gregtech.api.enums.GT_Values.V[this.mTier]); + this.mMaxProgresstime = ((int)(tMass * 512L / (1 << this.mTier - 1))); + if ((this.mOutputItems[0] = GT_OreDictUnificator.get(OrePrefixes.dust, tMaterial, 1L)) == null) + { + if ((this.mOutputItems[0] = GT_OreDictUnificator.get(OrePrefixes.cell, tMaterial, 1L)) != null) { + if ((this.mOutputFluid = GT_Utility.getFluidForFilledItem(this.mOutputItems[0], true)) == null) + { + if (ItemList.Cell_Empty.isStackEqual(getInputAt(0))) { + if (canOutput(new ItemStack[] { this.mOutputItems[0] })) + { + getInputAt(0).stackSize -= 1; FluidStack + tmp231_230 = tFluid;tmp231_230.amount = ((int)(tmp231_230.amount - tMass)); + return 2; + } + } + } + else + { + this.mOutputItems[0] = null; + if ((getDrainableStack() == null) || ((getDrainableStack().isFluidEqual(this.mOutputFluid)) && (getDrainableStack().amount < 16000))) + { + FluidStack tmp287_286 = tFluid;tmp287_286.amount = ((int)(tmp287_286.amount - tMass)); + return 2; + } + } + } + } + else if (canOutput(new ItemStack[] { this.mOutputItems[0] })) + { + FluidStack tmp322_321 = tFluid;tmp322_321.amount = ((int)(tmp322_321.amount - tMass)); + return 2; + } + } + } + } + return 0; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) + { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (ItemList.Cell_Empty.isStackEqual(aStack)); + } + + public boolean isFluidInputAllowed(FluidStack aFluid) + { + return aFluid.isFluidEqual(Materials.UUMatter.getFluid(1L)); + } + + public int getCapacity() + { + if ((sHeaviestElementMass == 0) && (GregTech_API.sPostloadFinished)) + { + Materials tMaterial; + for (Iterator i$ = Materials.VALUES.iterator(); i$.hasNext(); sHeaviestElementMass = Math.max(sHeaviestElementMass, (int)tMaterial.getMass())) + { + tMaterial = (Materials)i$.next(); + if ((tMaterial.mElement == null) || (tMaterial.mElement.mIsIsotope)) {} + } + } + return sHeaviestElementMass; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java new file mode 100644 index 0000000000..aab40f712d --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java @@ -0,0 +1,82 @@ +package gregtech.common.tileentities.machines.basic; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_RockBreaker + extends GT_MetaTileEntity_BasicMachine +{ + public GT_MetaTileEntity_RockBreaker(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier, 1, "Put Lava and Water adjacent", 1, 1, "RockBreaker.png", "", new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_ROCK_BREAKER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_ROCK_BREAKER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_ROCK_BREAKER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_ROCK_BREAKER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_ROCK_BREAKER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_ROCK_BREAKER) }); + } + + public GT_MetaTileEntity_RockBreaker(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) + { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_RockBreaker(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public GT_Recipe.GT_Recipe_Map getRecipeList() + { + return GT_Recipe.GT_Recipe_Map.sRockBreakerFakeRecipes; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) + { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); + } + + public int checkRecipe() + { + IGregTechTileEntity aBaseMetaTileEntity = getBaseMetaTileEntity(); + if ((aBaseMetaTileEntity.getBlockOffset(0, 0, 1) == Blocks.water) || (aBaseMetaTileEntity.getBlockOffset(0, 0, -1) == Blocks.water) || (aBaseMetaTileEntity.getBlockOffset(-1, 0, 0) == Blocks.water) || (aBaseMetaTileEntity.getBlockOffset(1, 0, 0) == Blocks.water)) + { + ItemStack tOutput = null; + if (aBaseMetaTileEntity.getBlockOffset(0, 1, 0) == Blocks.lava) { + tOutput = new ItemStack(Blocks.stone, 1); + } else if ((aBaseMetaTileEntity.getBlockOffset(0, 0, 1) == Blocks.lava) || (aBaseMetaTileEntity.getBlockOffset(0, 0, -1) == Blocks.lava) || (aBaseMetaTileEntity.getBlockOffset(-1, 0, 0) == Blocks.lava) || (aBaseMetaTileEntity.getBlockOffset(1, 0, 0) == Blocks.lava)) { + tOutput = new ItemStack(Blocks.cobblestone, 1); + } + if (tOutput != null) { + if (GT_Utility.areStacksEqual(getInputAt(0), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L))) + { + tOutput = new ItemStack(Blocks.obsidian, 1); + if (canOutput(new ItemStack[] { tOutput })) + { + getInputAt(0).stackSize -= 1; + this.mOutputItems[0] = tOutput; + this.mMaxProgresstime = (128 / (1 << this.mTier - 1)); + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + return 2; + } + } + else if (canOutput(new ItemStack[] { tOutput })) + { + this.mOutputItems[0] = tOutput; + this.mMaxProgresstime = (16 / (1 << this.mTier - 1)); + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + return 2; + } + } + } + return 0; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java new file mode 100644 index 0000000000..6b53904fb4 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java @@ -0,0 +1,215 @@ +package gregtech.common.tileentities.machines.basic; + +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAlleleRegistry; +import forestry.api.genetics.IIndividual; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Element; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.ItemData; +import gregtech.api.objects.MaterialStack; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; + +import java.util.Map; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_Scanner + extends GT_MetaTileEntity_BasicMachine +{ + public GT_MetaTileEntity_Scanner(int aID, String aName, String aNameRegional, int aTier) + { + super(aID, aName, aNameRegional, aTier, 1, "Scans Crops and other things.", 1, 1, "Scanner.png", "", new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_SCANNER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_SCANNER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_SCANNER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_SCANNER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_SCANNER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_SCANNER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_SCANNER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_SCANNER) }); + } + + public GT_MetaTileEntity_Scanner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) + { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT_MetaTileEntity_Scanner(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + public int checkRecipe() + { + ItemStack aStack = getInputAt(0); + if (getOutputAt(0) != null) + { + this.mOutputBlocked += 1; + } + else if ((GT_Utility.isStackValid(aStack)) && (aStack.stackSize > 0)) + { + if ((getFillableStack() != null) && (getFillableStack().containsFluid(Materials.Honey.getFluid(100L)))) { + try + { + Object tIndividual = AlleleManager.alleleRegistry.getIndividual(aStack); + if (tIndividual != null) + { + if (((IIndividual)tIndividual).analyze()) + { + getFillableStack().amount -= 100; + this.mOutputItems[0] = GT_Utility.copy(new Object[] { aStack }); + aStack.stackSize = 0; + NBTTagCompound tNBT = new NBTTagCompound(); + ((IIndividual)tIndividual).writeToNBT(tNBT); + this.mOutputItems[0].setTagCompound(tNBT); + this.mMaxProgresstime = (500 / (1 << this.mTier - 1)); + this.mEUt = (2 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + return 2; + } + this.mOutputItems[0] = GT_Utility.copy(new Object[] { aStack }); + aStack.stackSize = 0; + this.mMaxProgresstime = 1; + this.mEUt = 1; + return 2; + } + } + catch (Throwable e) + { + if (GT_Values.D1) { + e.printStackTrace(GT_Log.err); + } + } + } + if (ItemList.IC2_Crop_Seeds.isStackEqual(aStack, true, true)) + { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + if (tNBT.getByte("scan") < 4) + { + tNBT.setByte("scan", (byte)4); + this.mMaxProgresstime = (160 / (1 << this.mTier - 1)); + this.mEUt = (8 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + } + else + { + this.mMaxProgresstime = 1; + this.mEUt = 1; + } + aStack.stackSize -= 1; + this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[] { aStack }); + this.mOutputItems[0].setTagCompound(tNBT); + return 2; + } + if (ItemList.Tool_DataOrb.isStackEqual(getSpecialSlot(), false, true)) + { + if (ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) + { + aStack.stackSize -= 1; + this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[] { getSpecialSlot() }); + this.mMaxProgresstime = (512 / (1 << this.mTier - 1)); + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + return 2; + } + ItemData tData = GT_OreDictUnificator.getAssociation(aStack); + if ((tData != null) && ((tData.mPrefix == OrePrefixes.dust) || (tData.mPrefix == OrePrefixes.cell)) && (tData.mMaterial.mMaterial.mElement != null) && (!tData.mMaterial.mMaterial.mElement.mIsIsotope) && (tData.mMaterial.mMaterial != Materials.Magic) && (tData.mMaterial.mMaterial.getMass() > 0L)) + { + getSpecialSlot().stackSize -= 1; + aStack.stackSize -= 1; + + this.mOutputItems[0] = ItemList.Tool_DataOrb.get(1L, new Object[0]); + Behaviour_DataOrb.setDataTitle(this.mOutputItems[0], "Elemental-Scan"); + Behaviour_DataOrb.setDataName(this.mOutputItems[0], tData.mMaterial.mMaterial.mElement.name()); + this.mMaxProgresstime = ((int)(tData.mMaterial.mMaterial.getMass() * 8192L / (1 << this.mTier - 1))); + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + return 2; + } + } + if (ItemList.Tool_DataStick.isStackEqual(getSpecialSlot(), false, true)) + { + if (ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) + { + aStack.stackSize -= 1; + this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[] { getSpecialSlot() }); + this.mMaxProgresstime = (128 / (1 << this.mTier - 1)); + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + return 2; + } + if (aStack.getItem() == Items.written_book) + { + getSpecialSlot().stackSize -= 1; + aStack.stackSize -= 1; + + this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[] { getSpecialSlot() }); + this.mOutputItems[0].setTagCompound(aStack.getTagCompound()); + this.mMaxProgresstime = (128 / (1 << this.mTier - 1)); + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + return 2; + } + if (aStack.getItem() == Items.filled_map) + { + getSpecialSlot().stackSize -= 1; + aStack.stackSize -= 1; + + this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[] { getSpecialSlot() }); + this.mOutputItems[0].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "map_id", (short)aStack.getItemDamage())); + this.mMaxProgresstime = (128 / (1 << this.mTier - 1)); + this.mEUt = (32 * (1 << this.mTier - 1) * (1 << this.mTier - 1)); + return 2; + } + } + } + return 0; + } + +@Override +public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (mProgresstime>=(mMaxProgresstime-1)) {try{ + if(this.mOutputItems[0].getUnlocalizedName().equals("gt.metaitem.01.32707")){ + GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "scanning");}}catch (Exception e){} + } + super.onPostTick(aBaseMetaTileEntity, aTick); +} + + + public GT_Recipe.GT_Recipe_Map getRecipeList() + { + return GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes; + } + + public int getCapacity() + { + return 1000; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) + { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); + } + + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) + { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, aZ); + } + } + + public void startProcess() + { + sendLoopStart((byte)1); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java new file mode 100644 index 0000000000..e0c6225a61 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java @@ -0,0 +1,340 @@ +package gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GT_Values.V; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityHanging; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityDragonPart; +import net.minecraft.entity.effect.EntityWeatherEffect; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityEnderEye; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityFireball; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Utility; +import gregtech.common.gui.GT_Container_Teleporter; +import gregtech.common.gui.GT_GUIContainer_FusionReactor; +import gregtech.common.gui.GT_GUIContainer_Teleporter; + +public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank{ + + public int mTargetX = 0; + public int mTargetY = 0; + public int mTargetZ = 0; + public int mTargetD = 0; + public boolean mDebug = false; + public boolean hasEgg = false; + public static boolean sInterDimensionalTeleportAllowed = true; + + public GT_MetaTileEntity_Teleporter(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Teleport long distances with this little device."); + } + + public GT_MetaTileEntity_Teleporter(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + this.hasEgg = checkForEgg(); + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_Teleporter(aPlayerInventory, aBaseMetaTileEntity); + } + + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_Teleporter(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Teleporter(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public String[] getInfoData() + { + return new String[] { "Coordinates:", "X: " + this.mTargetX, "Y: " + this.mTargetY, "Z: " + this.mTargetZ, "Dimension: " + this.mTargetD }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1], (aSide !=this.getBaseMetaTileEntity().getFrontFacing()) ? null : aActive ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER) }; + } + + + public void saveNBTData(NBTTagCompound aNBT) + { + aNBT.setInteger("mTargetX", this.mTargetX); + aNBT.setInteger("mTargetY", this.mTargetY); + aNBT.setInteger("mTargetZ", this.mTargetZ); + aNBT.setInteger("mTargetD", this.mTargetD); + aNBT.setBoolean("mDebug", this.mDebug); + } + + public void loadNBTData(NBTTagCompound aNBT) + { + this.mTargetX = aNBT.getInteger("mTargetX"); + this.mTargetY = aNBT.getInteger("mTargetY"); + this.mTargetZ = aNBT.getInteger("mTargetZ"); + this.mTargetD = aNBT.getInteger("mTargetD"); + this.mDebug = aNBT.getBoolean("mDebug"); + } + + public void onConfigLoad(GT_Config aConfig) + { + sInterDimensionalTeleportAllowed = aConfig.get(ConfigCategories.machineconfig, "Teleporter.Interdimensional", true); + } + + public void onFirstTick() + { + if (getBaseMetaTileEntity().isServerSide()) + { + if ((this.mTargetX == 0) && (this.mTargetY == 0) && (this.mTargetZ == 0) && (this.mTargetD == 0)) + { + this.mTargetX = getBaseMetaTileEntity().getXCoord(); + this.mTargetY = getBaseMetaTileEntity().getYCoord(); + this.mTargetZ = getBaseMetaTileEntity().getZCoord(); + this.mTargetD = getBaseMetaTileEntity().getWorld().provider.dimensionId; + } + this.hasEgg = checkForEgg(); + } + } + + public boolean checkForEgg() + { + for (byte i = -5; i <= 5; i = (byte)(i + 1)) { + for (byte j = -5; j <= 5; j = (byte)(j + 1)) { + for (byte k = -5; k <= 5; k = (byte)(k + 1)) { + if (getBaseMetaTileEntity().getBlockOffset(i, j, k) == Blocks.dragon_egg) { + return true; + } + } + } + } + return false; + } + + public boolean hasDimensionalTeleportCapability() + { + return (this.mDebug) || (this.hasEgg); + } + + public boolean isDimensionalTeleportAvailable() + { + return (this.mDebug) || ((hasDimensionalTeleportCapability()) && (GT_Utility.isRealDimension(this.mTargetD)) && (GT_Utility.isRealDimension(getBaseMetaTileEntity().getWorld().provider.dimensionId))); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (getBaseMetaTileEntity().isServerSide()) + { + if (getBaseMetaTileEntity().getTimer() % 100L == 50L) { + this.hasEgg = checkForEgg(); + } + if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().getRedstone())) + { + if(getBaseMetaTileEntity().decreaseStoredEnergyUnits(8192, false)){ + int tDistance = distanceCalculation(); + for (Object tObject : getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 2) - 1, getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 2) - 1, getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 2) - 1, getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 2) + 2, getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 2) + 2, getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 2) + 2))) { + if (((tObject instanceof Entity)) && (!((Entity)tObject).isDead)) + { + Entity tEntity = (Entity)tObject; + if (getBaseMetaTileEntity().decreaseStoredEnergyUnits((int)(tDistance * tDistance * weightCalculation(tEntity)), false)) + { + if (tEntity.ridingEntity != null) { + tEntity.mountEntity(null); + } + if (tEntity.riddenByEntity != null) { + tEntity.riddenByEntity.mountEntity(null); + } + if ((this.mTargetD == getBaseMetaTileEntity().getWorld().provider.dimensionId) || (!isDimensionalTeleportAvailable()) || (!GT_Utility.moveEntityToDimensionAtCoords(tEntity, this.mTargetD, this.mTargetX + 0.5D, this.mTargetY + 0.5D, this.mTargetZ + 0.5D))) { + if ((tEntity instanceof EntityLivingBase)) { + ((EntityLivingBase)tEntity).setPositionAndUpdate(this.mTargetX + 0.5D, this.mTargetY + 0.5D, this.mTargetZ + 0.5D); + } else { + tEntity.setPosition(this.mTargetX + 0.5D, this.mTargetY + 0.5D, this.mTargetZ + 0.5D); + } + } + } + } + }} + getBaseMetaTileEntity().setActive(true); + } + else + { + getBaseMetaTileEntity().setActive(false); + } + } + } + + private int distanceCalculation() + { + return Math.abs(((this.mTargetD != getBaseMetaTileEntity().getWorld().provider.dimensionId) && (isDimensionalTeleportAvailable()) ? 100 : 1) * (int)Math.sqrt(Math.pow(getBaseMetaTileEntity().getXCoord() - this.mTargetX, 2.0D) + Math.pow(getBaseMetaTileEntity().getYCoord() - this.mTargetY, 2.0D) + Math.pow(getBaseMetaTileEntity().getZCoord() - this.mTargetZ, 2.0D))); + } + + private static float weightCalculation(Entity aEntity) + { + try + { + if ((aEntity instanceof EntityFX)) { + return -1.0F; + } + } + catch (Throwable e) {} + if ((aEntity instanceof EntityFishHook)) { + return -1.0F; + } + if ((aEntity instanceof EntityDragonPart)) { + return -1.0F; + } + if ((aEntity instanceof EntityWeatherEffect)) { + return -1.0F; + } + if ((aEntity instanceof EntityPlayer)) + { + EntityPlayer tPlayer = (EntityPlayer)aEntity; + int tCount = 64; + for (int i = 0; i < 36; i++) { + if (tPlayer.inventory.getStackInSlot(i) != null) { + tCount += (tPlayer.inventory.getStackInSlot(i).getMaxStackSize() > 1 ? tPlayer.inventory.getStackInSlot(i).stackSize : 64); + } + } + for (int i = 0; i < 4; i++) { + if (tPlayer.inventory.armorInventory[i] != null) { + tCount += 256; + } + } + return Math.min(5.0F, tCount / 666.6F); + } + if (GT_Utility.getClassName(aEntity).equals("EntityItnt")) { + return 5.0F; + } + if (GT_Utility.getClassName(aEntity).equals("EntityNuke")) { + return 50.0F; + } + if ((aEntity instanceof EntityArrow)) { + return 0.001F; + } + if ((aEntity instanceof EntityBoat)) { + return 0.1F; + } + if ((aEntity instanceof EntityEnderCrystal)) { + return 2.0F; + } + if ((aEntity instanceof EntityEnderEye)) { + return 0.001F; + } + if ((aEntity instanceof EntityFireball)) { + return 0.001F; + } + if ((aEntity instanceof EntityFireworkRocket)) { + return 0.001F; + } + if ((aEntity instanceof EntityHanging)) { + return 0.005F; + } + if ((aEntity instanceof EntityItem)) { + return 0.001F; + } + if ((aEntity instanceof EntityLiving)) { + return 0.5F; + } + if ((aEntity instanceof EntityMinecart)) { + return 0.1F; + } + if ((aEntity instanceof EntityThrowable)) { + return 0.001F; + } + if ((aEntity instanceof EntityTNTPrimed)) { + return 5.0F; + } + if ((aEntity instanceof EntityXPOrb)) { + return 0.001F; + } + return -1.0F; + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isOverclockerUpgradable() {return false;} + @Override public boolean isTransformerUpgradable() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isFacingValid(byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isInputFacing(byte aSide) {return true;} + @Override public boolean isOutputFacing(byte aSide) {return false;} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return V[mTier]*16;} + @Override public long maxEUStore() {return 100000000;} + @Override public long maxEUInput() {return V[mTier];} + @Override public long maxSteamStore() {return maxEUStore();} + @Override public long maxAmperesIn() {return 2;} + @Override public int getStackDisplaySlot() {return 2;} + @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + +} -- cgit