Convert AlloyFurnace and AlloySmelter

This commit is contained in:
Ourten 2017-01-08 13:10:13 +01:00
parent 619ddb14b8
commit 8a0a133e02
9 changed files with 532 additions and 613 deletions

View file

@ -6,9 +6,12 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler; import net.minecraftforge.fml.common.network.IGuiHandler;
import reborncore.api.recipe.RecipeHandler;
import reborncore.api.tile.IContainerLayout; import reborncore.api.tile.IContainerLayout;
import reborncore.common.container.RebornContainer; import reborncore.common.container.RebornContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.machines.AlloySmelterRecipe;
import techreborn.client.container.*; import techreborn.client.container.*;
import techreborn.client.container.builder.ContainerBuilder; import techreborn.client.container.builder.ContainerBuilder;
import techreborn.client.gui.*; import techreborn.client.gui.*;
@ -70,7 +73,7 @@ public class GuiHandler implements IGuiHandler {
@Override @Override
public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x, public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x,
final int y, final int z) { final int y, final int z) {
RebornContainer container = null; final RebornContainer container = null;
if (ID == GuiHandler.gasTurbineID || ID == GuiHandler.semifluidGeneratorID if (ID == GuiHandler.gasTurbineID || ID == GuiHandler.semifluidGeneratorID
|| ID == GuiHandler.thermalGeneratorID || ID == GuiHandler.dieselGeneratorID) { || ID == GuiHandler.thermalGeneratorID || ID == GuiHandler.dieselGeneratorID) {
return new ContainerBuilder("fluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142) return new ContainerBuilder("fluidgenerator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
@ -94,8 +97,17 @@ public class GuiHandler implements IGuiHandler {
} else if (ID == GuiHandler.blastFurnaceID) { } else if (ID == GuiHandler.blastFurnaceID) {
return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)), player); return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == GuiHandler.alloySmelterID) { } else if (ID == GuiHandler.alloySmelterID) {
container = new ContainerAlloySmelter(player, return new ContainerBuilder("alloysmelter").player(player.inventory).inventory(8, 84).hotbar(8, 142)
(TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z))); .addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z)))
.filterSlot(0, 47, 17, stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isItemEqual(recipe.getInputs().get(0), stack, true, true, true)))
.filterSlot(1, 65, 17, stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isItemEqual(recipe.getInputs().get(1), stack, true, true, true)))
.outputSlot(2, 116, 35).energySlot(3, 56, 53).upgradeSlot(4, 152, 8).upgradeSlot(5, 152, 26)
.upgradeSlot(6, 152, 44).upgradeSlot(7, 152, 62).syncEnergyValue().syncCrafterValue().addInventory()
.create();
} else if (ID == GuiHandler.industrialGrinderID) { } else if (ID == GuiHandler.industrialGrinderID) {
return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)), return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)),
player); player);
@ -120,7 +132,23 @@ public class GuiHandler implements IGuiHandler {
} else if (ID == GuiHandler.aesuID) { } else if (ID == GuiHandler.aesuID) {
return new ContainerAESU((TileAesu) world.getTileEntity(new BlockPos(x, y, z)), player); return new ContainerAESU((TileAesu) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == GuiHandler.alloyFurnaceID) { } else if (ID == GuiHandler.alloyFurnaceID) {
return new ContainerAlloyFurnace((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)), player); return new ContainerBuilder("alloyfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z)))
.filterSlot(0, 47, 17, stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isItemEqual(recipe.getInputs().get(0), stack, true, true, true)))
.filterSlot(1, 65, 17, stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isItemEqual(recipe.getInputs().get(1), stack, true, true, true)))
.outputSlot(2, 116, 35).fuelSlot(3, 56, 53)
.syncIntegerValue(((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)))::getBurnTime,
((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)))::setBurnTime)
.syncIntegerValue(((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)))::getCookTime,
((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)))::setCookTime)
.syncIntegerValue(
((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)))::getCurrentItemBurnTime,
((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)))::setCurrentItemBurnTime)
.addInventory().create();
} else if (ID == GuiHandler.sawMillID) { } else if (ID == GuiHandler.sawMillID) {
return new ContainerIndustrialSawmill((TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)), return new ContainerIndustrialSawmill((TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)),
player); player);

View file

@ -1,121 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.SlotFurnaceFuel;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import net.minecraft.item.ItemStack;
import reborncore.api.recipe.IBaseRecipeType;
import reborncore.api.recipe.RecipeHandler;
import reborncore.common.container.RebornContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.machines.AlloySmelterRecipe;
import techreborn.tiles.TileAlloyFurnace;
import javax.annotation.Nullable;
public class ContainerAlloyFurnace extends RebornContainer {
public int tickTime;
EntityPlayer player;
TileAlloyFurnace tile;
int currentItemBurnTime;
int burnTime;
int cookTime;
public ContainerAlloyFurnace(TileAlloyFurnace tileAlloyfurnace, EntityPlayer player) {
tile = tileAlloyfurnace;
this.player = player;
// input
this.addSlotToContainer(new SlotInputCustom(tileAlloyfurnace.inventory, 0, 47, 17, 0));
this.addSlotToContainer(new SlotInputCustom(tileAlloyfurnace.inventory, 1, 65, 17, 1));
// outputs
this.addSlotToContainer(new SlotOutput(tileAlloyfurnace.inventory, 2, 116, 35));
// Fuel
this.addSlotToContainer(new SlotFurnaceFuel(tileAlloyfurnace.inventory, 3, 56, 53));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
}
}
public static class SlotInputCustom extends BaseSlot {
int recipeSlot = 0;
public SlotInputCustom(IInventory inventoryIn, int index, int xPosition, int yPosition, int recipeSlot) {
super(inventoryIn, index, xPosition, yPosition);
this.recipeSlot = recipeSlot;
}
@Override
public boolean isItemValid(
@Nullable
ItemStack stack) {
for(IBaseRecipeType recipe : RecipeHandler.recipeList){
if(recipe instanceof AlloySmelterRecipe){
if(ItemUtils.isItemEqual(recipe.getInputs().get(recipeSlot), stack, true, true, true)){
return true;
}
}
}
return false;
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public void addListener(IContainerListener crafting) {
super.addListener(crafting);
crafting.sendProgressBarUpdate(this, 0, tile.currentItemBurnTime);
crafting.sendProgressBarUpdate(this, 1, tile.burnTime);
crafting.sendProgressBarUpdate(this, 2, tile.cookTime);
}
@Override
public void detectAndSendChanges() {
for (int i = 0; i < this.listeners.size(); i++) {
IContainerListener crafting = this.listeners.get(i);
if (this.currentItemBurnTime != tile.currentItemBurnTime) {
crafting.sendProgressBarUpdate(this, 0, tile.currentItemBurnTime);
}
if (this.burnTime != tile.burnTime) {
crafting.sendProgressBarUpdate(this, 1, tile.burnTime);
}
if (this.cookTime != tile.cookTime) {
crafting.sendProgressBarUpdate(this, 2, tile.cookTime);
}
}
super.detectAndSendChanges();
}
@Override
public void updateProgressBar(int id, int value) {
super.updateProgressBar(id, value);
if (id == 0) {
this.currentItemBurnTime = value;
} else if (id == 1) {
this.burnTime = value;
} else if (id == 2) {
this.cookTime = value;
}
this.tile.currentItemBurnTime = this.currentItemBurnTime;
this.tile.burnTime = this.burnTime;
this.tile.cookTime = this.cookTime;
}
}

View file

@ -1,67 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import reborncore.api.tile.IContainerLayout;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotCharge;
import reborncore.client.gui.slots.SlotInput;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileAlloySmelter;
import javax.annotation.Nullable;
import java.util.List;
public class ContainerAlloySmelter extends ContainerCrafting {
public int tickTime;
EntityPlayer player;
TileAlloySmelter tile;
public ContainerAlloySmelter(EntityPlayer player, TileAlloySmelter tile) {
super(tile.crafter);
this.player = player;
this.tile = tile;
addPlayerSlots();
addInventorySlots();
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
public void addInventorySlots() {
// input
this.addSlotToContainer(new ContainerAlloyFurnace.SlotInputCustom(tile.inventory, 0, 47, 17, 0));
this.addSlotToContainer(new ContainerAlloyFurnace.SlotInputCustom(tile.inventory, 1, 65, 17, 1));
// outputs
this.addSlotToContainer(new SlotOutput(tile.inventory, 2, 116, 35));
// battery
this.addSlotToContainer(new SlotCharge(tile.inventory, 3, 56, 53));
// upgrades
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 4, 152, 8));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 5, 152, 26));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 6, 152, 44));
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 7, 152, 62));
}
public void addPlayerSlots() {
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
}
}
}

View file

@ -5,39 +5,55 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
import techreborn.client.container.ContainerAlloyFurnace;
import reborncore.api.recipe.RecipeHandler;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.machines.AlloySmelterRecipe;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.TileAlloyFurnace; import techreborn.tiles.TileAlloyFurnace;
public class GuiAlloyFurnace extends GuiContainer { public class GuiAlloyFurnace extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", private static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/alloy_furnace.png"); "textures/gui/alloy_furnace.png");
TileAlloyFurnace alloyfurnace; TileAlloyFurnace alloyfurnace;
ContainerAlloyFurnace containerAlloyFurnace; public GuiAlloyFurnace(final EntityPlayer player, final TileAlloyFurnace tileAlloyFurnace) {
super(new ContainerBuilder("alloyfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142)
public GuiAlloyFurnace(EntityPlayer player, TileAlloyFurnace tileAlloyFurnace) { .addInventory().tile(tileAlloyFurnace)
super(new ContainerAlloyFurnace(tileAlloyFurnace, player)); .filterSlot(0, 47, 17,
stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isItemEqual(recipe.getInputs().get(0), stack, true, true, true)))
.filterSlot(1, 65, 17,
stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isItemEqual(recipe.getInputs().get(1), stack, true, true, true)))
.outputSlot(2, 116, 35).fuelSlot(3, 56, 53)
.syncIntegerValue(tileAlloyFurnace::getBurnTime, tileAlloyFurnace::setBurnTime)
.syncIntegerValue(tileAlloyFurnace::getCookTime, tileAlloyFurnace::setCookTime)
.syncIntegerValue(tileAlloyFurnace::getCurrentItemBurnTime, tileAlloyFurnace::setCurrentItemBurnTime)
.addInventory().create());
this.xSize = 176; this.xSize = 176;
this.ySize = 167; this.ySize = 167;
this.alloyfurnace = tileAlloyFurnace; this.alloyfurnace = tileAlloyFurnace;
this.containerAlloyFurnace = (ContainerAlloyFurnace) this.inventorySlots;
} }
@Override @Override
public void initGui() { public void initGui() {
int k = (this.width - this.xSize) / 2; final int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2; final int l = (this.height - this.ySize) / 2;
super.initGui(); super.initGui();
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture); this.mc.getTextureManager().bindTexture(GuiAlloyFurnace.texture);
int k = (this.width - this.xSize) / 2; final int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2; final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if (this.alloyfurnace.isBurning()) { if (this.alloyfurnace.isBurning()) {
@ -48,12 +64,12 @@ public class GuiAlloyFurnace extends GuiContainer {
} }
} }
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { @Override
String name = I18n.translateToLocal("tile.techreborn.alloyfurnace.name"); protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.alloyfurnace.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752); 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752); this.ySize - 96 + 2, 4210752);
} }
} }

View file

