some cleaning, refactoring, and starting work on the coffee machine.

This commit is contained in:
Flanks255 2022-06-05 15:30:25 -05:00
parent ab672f6474
commit 123b5b1810
17 changed files with 42 additions and 55 deletions

View file

@ -1,7 +1,6 @@
package de.ellpeck.actuallyadditions.mod;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;

View file

@ -47,9 +47,14 @@ public class BlockCoffeeMachine extends DirectionalBlock.Container {
return super.use(state, world, pos, player, hand, hit);
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
//@Override
public TileEntity newBlockEntity(IBlockReader worldIn) {
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEntityCoffeeMachine();
}

View file

@ -36,4 +36,12 @@ public abstract class AAScreen<T extends Container> extends ContainerScreen<T> {
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
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;
}
}

View file

@ -40,8 +40,6 @@ public class GuiBreaker extends AAScreen<ContainerBreaker> {
@Override
public void init(Minecraft pMinecraft, int pWidth, int pHeight) {
super.init(pMinecraft, pWidth, pHeight);
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
}
@Override

View file

@ -43,9 +43,6 @@ public class GuiCanolaPress extends AAScreen<ContainerCanolaPress> {
super.init();
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);
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
}
@Override

View file

@ -43,8 +43,6 @@ public class GuiCoalGenerator extends AAScreen<ContainerCoalGenerator> {
public void init() {
super.init();
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

View file

@ -14,16 +14,24 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
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.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation;
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.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collections;
@OnlyIn(Dist.CLIENT)
public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
@ -45,20 +53,22 @@ public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
public void init() {
super.init();
// Button buttonOkay = new Button(this.leftPos + 60, this.topPos + 11, 58, 20, StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.ok"));
// this.addButton(buttonOkay);
//
// 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.addButton(new Button(this.leftPos + 60, this.topPos + 11, 58, 20, new TranslationTextComponent("info.actuallyadditions.gui.ok"),
(b) -> PacketHandlerHelper.sendButtonPacket(this.machine, 0)));
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);
}
@Override
public void render(@Nonnull MatrixStack matrices, int x, int y, float 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) {
//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);
@ -66,12 +76,7 @@ public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
}
@Override
public void renderLabels(@Nonnull MatrixStack matrices, 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) {
public void renderBg(@Nonnull MatrixStack matrices, float f, int x, int y) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.getMinecraft().getTextureManager().bind(AssetUtil.GUI_INVENTORY_LOCATION);
@ -96,9 +101,4 @@ public class GuiCoffeeMachine extends AAScreen<ContainerCoffeeMachine> {
this.energy.draw(matrices);
this.fluid.draw(matrices);
}
// @Override
// public void actionPerformed(Button button) {
// PacketHandlerHelper.sendButtonPacket(this.machine, button.id);
// }
}

View file

@ -46,15 +46,9 @@ public class GuiDirectionalBreaker extends AAScreen<ContainerDirectionalBreaker>
@Override
public void render(@Nonnull MatrixStack matrices, int x, int y, float f) {
super.render(matrices, x, y, f);
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
public void renderBg(MatrixStack matrices, float f, int x, int y) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -44,9 +44,6 @@ public class GuiFarmer extends AAScreen<ContainerFarmer> {
super.init();
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

View file

@ -51,9 +51,6 @@ public class GuiFermentingBarrel extends AAScreen<ContainerFermentingBarrel> {
super.init();
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);
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
}
@Override

View file

@ -49,8 +49,6 @@ public class GuiFluidCollector extends AAScreen<ContainerFluidCollector> {
public void init() {
super.init();
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

View file

@ -65,8 +65,6 @@ public class GuiFurnaceDouble extends AAScreen<ContainerFurnaceDouble> {
public void init() {
super.init();
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));
buttonAutoSplit.setFGColor(this.tileFurnace.isAutoSplit ? TextFormatting.DARK_GREEN.getColor() : TextFormatting.RED.getColor());
this.addButton(this.buttonAutoSplit);

View file

@ -47,8 +47,6 @@ public class GuiOilGenerator extends AAScreen<ContainerOilGenerator> {
super.init();
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);
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
}
@Override

View file

@ -60,11 +60,6 @@ public class GuiRangedCollector extends AAScreen<ContainerRangedCollector> {
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
public void renderBg(MatrixStack matrices, float f, int x, int y) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -33,10 +33,12 @@ import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
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 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
@Override
public FluidStack drain(int maxDrain, FluidAction action) {
@ -242,7 +244,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
@Override
public ITextComponent getDisplayName() {
return StringTextComponent.EMPTY;
return new TranslationTextComponent("container.actuallyadditions.coffeeMachine");
}
@Nullable

View file

@ -20,6 +20,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.ForgeI18n;
@Deprecated
public final class StringUtil {
public static final int DECIMAL_COLOR_WHITE = 16777215;
@ -32,6 +33,7 @@ public final class StringUtil {
/**
* Localizes a given String
*/
@Deprecated
@OnlyIn(Dist.CLIENT)
public static String localize(String text) {
return I18n.get(text);

View file

@ -544,6 +544,7 @@
"info.actuallyadditions.gui.inbound": "INBOUND",
"info.actuallyadditions.gui.outbound": "OUTBOUND",
"info.actuallyadditions.gui.coffee": "Coffee",
"info.actuallyadditions.gui.coffee_amount": "%d/%d Coffee",
"info.actuallyadditions.gui.ok": "Ok",
"info.actuallyadditions.gui.the": "the",
"info.actuallyadditions.gui.smart": "Smart Whitelist",