Convert VacuumFreezer and ImplosionCompressor

This commit is contained in:
Ourten 2017-01-08 16:01:24 +01:00
parent ea98e4a8a0
commit b5881e2102
6 changed files with 57 additions and 161 deletions

View file

@ -128,8 +128,10 @@ public class GuiHandler implements IGuiHandler {
return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)), return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)),
player); player);
} else if (ID == GuiHandler.implosionCompresserID) { } else if (ID == GuiHandler.implosionCompresserID) {
return new ContainerImplosionCompressor( return new ContainerBuilder("implosioncompressor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
(TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z)), player); .addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 37, 26)
.slot(1, 37, 44).outputSlot(2, 93, 35).outputSlot(3, 111, 35).syncEnergyValue().syncCrafterValue()
.addInventory().create();
} else if (ID == GuiHandler.matterfabID) { } else if (ID == GuiHandler.matterfabID) {
return new ContainerBuilder("matterfabricator").player(player.inventory).inventory(8, 84).hotbar(8, 142) return new ContainerBuilder("matterfabricator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 33, 17) .addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 33, 17)
@ -196,7 +198,9 @@ public class GuiHandler implements IGuiHandler {
.energySlot(1, 80, 21).energySlot(2, 98, 21).energySlot(3, 62, 39).energySlot(4, 80, 39) .energySlot(1, 80, 21).energySlot(2, 98, 21).energySlot(3, 62, 39).energySlot(4, 80, 39)
.energySlot(5, 98, 39).syncEnergyValue().addInventory().create(); .energySlot(5, 98, 39).syncEnergyValue().addInventory().create();
} else if (ID == GuiHandler.vacuumFreezerID) { } else if (ID == GuiHandler.vacuumFreezerID) {
return new ContainerVacuumFreezer((TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z)), player); return new ContainerBuilder("vacuumfreezer").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).slot(0, 56, 34)
.outputSlot(1, 116, 35).syncEnergyValue().syncCrafterValue().addInventory().create();
} else if (ID == GuiHandler.generatorID) { } else if (ID == GuiHandler.generatorID) {
return new ContainerBuilder("generator").player(player.inventory).inventory(8, 84).hotbar(8, 142) return new ContainerBuilder("generator").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).fuelSlot(0, 80, 53) .addInventory().tile((IInventory) world.getTileEntity(new BlockPos(x, y, z))).fuelSlot(0, 80, 53)

View file

@ -1,77 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.tiles.multiblock.TileImplosionCompressor;
public class ContainerImplosionCompressor extends ContainerCrafting {
public int tickTime;
public int multIBlockState = 0;
EntityPlayer player;
TileImplosionCompressor tile;
public ContainerImplosionCompressor(TileImplosionCompressor tilecompressor, EntityPlayer player) {
super(tilecompressor.crafter);
tile = tilecompressor;
this.player = player;
// input
this.addSlotToContainer(new BaseSlot(tilecompressor.inventory, 0, 37, 26));
this.addSlotToContainer(new BaseSlot(tilecompressor.inventory, 1, 37, 44));
// outputs
this.addSlotToContainer(new SlotOutput(tilecompressor.inventory, 2, 93, 35));
this.addSlotToContainer(new SlotOutput(tilecompressor.inventory, 3, 111, 35));
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));
}
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < this.listeners.size(); i++) {
IContainerListener IContainerListener = this.listeners.get(i);
if (this.multIBlockState != getMultIBlockStateint()) {
IContainerListener.sendProgressBarUpdate(this, 3, getMultIBlockStateint());
}
}
}
@Override
public void addListener(IContainerListener crafting) {
super.addListener(crafting);
crafting.sendProgressBarUpdate(this, 3, getMultIBlockStateint());
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
if (id == 3) {
this.multIBlockState = value;
}
}
public int getMultIBlockStateint() {
return tile.getMutliBlock() ? 1 : 0;
}
}

View file