@ -5,57 +5,74 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
import reborncore.common.container.RebornContainer;
import techreborn.client.container.ContainerAlloySmelter; import reborncore.api.recipe.RecipeHandler;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.machines.AlloySmelterRecipe;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.TileAlloySmelter; import techreborn.tiles.TileAlloySmelter;
public class GuiAlloySmelter extends GuiContainer { public class GuiAlloySmelter extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/electric_alloy_furnace.png"); "textures/gui/electric_alloy_furnace.png");
TileAlloySmelter alloysmelter; TileAlloySmelter alloysmelter;
public GuiAlloySmelter(EntityPlayer player, TileAlloySmelter tilealloysmelter) { public GuiAlloySmelter(final EntityPlayer player, final TileAlloySmelter tilealloysmelter) {
super(RebornContainer.createContainer(ContainerAlloySmelter.class, tilealloysmelter, player)); super(new ContainerBuilder("alloysmelter").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tilealloysmelter)
.filterSlot(0, 47, 17,
stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isItemEqual(recipe.getInputs().get(0), stack, true, true, true)))
.filterSlot(1, 65, 17,
stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isItemEqual(recipe.getInputs().get(1), stack, true, true, true)))
.outputSlot(2, 116, 35).energySlot(3, 56, 53).upgradeSlot(4, 152, 8).upgradeSlot(5, 152, 26)
.upgradeSlot(6, 152, 44).upgradeSlot(7, 152, 62).syncEnergyValue().syncCrafterValue().addInventory()
.create());
this.xSize = 176; this.xSize = 176;
this.ySize = 167; this.ySize = 167;
alloysmelter = tilealloysmelter; this.alloysmelter = tilealloysmelter;
} }
@Override @Override
public void initGui() { public void initGui() {
int k = (this.width - this.xSize) / 2; final int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2; final int l = (this.height - this.ySize) / 2;
super.initGui(); super.initGui();
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture); this.mc.getTextureManager().bindTexture(GuiAlloySmelter.texture);
int k = (this.width - this.xSize) / 2; final int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2; final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0; int j = 0;
j = alloysmelter.getProgressScaled(24); j = this.alloysmelter.getProgressScaled(24);
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16);
} }
j = alloysmelter.getEnergyScaled(12); j = this.alloysmelter.getEnergyScaled(12);
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { @Override
String name = I18n.translateToLocal("tile.techreborn.alloysmelter.name"); protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.alloysmelter.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752); 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752); this.ySize - 96 + 2, 4210752);
} }
} }

View file

@ -12,51 +12,51 @@ import techreborn.tiles.TileScrapboxinator;
public class GuiScrapboxinator extends GuiContainer { public class GuiScrapboxinator extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/scrapboxinator.png"); "textures/gui/scrapboxinator.png");
TileScrapboxinator tile; TileScrapboxinator tile;
public GuiScrapboxinator(final EntityPlayer player, final TileScrapboxinator scrapboxinator) { public GuiScrapboxinator(final EntityPlayer player, final TileScrapboxinator scrapboxinator) {
super(new ContainerBuilder("scrapboxinator").player(player.inventory).inventory(8, 84).hotbar(8, 142) super(new ContainerBuilder("scrapboxinator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(scrapboxinator) .addInventory().tile(scrapboxinator)
.filterSlot(0, 56, 34, stack -> stack.getItem() == ModItems.SCRAP_BOX).outputSlot(1, 116, 34) .filterSlot(0, 56, 34, stack -> stack.getItem() == ModItems.SCRAP_BOX).outputSlot(1, 116, 34)
.upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44).upgradeSlot(5, 152, 62) .upgradeSlot(2, 152, 8).upgradeSlot(3, 152, 26).upgradeSlot(4, 152, 44).upgradeSlot(5, 152, 62)
.syncEnergyValue().syncIntegerValue(scrapboxinator::getProgress, scrapboxinator::setProgress) .syncEnergyValue().syncIntegerValue(scrapboxinator::getProgress, scrapboxinator::setProgress)
.addInventory().create()); .addInventory().create());
this.xSize = 176; this.xSize = 176;
this.ySize = 167; this.ySize = 167;
this.tile = scrapboxinator; this.tile = scrapboxinator;
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(GuiScrapboxinator.texture); this.mc.getTextureManager().bindTexture(GuiScrapboxinator.texture);
final int k = (this.width - this.xSize) / 2; final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2; final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0; int j = 0;
j = this.tile.gaugeProgressScaled(24); j = this.tile.gaugeProgressScaled(24);
// System.out.println(compressor.gaugeProgressScaled(10)); // System.out.println(compressor.gaugeProgressScaled(10));
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
} }
j = this.tile.getEnergyScaled(12); j = this.tile.getEnergyScaled(12);
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }
@Override @Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = net.minecraft.util.text.translation.I18n.translateToLocal("tile.techreborn.scrapboxinator.name"); final String name = net.minecraft.util.text.translation.I18n.translateToLocal("tile.techreborn.scrapboxinator.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752); 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2,
4210752); 4210752);
} }
} }

View file

