diff options
author | Dream-Master <dream-master@gmx.net> | 2017-06-19 20:23:23 +0200 |
---|---|---|
committer | Dream-Master <dream-master@gmx.net> | 2017-06-19 20:23:23 +0200 |
commit | 6d699a54ccc744088e9ade6de2f17c6a85d8e19d (patch) | |
tree | 5dd08f07d257e1d5118f775a912e43c2c1a734a3 /src/main/java/gregtech/common/tileentities/machines | |
parent | e401ef5f788e131114b618a140a562e2633faa2a (diff) | |
parent | b73a2e00174e491ca9870524034c3273c68fa5d5 (diff) | |
download | GT5-Unofficial-6d699a54ccc744088e9ade6de2f17c6a85d8e19d.tar.gz GT5-Unofficial-6d699a54ccc744088e9ade6de2f17c6a85d8e19d.tar.bz2 GT5-Unofficial-6d699a54ccc744088e9ade6de2f17c6a85d8e19d.zip |
Merge remote-tracking branch 'Petrochemy/BrickedBlastFurnace' into BrickedBlastFurnace
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines')
3 files changed, 397 insertions, 314 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BrickedBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BrickedBlastFurnace.java new file mode 100644 index 0000000000..e966b8794a --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BrickedBlastFurnace.java @@ -0,0 +1,57 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import net.minecraft.block.Block; + +public class GT_MetaTileEntity_BrickedBlastFurnace extends GT_MetaTileEntity_PrimitiveBlastFurnace{ + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_DENSEBRICKS)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_BRICKEDBLASTFURNACE_INACTIVE)}; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_BRICKEDBLASTFURNACE_ACTIVE)}; + + public GT_MetaTileEntity_BrickedBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_BrickedBlastFurnace(String aName) { + super(aName); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_BrickedBlastFurnace(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Bricked Blast Furnace", + "Useable for Steel and general Pyrometallurgy", + "Size(WxHxD): 3x4x3 (Hollow, with opening on top)", + "Built from 32 Bricks", + "Causes 50 Pollution per second"}; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return aActive ? FACING_ACTIVE : FACING_FRONT; + } + return FACING_SIDE; + } + + @Override + protected boolean isCorrectCasingBlock(Block block) { + return true; + } + + @Override + protected boolean isCorrectCasingMetaID(int metaID) { + return true; + } + + @Override + public String getName() { + return "Bricked Blast Furnace"; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java index c46ad5e7bc..a6c6ea939c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java @@ -1,48 +1,24 @@ package gregtech.common.tileentities.machines.multi;
-import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.Materials;
-import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.MetaTileEntity;
-import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
-import gregtech.api.objects.XSTR;
-import gregtech.api.util.GT_OreDictUnificator;
-import gregtech.api.util.GT_Utility;
-import gregtech.common.GT_Pollution;
-import gregtech.common.gui.GT_Container_BronzeBlastFurnace;
-import gregtech.common.gui.GT_GUIContainer_BronzeBlastFurnace;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.world.World;
-import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraft.block.Block;
public class GT_MetaTileEntity_BronzeBlastFurnace
- extends MetaTileEntity {
+ extends GT_MetaTileEntity_PrimitiveBlastFurnace {
private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS)};
private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE)};
private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE_ACTIVE)};
- public int mMaxProgresstime = 0;
- public int mUpdate = 5;
- public int mProgresstime = 0;
- public boolean mMachine = false;
- public ItemStack mOutputItem1;
- public ItemStack mOutputItem2;
public GT_MetaTileEntity_BronzeBlastFurnace(int aID, String aName, String aNameRegional) {
- super(aID, aName, aNameRegional, 4);
+ super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_BronzeBlastFurnace(String aName) {
- super(aName, 4);
+ super(aName);
}
public String[] getDescription() {
@@ -61,296 +37,20 @@ public class GT_MetaTileEntity_BronzeBlastFurnace return FACING_SIDE;
}
- public boolean isSteampowered() {
- return false;
+ @Override
+ protected boolean isCorrectCasingBlock(Block block) {
+ return block == GregTech_API.sBlockCasings1;
}
- public boolean isElectric() {
- return false;
+ @Override
+ protected boolean isCorrectCasingMetaID(int metaID) {
+ return metaID == 10;
}
- public boolean isPneumatic() {
- return false;
+ @Override
+ public String getName() {
+ return "Bronze Blast Furnace";
}
- public boolean isEnetInput() {
- return false;
- }
-
- public boolean isEnetOutput() {
- return false;
- }
-
- public boolean isInputFacing(byte aSide) {
- return false;
- }
-
- public boolean isOutputFacing(byte aSide) {
- return false;
- }
-
- public boolean isTeleporterCompatible() {
- return false;
- }
-
- public boolean isFacingValid(byte aFacing) {
- return aFacing > 1;
- }
-
- public boolean isAccessAllowed(EntityPlayer aPlayer) {
- return true;
- }
-
- public int getProgresstime() {
- return this.mProgresstime;
- }
-
- public int maxProgresstime() {
- return this.mMaxProgresstime;
- }
-
- public int increaseProgress(int aProgress) {
- this.mProgresstime += aProgress;
- return this.mMaxProgresstime - this.mProgresstime;
- }
-
- public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
- return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID));
- }
-
- public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
- return new GT_MetaTileEntity_BronzeBlastFurnace(this.mName);
- }
-
- public void saveNBTData(NBTTagCompound aNBT) {
- aNBT.setInteger("mProgresstime", this.mProgresstime);
- aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime);
- if (this.mOutputItem1 != null) {
- NBTTagCompound tNBT = new NBTTagCompound();
- this.mOutputItem1.writeToNBT(tNBT);
- aNBT.setTag("mOutputItem1", tNBT);
- }
- if (this.mOutputItem2 != null) {
- NBTTagCompound tNBT = new NBTTagCompound();
- this.mOutputItem2.writeToNBT(tNBT);
- aNBT.setTag("mOutputItem2", tNBT);
- }
- }
-
- public void loadNBTData(NBTTagCompound aNBT) {
- this.mUpdate = 5;
- this.mProgresstime = aNBT.getInteger("mProgresstime");
- this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime");
- this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1");
- this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2");
- }
-
- public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
- aBaseMetaTileEntity.openGUI(aPlayer);
- return true;
- }
-
- public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_Container_BronzeBlastFurnace(aPlayerInventory, aBaseMetaTileEntity);
- }
-
- public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_BronzeBlastFurnace(aPlayerInventory, aBaseMetaTileEntity);
- }
-
- private boolean checkMachine() {
- int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX;
- int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ;
- for (int i = -1; i < 2; i++) {
- for (int j = -1; j < 3; j++) {
- for (int k = -1; k < 2; k++) {
- if ((xDir + i != 0) || (j != 0) || (zDir + k != 0)) {
- if ((i != 0) || (j == -1) || (k != 0)) {
- if ((getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) != GregTech_API.sBlockCasings1) || (getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) {
- return false;
- }
- } else if ((!GT_Utility.arrayContains(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[]{Blocks.lava, Blocks.flowing_lava, null})) && (!getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) {
- return false;
- }
- }
- }
- }
- }
- return true;
- }
- public void onMachineBlockUpdate() {
- this.mUpdate = 5;
- }
-
- public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
- if (aBaseMetaTileEntity.isServerSide()) {
- if (this.mUpdate-- == 0) {
- this.mMachine = checkMachine();
- }
- if (this.mMachine) {
- if (this.mMaxProgresstime > 0) {
- if (++this.mProgresstime >= this.mMaxProgresstime) {
- addOutputProducts();
- this.mOutputItem1 = null;
- this.mOutputItem2 = null;
- this.mProgresstime = 0;
- this.mMaxProgresstime = 0;
- GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel");
- }
- } else if (aBaseMetaTileEntity.isAllowedToWork()) {
- checkRecipe();
- }
- }
- if(this.mMaxProgresstime>0 && (aTimer % 20L == 0L)){
- GT_Pollution.addPollution(getBaseMetaTileEntity(), 200);
- }
-
- aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine));
- if (aBaseMetaTileEntity.isActive()) {
- if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) {
- aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2);
- this.mUpdate = 1;
- }
- if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) {
- aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2);
- this.mUpdate = 1;
- }
- } else {
- if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) {
- aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2);
- this.mUpdate = 1;
- }
- if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) {
- aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2);
- this.mUpdate = 1;
- }
- }
- }else if(aBaseMetaTileEntity.isActive()){
- World aWorld=aBaseMetaTileEntity.getWorld();
- double xPos=aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1);
- double yPos=aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1)+0.05F;
- double zPos=aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1);
- XSTR floatGen=new XSTR();
- aWorld.spawnParticle("largesmoke", xPos + floatGen.nextFloat(), yPos, zPos + floatGen.nextFloat(), 0.0D, 0.3D, 0.0D);
- //Pollution particles intensify
- if(GT_Pollution.getPollution(getBaseMetaTileEntity())>GT_Mod.gregtechproxy.mPollutionSmogLimit){
- aWorld.spawnParticle("largesmoke", xPos + floatGen.nextFloat(), yPos, zPos + floatGen.nextFloat(), 0.0D, 0.45D, 0.0D);
- aWorld.spawnParticle("largesmoke", xPos + floatGen.nextFloat(), yPos, zPos + floatGen.nextFloat(), 0.0D, 0.6D, 0.0D);
- }
- }
- }
-
- private void addOutputProducts() {
- if (this.mOutputItem1 != null) {
- if (this.mInventory[2] == null) {
- this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1});
- } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) {
- this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize);
- }
- }
- if (this.mOutputItem2 != null) {
- if (this.mInventory[3] == null) {
- this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2});
- } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) {
- this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize);
- }
- }
- }
-
- private boolean spaceForOutput(ItemStack aStack1, ItemStack aStack2) {
- if (((this.mInventory[2] == null) || (aStack1 == null) || ((this.mInventory[2].stackSize + aStack1.stackSize <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && (
- (this.mInventory[3] == null) || (aStack2 == null) || ((this.mInventory[3].stackSize + aStack2.stackSize <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) {
- return true;
- }
- return false;
- }
-
- private boolean checkRecipe() {
- if (!this.mMachine) {
- return false;
- }
- if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) {
- if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) {
- if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 1);
- getBaseMetaTileEntity().decrStackSize(1, 4);
- this.mMaxProgresstime = 7200;
- return true;
- }
- if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 1);
- getBaseMetaTileEntity().decrStackSize(1, 2);
- this.mMaxProgresstime = 4800;
- return true;
- }
- if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 9);
- getBaseMetaTileEntity().decrStackSize(1, 4);
- this.mMaxProgresstime = 64800;
- return true;
- }
- } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) {
- if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 1);
- getBaseMetaTileEntity().decrStackSize(1, 2);
- this.mMaxProgresstime = 3600;
- return true;
- }
- if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 1);
- getBaseMetaTileEntity().decrStackSize(1, 1);
- this.mMaxProgresstime = 2400;
- return true;
- }
- if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 9);
- getBaseMetaTileEntity().decrStackSize(1, 2);
- this.mMaxProgresstime = 32400;
- return true;
- }
- } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) {
- if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 1);
- getBaseMetaTileEntity().decrStackSize(1, 36);
- this.mMaxProgresstime = 64800;
- return true;
- }
- if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 1);
- getBaseMetaTileEntity().decrStackSize(1, 18);
- this.mMaxProgresstime = 43200;
- return true;
- }
- if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) {
- getBaseMetaTileEntity().decrStackSize(0, 1);
- getBaseMetaTileEntity().decrStackSize(1, 4);
- this.mMaxProgresstime = 64800;
- return true;
- }
- }
- }
- this.mOutputItem1 = null;
- this.mOutputItem2 = null;
- return false;
- }
-
- public boolean isGivingInformation() {
- return false;
- }
-
- public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return aIndex > 1;
- }
-
- public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]);
- }
-
- public byte getTileEntityBaseType() {
- return 0;
- }
-}
+}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java new file mode 100644 index 0000000000..769688f43b --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java @@ -0,0 +1,326 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; +import gregtech.common.gui.GT_Container_PrimitiveBlastFurnace; +import gregtech.common.gui.GT_GUIContainer_PrimitiveBlastFurnace; +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.common.util.ForgeDirection; + +public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEntity { + public static final int INPUT_SLOTS = 3, OUTPUT_SLOTS = 3; + + public int mMaxProgresstime = 0; + public int mUpdate = 5; + public int mProgresstime = 0; + public boolean mMachine = false; + + public ItemStack[] mOutputItems = new ItemStack[OUTPUT_SLOTS]; + + @Deprecated + public ItemStack mOutputItem1; + @Deprecated + public ItemStack mOutputItem2; + + public GT_MetaTileEntity_PrimitiveBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, INPUT_SLOTS + OUTPUT_SLOTS); + } + + public GT_MetaTileEntity_PrimitiveBlastFurnace(String aName) { + super(aName, INPUT_SLOTS + OUTPUT_SLOTS); + } + + public boolean isSteampowered() { + return false; + } + + public boolean isElectric() { + return false; + } + + public boolean isPneumatic() { + return false; + } + + public boolean isEnetInput() { + return false; + } + + public boolean isEnetOutput() { + return false; + } + + public boolean isInputFacing(byte aSide) { + return false; + } + + public boolean isOutputFacing(byte aSide) { + return false; + } + + public boolean isTeleporterCompatible() { + return false; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public int getProgresstime() { + return this.mProgresstime; + } + + public int maxProgresstime() { + return this.mMaxProgresstime; + } + + public int increaseProgress(int aProgress) { + this.mProgresstime += aProgress; + return this.mMaxProgresstime - this.mProgresstime; + } + + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_BronzeBlastFurnace(this.mName); + } + + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mProgresstime", this.mProgresstime); + aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); + if (this.mOutputItems != null) { + for (int i = 0; i < mOutputItems.length; i++) { + if (this.mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + } + } + } + + public void loadNBTData(NBTTagCompound aNBT) { + this.mUpdate = 5; + this.mProgresstime = aNBT.getInteger("mProgresstime"); + this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + this.mOutputItems = new ItemStack[OUTPUT_SLOTS]; + for (int i = 0; i < OUTPUT_SLOTS; i++) { + this.mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_PrimitiveBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_PrimitiveBlastFurnace(aPlayerInventory, aBaseMetaTileEntity, getName()); + } + + private boolean checkMachine() { + int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 3; j++) { + for (int k = -1; k < 2; k++) { + if ((xDir + i != 0) || (j != 0) || (zDir + k != 0)) { + if ((i != 0) || (j == -1) || (k != 0)) { + if (!isCorrectCasingBlock(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k)) + || !isCorrectCasingMetaID(getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k))) { + return false; + } + } else if ((!GT_Utility.arrayContains(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), + new Object[] { Blocks.lava, Blocks.flowing_lava, null })) + && (!getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { + return false; + } + } + } + } + } + return true; + } + + protected abstract boolean isCorrectCasingBlock(Block block); + + protected abstract boolean isCorrectCasingMetaID(int metaID); + + public void onMachineBlockUpdate() { + this.mUpdate = 5; + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { + aBaseMetaTileEntity.getWorld().spawnParticle("largesmoke", + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + (new XSTR()).nextFloat(), + aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + (new XSTR()).nextFloat(), 0.0D, 0.3D, 0.0D); + } + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate-- == 0) { + this.mMachine = checkMachine(); + } + if (this.mMachine) { + if (this.mMaxProgresstime > 0) { + if (++this.mProgresstime >= this.mMaxProgresstime) { + addOutputProducts(); + this.mOutputItems = null; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + GT_Mod.achievements.issueAchievement( + aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel"); + } + } else if (aBaseMetaTileEntity.isAllowedToWork()) { + checkRecipe(); + } + } + if (this.mMaxProgresstime > 0 && (aTimer % 20L == 0L)) { + GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), + new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), + this.getBaseMetaTileEntity().getZCoord()), + 50); + } + + aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); + if (aBaseMetaTileEntity.isActive()) { + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), + Blocks.lava, 1, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), + Blocks.lava, 1, 2); + this.mUpdate = 1; + } + } else { + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), + Blocks.air, 0, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord() + 1, + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), + Blocks.air, 0, 2); + this.mUpdate = 1; + } + } + } + } + + private void addOutputProducts() { + if (this.mOutputItems == null) { + return; + } + int limit = Math.min(mOutputItems.length, OUTPUT_SLOTS); + for (int i = 0; i < limit; i++) { + int absi = INPUT_SLOTS + i; + if (this.mInventory[absi] == null) { + this.mInventory[absi] = GT_Utility.copy(this.mOutputItems[i]); + } else if (GT_Utility.areStacksEqual(this.mInventory[absi], this.mOutputItems[i])) { + this.mInventory[absi].stackSize = Math.min(this.mInventory[absi].getMaxStackSize(), + this.mInventory[absi].stackSize + this.mOutputItems[i].stackSize); + } + } + } + + private boolean spaceForOutput(ItemStack outputStack, int relativeOutputSlot) { + int absoluteSlot = relativeOutputSlot + INPUT_SLOTS; + if (this.mInventory[absoluteSlot] == null || outputStack == null) { + return true; + } + if (((this.mInventory[absoluteSlot].stackSize + outputStack.stackSize <= this.mInventory[absoluteSlot].getMaxStackSize()) + && (GT_Utility.areStacksEqual(this.mInventory[absoluteSlot], outputStack)))) { + return true; + } + return false; + } + + private boolean checkRecipe() { + if (!this.mMachine) { + return false; + } + ItemStack[] inputs = new ItemStack[INPUT_SLOTS]; + System.arraycopy(mInventory, 0, inputs, 0, INPUT_SLOTS); + GT_Recipe recipe = GT_Recipe.GT_Recipe_Map.sPrimitiveBlastRecipes.findRecipe(getBaseMetaTileEntity(), false, 0, null, inputs); + if (recipe == null) { + this.mOutputItems = null; + return false; + } + for (int i = 0; i < OUTPUT_SLOTS; i++) { + if (!spaceForOutput(recipe.getOutput(i), i)) { + this.mOutputItems = null; + return false; + } + } + + if (!recipe.isRecipeInputEqual(true, null, inputs)) { + this.mOutputItems = null; + return false; + } + for (int i = 0; i < INPUT_SLOTS; i++) { + if (mInventory[i] != null && mInventory[i].stackSize == 0) { + mInventory[i] = null; + } + } + + this.mMaxProgresstime = recipe.mDuration; + this.mOutputItems = recipe.mOutputs; + return true; + } + + public boolean isGivingInformation() { + return false; + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex > INPUT_SLOTS; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); + } + + public byte getTileEntityBaseType() { + return 0; + } + + public abstract String getName(); +}
\ No newline at end of file |