mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
some cleaning, refactoring, and starting work on the coffee machine.
This commit is contained in:
parent
ab672f6474
commit
123b5b1810
17 changed files with 42 additions and 55 deletions
|
@ -1,7 +1,6 @@
|
||||||
package de.ellpeck.actuallyadditions.mod;
|
package de.ellpeck.actuallyadditions.mod;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.SoundEvent;
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.fml.RegistryObject;
|
import net.minecraftforge.fml.RegistryObject;
|
||||||
|
|
|
@ -47,9 +47,14 @@ public class BlockCoffeeMachine extends DirectionalBlock.Container {
|
||||||
return super.use(state, world, pos, player, hand, hit);
|
return super.use(state, world, pos, player, hand, hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTileEntity(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
//@Override
|
@Override
|
||||||
public TileEntity newBlockEntity(IBlockReader worldIn) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return new TileEntityCoffeeMachine();
|
return new TileEntityCoffeeMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,12 @@ public abstract class AAScreen<T extends Container> extends ContainerScreen<T> {
|
||||||
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
|
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
|
||||||
font.draw(matrices, this.title, titleLabelX, titleLabelY, 0xFFFFFF);
|
font.draw(matrices, this.title, titleLabelX, titleLabelY, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
||||||
|
titleLabelY = -10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,6 @@ public class GuiBreaker extends AAScreen<ContainerBreaker> {
|
||||||
@Override
|
@Override
|
||||||
public void init(Minecraft pMinecraft, int pWidth, int pHeight) {
|
public void init(Minecraft pMinecraft, int pWidth, int pHeight) {
|
||||||
super.init(pMinecraft, pWidth, pHeight);
|
super.init(pMinecraft, pWidth, pHeight);
|
||||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
|
||||||
titleLabelY = -10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,9 +43,6 @@ public class GuiCanolaPress extends AAScreen<ContainerCanolaPress> {
|
||||||
super.init();
|
super.init();
|
||||||
this.energy = new EnergyDisplay(this.leftPos + 42, this.topPos + 5, this.press.storage);
|
this.energy = new EnergyDisplay(this.leftPos + 42, this.topPos + 5, this.press.storage);
|
||||||
this.fluid = new FluidDisplay(this.leftPos + 116, this.topPos + 5, this.press.tank);
|
this.fluid = new FluidDisplay(this.leftPos + 116, this.topPos + 5, this.press.tank);
|
||||||
|
|
||||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
|
||||||
titleLabelY = -10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,8 +43,6 @@ public class GuiCoalGenerator extends AAScreen<ContainerCoalGenerator> {
|
||||||
public void init() {
|
public void init() {
|
||||||
super.init();
|
super.init();
|
||||||
this.energy = new EnergyDisplay(this.leftPos + 42, this.topPos + 5, this.generator.storage);
|
this.energy = new EnergyDisplay(this.leftPos + 42, this.topPos + 5, this.generator.storage);
|
||||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
|
||||||
titleLabelY = -10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,16 +14,24 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoffeeMachine;
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoffeeMachine;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.util.text.TextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
|
public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
|
||||||
|
@ -45,20 +53,22 @@ public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
|
||||||
public void init() {
|
public void init() {
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
// Button buttonOkay = new Button(this.leftPos + 60, this.topPos + 11, 58, 20, StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.ok"));
|
this.addButton(new Button(this.leftPos + 60, this.topPos + 11, 58, 20, new TranslationTextComponent("info.actuallyadditions.gui.ok"),
|
||||||
// this.addButton(buttonOkay);
|
(b) -> PacketHandlerHelper.sendButtonPacket(this.machine, 0)));
|
||||||
//
|
|
||||||
// this.energy = new EnergyDisplay(this.leftPos + 16, this.topPos + 5, this.machine.storage);
|
this.energy = new EnergyDisplay(this.leftPos + 16, this.topPos + 5, this.machine.storage);
|
||||||
// this.fluid = new FluidDisplay(this.leftPos - 30, this.topPos + 1, this.machine.tank, true, false);
|
this.fluid = new FluidDisplay(this.leftPos - 30, this.topPos + 1, this.machine.tank, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(@Nonnull MatrixStack matrices, int x, int y, float f) {
|
public void render(@Nonnull MatrixStack matrices, int x, int y, float f) {
|
||||||
super.render(matrices, x, y, f);
|
super.render(matrices, x, y, f);
|
||||||
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
|
||||||
String text2 = this.machine.coffeeCacheAmount + "/" + TileEntityCoffeeMachine.COFFEE_CACHE_MAX_AMOUNT + " " + StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.coffee");
|
TextComponent text = new TranslationTextComponent("info.actuallyadditions.gui.coffee_amount", this.machine.coffeeCacheAmount, TileEntityCoffeeMachine.COFFEE_CACHE_MAX_AMOUNT);
|
||||||
if (x >= this.leftPos + 40 && y >= this.topPos + 25 && x <= this.leftPos + 49 && y <= this.topPos + 56) {
|
if (x >= this.leftPos + 40 && y >= this.topPos + 25 && x <= this.leftPos + 49 && y <= this.topPos + 56) {
|
||||||
//this.drawHoveringText(Collections.singletonList(text2), x, y);
|
GuiUtils.drawHoveringText(matrices, Collections.singletonList(text), x, y, mc.getWindow().getWidth(), mc.getWindow().getWidth(), -1, font);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.energy.render(matrices, x, y);
|
this.energy.render(matrices, x, y);
|
||||||
|
@ -66,12 +76,7 @@ public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
|
public void renderBg(@Nonnull MatrixStack matrices, float f, int x, int y) {
|
||||||
AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.machine);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderBg(MatrixStack matrices, float f, int x, int y) {
|
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
this.getMinecraft().getTextureManager().bind(AssetUtil.GUI_INVENTORY_LOCATION);
|
this.getMinecraft().getTextureManager().bind(AssetUtil.GUI_INVENTORY_LOCATION);
|
||||||
|
@ -96,9 +101,4 @@ public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
|
||||||
this.energy.draw(matrices);
|
this.energy.draw(matrices);
|
||||||
this.fluid.draw(matrices);
|
this.fluid.draw(matrices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void actionPerformed(Button button) {
|
|
||||||
// PacketHandlerHelper.sendButtonPacket(this.machine, button.id);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,15 +46,9 @@ public class GuiDirectionalBreaker extends AAScreen<ContainerDirectionalBreaker>
|
||||||
@Override
|
@Override
|
||||||
public void render(@Nonnull MatrixStack matrices, int x, int y, float f) {
|
public void render(@Nonnull MatrixStack matrices, int x, int y, float f) {
|
||||||
super.render(matrices, x, y, f);
|
super.render(matrices, x, y, f);
|
||||||
|
|
||||||
this.energy.render(matrices, x, y);
|
this.energy.render(matrices, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
|
|
||||||
AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.breaker);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderBg(MatrixStack matrices, float f, int x, int y) {
|
public void renderBg(MatrixStack matrices, float f, int x, int y) {
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
|
@ -44,9 +44,6 @@ public class GuiFarmer extends AAScreen<ContainerFarmer> {
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
this.energy = new EnergyDisplay(this.leftPos + 33, this.topPos + 6, this.farmer.storage);
|
this.energy = new EnergyDisplay(this.leftPos + 33, this.topPos + 6, this.farmer.storage);
|
||||||
|
|
||||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
|
||||||
titleLabelY = -10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,9 +51,6 @@ public class GuiFermentingBarrel extends AAScreen<ContainerFermentingBarrel> {
|
||||||
super.init();
|
super.init();
|
||||||
this.input = new FluidDisplay(this.leftPos + 60, this.topPos + 5, this.press.tanks.inputTank);
|
this.input = new FluidDisplay(this.leftPos + 60, this.topPos + 5, this.press.tanks.inputTank);
|
||||||
this.output = new FluidDisplay(this.leftPos + 98, this.topPos + 5, this.press.tanks.outputTank);
|
this.output = new FluidDisplay(this.leftPos + 98, this.topPos + 5, this.press.tanks.outputTank);
|
||||||
|
|
||||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
|
||||||
titleLabelY = -10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -49,8 +49,6 @@ public class GuiFluidCollector extends AAScreen<ContainerFluidCollector> {
|
||||||
public void init() {
|
public void init() {
|
||||||
super.init();
|
super.init();
|
||||||
this.fluid = new FluidDisplay(this.leftPos + 67, this.topPos + 5, this.collector.tank);
|
this.fluid = new FluidDisplay(this.leftPos + 67, this.topPos + 5, this.collector.tank);
|
||||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
|
||||||
titleLabelY = -10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -65,8 +65,6 @@ public class GuiFurnaceDouble extends AAScreen<ContainerFurnaceDouble> {
|
||||||
public void init() {
|
public void init() {
|
||||||
super.init();
|
super.init();
|
||||||
this.energy = new EnergyDisplay(this.leftPos + 27, this.topPos + 5, this.tileFurnace.storage);
|
this.energy = new EnergyDisplay(this.leftPos + 27, this.topPos + 5, this.tileFurnace.storage);
|
||||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
|
||||||
titleLabelY = -10;
|
|
||||||
this.buttonAutoSplit = new Buttons.SmallerButton(this.leftPos, this.topPos, new StringTextComponent("S"), (button) -> PacketHandlerHelper.sendButtonPacket(this.tileFurnace, 0));
|
this.buttonAutoSplit = new Buttons.SmallerButton(this.leftPos, this.topPos, new StringTextComponent("S"), (button) -> PacketHandlerHelper.sendButtonPacket(this.tileFurnace, 0));
|
||||||
buttonAutoSplit.setFGColor(this.tileFurnace.isAutoSplit ? TextFormatting.DARK_GREEN.getColor() : TextFormatting.RED.getColor());
|
buttonAutoSplit.setFGColor(this.tileFurnace.isAutoSplit ? TextFormatting.DARK_GREEN.getColor() : TextFormatting.RED.getColor());
|
||||||
this.addButton(this.buttonAutoSplit);
|
this.addButton(this.buttonAutoSplit);
|
||||||
|
|
|
@ -47,8 +47,6 @@ public class GuiOilGenerator extends AAScreen<ContainerOilGenerator> {
|
||||||
super.init();
|
super.init();
|
||||||
this.energy = new EnergyDisplay(this.leftPos + 42, this.topPos + 5, this.generator.storage);
|
this.energy = new EnergyDisplay(this.leftPos + 42, this.topPos + 5, this.generator.storage);
|
||||||
this.fluid = new FluidDisplay(this.leftPos + 116, this.topPos + 5, this.generator.tank);
|
this.fluid = new FluidDisplay(this.leftPos + 116, this.topPos + 5, this.generator.tank);
|
||||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
|
||||||
titleLabelY = -10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -60,11 +60,6 @@ public class GuiRangedCollector extends AAScreen<ContainerRangedCollector> {
|
||||||
this.filter.tick();
|
this.filter.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
|
|
||||||
AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.collector);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderBg(MatrixStack matrices, float f, int x, int y) {
|
public void renderBg(MatrixStack matrices, float f, int x, int y) {
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
|
@ -33,10 +33,12 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
import net.minecraftforge.fluids.FluidAttributes;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||||
|
@ -58,7 +60,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 250, 0);
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 250, 0);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
||||||
|
|
||||||
public final FluidTank tank = new FluidTank(4 * Util.BUCKET) {
|
public final FluidTank tank = new FluidTank(4 * FluidAttributes.BUCKET_VOLUME) {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||||
|
@ -242,7 +244,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getDisplayName() {
|
public ITextComponent getDisplayName() {
|
||||||
return StringTextComponent.EMPTY;
|
return new TranslationTextComponent("container.actuallyadditions.coffeeMachine");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.ForgeI18n;
|
import net.minecraftforge.fml.ForgeI18n;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public final class StringUtil {
|
public final class StringUtil {
|
||||||
|
|
||||||
public static final int DECIMAL_COLOR_WHITE = 16777215;
|
public static final int DECIMAL_COLOR_WHITE = 16777215;
|
||||||
|
@ -32,6 +33,7 @@ public final class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Localizes a given String
|
* Localizes a given String
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static String localize(String text) {
|
public static String localize(String text) {
|
||||||
return I18n.get(text);
|
return I18n.get(text);
|
||||||
|
|
|
@ -544,6 +544,7 @@
|
||||||
"info.actuallyadditions.gui.inbound": "INBOUND",
|
"info.actuallyadditions.gui.inbound": "INBOUND",
|
||||||
"info.actuallyadditions.gui.outbound": "OUTBOUND",
|
"info.actuallyadditions.gui.outbound": "OUTBOUND",
|
||||||
"info.actuallyadditions.gui.coffee": "Coffee",
|
"info.actuallyadditions.gui.coffee": "Coffee",
|
||||||
|
"info.actuallyadditions.gui.coffee_amount": "%d/%d Coffee",
|
||||||
"info.actuallyadditions.gui.ok": "Ok",
|
"info.actuallyadditions.gui.ok": "Ok",
|
||||||
"info.actuallyadditions.gui.the": "the",
|
"info.actuallyadditions.gui.the": "the",
|
||||||
"info.actuallyadditions.gui.smart": "Smart Whitelist",
|
"info.actuallyadditions.gui.smart": "Smart Whitelist",
|
||||||
|
|
Loading…
Reference in a new issue