@ -1,16 +1,13 @@
package techreborn.compat.jei; package techreborn.compat.jei;
import mezz.jei.api.BlankModPlugin; import javax.annotation.Nonnull;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
import mezz.jei.config.Config;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
import reborncore.api.recipe.RecipeHandler; import reborncore.api.recipe.RecipeHandler;
import techreborn.Core; import techreborn.Core;
import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.api.generator.GeneratorRecipeHelper;
@ -62,10 +59,17 @@ import techreborn.items.ItemParts;
import techreborn.parts.TechRebornParts; import techreborn.parts.TechRebornParts;
import techreborn.parts.powerCables.EnumCableType; import techreborn.parts.powerCables.EnumCableType;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
import mezz.jei.config.Config;
@mezz.jei.api.JEIPlugin @mezz.jei.api.JEIPlugin
public class TechRebornJeiPlugin extends BlankModPlugin { public class TechRebornJeiPlugin extends BlankModPlugin {
private static void addDebugRecipes(final IModRegistry registry) { private static void addDebugRecipes(final IModRegistry registry) {
@ -75,13 +79,13 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
final int time = (int) Math.round(200 + Math.random() * 100); final int time = (int) Math.round(200 + Math.random() * 100);
final AssemblingMachineRecipe assemblingMachineRecipe = new AssemblingMachineRecipe(diamondBlock, diamondBlock, final AssemblingMachineRecipe assemblingMachineRecipe = new AssemblingMachineRecipe(diamondBlock, diamondBlock,
dirtBlock, time, 120); dirtBlock, time, 120);
debugRecipes.add(assemblingMachineRecipe); debugRecipes.add(assemblingMachineRecipe);
} }
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
final int time = (int) Math.round(200 + Math.random() * 100); final int time = (int) Math.round(200 + Math.random() * 100);
final ImplosionCompressorRecipe recipe = new ImplosionCompressorRecipe(diamondBlock, diamondBlock, dirtBlock, final ImplosionCompressorRecipe recipe = new ImplosionCompressorRecipe(diamondBlock, diamondBlock, dirtBlock,
dirtBlock, time, 120); dirtBlock, time, 120);
debugRecipes.add(recipe); debugRecipes.add(recipe);
} }
registry.addRecipes(debugRecipes); registry.addRecipes(debugRecipes);
@ -89,9 +93,9 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
@Override @Override
public void register( public void register(
@Nonnull @Nonnull
final final
IModRegistry registry) { IModRegistry registry) {
final IJeiHelpers jeiHelpers = registry.getJeiHelpers(); final IJeiHelpers jeiHelpers = registry.getJeiHelpers();
final IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
@ -155,26 +159,26 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
} }
registry.addRecipeCategories(new AlloySmelterRecipeCategory(guiHelper), registry.addRecipeCategories(new AlloySmelterRecipeCategory(guiHelper),
new AssemblingMachineRecipeCategory(guiHelper), new BlastFurnaceRecipeCategory(guiHelper), new AssemblingMachineRecipeCategory(guiHelper), new BlastFurnaceRecipeCategory(guiHelper),
new CentrifugeRecipeCategory(guiHelper), new ChemicalReactorRecipeCategory(guiHelper), new CentrifugeRecipeCategory(guiHelper), new ChemicalReactorRecipeCategory(guiHelper),
new FusionReactorRecipeCategory(guiHelper), new IndustrialGrinderRecipeCategory(guiHelper), new FusionReactorRecipeCategory(guiHelper), new IndustrialGrinderRecipeCategory(guiHelper),
new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper), new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper),
new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper), new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper),
new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper), new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper),
new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper)); new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
for (final EFluidGenerator type : EFluidGenerator.values()) for (final EFluidGenerator type : EFluidGenerator.values())
registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper)); registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper));
registry.addRecipeHandlers(new AlloySmelterRecipeHandler(jeiHelpers), registry.addRecipeHandlers(new AlloySmelterRecipeHandler(jeiHelpers),
new AssemblingMachineRecipeHandler(jeiHelpers), new BlastFurnaceRecipeHandler(jeiHelpers), new AssemblingMachineRecipeHandler(jeiHelpers), new BlastFurnaceRecipeHandler(jeiHelpers),
new CentrifugeRecipeHandler(jeiHelpers), new ChemicalReactorRecipeHandler(jeiHelpers), new CentrifugeRecipeHandler(jeiHelpers), new ChemicalReactorRecipeHandler(jeiHelpers),
new FusionReactorRecipeHandler(), new IndustrialGrinderRecipeHandler(jeiHelpers), new FusionReactorRecipeHandler(), new IndustrialGrinderRecipeHandler(jeiHelpers),
new ImplosionCompressorRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers), new ImplosionCompressorRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers),
new RollingMachineRecipeHandler(), new VacuumFreezerRecipeHandler(jeiHelpers), new RollingMachineRecipeHandler(), new VacuumFreezerRecipeHandler(jeiHelpers),
new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers), new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers),
new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers), new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers),
new FluidGeneratorRecipeHandler(jeiHelpers)); new FluidGeneratorRecipeHandler(jeiHelpers));
registry.addRecipes(RecipeHandler.recipeList); registry.addRecipes(RecipeHandler.recipeList);
registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes); registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes);
@ -185,7 +189,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipes(RollingMachineRecipeMaker.getRecipes(jeiHelpers)); registry.addRecipes(RollingMachineRecipeMaker.getRecipes(jeiHelpers));
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
Core.logHelper Core.logHelper
.error("Could not register rolling machine recipes. JEI may have changed its internal recipe wrapper locations."); .error("Could not register rolling machine recipes. JEI may have changed its internal recipe wrapper locations.");
e.printStackTrace(); e.printStackTrace();
} }
@ -194,17 +198,17 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
} }
registry.addDescription(ItemParts.getPartByName("rubberSap"), registry.addDescription(ItemParts.getPartByName("rubberSap"),
I18n.translateToLocal("techreborn.desc.rubberSap")); I18n.translateToLocal("techreborn.desc.rubberSap"));
if (!ConfigTechReborn.ScrapboxDispenser) { if (!ConfigTechReborn.ScrapboxDispenser) {
registry.addDescription(new ItemStack(ModItems.SCRAP_BOX), registry.addDescription(new ItemStack(ModItems.SCRAP_BOX),
I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser")); I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser"));
} else { } else {
registry.addDescription(new ItemStack(ModItems.SCRAP_BOX), registry.addDescription(new ItemStack(ModItems.SCRAP_BOX),
I18n.translateToLocal("techreborn.desc.scrapBox")); I18n.translateToLocal("techreborn.desc.scrapBox"));
} }
registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER, registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER,
VanillaRecipeCategoryUid.FUEL); VanillaRecipeCategoryUid.FUEL);
registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER); registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE); registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
registry.addRecipeClickArea(GuiBlastFurnace.class, 63, 36, 24, 15, RecipeCategoryUids.BLAST_FURNACE); registry.addRecipeClickArea(GuiBlastFurnace.class, 63, 36, 24, 15, RecipeCategoryUids.BLAST_FURNACE);
@ -213,96 +217,97 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR); registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR);
registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER); registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER);
registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15, registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15,
RecipeCategoryUids.IMPLOSION_COMPRESSOR); RecipeCategoryUids.IMPLOSION_COMPRESSOR);
registry.addRecipeClickArea(GuiIndustrialElectrolyzer.class, 72, 37, 33, 14, registry.addRecipeClickArea(GuiIndustrialElectrolyzer.class, 72, 37, 33, 14,
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER); RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE); registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE);
registry.addRecipeClickArea(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER); registry.addRecipeClickArea(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER);
registry.addRecipeClickArea(GuiGrinder.class, 78, 36, 24, 16, RecipeCategoryUids.GRINDER); registry.addRecipeClickArea(GuiGrinder.class, 78, 36, 24, 16, RecipeCategoryUids.GRINDER);
registry.addRecipeClickArea(GuiExtractor.class, 78, 36, 24, 16, RecipeCategoryUids.EXTRACTOR); registry.addRecipeClickArea(GuiExtractor.class, 78, 36, 24, 16, RecipeCategoryUids.EXTRACTOR);
registry.addRecipeClickArea(GuiCompressor.class, 78, 36, 24, 16, RecipeCategoryUids.COMPRESSOR); registry.addRecipeClickArea(GuiCompressor.class, 78, 36, 24, 16, RecipeCategoryUids.COMPRESSOR);
registry.addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING, registry.addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING,
VanillaRecipeCategoryUid.FUEL); VanillaRecipeCategoryUid.FUEL);
registry.addRecipeClickArea(GuiElectricFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING); registry.addRecipeClickArea(GuiElectricFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING);
registry.addRecipeClickArea(GuiSemifluidGenerator.class, 79, 34, 18, 18, registry.addRecipeClickArea(GuiSemifluidGenerator.class, 79, 34, 18, 18,
EFluidGenerator.SEMIFLUID.getRecipeID()); EFluidGenerator.SEMIFLUID.getRecipeID());
registry.addRecipeClickArea(GuiDieselGenerator.class, 79, 34, 18, 18, registry.addRecipeClickArea(GuiDieselGenerator.class, 79, 34, 18, 18,
EFluidGenerator.DIESEL.getRecipeID()); EFluidGenerator.DIESEL.getRecipeID());
registry.addRecipeClickArea(GuiGasTurbine.class, 79, 34, 18, 18, registry.addRecipeClickArea(GuiGasTurbine.class, 79, 34, 18, 18,
EFluidGenerator.GAS.getRecipeID()); EFluidGenerator.GAS.getRecipeID());
registry.addRecipeClickArea(GuiThermalGenerator.class, 79, 34, 18, 18, registry.addRecipeClickArea(GuiThermalGenerator.class, 79, 34, 18, 18,
EFluidGenerator.THERMAL.getRecipeID()); EFluidGenerator.THERMAL.getRecipeID());
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.COMPRESSOR), RecipeCategoryUids.COMPRESSOR); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.COMPRESSOR), RecipeCategoryUids.COMPRESSOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_ALLOY_FURNACE), RecipeCategoryUids.ALLOY_SMELTER); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_ALLOY_FURNACE), RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ALLOY_SMELTER), RecipeCategoryUids.ALLOY_SMELTER); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ALLOY_SMELTER), RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ASSEMBLY_MACHINE), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ASSEMBLY_MACHINE),
RecipeCategoryUids.ASSEMBLING_MACHINE); RecipeCategoryUids.ASSEMBLING_MACHINE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_BLAST_FURNACE), RecipeCategoryUids.BLAST_FURNACE); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_BLAST_FURNACE), RecipeCategoryUids.BLAST_FURNACE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_CENTRIFUGE), RecipeCategoryUids.CENTRIFUGE); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_CENTRIFUGE), RecipeCategoryUids.CENTRIFUGE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.CHEMICAL_REACTOR), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.CHEMICAL_REACTOR),
RecipeCategoryUids.CHEMICAL_REACTOR); RecipeCategoryUids.CHEMICAL_REACTOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.EXTRACTOR), RecipeCategoryUids.EXTRACTOR); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.EXTRACTOR), RecipeCategoryUids.EXTRACTOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER),
RecipeCategoryUids.FUSION_REACTOR); RecipeCategoryUids.FUSION_REACTOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GRINDER), RecipeCategoryUids.GRINDER); registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GRINDER), RecipeCategoryUids.GRINDER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IMPLOSION_COMPRESSOR), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IMPLOSION_COMPRESSOR),
RecipeCategoryUids.IMPLOSION_COMPRESSOR); RecipeCategoryUids.IMPLOSION_COMPRESSOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_ELECTROLYZER), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_ELECTROLYZER),
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER); RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_GRINDER), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_GRINDER),
RecipeCategoryUids.INDUSTRIAL_GRINDER); RecipeCategoryUids.INDUSTRIAL_GRINDER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ROLLING_MACHINE), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ROLLING_MACHINE),
RecipeCategoryUids.ROLLING_MACHINE); RecipeCategoryUids.ROLLING_MACHINE);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.SCRAP_BOX), RecipeCategoryUids.SCRAPBOX); registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.SCRAP_BOX), RecipeCategoryUids.SCRAPBOX);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.SEMIFLUID_GENERATOR), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.SEMIFLUID_GENERATOR),
EFluidGenerator.SEMIFLUID.getRecipeID()); EFluidGenerator.SEMIFLUID.getRecipeID());
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GAS_TURBINE), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GAS_TURBINE),
EFluidGenerator.GAS.getRecipeID()); EFluidGenerator.GAS.getRecipeID());
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.DIESEL_GENERATOR), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.DIESEL_GENERATOR),
EFluidGenerator.DIESEL.getRecipeID()); EFluidGenerator.DIESEL.getRecipeID());
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.THERMAL_GENERATOR), registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.THERMAL_GENERATOR),
EFluidGenerator.THERMAL.getRecipeID()); EFluidGenerator.THERMAL.getRecipeID());
final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry(); final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36); .addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36); .addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36); .addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36); .addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR,
recipeTransferRegistry
.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR,
0, 2, 4, 36); 0, 2, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class, recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class,
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36); RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11, .addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11,
36); 36);
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36); .addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("assemblingmachine", RecipeCategoryUids.ASSEMBLING_MACHINE, 36, 2, 0, new BuiltContainerTransferInfo("alloyfurnace", RecipeCategoryUids.ALLOY_SMELTER, 36, 2, 0, 36));
36));
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("chemicalreactor", RecipeCategoryUids.CHEMICAL_REACTOR, 36, 2, 0, 36)); new BuiltContainerTransferInfo("alloyfurnace", VanillaRecipeCategoryUid.FUEL, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("centrifuge", RecipeCategoryUids.CENTRIFUGE, 36, 2, 0, 36)); new BuiltContainerTransferInfo("alloysmelter", RecipeCategoryUids.ALLOY_SMELTER, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("grinder", RecipeCategoryUids.GRINDER, 36, 1, 0, 36)); new BuiltContainerTransferInfo("assemblingmachine", RecipeCategoryUids.ASSEMBLING_MACHINE, 36, 2, 0,
36));
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("extractor", RecipeCategoryUids.EXTRACTOR, 36, 1, 0, 36)); new BuiltContainerTransferInfo("chemicalreactor", RecipeCategoryUids.CHEMICAL_REACTOR, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("compressor", RecipeCategoryUids.COMPRESSOR, 36, 1, 0, 36)); new BuiltContainerTransferInfo("centrifuge", RecipeCategoryUids.CENTRIFUGE, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("grinder", RecipeCategoryUids.GRINDER, 36, 1, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("extractor", RecipeCategoryUids.EXTRACTOR, 36, 1, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("compressor", RecipeCategoryUids.COMPRESSOR, 36, 1, 0, 36));
if (CompatManager.isQuantumStorageLoaded) { if (CompatManager.isQuantumStorageLoaded) {
registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.QUANTUM_CHEST)); registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.QUANTUM_CHEST));

