Changed the Primitive Blast Furnace so that it uses the new Recipe Map
This commit is contained in:
parent
7982374b38
commit
b3e0b41ee6
1 changed files with 271 additions and 273 deletions
|
@ -9,6 +9,7 @@ import gregtech.api.metatileentity.MetaTileEntity;
|
||||||
import gregtech.api.objects.GT_ItemStack;
|
import gregtech.api.objects.GT_ItemStack;
|
||||||
import gregtech.api.objects.XSTR;
|
import gregtech.api.objects.XSTR;
|
||||||
import gregtech.api.util.GT_OreDictUnificator;
|
import gregtech.api.util.GT_OreDictUnificator;
|
||||||
|
import gregtech.api.util.GT_Recipe;
|
||||||
import gregtech.api.util.GT_Utility;
|
import gregtech.api.util.GT_Utility;
|
||||||
import gregtech.common.GT_Pollution;
|
import gregtech.common.GT_Pollution;
|
||||||
import gregtech.common.gui.GT_Container_BronzeBlastFurnace;
|
import gregtech.common.gui.GT_Container_BronzeBlastFurnace;
|
||||||
|
@ -22,310 +23,307 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace
|
public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEntity {
|
||||||
extends MetaTileEntity {
|
private static final int INPUT_SLOTS = 2, OUTPUT_SLOTS = 2;
|
||||||
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_PrimitiveBlastFurnace(int aID, String aName, String aNameRegional) {
|
public int mMaxProgresstime = 0;
|
||||||
super(aID, aName, aNameRegional, 4);
|
public int mUpdate = 5;
|
||||||
}
|
public int mProgresstime = 0;
|
||||||
|
public boolean mMachine = false;
|
||||||
|
|
||||||
public GT_MetaTileEntity_PrimitiveBlastFurnace(String aName) {
|
public ItemStack[] mOutputItems = new ItemStack[OUTPUT_SLOTS];
|
||||||
super(aName, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSteampowered() {
|
@Deprecated
|
||||||
return false;
|
public ItemStack mOutputItem1;
|
||||||
}
|
@Deprecated
|
||||||
|
public ItemStack mOutputItem2;
|
||||||
|
|
||||||
public boolean isElectric() {
|
public GT_MetaTileEntity_PrimitiveBlastFurnace(int aID, String aName, String aNameRegional) {
|
||||||
return false;
|
super(aID, aName, aNameRegional, INPUT_SLOTS + OUTPUT_SLOTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPneumatic() {
|
public GT_MetaTileEntity_PrimitiveBlastFurnace(String aName) {
|
||||||
return false;
|
super(aName, INPUT_SLOTS + OUTPUT_SLOTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnetInput() {
|
public boolean isSteampowered() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnetOutput() {
|
public boolean isElectric() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInputFacing(byte aSide) {
|
public boolean isPneumatic() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOutputFacing(byte aSide) {
|
public boolean isEnetInput() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTeleporterCompatible() {
|
public boolean isEnetOutput() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFacingValid(byte aFacing) {
|
public boolean isInputFacing(byte aSide) {
|
||||||
return aFacing > 1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAccessAllowed(EntityPlayer aPlayer) {
|
public boolean isOutputFacing(byte aSide) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgresstime() {
|
public boolean isTeleporterCompatible() {
|
||||||
return this.mProgresstime;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int maxProgresstime() {
|
public boolean isFacingValid(byte aFacing) {
|
||||||
return this.mMaxProgresstime;
|
return aFacing > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int increaseProgress(int aProgress) {
|
public boolean isAccessAllowed(EntityPlayer aPlayer) {
|
||||||
this.mProgresstime += aProgress;
|
return true;
|
||||||
return this.mMaxProgresstime - this.mProgresstime;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
|
public int getProgresstime() {
|
||||||
return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID));
|
return this.mProgresstime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
|
public int maxProgresstime() {
|
||||||
return new GT_MetaTileEntity_BronzeBlastFurnace(this.mName);
|
return this.mMaxProgresstime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveNBTData(NBTTagCompound aNBT) {
|
public int increaseProgress(int aProgress) {
|
||||||
aNBT.setInteger("mProgresstime", this.mProgresstime);
|
this.mProgresstime += aProgress;
|
||||||
aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime);
|
return this.mMaxProgresstime - this.mProgresstime;
|
||||||
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) {
|
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
|
||||||
this.mUpdate = 5;
|
return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID));
|
||||||
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) {
|
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
|
||||||
if (aBaseMetaTileEntity.isClientSide()) {
|
return new GT_MetaTileEntity_BronzeBlastFurnace(this.mName);
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
aBaseMetaTileEntity.openGUI(aPlayer);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
|
public void saveNBTData(NBTTagCompound aNBT) {
|
||||||
return new GT_Container_BronzeBlastFurnace(aPlayerInventory, aBaseMetaTileEntity);
|
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 Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
|
public void loadNBTData(NBTTagCompound aNBT) {
|
||||||
return new GT_GUIContainer_BronzeBlastFurnace(aPlayerInventory, aBaseMetaTileEntity);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkMachine() {
|
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
|
||||||
int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX;
|
if (aBaseMetaTileEntity.isClientSide()) {
|
||||||
int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ;
|
return true;
|
||||||
for (int i = -1; i < 2; i++) {
|
}
|
||||||
for (int j = -1; j < 3; j++) {
|
aBaseMetaTileEntity.openGUI(aPlayer);
|
||||||
for (int k = -1; k < 2; k++) {
|
return true;
|
||||||
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);
|
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
|
||||||
|
return new GT_Container_BronzeBlastFurnace(aPlayerInventory, aBaseMetaTileEntity);
|
||||||
protected abstract boolean isCorrectCasingMetaID(int metaID);
|
}
|
||||||
|
|
||||||
public void onMachineBlockUpdate() {
|
|
||||||
this.mUpdate = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
|
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
|
||||||
if ((aBaseMetaTileEntity.isClientSide()) &&
|
return new GT_GUIContainer_BronzeBlastFurnace(aPlayerInventory, aBaseMetaTileEntity);
|
||||||
(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.mOutputItem1 = null;
|
|
||||||
this.mOutputItem2 = 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() {
|
private boolean checkMachine() {
|
||||||
if (this.mOutputItem1 != null) {
|
int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX;
|
||||||
if (this.mInventory[2] == null) {
|
int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ;
|
||||||
this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1});
|
for (int i = -1; i < 2; i++) {
|
||||||
} else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) {
|
for (int j = -1; j < 3; j++) {
|
||||||
this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize);
|
for (int k = -1; k < 2; k++) {
|
||||||
}
|
if ((xDir + i != 0) || (j != 0) || (zDir + k != 0)) {
|
||||||
}
|
if ((i != 0) || (j == -1) || (k != 0)) {
|
||||||
if (this.mOutputItem2 != null) {
|
if (!isCorrectCasingBlock(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k))
|
||||||
if (this.mInventory[3] == null) {
|
|| !isCorrectCasingMetaID(getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k))) {
|
||||||
this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2});
|
return false;
|
||||||
} 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);
|
} 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;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean spaceForOutput(ItemStack aStack1, ItemStack aStack2) {
|
protected abstract boolean isCorrectCasingBlock(Block block);
|
||||||
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() {
|
protected abstract boolean isCorrectCasingMetaID(int metaID);
|
||||||
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() {
|
public void onMachineBlockUpdate() {
|
||||||
return false;
|
this.mUpdate = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
|
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
|
||||||
return aIndex > 1;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
|
aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine));
|
||||||
return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public byte getTileEntityBaseType() {
|
private void addOutputProducts() {
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue