Centrifuge stuff

This commit is contained in:
ProfessorProspector 2017-01-08 03:18:28 -08:00
parent 0a9a62c455
commit 3c40e25b6a
6 changed files with 179 additions and 134 deletions

View file

@ -1,30 +1,19 @@
package techreborn.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
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.builder.ContainerBuilder;
import techreborn.tiles.TileCentrifuge;
public class GuiCentrifuge extends GuiContainer {
public class GuiCentrifuge extends GuiBase {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_centrifuge.png");
TileCentrifuge tile;
TileCentrifuge centrifuge;
public GuiCentrifuge(final EntityPlayer player, final TileCentrifuge tileCentrifuge) {
super(new ContainerBuilder("centrifuge").player(player.inventory).inventory(8, 84).hotbar(8, 142).addInventory()
.tile(tileCentrifuge).slot(0, 80, 35).slot(1, 50, 5).outputSlot(2, 80, 5).outputSlot(3, 110, 35)
.outputSlot(4, 80, 65).outputSlot(5, 50, 35).energySlot(6, 8, 51).upgradeSlot(7, 152, 8)
.upgradeSlot(8, 152, 26).upgradeSlot(9, 152, 44).upgradeSlot(10, 152, 62).syncEnergyValue()
public GuiCentrifuge(final EntityPlayer player, final TileCentrifuge tile) {
super(player, tile, new ContainerBuilder("centrifuge").player(player.inventory).inventory().hotbar().addInventory()
.tile(tile).slot(0, 40, 34).slot(1, 40, 54).outputSlot(2, 82, 44).outputSlot(3, 101, 25)
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
.syncCrafterValue().addInventory().create());
this.xSize = 176;
this.ySize = 167;
this.centrifuge = tileCentrifuge;
this.tile = tile;
}
@Override
@ -35,38 +24,29 @@ public class GuiCentrifuge extends GuiContainer {
}
@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(GuiCentrifuge.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);
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
Layer layer = Layer.BACKGROUND;
int j = 0;
drawSlot(8, 72, layer);
j = this.centrifuge.getProgressScaled(11);
if (j > 0) {
this.drawTexturedModalRect(k + 83, l + 23 + 10 - j, 177, 15 + 10 - j, 10, j);
this.drawTexturedModalRect(k + 98, l + 38, 177, 51, j, 10);
this.drawTexturedModalRect(k + 83, l + 53, 177, 39, 10, j);
this.drawTexturedModalRect(k + 68 + 10 - j, l + 38, 177 + 10 - j, 27, j, 10);
}
drawSlot(40, 34, layer);
drawSlot(40, 54, layer);
j = this.centrifuge.getEnergyScaled(12);
drawSlot(82, 44, layer);
drawSlot(101, 25, layer);
drawSlot(120, 44, layer);
drawSlot(101, 63, layer);
if (j > 0) {
this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
}
builder.drawJEIButton(this, 150, 4, mouseX, mouseY, layer);
}
@Override
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
final String namePt1 = I18n.translateToLocal("tile.techreborn.industrialBlock.name");
final String namePt2 = I18n.translateToLocal("tile.techreborn.centrifuge.name").replace(namePt1 + " ", "");
this.fontRendererObj.drawString(namePt1, 98, 6, 4210752);
this.fontRendererObj.drawString(namePt2, 98, 14, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(this.centrifuge.getProgressScaled(100) + "%", 98, this.ySize - 96 + 2, 4210752);
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
Layer layer = Layer.FOREGROUND;
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 61, 47, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
builder.drawMultiEnergyBar(this, 9, 18, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
}

View file

@ -60,11 +60,62 @@ public class TRBuilder extends GuiBuilder {
gui.addPowerButton(x, y, buttonID, layer);
}
public void drawProgressBar(GuiBase gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, ProgressDirection direction, GuiBase.Layer layer) {
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
if (layer == GuiBase.Layer.FOREGROUND) {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
gui.drawTexturedModalRect(x, y, direction.x, direction.y, direction.width, direction.height);
if (direction.equals(ProgressDirection.RIGHT)) {
int j = (int) ((double) progress / (double) maxProgress * 16);
if (j < 0)
j = 0;
gui.drawTexturedModalRect(x, y, direction.xActive, direction.yActive, j, 10);
}
if (isInRect(x, y, direction.width, direction.height, mouseX, mouseY)) {
int percentage = percentage(maxProgress, progress);
List<String> list = new ArrayList<>();
list.add(getPercentageColour(percentage) + "" + percentage + "%");
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRendererObj);
GlStateManager.disableLighting();
GlStateManager.color(1, 1, 1, 1);
}
}
public void drawJEIButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
if (layer == GuiBase.Layer.FOREGROUND) {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
if (isInRect(x, y, 20, 12, mouseX, mouseY)) {
gui.drawTexturedModalRect(x, y, 184, 82, 20, 12);
} else {
gui.drawTexturedModalRect(x, y, 184, 70, 20, 12);
}
}
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) {
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
if (layer == GuiBase.Layer.FOREGROUND) {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
if (!suffix.equals("")) {
suffix = " " + suffix;
@ -116,4 +167,23 @@ public class TRBuilder extends GuiBuilder {
return 0;
return (int) ((CurrentValue * 100.0f) / MaxValue);
}
public enum ProgressDirection {
RIGHT(84, 151, 100, 151, 16, 10)/*, DOWN(104, 171, 114, 171, 10, 16), UP(84, 171, 94, 171, 10, 16), LEFT(84, 161, 100, 161, 16, 10)*/;
public int x;
public int y;
public int xActive;
public int yActive;
public int width;
public int height;
ProgressDirection(int x, int y, int xActive, int yActive, int width, int height) {
this.x = x;
this.y = y;
this.xActive = xActive;
this.yActive = yActive;
this.width = width;
this.height = height;
}
}
}

View file

@ -1,13 +1,16 @@
package techreborn.compat.jei;
import javax.annotation.Nonnull;
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 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;
@ -59,17 +62,10 @@ 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) {
@ -93,7 +89,8 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
@Override
public void register(
@Nonnull final
@Nonnull
final
IModRegistry registry) {
final IJeiHelpers jeiHelpers = registry.getJeiHelpers();
final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
@ -132,13 +129,13 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModFluids.BLOCK_OIL));
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModItems.MISSING_RECIPE_PLACEHOLDER));
if(IC2Duplicates.deduplicate()){
for(final IC2Duplicates duplicate : IC2Duplicates.values()){
if(duplicate.hasIC2Stack()){
if (IC2Duplicates.deduplicate()) {
for (final IC2Duplicates duplicate : IC2Duplicates.values()) {
if (duplicate.hasIC2Stack()) {
jeiHelpers.getItemBlacklist().addItemToBlacklist(duplicate.getTrStack());
}
}
if(TechRebornParts.cables != null){
if (TechRebornParts.cables != null) {
for (int i = 0; i < EnumCableType.values().length; i++) {
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(TechRebornParts.cables, 1, i));
}
@ -147,7 +144,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
jeiHelpers.getItemBlacklist().addItemToBlacklist(ItemParts.getPartByName("rubberSap"));
jeiHelpers.getItemBlacklist().addItemToBlacklist(ItemParts.getPartByName("electronicCircuit"));
jeiHelpers.getItemBlacklist().addItemToBlacklist(ItemParts.getPartByName("advancedCircuit"));
if(!Core.worldGen.config.rubberTreeConfig.shouldSpawn){
if (!Core.worldGen.config.rubberTreeConfig.shouldSpawn) {
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.RUBBER_SAPLING));
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.RUBBER_LOG));
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.RUBBER_PLANKS));
@ -166,7 +163,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper),
new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
for(final EFluidGenerator type : EFluidGenerator.values())
for (final EFluidGenerator type : EFluidGenerator.values())
registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper));
registry.addRecipeHandlers(new AlloySmelterRecipeHandler(jeiHelpers),
@ -211,10 +208,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
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);
registry.addRecipeClickArea(GuiCentrifuge.class, 98, 37, 9, 12, RecipeCategoryUids.CENTRIFUGE);
registry.addRecipeClickArea(GuiCentrifuge.class, 68, 37, 9, 12, RecipeCategoryUids.CENTRIFUGE);
registry.addRecipeClickArea(GuiCentrifuge.class, 83, 23, 12, 9, RecipeCategoryUids.CENTRIFUGE);
registry.addRecipeClickArea(GuiCentrifuge.class, 83, 53, 12, 9, RecipeCategoryUids.CENTRIFUGE);
registry.addRecipeClickArea(GuiCentrifuge.class, 150, 4, 20, 12, RecipeCategoryUids.CENTRIFUGE);
registry.addRecipeClickArea(GuiChemicalReactor.class, 73, 39, 32, 12, RecipeCategoryUids.CHEMICAL_REACTOR);
registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR);
registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER);