View file

@ -8,6 +8,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import reborncore.api.recipe.IBaseRecipeType; import reborncore.api.recipe.IBaseRecipeType;
import reborncore.api.recipe.RecipeHandler; import reborncore.api.recipe.RecipeHandler;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
@ -15,271 +16,301 @@ import reborncore.common.IWrenchable;
import reborncore.common.tile.TileLegacyMachineBase; import reborncore.common.tile.TileLegacyMachineBase;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchable, IInventoryProvider { public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchable, IInventoryProvider {
public int tickTime; public int tickTime;
public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this); public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this);
public int burnTime; public int burnTime;
public int currentItemBurnTime; public int currentItemBurnTime;
public int cookTime; public int cookTime;
int input1 = 0; int input1 = 0;
int input2 = 1; int input2 = 1;
int output = 2; int output = 2;
int fuel = 3; int fuel = 3;
public TileAlloyFurnace() { public TileAlloyFurnace() {
} }
/** /**
* Returns the number of ticks that the supplied fuel item will keep the * Returns the number of ticks that the supplied fuel item will keep the
* furnace burning, or 0 if the item isn't fuel * furnace burning, or 0 if the item isn't fuel
*/ */
public static int getItemBurnTime(ItemStack stack) { public static int getItemBurnTime(final ItemStack stack) {
if (stack == null) { if (stack == null) {
return 0; return 0;
} else { } else {
Item item = stack.getItem(); final Item item = stack.getItem();
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) {
Block block = Block.getBlockFromItem(item); final Block block = Block.getBlockFromItem(item);
if (block == Blocks.WOODEN_SLAB) { if (block == Blocks.WOODEN_SLAB) {
return 150; return 150;
} }
if (block.getMaterial(block.getDefaultState()) == Material.WOOD) { if (block.getMaterial(block.getDefaultState()) == Material.WOOD) {
return 300; return 300;
} }
if (block == Blocks.COAL_BLOCK) { if (block == Blocks.COAL_BLOCK) {
return 16000; return 16000;
} }
} }
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
return 200; return 200;
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
return 200; return 200;
// if (item instanceof ItemHoe && ((ItemHoe) // if (item instanceof ItemHoe && ((ItemHoe)
// item).getToolMaterialName().equals("WOOD")) return 200; // item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.STICK) if (item == Items.STICK)
return 100; return 100;
if (item == Items.COAL) if (item == Items.COAL)
return 1600; return 1600;
if (item == Items.LAVA_BUCKET) if (item == Items.LAVA_BUCKET)
return 20000; return 20000;
if (item == Item.getItemFromBlock(Blocks.SAPLING)) if (item == Item.getItemFromBlock(Blocks.SAPLING))
return 100; return 100;
if (item == Items.BLAZE_ROD) if (item == Items.BLAZE_ROD)
return 2400; return 2400;
return GameRegistry.getFuelValue(stack); return GameRegistry.getFuelValue(stack);
} }
} }
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity(); super.updateEntity();
boolean flag = this.burnTime > 0; final boolean flag = this.burnTime > 0;
boolean flag1 = false; boolean flag1 = false;
if (this.burnTime > 0) { if (this.burnTime > 0) {
--this.burnTime; --this.burnTime;
} }
if (!this.world.isRemote) { if (!this.world.isRemote) {
if (this.burnTime != 0 || getStackInSlot(input1) != ItemStack.EMPTY && getStackInSlot(fuel) != ItemStack.EMPTY) { if (this.burnTime != 0 || this.getStackInSlot(this.input1) != ItemStack.EMPTY && this.getStackInSlot(this.fuel) != ItemStack.EMPTY) {
if (this.burnTime == 0 && this.canSmelt()) { if (this.burnTime == 0 && this.canSmelt()) {
this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel)); this.currentItemBurnTime = this.burnTime = TileAlloyFurnace.getItemBurnTime(this.getStackInSlot(this.fuel));
if (this.burnTime > 0) { if (this.burnTime > 0) {
flag1 = true; flag1 = true;
if (this.getStackInSlot(fuel) != ItemStack.EMPTY) { if (this.getStackInSlot(this.fuel) != ItemStack.EMPTY) {
decrStackSize(fuel, 1); this.decrStackSize(this.fuel, 1);
} }
} }
} }
if (this.isBurning() && this.canSmelt()) { if (this.isBurning() && this.canSmelt()) {
++this.cookTime; ++this.cookTime;
if (this.cookTime == 200) { if (this.cookTime == 200) {
this.cookTime = 0; this.cookTime = 0;
this.smeltItem(); this.smeltItem();
flag1 = true; flag1 = true;
} }
} else { } else {
this.cookTime = 0; this.cookTime = 0;
} }
} }
if (flag != this.burnTime > 0) { if (flag != this.burnTime > 0) {
flag1 = true; flag1 = true;
// TODO sync on/off // TODO sync on/off
} }
} }
if (flag1) { if (flag1) {
this.markDirty(); this.markDirty();
} }
} }
public boolean hasAllInputs(IBaseRecipeType recipeType) { public boolean hasAllInputs(final IBaseRecipeType recipeType) {
if (recipeType == null) { if (recipeType == null) {
return false; return false;
} }
for (ItemStack input : recipeType.getInputs()) { for (final ItemStack input : recipeType.getInputs()) {
Boolean hasItem = false; Boolean hasItem = false;
for (int inputslot = 0; inputslot < 2; inputslot++) { for (int inputslot = 0; inputslot < 2; inputslot++) {
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, if (ItemUtils.isItemEqual(input, this.inventory.getStackInSlot(inputslot), true, true,
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).getCount() >= input.getCount()) { recipeType.useOreDic()) && this.inventory.getStackInSlot(inputslot).getCount() >= input.getCount()) {
hasItem = true; hasItem = true;
} }
} }
if (!hasItem) if (!hasItem)
return false; return false;
} }
return true; return true;
} }
private boolean canSmelt() { private boolean canSmelt() {
if (this.getStackInSlot(input1) == ItemStack.EMPTY || this.getStackInSlot(input2) == ItemStack.EMPTY) { if (this.getStackInSlot(this.input1) == ItemStack.EMPTY || this.getStackInSlot(this.input2) == ItemStack.EMPTY) {
return false; return false;
} else { } else {
ItemStack itemstack = null; ItemStack itemstack = null;
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
if (hasAllInputs(recipeType)) { if (this.hasAllInputs(recipeType)) {
itemstack = recipeType.getOutput(0); itemstack = recipeType.getOutput(0);
break; break;
} }
} }
if (itemstack == null) if (itemstack == null)
return false; return false;
if (this.getStackInSlot(output) == ItemStack.EMPTY) if (this.getStackInSlot(this.output) == ItemStack.EMPTY)
return true; return true;
if (!this.getStackInSlot(output).isItemEqual(itemstack)) if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
return false; return false;
int result = getStackInSlot(output).getCount() + itemstack.getCount(); final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount();
return result <= getInventoryStackLimit() && result <= this.getStackInSlot(output).getMaxStackSize(); // Forge return result <= this.getInventoryStackLimit() && result <= this.getStackInSlot(this.output).getMaxStackSize(); // Forge
// BugFix: // BugFix:
// Make // Make
// it // it
// respect // respect
// stack // stack
// sizes // sizes
// properly. // properly.
} }
} }
/** /**
* Turn one item from the furnace source stack into the appropriate smelted * Turn one item from the furnace source stack into the appropriate smelted
* item in the furnace result stack * item in the furnace result stack
*/ */
public void smeltItem() { public void smeltItem() {
if (this.canSmelt()) { if (this.canSmelt()) {
ItemStack itemstack = null; ItemStack itemstack = null;
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
if (hasAllInputs(recipeType)) { if (this.hasAllInputs(recipeType)) {
itemstack = recipeType.getOutput(0); itemstack = recipeType.getOutput(0);
break; break;
} }
if (itemstack != ItemStack.EMPTY) { if (itemstack != ItemStack.EMPTY) {
break; break;
} }
} }
if (this.getStackInSlot(output) == ItemStack.EMPTY) { if (this.getStackInSlot(this.output) == ItemStack.EMPTY) {
setInventorySlotContents(output, itemstack.copy()); this.setInventorySlotContents(this.output, itemstack.copy());
} else if (this.getStackInSlot(output).getItem() == itemstack.getItem()) { } else if (this.getStackInSlot(this.output).getItem() == itemstack.getItem()) {
decrStackSize(output, -itemstack.getCount()); this.decrStackSize(this.output, -itemstack.getCount());
} }
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) { for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
boolean hasAllRecipes = true; boolean hasAllRecipes = true;
if (hasAllInputs(recipeType)) { if (this.hasAllInputs(recipeType)) {
} else { } else {
hasAllRecipes = false; hasAllRecipes = false;
} }
if (hasAllRecipes) { if (hasAllRecipes) {
for (ItemStack input : recipeType.getInputs()) { for (final ItemStack input : recipeType.getInputs()) {
for (int inputSlot = 0; inputSlot < 2; inputSlot++) { for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, if (ItemUtils.isItemEqual(input, this.inventory.getStackInSlot(inputSlot), true, true,
recipeType.useOreDic())) { recipeType.useOreDic())) {
inventory.decrStackSize(inputSlot, input.getCount()); this.inventory.decrStackSize(inputSlot, input.getCount());
break; break;
} }
} }
} }
} }
} }
} }
} }
/** /**
* Furnace isBurning * Furnace isBurning
*/ */
public boolean isBurning() { public boolean isBurning() {
return this.burnTime > 0; return this.burnTime > 0;
} }
public int getBurnTimeRemainingScaled(int scale) { public int getBurnTimeRemainingScaled(final int scale) {
if (this.currentItemBurnTime == 0) { if (this.currentItemBurnTime == 0) {
this.currentItemBurnTime = 200; this.currentItemBurnTime = 200;
} }
return this.burnTime * scale / this.currentItemBurnTime; return this.burnTime * scale / this.currentItemBurnTime;
} }
public int getCookProgressScaled(int scale) { public int getCookProgressScaled(final int scale) {
return this.cookTime * scale / 200; return this.cookTime * scale / 200;
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing() {
return getFacingEnum(); return this.getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@Override @Override
public float getWrenchDropRate() { public float getWrenchDropRate() {
return 1.0F; return 1.0F;
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.IRON_ALLOY_FURNACE, 1); return new ItemStack(ModBlocks.IRON_ALLOY_FURNACE, 1);
} }
public boolean isComplete() { public boolean isComplete() {
return false; return false;
} }
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return this.inventory;
} }
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(final EnumFacing side) {
return new int[] { 0, 1, 2 }; return new int[] { 0, 1, 2 };
} }
@Override @Override
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
return index == 0 || index == 1; return index == 0 || index == 1;
} }
@Override @Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
return index == 2; return index == 2;
} }
public int getBurnTime()
{
return this.burnTime;
}
public void setBurnTime(final int burnTime)
{
this.burnTime = burnTime;
}
public int getCurrentItemBurnTime()
{
return this.currentItemBurnTime;
}
public void setCurrentItemBurnTime(final int currentItemBurnTime)
{
this.currentItemBurnTime = currentItemBurnTime;
}
public int getCookTime()
{
return this.cookTime;
}
public void setCookTime(final int cookTime)
{
this.cookTime = cookTime;
}
} }

