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.minecraftforge.fml.common.network.IGuiHandler;
import reborncore.api.recipe.RecipeHandler;
import reborncore.api.tile.IContainerLayout;
import reborncore.common.container.RebornContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.machines.AlloySmelterRecipe;
import techreborn.client.container.*;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.client.gui.*;
@ -70,7 +73,7 @@ public class GuiHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x,
final int y, final int z) {
RebornContainer container = null;
final RebornContainer container = null;
if (ID == GuiHandler.gasTurbineID || ID == GuiHandler.semifluidGeneratorID
|| ID == GuiHandler.thermalGeneratorID || ID == GuiHandler.dieselGeneratorID) {
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) {
return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == GuiHandler.alloySmelterID) {
container = new ContainerAlloySmelter(player,
(TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z)));
return new ContainerBuilder("alloysmelter").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).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) {
return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)),
player);
@ -120,7 +132,23 @@ public class GuiHandler implements IGuiHandler {
} else if (ID == GuiHandler.aesuID) {
return new ContainerAESU((TileAesu) world.getTileEntity(new BlockPos(x, y, z)), player);
} 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) {
return new ContainerIndustrialSawmill((TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)),
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.util.ResourceLocation;
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;
public class GuiAlloyFurnace extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/alloy_furnace.png");
"textures/gui/alloy_furnace.png");
TileAlloyFurnace alloyfurnace;
ContainerAlloyFurnace containerAlloyFurnace;
public GuiAlloyFurnace(EntityPlayer player, TileAlloyFurnace tileAlloyFurnace) {
super(new ContainerAlloyFurnace(tileAlloyFurnace, player));
public GuiAlloyFurnace(final EntityPlayer player, final TileAlloyFurnace tileAlloyFurnace) {
super(new ContainerBuilder("alloyfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(tileAlloyFurnace)
.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.ySize = 167;
this.alloyfurnace = tileAlloyFurnace;
this.containerAlloyFurnace = (ContainerAlloyFurnace) this.inventorySlots;
}
@Override
public void initGui() {
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
super.initGui();
}
@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);
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.mc.getTextureManager().bindTexture(GuiAlloyFurnace.texture);
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if (this.alloyfurnace.isBurning()) {
@ -48,12 +64,12 @@ public class GuiAlloyFurnace extends GuiContainer {
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.alloyfurnace.name");
@Override
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,
4210752);
4210752);
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.util.ResourceLocation;
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;
public class GuiAlloySmelter extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/electric_alloy_furnace.png");
"textures/gui/electric_alloy_furnace.png");
TileAlloySmelter alloysmelter;
public GuiAlloySmelter(EntityPlayer player, TileAlloySmelter tilealloysmelter) {
super(RebornContainer.createContainer(ContainerAlloySmelter.class, tilealloysmelter, player));
public GuiAlloySmelter(final EntityPlayer player, final TileAlloySmelter tilealloysmelter) {
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.ySize = 167;
alloysmelter = tilealloysmelter;
this.alloysmelter = tilealloysmelter;
}
@Override
public void initGui() {
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
super.initGui();
}
@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);
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.mc.getTextureManager().bindTexture(GuiAlloySmelter.texture);
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = alloysmelter.getProgressScaled(24);
j = this.alloysmelter.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16);
}
j = alloysmelter.getEnergyScaled(12);
j = this.alloysmelter.getEnergyScaled(12);
if (j > 0) {
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_) {
String name = I18n.translateToLocal("tile.techreborn.alloysmelter.name");
@Override
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,
4210752);
4210752);
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 static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/scrapboxinator.png");
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/scrapboxinator.png");
TileScrapboxinator tile;
TileScrapboxinator tile;
public GuiScrapboxinator(final EntityPlayer player, final TileScrapboxinator scrapboxinator) {
super(new ContainerBuilder("scrapboxinator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(scrapboxinator)
.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)
.syncEnergyValue().syncIntegerValue(scrapboxinator::getProgress, scrapboxinator::setProgress)
.addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.tile = scrapboxinator;
}
public GuiScrapboxinator(final EntityPlayer player, final TileScrapboxinator scrapboxinator) {
super(new ContainerBuilder("scrapboxinator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(scrapboxinator)
.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)
.syncEnergyValue().syncIntegerValue(scrapboxinator::getProgress, scrapboxinator::setProgress)
.addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.tile = scrapboxinator;
}
@Override
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);
this.mc.getTextureManager().bindTexture(GuiScrapboxinator.texture);
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
@Override
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);
this.mc.getTextureManager().bindTexture(GuiScrapboxinator.texture);
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
int j = 0;
j = this.tile.gaugeProgressScaled(24);
// System.out.println(compressor.gaugeProgressScaled(10));
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = this.tile.gaugeProgressScaled(24);
// System.out.println(compressor.gaugeProgressScaled(10));
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = this.tile.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
j = this.tile.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
@Override
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");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2,
4210752);
}
@Override
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");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2,
4210752);
}
}

View file

@ -1,16 +1,13 @@
package techreborn.compat.jei;
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;
import javax.annotation.Nonnull;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.translation.I18n;
import reborncore.api.recipe.RecipeHandler;
import techreborn.Core;
import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.GeneratorRecipeHelper;
@ -62,10 +59,17 @@ import techreborn.items.ItemParts;
import techreborn.parts.TechRebornParts;
import techreborn.parts.powerCables.EnumCableType;
import javax.annotation.Nonnull;
import java.util.ArrayList;
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
public class TechRebornJeiPlugin extends BlankModPlugin {
private static void addDebugRecipes(final IModRegistry registry) {
@ -75,13 +79,13 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
for (int i = 0; i < 10; i++) {
final int time = (int) Math.round(200 + Math.random() * 100);
final AssemblingMachineRecipe assemblingMachineRecipe = new AssemblingMachineRecipe(diamondBlock, diamondBlock,
dirtBlock, time, 120);
dirtBlock, time, 120);
debugRecipes.add(assemblingMachineRecipe);
}
for (int i = 0; i < 10; i++) {
final int time = (int) Math.round(200 + Math.random() * 100);
final ImplosionCompressorRecipe recipe = new ImplosionCompressorRecipe(diamondBlock, diamondBlock, dirtBlock,
dirtBlock, time, 120);
dirtBlock, time, 120);
debugRecipes.add(recipe);
}
registry.addRecipes(debugRecipes);
@ -89,9 +93,9 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
@Override
public void register(
@Nonnull
final
IModRegistry registry) {
@Nonnull
final
IModRegistry registry) {
final IJeiHelpers jeiHelpers = registry.getJeiHelpers();
final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
@ -155,26 +159,26 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
}
registry.addRecipeCategories(new AlloySmelterRecipeCategory(guiHelper),
new AssemblingMachineRecipeCategory(guiHelper), new BlastFurnaceRecipeCategory(guiHelper),
new CentrifugeRecipeCategory(guiHelper), new ChemicalReactorRecipeCategory(guiHelper),
new FusionReactorRecipeCategory(guiHelper), new IndustrialGrinderRecipeCategory(guiHelper),
new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper),
new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper),
new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper),
new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
new AssemblingMachineRecipeCategory(guiHelper), new BlastFurnaceRecipeCategory(guiHelper),
new CentrifugeRecipeCategory(guiHelper), new ChemicalReactorRecipeCategory(guiHelper),
new FusionReactorRecipeCategory(guiHelper), new IndustrialGrinderRecipeCategory(guiHelper),
new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper),
new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper),
new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper),
new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
for (final EFluidGenerator type : EFluidGenerator.values())
registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper));
registry.addRecipeHandlers(new AlloySmelterRecipeHandler(jeiHelpers),
new AssemblingMachineRecipeHandler(jeiHelpers), new BlastFurnaceRecipeHandler(jeiHelpers),
new CentrifugeRecipeHandler(jeiHelpers), new ChemicalReactorRecipeHandler(jeiHelpers),
new FusionReactorRecipeHandler(), new IndustrialGrinderRecipeHandler(jeiHelpers),
new ImplosionCompressorRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers),
new RollingMachineRecipeHandler(), new VacuumFreezerRecipeHandler(jeiHelpers),
new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers),
new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers),
new FluidGeneratorRecipeHandler(jeiHelpers));
new AssemblingMachineRecipeHandler(jeiHelpers), new BlastFurnaceRecipeHandler(jeiHelpers),
new CentrifugeRecipeHandler(jeiHelpers), new ChemicalReactorRecipeHandler(jeiHelpers),
new FusionReactorRecipeHandler(), new IndustrialGrinderRecipeHandler(jeiHelpers),
new ImplosionCompressorRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers),
new RollingMachineRecipeHandler(), new VacuumFreezerRecipeHandler(jeiHelpers),
new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers),
new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers),
new FluidGeneratorRecipeHandler(jeiHelpers));
registry.addRecipes(RecipeHandler.recipeList);
registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes);
@ -185,7 +189,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
registry.addRecipes(RollingMachineRecipeMaker.getRecipes(jeiHelpers));
} catch (final RuntimeException e) {
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();
}
@ -194,17 +198,17 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
}
registry.addDescription(ItemParts.getPartByName("rubberSap"),
I18n.translateToLocal("techreborn.desc.rubberSap"));
I18n.translateToLocal("techreborn.desc.rubberSap"));
if (!ConfigTechReborn.ScrapboxDispenser) {
registry.addDescription(new ItemStack(ModItems.SCRAP_BOX),
I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser"));
I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser"));
} else {
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,
VanillaRecipeCategoryUid.FUEL);
VanillaRecipeCategoryUid.FUEL);
registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
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(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER);
registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15,
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
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(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER);
registry.addRecipeClickArea(GuiGrinder.class, 78, 36, 24, 16, RecipeCategoryUids.GRINDER);
registry.addRecipeClickArea(GuiExtractor.class, 78, 36, 24, 16, RecipeCategoryUids.EXTRACTOR);
registry.addRecipeClickArea(GuiCompressor.class, 78, 36, 24, 16, RecipeCategoryUids.COMPRESSOR);
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(GuiSemifluidGenerator.class, 79, 34, 18, 18,
EFluidGenerator.SEMIFLUID.getRecipeID());
EFluidGenerator.SEMIFLUID.getRecipeID());
registry.addRecipeClickArea(GuiDieselGenerator.class, 79, 34, 18, 18,
EFluidGenerator.DIESEL.getRecipeID());
EFluidGenerator.DIESEL.getRecipeID());
registry.addRecipeClickArea(GuiGasTurbine.class, 79, 34, 18, 18,
EFluidGenerator.GAS.getRecipeID());
EFluidGenerator.GAS.getRecipeID());
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.IRON_ALLOY_FURNACE), RecipeCategoryUids.ALLOY_SMELTER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ALLOY_SMELTER), RecipeCategoryUids.ALLOY_SMELTER);
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_CENTRIFUGE), RecipeCategoryUids.CENTRIFUGE);
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.FUSION_CONTROL_COMPUTER),
RecipeCategoryUids.FUSION_REACTOR);
RecipeCategoryUids.FUSION_REACTOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GRINDER), RecipeCategoryUids.GRINDER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IMPLOSION_COMPRESSOR),
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_ELECTROLYZER),
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_GRINDER),
RecipeCategoryUids.INDUSTRIAL_GRINDER);
RecipeCategoryUids.INDUSTRIAL_GRINDER);
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(ModBlocks.SEMIFLUID_GENERATOR),
EFluidGenerator.SEMIFLUID.getRecipeID());
EFluidGenerator.SEMIFLUID.getRecipeID());
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GAS_TURBINE),
EFluidGenerator.GAS.getRecipeID());
EFluidGenerator.GAS.getRecipeID());
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.DIESEL_GENERATOR),
EFluidGenerator.DIESEL.getRecipeID());
EFluidGenerator.DIESEL.getRecipeID());
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.THERMAL_GENERATOR),
EFluidGenerator.THERMAL.getRecipeID());
EFluidGenerator.THERMAL.getRecipeID());
final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36);
.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
.addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
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,
.addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR,
0, 2, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class,
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11,
.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11,
36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("assemblingmachine", RecipeCategoryUids.ASSEMBLING_MACHINE, 36, 2, 0,
36));
new BuiltContainerTransferInfo("alloyfurnace", RecipeCategoryUids.ALLOY_SMELTER, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("chemicalreactor", RecipeCategoryUids.CHEMICAL_REACTOR, 36, 2, 0, 36));
new BuiltContainerTransferInfo("alloyfurnace", VanillaRecipeCategoryUid.FUEL, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("centrifuge", RecipeCategoryUids.CENTRIFUGE, 36, 2, 0, 36));
new BuiltContainerTransferInfo("alloysmelter", RecipeCategoryUids.ALLOY_SMELTER, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("grinder", RecipeCategoryUids.GRINDER, 36, 1, 0, 36));
new BuiltContainerTransferInfo("assemblingmachine", RecipeCategoryUids.ASSEMBLING_MACHINE, 36, 2, 0,
36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("extractor", RecipeCategoryUids.EXTRACTOR, 36, 1, 0, 36));
new BuiltContainerTransferInfo("chemicalreactor", RecipeCategoryUids.CHEMICAL_REACTOR, 36, 2, 0, 36));
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) {
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.util.EnumFacing;
import net.minecraftforge.fml.common.registry.GameRegistry;
import reborncore.api.recipe.IBaseRecipeType;
import reborncore.api.recipe.RecipeHandler;
import reborncore.api.tile.IInventoryProvider;
@ -15,271 +16,301 @@ import reborncore.common.IWrenchable;
import reborncore.common.tile.TileLegacyMachineBase;
import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchable, IInventoryProvider {
public int tickTime;
public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this);
public int burnTime;
public int currentItemBurnTime;
public int cookTime;
int input1 = 0;
int input2 = 1;
int output = 2;
int fuel = 3;
public int tickTime;
public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this);
public int burnTime;
public int currentItemBurnTime;
public int cookTime;
int input1 = 0;
int input2 = 1;
int output = 2;
int fuel = 3;
public TileAlloyFurnace() {
public TileAlloyFurnace() {
}
}
/**
* Returns the number of ticks that the supplied fuel item will keep the
* furnace burning, or 0 if the item isn't fuel
*/
public static int getItemBurnTime(ItemStack stack) {
if (stack == null) {
return 0;
} else {
Item item = stack.getItem();
/**
* Returns the number of ticks that the supplied fuel item will keep the
* furnace burning, or 0 if the item isn't fuel
*/
public static int getItemBurnTime(final ItemStack stack) {
if (stack == null) {
return 0;
} else {
final Item item = stack.getItem();
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) {
Block block = Block.getBlockFromItem(item);
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) {
final Block block = Block.getBlockFromItem(item);
if (block == Blocks.WOODEN_SLAB) {
return 150;
}
if (block == Blocks.WOODEN_SLAB) {
return 150;
}
if (block.getMaterial(block.getDefaultState()) == Material.WOOD) {
return 300;
}
if (block.getMaterial(block.getDefaultState()) == Material.WOOD) {
return 300;
}
if (block == Blocks.COAL_BLOCK) {
return 16000;
}
}
if (block == Blocks.COAL_BLOCK) {
return 16000;
}
}
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
return 200;
// if (item instanceof ItemHoe && ((ItemHoe)
// item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.STICK)
return 100;
if (item == Items.COAL)
return 1600;
if (item == Items.LAVA_BUCKET)
return 20000;
if (item == Item.getItemFromBlock(Blocks.SAPLING))
return 100;
if (item == Items.BLAZE_ROD)
return 2400;
return GameRegistry.getFuelValue(stack);
}
}
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
return 200;
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
return 200;
// if (item instanceof ItemHoe && ((ItemHoe)
// item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.STICK)
return 100;
if (item == Items.COAL)
return 1600;
if (item == Items.LAVA_BUCKET)
return 20000;
if (item == Item.getItemFromBlock(Blocks.SAPLING))
return 100;
if (item == Items.BLAZE_ROD)
return 2400;
return GameRegistry.getFuelValue(stack);
}
}
@Override
public void updateEntity() {
super.updateEntity();
boolean flag = this.burnTime > 0;
boolean flag1 = false;
if (this.burnTime > 0) {
--this.burnTime;
}
if (!this.world.isRemote) {
if (this.burnTime != 0 || getStackInSlot(input1) != ItemStack.EMPTY && getStackInSlot(fuel) != ItemStack.EMPTY) {
if (this.burnTime == 0 && this.canSmelt()) {
this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel));
if (this.burnTime > 0) {
flag1 = true;
if (this.getStackInSlot(fuel) != ItemStack.EMPTY) {
decrStackSize(fuel, 1);
}
}
}
if (this.isBurning() && this.canSmelt()) {
++this.cookTime;
if (this.cookTime == 200) {
this.cookTime = 0;
this.smeltItem();
flag1 = true;
}
} else {
this.cookTime = 0;
}
}
if (flag != this.burnTime > 0) {
flag1 = true;
// TODO sync on/off
}
}
if (flag1) {
this.markDirty();
}
}
@Override
public void updateEntity() {
super.updateEntity();
final boolean flag = this.burnTime > 0;
boolean flag1 = false;
if (this.burnTime > 0) {
--this.burnTime;
}
if (!this.world.isRemote) {
if (this.burnTime != 0 || this.getStackInSlot(this.input1) != ItemStack.EMPTY && this.getStackInSlot(this.fuel) != ItemStack.EMPTY) {
if (this.burnTime == 0 && this.canSmelt()) {
this.currentItemBurnTime = this.burnTime = TileAlloyFurnace.getItemBurnTime(this.getStackInSlot(this.fuel));
if (this.burnTime > 0) {
flag1 = true;
if (this.getStackInSlot(this.fuel) != ItemStack.EMPTY) {
this.decrStackSize(this.fuel, 1);
}
}
}
if (this.isBurning() && this.canSmelt()) {
++this.cookTime;
if (this.cookTime == 200) {
this.cookTime = 0;
this.smeltItem();
flag1 = true;
}
} else {
this.cookTime = 0;
}
}
if (flag != this.burnTime > 0) {
flag1 = true;
// TODO sync on/off
}
}
if (flag1) {
this.markDirty();
}
}
public boolean hasAllInputs(IBaseRecipeType recipeType) {
if (recipeType == null) {
return false;
}
for (ItemStack input : recipeType.getInputs()) {
Boolean hasItem = false;
for (int inputslot = 0; inputslot < 2; inputslot++) {
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true,
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).getCount() >= input.getCount()) {
hasItem = true;
}
}
if (!hasItem)
return false;
}
return true;
}
public boolean hasAllInputs(final IBaseRecipeType recipeType) {
if (recipeType == null) {
return false;
}
for (final ItemStack input : recipeType.getInputs()) {
Boolean hasItem = false;
for (int inputslot = 0; inputslot < 2; inputslot++) {
if (ItemUtils.isItemEqual(input, this.inventory.getStackInSlot(inputslot), true, true,
recipeType.useOreDic()) && this.inventory.getStackInSlot(inputslot).getCount() >= input.getCount()) {
hasItem = true;
}
}
if (!hasItem)
return false;
}
return true;
}
private boolean canSmelt() {
if (this.getStackInSlot(input1) == ItemStack.EMPTY || this.getStackInSlot(input2) == ItemStack.EMPTY) {
return false;
} else {
ItemStack itemstack = null;
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
if (hasAllInputs(recipeType)) {
itemstack = recipeType.getOutput(0);
break;
}
}
private boolean canSmelt() {
if (this.getStackInSlot(this.input1) == ItemStack.EMPTY || this.getStackInSlot(this.input2) == ItemStack.EMPTY) {
return false;
} else {
ItemStack itemstack = null;
for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
if (this.hasAllInputs(recipeType)) {
itemstack = recipeType.getOutput(0);
break;
}
}
if (itemstack == null)
return false;
if (this.getStackInSlot(output) == ItemStack.EMPTY)
return true;
if (!this.getStackInSlot(output).isItemEqual(itemstack))
return false;
int result = getStackInSlot(output).getCount() + itemstack.getCount();
return result <= getInventoryStackLimit() && result <= this.getStackInSlot(output).getMaxStackSize(); // Forge
// BugFix:
// Make
// it
// respect
// stack
// sizes
// properly.
}
}
if (itemstack == null)
return false;
if (this.getStackInSlot(this.output) == ItemStack.EMPTY)
return true;
if (!this.getStackInSlot(this.output).isItemEqual(itemstack))
return false;
final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount();
return result <= this.getInventoryStackLimit() && result <= this.getStackInSlot(this.output).getMaxStackSize(); // Forge
// BugFix:
// Make
// it
// respect
// stack
// sizes
// properly.
}
}
/**
* Turn one item from the furnace source stack into the appropriate smelted
* item in the furnace result stack
*/
public void smeltItem() {
if (this.canSmelt()) {
ItemStack itemstack = null;
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
if (hasAllInputs(recipeType)) {
itemstack = recipeType.getOutput(0);
break;
}
if (itemstack != ItemStack.EMPTY) {
break;
}
}
/**
* Turn one item from the furnace source stack into the appropriate smelted
* item in the furnace result stack
*/
public void smeltItem() {
if (this.canSmelt()) {
ItemStack itemstack = null;
for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
if (this.hasAllInputs(recipeType)) {
itemstack = recipeType.getOutput(0);
break;
}
if (itemstack != ItemStack.EMPTY) {
break;
}
}
if (this.getStackInSlot(output) == ItemStack.EMPTY) {
setInventorySlotContents(output, itemstack.copy());
} else if (this.getStackInSlot(output).getItem() == itemstack.getItem()) {
decrStackSize(output, -itemstack.getCount());
}
if (this.getStackInSlot(this.output) == ItemStack.EMPTY) {
this.setInventorySlotContents(this.output, itemstack.copy());
} else if (this.getStackInSlot(this.output).getItem() == itemstack.getItem()) {
this.decrStackSize(this.output, -itemstack.getCount());
}
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
boolean hasAllRecipes = true;
if (hasAllInputs(recipeType)) {
for (final IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
boolean hasAllRecipes = true;
if (this.hasAllInputs(recipeType)) {
} else {
hasAllRecipes = false;
}
if (hasAllRecipes) {
for (ItemStack input : recipeType.getInputs()) {
for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true,
recipeType.useOreDic())) {
inventory.decrStackSize(inputSlot, input.getCount());
break;
}
}
}
}
}
} else {
hasAllRecipes = false;
}
if (hasAllRecipes) {
for (final ItemStack input : recipeType.getInputs()) {
for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
if (ItemUtils.isItemEqual(input, this.inventory.getStackInSlot(inputSlot), true, true,
recipeType.useOreDic())) {
this.inventory.decrStackSize(inputSlot, input.getCount());
break;
}
}
}
}
}
}
}
}
}
/**
* Furnace isBurning
*/
public boolean isBurning() {
return this.burnTime > 0;
}
/**
* Furnace isBurning
*/
public boolean isBurning() {
return this.burnTime > 0;
}
public int getBurnTimeRemainingScaled(int scale) {
if (this.currentItemBurnTime == 0) {
this.currentItemBurnTime = 200;
}
public int getBurnTimeRemainingScaled(final int scale) {
if (this.currentItemBurnTime == 0) {
this.currentItemBurnTime = 200;
}
return this.burnTime * scale / this.currentItemBurnTime;
}
return this.burnTime * scale / this.currentItemBurnTime;
}
public int getCookProgressScaled(int scale) {
return this.cookTime * scale / 200;
}
public int getCookProgressScaled(final int scale) {
return this.cookTime * scale / 200;
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
return false;
}
@Override
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false;
}
@Override
public EnumFacing getFacing() {
return getFacingEnum();
}
@Override
public EnumFacing getFacing() {
return this.getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@Override
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@Override
public float getWrenchDropRate() {
return 1.0F;
}
@Override
public float getWrenchDropRate() {
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.IRON_ALLOY_FURNACE, 1);
}
@Override
public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.IRON_ALLOY_FURNACE, 1);
}
public boolean isComplete() {
return false;
}
public boolean isComplete() {
return false;
}
@Override
public Inventory getInventory() {
return inventory;
}
@Override
public Inventory getInventory() {
return this.inventory;
}
@Override
public int[] getSlotsForFace(EnumFacing side) {
return new int[] { 0, 1, 2 };
}
@Override
public int[] getSlotsForFace(final EnumFacing side) {
return new int[] { 0, 1, 2 };
}
@Override
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
return index == 0 || index == 1;
}
@Override
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
return index == 0 || index == 1;
}
@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
return index == 2;
}
@Override
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
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.item.ItemStack;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.ScrapboxList;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
@ -33,88 +35,88 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
super(1);
}
public int gaugeProgressScaled(int scale) {
return (progress * scale) / time;
public int gaugeProgressScaled(final int scale) {
return this.progress * scale / this.time;
}
@Override
public void updateEntity() {
boolean burning = isBurning();
final boolean burning = this.isBurning();
boolean updateInventory = false;
if (getEnergy() <= cost && canOpen()) {
if (getEnergy() > cost) {
if (this.getEnergy() <= this.cost && this.canOpen()) {
if (this.getEnergy() > this.cost) {
updateInventory = true;
}
}
if (isBurning() && canOpen()) {
updateState();
if (this.isBurning() && this.canOpen()) {
this.updateState();
progress++;
if (progress >= time) {
progress = 0;
recycleItems();
this.progress++;
if (this.progress >= this.time) {
this.progress = 0;
this.recycleItems();
updateInventory = true;
}
} else {
progress = 0;
updateState();
this.progress = 0;
this.updateState();
}
if (burning != isBurning()) {
if (burning != this.isBurning()) {
updateInventory = true;
}
if (updateInventory) {
markDirty();
this.markDirty();
}
}
public void recycleItems() {
if (this.canOpen() && !world.isRemote) {
int random = new Random().nextInt(ScrapboxList.stacks.size());
ItemStack out = ScrapboxList.stacks.get(random).copy();
if (getStackInSlot(output) == null) {
useEnergy(cost);
setInventorySlotContents(output, out);
if (this.canOpen() && !this.world.isRemote) {
final int random = new Random().nextInt(ScrapboxList.stacks.size());
final ItemStack out = ScrapboxList.stacks.get(random).copy();
if (this.getStackInSlot(this.output) == null) {
this.useEnergy(this.cost);
this.setInventorySlotContents(this.output, out);
}
if (getStackInSlot(input1).getCount() > 1) {
useEnergy(cost);
this.decrStackSize(input1, 1);
if (this.getStackInSlot(this.input1).getCount() > 1) {
this.useEnergy(this.cost);
this.decrStackSize(this.input1, 1);
} else {
useEnergy(cost);
setInventorySlotContents(input1, ItemStack.EMPTY);
this.useEnergy(this.cost);
this.setInventorySlotContents(this.input1, ItemStack.EMPTY);
}
}
}
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() {
return getEnergy() > cost;
return this.getEnergy() > this.cost;
}
public void updateState() {
IBlockState blockState = world.getBlockState(pos);
final IBlockState blockState = this.world.getBlockState(this.pos);
if (blockState.getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock();
if (blockState.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(progress > 0, world, pos);
final BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock();
if (blockState.getValue(BlockMachineBase.ACTIVE) != this.progress > 0)
blockMachineBase.setActive(this.progress > 0, this.world, this.pos);
}
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
return false;
}
@Override
public EnumFacing getFacing() {
return getFacingEnum();
return this.getFacingEnum();
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
}
@ -124,7 +126,7 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.SCRAPBOXINATOR, 1);
}
@ -134,12 +136,12 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
// ISidedInventory
@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 };
}
@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)
return false;
if (slotIndex == 1) {
@ -147,26 +149,26 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
return true;
}
}
return isItemValidForSlot(slotIndex, itemStack);
return this.isItemValidForSlot(slotIndex, itemStack);
}
@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;
}
@Override
public double getMaxPower() {
return capacity;
return this.capacity;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@ -187,6 +189,14 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
@Override
public Inventory getInventory() {
return inventory;
return this.inventory;
}
public int getProgress() {
return this.progress;
}
public void setProgress(final int progress) {
this.progress = progress;
}
}