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,7 +5,12 @@ 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 {
@ -15,29 +20,40 @@ public class GuiAlloyFurnace extends GuiContainer {
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,8 +5,12 @@ 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 {
@ -16,43 +20,56 @@ public class GuiAlloySmelter extends GuiContainer {
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,

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) {
@ -267,12 +271,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
EFluidGenerator.THERMAL.getRecipeID()); EFluidGenerator.THERMAL.getRecipeID());
final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry(); final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36); .addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
recipeTransferRegistry recipeTransferRegistry
@ -290,6 +289,12 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
recipeTransferRegistry 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("alloyfurnace", RecipeCategoryUids.ALLOY_SMELTER, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("alloyfurnace", VanillaRecipeCategoryUid.FUEL, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("alloysmelter", RecipeCategoryUids.ALLOY_SMELTER, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("assemblingmachine", RecipeCategoryUids.ASSEMBLING_MACHINE, 36, 2, 0, new BuiltContainerTransferInfo("assemblingmachine", RecipeCategoryUids.ASSEMBLING_MACHINE, 36, 2, 0,
36)); 36));

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,6 +16,7 @@ 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;
@ -38,14 +40,14 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
* 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;
@ -83,19 +85,19 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
@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);
} }
} }
} }
@ -120,15 +122,15 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
} }
} }
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;
} }
} }
@ -139,12 +141,12 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
} }
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;
} }
@ -152,12 +154,12 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
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
@ -175,8 +177,8 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
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;
} }
@ -185,25 +187,25 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
} }
} }
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;
} }
} }
@ -221,7 +223,7 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
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;
} }
@ -229,22 +231,22 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
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();
} }
@ -254,7 +256,7 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
} }
@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);
} }
@ -264,22 +266,51 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
@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;
} }
} }