@ -1,40 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.slots.BaseSlot;
import reborncore.client.gui.slots.SlotOutput;
import techreborn.tiles.multiblock.TileVacuumFreezer;
public class ContainerVacuumFreezer extends ContainerCrafting {
EntityPlayer player;
TileVacuumFreezer tile;
public ContainerVacuumFreezer(TileVacuumFreezer tileAlloysmelter, EntityPlayer player) {
super(tileAlloysmelter.crafter);
tile = tileAlloysmelter;
this.player = player;
// input
this.addSlotToContainer(new BaseSlot(tileAlloysmelter.inventory, 0, 56, 34));
// outputs
this.addSlotToContainer(new SlotOutput(tileAlloysmelter.inventory, 1, 116, 35));
for (int 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 (int i = 0; i < 9; ++i) {
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
}

View file

@ -5,59 +5,61 @@ 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.ContainerImplosionCompressor;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.multiblock.TileImplosionCompressor; import techreborn.tiles.multiblock.TileImplosionCompressor;
public class GuiImplosionCompressor extends GuiContainer { public class GuiImplosionCompressor extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/implosion_compressor.png"); "textures/gui/implosion_compressor.png");
TileImplosionCompressor compresser; TileImplosionCompressor compresser;
ContainerImplosionCompressor containerImplosionCompressor;
public GuiImplosionCompressor(EntityPlayer player, TileImplosionCompressor tilecompresser) { public GuiImplosionCompressor(final EntityPlayer player, final TileImplosionCompressor tilecompressor) {
super(new ContainerImplosionCompressor(tilecompresser, player)); super(new ContainerBuilder("implosioncompressor").player(player.inventory).inventory(8, 84).hotbar(8, 142)
containerImplosionCompressor = (ContainerImplosionCompressor) this.inventorySlots; .addInventory().tile(tilecompressor).slot(0, 37, 26).slot(1, 37, 44).outputSlot(2, 93, 35)
.outputSlot(3, 111, 35).syncEnergyValue().syncCrafterValue().addInventory().create());
this.xSize = 176; this.xSize = 176;
this.ySize = 167; this.ySize = 167;
compresser = tilecompresser; this.compresser = tilecompressor;
} }
@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(GuiImplosionCompressor.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 (containerImplosionCompressor.multIBlockState == 0) { if (!this.compresser.getMutliBlock()) {
// GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10); // GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1); this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
} }
this.mc.getTextureManager().bindTexture(texture); this.mc.getTextureManager().bindTexture(GuiImplosionCompressor.texture);
int j = compresser.getProgressScaled(24); int j = this.compresser.getProgressScaled(24);
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16);
} }
j = compresser.getEnergyScaled(12); j = this.compresser.getEnergyScaled(12);
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 14, 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.implosioncompressor.name"); protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String name = I18n.translateToLocal("tile.techreborn.implosioncompressor.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
} }

View file

@ -5,7 +5,8 @@ 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.ContainerVacuumFreezer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.tiles.multiblock.TileVacuumFreezer; import techreborn.tiles.multiblock.TileVacuumFreezer;
public class GuiVacuumFreezer extends GuiContainer { public class GuiVacuumFreezer extends GuiContainer {
@ -14,43 +15,46 @@ public class GuiVacuumFreezer extends GuiContainer {
TileVacuumFreezer crafter; TileVacuumFreezer crafter;
public GuiVacuumFreezer(EntityPlayer player, TileVacuumFreezer freezer) { public GuiVacuumFreezer(final EntityPlayer player, final TileVacuumFreezer freezer) {
super(new ContainerVacuumFreezer(freezer, player)); super(new ContainerBuilder("vacuumfreezer").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(freezer).slot(0, 56, 34).outputSlot(1, 116, 35).syncEnergyValue()
.syncCrafterValue().addInventory().create());
this.xSize = 176; this.xSize = 176;
this.ySize = 167; this.ySize = 167;
crafter = freezer; this.crafter = freezer;
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) {
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(GuiVacuumFreezer.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 = crafter.getProgressScaled(24); int j = this.crafter.getProgressScaled(24);
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 80, l + 37, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 80, l + 37, 176, 14, j + 1, 16);
} }
j = (int) (crafter.getEnergy() * 12f / crafter.getMaxPower()); j = (int) (this.crafter.getEnergy() * 12f / this.crafter.getMaxPower());
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
if (!crafter.getMultiBlock()) { if (!this.crafter.getMultiBlock()) {
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1); this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
} }
j = crafter.getEnergyScaled(12); j = this.crafter.getEnergyScaled(12);
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
} }
} }
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { @Override
String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name"); protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
final String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 8, this.ySize - 96 + 2, 4210752); this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
} }

View file

@ -14,7 +14,9 @@ import techreborn.api.generator.GeneratorRecipeHelper;
import techreborn.api.reactor.FusionReactorRecipeHelper; import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.api.recipe.machines.AssemblingMachineRecipe; import techreborn.api.recipe.machines.AssemblingMachineRecipe;
import techreborn.api.recipe.machines.ImplosionCompressorRecipe; import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
import techreborn.client.container.*; import techreborn.client.container.ContainerFusionReactor;
import techreborn.client.container.ContainerIndustrialElectrolyzer;
import techreborn.client.container.ContainerIndustrialGrinder;
import techreborn.client.gui.*; import techreborn.client.gui.*;
import techreborn.compat.CompatManager; import techreborn.compat.CompatManager;
import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory; import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory;
@ -272,20 +274,21 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry(); final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
recipeTransferRegistry
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36); .addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
recipeTransferRegistry recipeTransferRegistry
.addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36); .addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR,
0, 2, 4, 36);
recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class, recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class,
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36); RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
recipeTransferRegistry
.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("implosioncompressor", RecipeCategoryUids.IMPLOSION_COMPRESSOR, 36, 2, 0,
36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("vacuumfreezer", RecipeCategoryUids.VACUUM_FREEZER, 36, 1, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("blastfurnace", RecipeCategoryUids.BLAST_FURNACE, 36, 2, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(
new BuiltContainerTransferInfo("rollingmachine", RecipeCategoryUids.ROLLING_MACHINE, 36, 9, 0, 36)); new BuiltContainerTransferInfo("rollingmachine", RecipeCategoryUids.ROLLING_MACHINE, 36, 9, 0, 36));
recipeTransferRegistry.addRecipeTransferHandler( recipeTransferRegistry.addRecipeTransferHandler(