View file

@ -6,22 +6,22 @@ import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
import javax.annotation.Nonnull;
public class CentrifugeRecipeCategory extends BlankRecipeCategory<CentrifugeRecipeWrapper> {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_centrifuge.png");
private static final int[] INPUT_SLOTS = { 0, 1 };
private static final int[] OUTPUT_SLOTS = { 2, 3, 4, 5 };
private final IDrawable background;
private final String title;
public CentrifugeRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createDrawable(GuiCentrifuge.texture, 49, 4, 78, 78);
background = guiHelper.createDrawable(texture, 49, 4, 78, 78);
title = I18n.translateToLocal("tile.techreborn.centrifuge.name");
}

View file

@ -5,13 +5,14 @@ import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import techreborn.api.recipe.machines.CentrifugeRecipe;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.compat.jei.BaseRecipeWrapper;
import javax.annotation.Nonnull;
public class CentrifugeRecipeWrapper extends BaseRecipeWrapper<CentrifugeRecipe> {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_centrifuge.png");
private final IDrawableAnimated progressUp;
private final IDrawableAnimated progressLeft;
private final IDrawableAnimated progressDown;
@ -24,10 +25,10 @@ public class CentrifugeRecipeWrapper extends BaseRecipeWrapper<CentrifugeRecipe>
CentrifugeRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
IDrawableStatic progressUpStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 14, 12, 12);
IDrawableStatic progressLeftStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 26, 12, 12);
IDrawableStatic progressDownStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 38, 12, 12);
IDrawableStatic progressRightStatic = guiHelper.createDrawable(GuiCentrifuge.texture, 176, 50, 12, 12);
IDrawableStatic progressUpStatic = guiHelper.createDrawable(texture, 176, 14, 12, 12);
IDrawableStatic progressLeftStatic = guiHelper.createDrawable(texture, 176, 26, 12, 12);
IDrawableStatic progressDownStatic = guiHelper.createDrawable(texture, 176, 38, 12, 12);
IDrawableStatic progressRightStatic = guiHelper.createDrawable(texture, 176, 50, 12, 12);
int ticksPerCycle = baseRecipe.tickTime() / 4; // speed up the animation
// a bit

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB