Skip to content

Commit

Permalink
feat: widget locking displays
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jul 21, 2024
1 parent 4e7eb53 commit e467afa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
Expand All @@ -48,8 +49,8 @@
import static gregtech.api.capability.GregtechDataCodes.FISSION_LOCK_UPDATE;

public class MetaTileEntityCoolantImportHatch extends MetaTileEntityMultiblockNotifiablePart
implements IMultiblockAbilityPart<ICoolantHandler>, ICoolantHandler,
IControllable, IFissionReactorHatch {
implements IMultiblockAbilityPart<ICoolantHandler>, ICoolantHandler,
IControllable, IFissionReactorHatch {

private boolean workingEnabled;
private LockableFluidTank fluidTank;
Expand Down Expand Up @@ -87,18 +88,24 @@ protected ModularUI createUI(EntityPlayer entityPlayer) {

public ModularUI.Builder createTankUI(IFluidTank fluidTank, String title, EntityPlayer entityPlayer) {
ModularUI.Builder builder = ModularUI.defaultBuilder();
builder.image(7, 16, 81, 55, GuiTextures.DISPLAY);
TankWidget tankWidget = new TankWidget(fluidTank, 69, 52, 18, 18)
builder.image(7, 16, 131, 55, GuiTextures.DISPLAY);
TankWidget tankWidget = new TankWidget(fluidTank, 119, 52, 18, 18)
.setHideTooltip(true).setAlwaysShowFull(true);
builder.widget(tankWidget);
builder.label(11, 20, "gregtech.gui.fluid_amount", 0xFFFFFF);
builder.dynamicLabel(11, 30, tankWidget::getFormattedFluidAmount, 0xFFFFFF);
builder.dynamicLabel(11, 40, tankWidget::getFluidLocalizedName, 0xFFFFFF);
builder.dynamicLabel(11, 40, () -> {
if (isLocked()) {
return tankWidget.getFluidLocalizedName() + " " + I18n.format("gregtech.gui.locked");
} else {
return tankWidget.getFluidLocalizedName();
}
}, 0xFFFFFF);
return builder.label(6, 6, title)
.widget(new FluidContainerSlotWidget(importItems, 0, 90, 16, false)
.widget(new FluidContainerSlotWidget(importItems, 0, 140, 16, false)
.setBackgroundTexture(GuiTextures.SLOT, GuiTextures.IN_SLOT_OVERLAY))
.widget(new ImageWidget(91, 36, 14, 15, GuiTextures.TANK_ICON))
.widget(new SlotWidget(exportItems, 0, 90, 53, true, false)
.widget(new ImageWidget(141, 36, 14, 15, GuiTextures.TANK_ICON))
.widget(new SlotWidget(exportItems, 0, 140, 53, true, false)
.setBackgroundTexture(GuiTextures.SLOT, GuiTextures.OUT_SLOT_OVERLAY))
.bindPlayerInventory(entityPlayer.inventory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import gregtech.api.capability.IControllable;
import gregtech.api.capability.IFuelRodHandler;
import gregtech.api.gui.GuiTextures;
import gregtech.api.gui.IRenderContext;
import gregtech.api.gui.ModularUI;
import gregtech.api.gui.widgets.BlockableSlotWidget;
import gregtech.api.gui.widgets.SlotWidget;
import gregtech.api.items.itemhandlers.LockableItemStackHandler;
import gregtech.api.metatileentity.MetaTileEntity;
Expand All @@ -16,9 +18,11 @@
import gregtech.api.nuclear.fission.components.FuelRod;
import gregtech.api.unification.material.properties.FissionFuelProperty;
import gregtech.client.renderer.texture.Textures;
import gregtech.client.utils.RenderUtil;
import gregtech.common.blocks.BlockFissionCasing;
import gregtech.common.blocks.MetaBlocks;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand All @@ -42,8 +46,7 @@
import static gregtech.api.capability.GregtechDataCodes.FISSION_LOCK_UPDATE;

public class MetaTileEntityFuelRodImportBus extends MetaTileEntityMultiblockNotifiablePart
implements IMultiblockAbilityPart<IFuelRodHandler>, IFuelRodHandler,
IControllable, IFissionReactorHatch {
implements IMultiblockAbilityPart<IFuelRodHandler>, IFuelRodHandler, IControllable, IFissionReactorHatch {

private boolean workingEnabled;
private IFissionFuelStats fuelProperty;
Expand Down Expand Up @@ -81,11 +84,10 @@ protected IItemHandlerModifiable createImportItemHandler() {
}

private ModularUI.Builder createUITemplate(EntityPlayer player) {
ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, 176, 143)
.label(10, 5, getMetaFullName());
ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, 176, 143).label(10, 5, getMetaFullName());

builder.widget(new SlotWidget(importItems, 0, 79, 18, true, true)
.setBackgroundTexture(GuiTextures.SLOT));
builder.widget(new BlockableSlotWidget(importItems, 0, 79, 18, true, true)
.setIsBlocked(this::isLocked).setBackgroundTexture(GuiTextures.SLOT));

return builder.bindPlayerInventory(player.inventory, GuiTextures.SLOT, 7, 60);
}
Expand Down Expand Up @@ -140,8 +142,7 @@ public void readFromNBT(NBTTagCompound data) {
@Override
public NBTTagCompound writeToNBT(NBTTagCompound data) {
data.setBoolean("locked", getLockedImport().isLocked());
if (partialFuel != null)
data.setInteger("partialFuel", this.partialFuel.hashCode());
if (partialFuel != null) data.setInteger("partialFuel", this.partialFuel.hashCode());
return super.writeToNBT(data);
}

Expand Down Expand Up @@ -237,8 +238,7 @@ public MetaTileEntityFuelRodExportBus getExportHatch(int depth) {
return null;
}
}
if (getWorld()
.getTileEntity(pos.move(this.frontFacing.getOpposite())) instanceof IGregTechTileEntity gtTe) {
if (getWorld().getTileEntity(pos.move(this.frontFacing.getOpposite())) instanceof IGregTechTileEntity gtTe) {
MetaTileEntity mte = gtTe.getMetaTileEntity();
if (mte instanceof MetaTileEntityFuelRodExportBus) {
return (MetaTileEntityFuelRodExportBus) mte;
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ metaitem.nuclear.tooltip.duration=Total heat energy: %d MJ
metaitem.nuclear.tooltip.temperature=Melting point: %d K
metaitem.nuclear.tooltip.cross_section_fast=Fast neutron prob: %d barn
metaitem.nuclear.tooltip.cross_section_slow=Slow neutron prob: %d barn
metaitem.nuclear.tooltip.neutron_time.0=Avg. neutron: %ds (§aSafe§r)
metaitem.nuclear.tooltip.neutron_time.1=Avg. neutron: %ds (§cSafer§r)
metaitem.nuclear.tooltip.neutron_time.2=Avg. neutron: %ds (§4Unsafe§r)
metaitem.nuclear.tooltip.neutron_time.3=Avg. neutron: %ds (§0Very unsafe§r)
metaitem.nuclear.tooltip.neutron_time.0=Avg. neutron: %ds (§1Safe§r)
metaitem.nuclear.tooltip.neutron_time.1=Avg. neutron: %ds (§2Safer§r)
metaitem.nuclear.tooltip.neutron_time.2=Avg. neutron: %ds (§cUnsafe§r)
metaitem.nuclear.tooltip.neutron_time.3=Avg. neutron: %ds (§4Very unsafe§r)

metaitem.int_circuit.configuration=§aConfigured Value: §f%d§7
metaitem.credit.copper.name=Copper Credit
Expand Down Expand Up @@ -5615,6 +5615,8 @@ gregtech.gui.fission.lock.enabled=Unlock Fuel and Coolant types and stop the Rea
gregtech.gui.fission.helper.disabled=When I'm smiling, I regulate your control rods for you! - Smiley, the Control Rod Specialist
gregtech.gui.fission.helper.enabled=When I'm smiling, I regulate your control rods for you! - Smiley, the Control Rod Specialist

gregtech.gui.locked=(Locked)

ore.spawnlocation.name=Ore Spawn Information
gregtech.jei.ore.surface_rock_1=Surface Rocks with this material denote vein spawn locations.
gregtech.jei.ore.surface_rock_2=They can be broken for 3 Tiny Piles of the dust, with Fortune giving a bonus.
Expand Down

0 comments on commit e467afa

Please sign in to comment.