View file

@ -5,12 +5,14 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable; import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.ScrapboxList; import techreborn.api.ScrapboxList;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModItems; import techreborn.init.ModItems;
@ -33,88 +35,88 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
super(1); super(1);
} }
public int gaugeProgressScaled(int scale) { public int gaugeProgressScaled(final int scale) {
return (progress * scale) / time; return this.progress * scale / this.time;
} }
@Override @Override
public void updateEntity() { public void updateEntity() {
boolean burning = isBurning(); final boolean burning = this.isBurning();
boolean updateInventory = false; boolean updateInventory = false;
if (getEnergy() <= cost && canOpen()) { if (this.getEnergy() <= this.cost && this.canOpen()) {
if (getEnergy() > cost) { if (this.getEnergy() > this.cost) {
updateInventory = true; updateInventory = true;
} }
} }
if (isBurning() && canOpen()) { if (this.isBurning() && this.canOpen()) {
updateState(); this.updateState();
progress++; this.progress++;
if (progress >= time) { if (this.progress >= this.time) {
progress = 0; this.progress = 0;
recycleItems(); this.recycleItems();
updateInventory = true; updateInventory = true;
} }
} else { } else {
progress = 0; this.progress = 0;
updateState(); this.updateState();
} }
if (burning != isBurning()) { if (burning != this.isBurning()) {
updateInventory = true; updateInventory = true;
} }
if (updateInventory) { if (updateInventory) {
markDirty(); this.markDirty();
} }
} }
public void recycleItems() { public void recycleItems() {
if (this.canOpen() && !world.isRemote) { if (this.canOpen() && !this.world.isRemote) {
int random = new Random().nextInt(ScrapboxList.stacks.size()); final int random = new Random().nextInt(ScrapboxList.stacks.size());
ItemStack out = ScrapboxList.stacks.get(random).copy(); final ItemStack out = ScrapboxList.stacks.get(random).copy();
if (getStackInSlot(output) == null) { if (this.getStackInSlot(this.output) == null) {
useEnergy(cost); this.useEnergy(this.cost);
setInventorySlotContents(output, out); this.setInventorySlotContents(this.output, out);
} }
if (getStackInSlot(input1).getCount() > 1) { if (this.getStackInSlot(this.input1).getCount() > 1) {
useEnergy(cost); this.useEnergy(this.cost);
this.decrStackSize(input1, 1); this.decrStackSize(this.input1, 1);
} else { } else {
useEnergy(cost); this.useEnergy(this.cost);
setInventorySlotContents(input1, ItemStack.EMPTY); this.setInventorySlotContents(this.input1, ItemStack.EMPTY);
} }
} }
} }
public boolean canOpen() { public boolean canOpen() {
return getStackInSlot(input1) != ItemStack.EMPTY && getStackInSlot(output) == ItemStack.EMPTY; return this.getStackInSlot(this.input1) != ItemStack.EMPTY && this.getStackInSlot(this.output) == ItemStack.EMPTY;
} }
public boolean isBurning() { public boolean isBurning() {
return getEnergy() > cost; return this.getEnergy() > this.cost;
} }
public void updateState() { public void updateState() {
IBlockState blockState = world.getBlockState(pos); final IBlockState blockState = this.world.getBlockState(this.pos);
if (blockState.getBlock() instanceof BlockMachineBase) { if (blockState.getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock(); final BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock();
if (blockState.getValue(BlockMachineBase.ACTIVE) != progress > 0) if (blockState.getValue(BlockMachineBase.ACTIVE) != this.progress > 0)
blockMachineBase.setActive(progress > 0, world, pos); blockMachineBase.setActive(this.progress > 0, this.world, this.pos);
} }
} }
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) { public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false; return false;
} }
@Override @Override
public EnumFacing getFacing() { public EnumFacing getFacing() {
return getFacingEnum(); return this.getFacingEnum();
} }
@Override @Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) { public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking(); return entityPlayer.isSneaking();
} }
@ -124,7 +126,7 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
} }
@Override @Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.SCRAPBOXINATOR, 1); return new ItemStack(ModBlocks.SCRAPBOXINATOR, 1);
} }
@ -134,12 +136,12 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
// ISidedInventory // ISidedInventory
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(final EnumFacing side) {
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 }; return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
} }
@Override @Override
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
if (slotIndex == 2) if (slotIndex == 2)
return false; return false;
if (slotIndex == 1) { if (slotIndex == 1) {
@ -147,26 +149,26 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
return true; return true;
} }
} }
return isItemValidForSlot(slotIndex, itemStack); return this.isItemValidForSlot(slotIndex, itemStack);
} }
@Override @Override
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
return slotIndex == 2; return slotIndex == 2;
} }
@Override @Override
public double getMaxPower() { public double getMaxPower() {
return capacity; return this.capacity;
} }
@Override @Override
public boolean canAcceptEnergy(EnumFacing direction) { public boolean canAcceptEnergy(final EnumFacing direction) {
return true; return true;
} }
@Override @Override
public boolean canProvideEnergy(EnumFacing direction) { public boolean canProvideEnergy(final EnumFacing direction) {
return false; return false;
} }
@ -187,6 +189,14 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return this.inventory;
}
public int getProgress() {
return this.progress;
}
public void setProgress(final int progress) {
this.progress = progress;
} }
} }