Rewrite some of the logic behind the matter fabricator, now works with ic2 scrap as well.

Closes #1002 and Closes #822

(cherry picked from commit 93ccd8b)
This commit is contained in:
modmuss50 2017-03-13 10:22:06 +00:00
parent 76332ee946
commit bbf93c3ae3
No known key found for this signature in database
GPG key ID: 203A5ED4D3E48BEA
3 changed files with 27 additions and 44 deletions

View file

@ -79,6 +79,7 @@ public class IC2Dict {
IC2Duplicates.CARBON_FIBER.setIc2Stack(ItemName.crafting.getItemStack("carbon_fibre")); IC2Duplicates.CARBON_FIBER.setIc2Stack(ItemName.crafting.getItemStack("carbon_fibre"));
IC2Duplicates.CARBON_MESH.setIc2Stack(ItemName.crafting.getItemStack("carbon_mesh")); IC2Duplicates.CARBON_MESH.setIc2Stack(ItemName.crafting.getItemStack("carbon_mesh"));
IC2Duplicates.REFINED_IRON.setIc2Stack(ItemName.plate.getItemStack("iron")); IC2Duplicates.REFINED_IRON.setIc2Stack(ItemName.plate.getItemStack("iron"));
IC2Duplicates.SCRAP.setIc2Stack(ItemName.crafting.getItemStack(CraftingItemType.scrap));
//Rubber - ore dic: itemRubber, hidden from JEI //Rubber - ore dic: itemRubber, hidden from JEI
//Rubber Sap - only used to make rubber, hidden from JEI //Rubber Sap - only used to make rubber, hidden from JEI
//Rubber tree blocks, hidden when deduplication is on, and rubber tress are not set to gen, includes tree taps //Rubber tree blocks, hidden when deduplication is on, and rubber tress are not set to gen, includes tree taps

View file

@ -65,7 +65,8 @@ public enum IC2Duplicates {
MIXED_METAL(ItemIngots.getIngotByName("mixed_metal")), MIXED_METAL(ItemIngots.getIngotByName("mixed_metal")),
CARBON_FIBER(ItemParts.getPartByName("carbon_fiber")), CARBON_FIBER(ItemParts.getPartByName("carbon_fiber")),
CARBON_MESH(ItemParts.getPartByName("carbon_mesh")), CARBON_MESH(ItemParts.getPartByName("carbon_mesh")),
REFINED_IRON(ItemIngots.getIngotByName("refined_iron")); REFINED_IRON(ItemIngots.getIngotByName("refined_iron")),
SCRAP(ItemParts.getPartByName("scrap"));
ItemStack ic2Stack; ItemStack ic2Stack;
ItemStack trStack; ItemStack trStack;

View file

@ -38,6 +38,7 @@ import reborncore.common.util.ItemUtils;
import techreborn.client.container.IContainerProvider; import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder; import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.IC2Duplicates;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModItems; import techreborn.init.ModItems;
import techreborn.items.ItemParts; import techreborn.items.ItemParts;
@ -45,10 +46,9 @@ import techreborn.items.ItemParts;
public class TileMatterFabricator extends TilePowerAcceptor public class TileMatterFabricator extends TilePowerAcceptor
implements IWrenchable, IInventoryProvider, IContainerProvider { implements IWrenchable, IInventoryProvider, IContainerProvider {
public static int fabricationRate = 10000; public int fabricationRate = 10000;
public int tickTime; public int tickTime;
public Inventory inventory = new Inventory(7, "TileMatterFabricator", 64, this); public Inventory inventory = new Inventory(7, "TileMatterFabricator", 64, this);
public int progresstime = 0;
private int amplifier = 0; private int amplifier = 0;
public TileMatterFabricator() { public TileMatterFabricator() {
@ -106,9 +106,6 @@ public class TileMatterFabricator extends TilePowerAcceptor
// return slotIndex == 6; // return slotIndex == 6;
// } // }
public int maxProgresstime() {
return TileMatterFabricator.fabricationRate;
}
@Override @Override
public void updateEntity() { public void updateEntity() {
@ -117,34 +114,22 @@ public class TileMatterFabricator extends TilePowerAcceptor
if (!super.world.isRemote) { if (!super.world.isRemote) {
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
final ItemStack stack = this.inventory.getStackInSlot(i); final ItemStack stack = this.inventory.getStackInSlot(i);
if (this.amplifier < 10000 && stack != ItemStack.EMPTY) { if (stack != null) {
final int amp = this.getValue(stack) / 32; final int amp = this.getValue(stack);
if (ItemUtils.isItemEqual(stack, this.inventory.getStackInSlot(i), true, true)) { if(amp != 0 && this.canUseEnergy(85)){
if (this.canUseEnergy(1)) { this.useEnergy(85);
this.useEnergy(1); this.amplifier += amp;
this.amplifier += amp; this.inventory.decrStackSize(i, 1);
this.inventory.decrStackSize(i, 1);
}
} }
} }
} }
if (this.amplifier > 0) { if(amplifier >= fabricationRate){
if (this.amplifier > this.getEnergy()) { if(spaceForOutput()){
this.progresstime += this.getEnergy(); this.addOutputProducts();
this.amplifier -= this.getEnergy(); amplifier -= fabricationRate;
this.decreaseStoredEnergy(this.getEnergy(), true);
} else {
this.progresstime += this.amplifier;
this.decreaseStoredEnergy(this.amplifier, true);
this.amplifier = 0;
} }
} }
if (this.progresstime > this.maxProgresstime() && this.spaceForOutput()) {
this.progresstime -= this.maxProgresstime();
this.addOutputProducts();
}
} }
} }
@ -176,27 +161,23 @@ public class TileMatterFabricator extends TilePowerAcceptor
return true; return true;
} }
} }
} }
// TODO ic2
public int getValue(final ItemStack itemStack) { public int getValue(final ItemStack itemStack) {
// int value = getValue(Recipes.matterAmplifier.getOutputFor(itemStack,
// false));
if (itemStack.getItem() == ModItems.PARTS && itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()) { if (itemStack.getItem() == ModItems.PARTS && itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()) {
return 5000; return 200;
} else if (itemStack.getItem() == ModItems.SCRAP_BOX) { } else if (itemStack.getItem() == ModItems.SCRAP_BOX) {
return 45000; return 2000;
}
if(IC2Duplicates.SCRAP.hasIC2Stack()){
if(ItemUtils.isInputEqual(itemStack, IC2Duplicates.SCRAP.getIc2Stack(), true, true, true)){
return 200;
}
} }
return 0; return 0;
} }
// private static Integer getValue(RecipeOutput output) {
// if (output != null && output.metadata != null) {
// return output.metadata.getInteger("amplification");
// }
// return 0;
// }
@Override @Override
public double getMaxPower() { public double getMaxPower() {
return 100000000; return 100000000;
@ -233,16 +214,16 @@ public class TileMatterFabricator extends TilePowerAcceptor
} }
public int getProgress() { public int getProgress() {
return this.progresstime; return this.amplifier;
} }
public void setProgress(final int progress) { public void setProgress(final int progress) {
this.progresstime = progress; this.amplifier = progress;
} }
public int getProgressScaled(final int scale) { public int getProgressScaled(final int scale) {
if (this.progresstime != 0) { if (this.amplifier != 0) {
return this.progresstime * scale / this.maxProgresstime(); return Math.min(this.amplifier * scale / fabricationRate, 100);
} }
return 0; return 0;
} }