Skip to content

Commit 9c7e284

Browse files
committed
Update dependencies, fix UI issues
1 parent 41c2f1d commit 9c7e284

File tree

10 files changed

+105
-52
lines changed

10 files changed

+105
-52
lines changed

src/main/java/rearth/oritech/block/base/entity/ExpandableEnergyStorageBlockEntity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ public float getProgress() {
255255
return 0;
256256
}
257257

258+
259+
@Override
260+
public BlockPos getMachinePos() {
261+
return getPos();
262+
}
263+
264+
@Override
265+
public World getMachineWorld() {
266+
return getWorld();
267+
}
268+
258269
@Override
259270
public InventoryInputMode getInventoryInputMode() {
260271
return InventoryInputMode.FILL_LEFT_TO_RIGHT;

src/main/java/rearth/oritech/block/base/entity/ItemEnergyFrameInteractionBlockEntity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ public EnergyStorage getStorage(Direction direction) {
103103
return energyStorage;
104104
}
105105

106+
107+
@Override
108+
public BlockPos getMachinePos() {
109+
return getPos();
110+
}
111+
112+
@Override
113+
public World getMachineWorld() {
114+
return getWorld();
115+
}
116+
106117
@Override
107118
public void writeScreenOpeningData(ServerPlayerEntity player, PacketByteBuf buf) {
108119
buf.writeBlockPos(this.getPos());

src/main/java/rearth/oritech/block/base/entity/UpgradableMachineBlockEntity.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
import net.minecraft.server.network.ServerPlayerEntity;
1212
import net.minecraft.util.math.BlockPos;
1313
import net.minecraft.util.math.Direction;
14+
import net.minecraft.world.World;
1415
import org.jetbrains.annotations.Nullable;
1516
import rearth.oritech.client.ui.UpgradableMachineScreenHandler;
16-
import rearth.oritech.util.*;
17+
import rearth.oritech.util.DynamicEnergyStorage;
18+
import rearth.oritech.util.MachineAddonController;
19+
import rearth.oritech.util.ScreenProvider;
1720

18-
import java.util.*;
21+
import java.util.ArrayList;
22+
import java.util.List;
1923

2024
public abstract class UpgradableMachineBlockEntity extends MachineBlockEntity implements MachineAddonController {
2125

@@ -66,6 +70,17 @@ public BaseAddonData getBaseAddonData() {
6670
return addonData;
6771
}
6872

73+
74+
@Override
75+
public BlockPos getMachinePos() {
76+
return getPos();
77+
}
78+
79+
@Override
80+
public World getMachineWorld() {
81+
return getWorld();
82+
}
83+
6984
@Override
7085
public void setBaseAddonData(BaseAddonData data) {
7186
this.addonData = data;

src/main/java/rearth/oritech/block/entity/machines/generators/BigSolarPanelEntity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ private AnimationController<BigSolarPanelEntity> getAnimationController() {
191191
});
192192
}
193193

194+
@Override
195+
public BlockPos getMachinePos() {
196+
return getPos();
197+
}
198+
199+
@Override
200+
public World getMachineWorld() {
201+
return getWorld();
202+
}
203+
194204
public long getAdjustedTimeOfDay() {
195205
return (world.getTimeOfDay() + getTimeOffset()) % 24000;
196206
}

src/main/java/rearth/oritech/block/entity/machines/interaction/LaserArmBlockEntity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,17 @@ public long getLastFiredAt() {
454454
return lastFiredAt;
455455
}
456456

457+
458+
@Override
459+
public BlockPos getMachinePos() {
460+
return getPos();
461+
}
462+
463+
@Override
464+
public World getMachineWorld() {
465+
return getWorld();
466+
}
467+
457468
public void setLastFiredAt(long lastFiredAt) {
458469
this.lastFiredAt = lastFiredAt;
459470
}

src/main/java/rearth/oritech/client/ui/BasicMachineScreen.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public class BasicMachineScreen<S extends BasicMachineScreenHandler> extends Bas
3434
public static final Identifier GUI_COMPONENTS = new Identifier(Oritech.MOD_ID, "textures/gui/modular/machine_gui_components.png");
3535
public FlowLayout root;
3636
private TextureComponent progress_indicator;
37-
private TextureComponent energy_indicator;
38-
private Component energy_indicator_background;
37+
private TextureComponent energyIndicator;
3938
private ButtonComponent cycleInputButton;
4039
private BoxComponent fluidFillStatusOverlay;
4140

@@ -72,10 +71,10 @@ protected void build(FlowLayout rootComponent) {
7271
.positioning(Positioning.absolute(176 + 117, 30)))
7372
.positioning(Positioning.relative(50, 50))
7473
.zIndex(-1)
75-
).child(
76-
buildOverlay().positioning(Positioning.relative(50, 50))
7774
).child(
7875
Components.texture(BACKGROUND, 0, 0, 176, 166, 176, 166)
76+
).child(
77+
buildOverlay().positioning(Positioning.relative(50, 50))
7978
);
8079
}
8180

@@ -114,8 +113,8 @@ private void updateEnergyBar() {
114113
var fillAmount = (float) amount / capacity;
115114
var tooltipText = getEnergyTooltip(amount, capacity);
116115

117-
energy_indicator_background.tooltip(tooltipText);
118-
energy_indicator.visibleArea(PositionedRectangle.of(0, 96 - ((int) (96 * (fillAmount))), 24, (int) (96 * fillAmount)));
116+
energyIndicator.tooltip(tooltipText);
117+
energyIndicator.visibleArea(PositionedRectangle.of(0, 96 - ((int) (96 * (fillAmount))), 24, (int) (96 * fillAmount)));
119118
}
120119

121120
public Text getEnergyTooltip(long amount, long max) {
@@ -303,30 +302,25 @@ private void addEnergyBar(FlowLayout panel) {
303302

304303
var config = handler.screenData.getEnergyConfiguration();
305304
var insetSize = 1;
305+
var tooltipText = Text.literal("10/50 RF");
306306

307307
var frame = Containers.horizontalFlow(Sizing.fixed(config.width() + insetSize * 2), Sizing.fixed(config.height() + insetSize * 2));
308308
frame.surface(Surface.PANEL_INSET);
309309
frame.padding(Insets.of(insetSize));
310310
frame.positioning(Positioning.absolute(config.x() - insetSize, config.y() - insetSize));
311311
panel.child(frame);
312312

313-
var fillAmount = 1f; // those will be overridden on tick
314-
var tooltipText = Text.literal("10/50 RF");
315-
316-
energy_indicator_background = Components.texture(GUI_COMPONENTS, 24, 0, 24, 96, 98, 96);
317-
energy_indicator_background.sizing(Sizing.fixed(config.width()), Sizing.fixed(config.height()));
318-
energy_indicator_background.positioning(Positioning.absolute(config.x(), config.y()));
319-
energy_indicator_background.tooltip(tooltipText);
313+
var indicator_background = Components.texture(GUI_COMPONENTS, 24, 0, 24, 96, 98, 96);
314+
indicator_background.sizing(Sizing.fixed(config.width()), Sizing.fixed(config.height()));
320315

321-
var offset = (1 - fillAmount) * config.height();
316+
energyIndicator = Components.texture(GUI_COMPONENTS, 0, 0, 24, (96), 98, 96);
317+
energyIndicator.sizing(Sizing.fixed(config.width()), Sizing.fixed(config.height()));
318+
energyIndicator.positioning(Positioning.absolute(0, 0));
319+
energyIndicator.tooltip(tooltipText);
322320

323-
energy_indicator = Components.texture(GUI_COMPONENTS, 0, 0, 24, (int) (96 * fillAmount), 98, 96);
324-
energy_indicator.sizing(Sizing.fixed(config.width()), Sizing.fixed((int) (config.height() * fillAmount)));
325-
energy_indicator.positioning(Positioning.absolute(config.x(), (int) (config.y() + offset)));
326-
327-
panel
328-
.child(energy_indicator_background)
329-
.child(energy_indicator);
321+
frame
322+
.child(indicator_background)
323+
.child(energyIndicator);
330324
}
331325

332326
public static class ColoredSpriteComponent extends SpriteComponent {

src/main/java/rearth/oritech/client/ui/InventoryProxyScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected void build(FlowLayout rootComponent) {
5757
button.active = i != handler.selectedSlot;
5858
}
5959

60-
addTitle(overlay);
60+
// addTitle(overlay);
6161
}
6262

6363
private void addTitle(FlowLayout overlay) {

src/main/java/rearth/oritech/util/MachineAddonController.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public interface MachineAddonController {
2222

2323
List<BlockPos> getConnectedAddons();
2424
List<BlockPos> getOpenSlots();
25-
BlockPos getPos();
26-
World getWorld();
25+
BlockPos getMachinePos();
26+
World getMachineWorld();
2727
Direction getFacingForAddon();
2828
DynamicEnergyStorage getStorageForAddon();
2929
SimpleInventory getInventoryForAddon();
@@ -57,9 +57,9 @@ default void initAddons() {
5757
default void resetAddons() {
5858

5959
for (var addon : getConnectedAddons()) {
60-
var state = Objects.requireNonNull(getWorld()).getBlockState(addon);
60+
var state = Objects.requireNonNull(getMachineWorld()).getBlockState(addon);
6161
if (state.getBlock() instanceof MachineAddonBlock) {
62-
getWorld().setBlockState(addon, state.with(MachineAddonBlock.ADDON_USED, false));
62+
getMachineWorld().setBlockState(addon, state.with(MachineAddonBlock.ADDON_USED, false));
6363
}
6464
}
6565

@@ -77,8 +77,8 @@ default List<AddonBlock> getAllAddons() {
7777
// go through all slots
7878
// check if slot is occupied by MachineAddonBlock, check if block is not used
7979
// if valid and extender: add all neighboring positions to search set
80-
var world = getWorld();
81-
var pos = getPos();
80+
var world = getMachineWorld();
81+
var pos = getMachinePos();
8282
assert world != null;
8383

8484
var openSlots = getOpenSlots();
@@ -178,8 +178,8 @@ default void getAdditionalStatFromAddon(AddonBlock addonBlock) {
178178
// update state of the found addons
179179
default void writeAddons(List<AddonBlock> addons) {
180180

181-
var world = getWorld();
182-
var pos = getPos();
181+
var world = getMachineWorld();
182+
var pos = getMachinePos();
183183
assert world != null;
184184

185185
for (var addon : addons) {
@@ -237,7 +237,7 @@ default void loadAddonNbtData(NbtCompound nbt) {
237237

238238
default AddonUiData getUiData() {
239239
var data = getBaseAddonData();
240-
return new AddonUiData(getConnectedAddons(), getOpenSlots(), data.efficiency, data.speed, getPos());
240+
return new AddonUiData(getConnectedAddons(), getOpenSlots(), data.efficiency, data.speed, getMachinePos());
241241
}
242242

243243
private static Set<BlockPos> getNeighbors(BlockPos pos) {

src/main/java/rearth/oritech/util/MultiblockMachineController.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public interface MultiblockMachineController {
3333

3434
List<Vec3i> getCorePositions();
3535
Direction getFacingForMultiblock();
36-
BlockPos getPos();
37-
World getWorld();
36+
BlockPos getMachinePos();
37+
World getMachineWorld();
3838
ArrayList<BlockPos> getConnectedCores();
3939
void setCoreQuality(float quality);
4040
float getCoreQuality();
@@ -80,7 +80,7 @@ default Boolean tryPlaceNextCore(PlayerEntity player) {
8080
if (heldItem.equals(BlockContent.MACHINE_CORE_GOOD.asItem())) {
8181
var nextPosition = this.getNextMissingCore();
8282
if (nextPosition != null && heldItem instanceof BlockItem blockItem) {
83-
this.getWorld().setBlockState(nextPosition, blockItem.getBlock().getDefaultState());
83+
this.getMachineWorld().setBlockState(nextPosition, blockItem.getBlock().getDefaultState());
8484
if (!player.isCreative()) {
8585
heldStack.decrement(1);
8686
if (heldStack.getCount() == 0)
@@ -94,14 +94,14 @@ default Boolean tryPlaceNextCore(PlayerEntity player) {
9494

9595
default BlockPos getNextMissingCore() {
9696

97-
var world = getWorld();
98-
var pos = getPos();
97+
var world = getMachineWorld();
98+
var pos = getMachinePos();
9999

100100
var ownFacing = getFacingForMultiblock();
101-
var targetPositions = getCorePositions();
101+
var targetMachinePositions = getCorePositions();
102102

103-
for (var targetPosition : targetPositions) {
104-
var rotatedPos = Geometry.rotatePosition(targetPosition, ownFacing);
103+
for (var targetMachinePosition : targetMachinePositions) {
104+
var rotatedPos = Geometry.rotatePosition(targetMachinePosition, ownFacing);
105105
var checkPos = pos.add(rotatedPos);
106106
var checkState = Objects.requireNonNull(world).getBlockState(checkPos);
107107

@@ -124,19 +124,19 @@ default boolean initMultiblock(BlockState state) {
124124
// update all multiblocks state to USED=true, write controller position to block state
125125

126126
if (state.get(MultiblockMachine.ASSEMBLED)) return true;
127-
var world = getWorld();
128-
var pos = getPos();
127+
var world = getMachineWorld();
128+
var pos = getMachinePos();
129129
var coreBlocksConnected = getConnectedCores();
130130

131131
var ownFacing = getFacingForMultiblock();
132132

133-
var targetPositions = getCorePositions();
134-
var coreBlocks = new ArrayList<MultiBlockElement>(targetPositions.size());
133+
var targetMachinePositions = getCorePositions();
134+
var coreBlocks = new ArrayList<MultiBlockElement>(targetMachinePositions.size());
135135

136136
var sumCoreQuality = 0f;
137137

138-
for (var targetPosition : targetPositions) {
139-
var rotatedPos = Geometry.rotatePosition(targetPosition, ownFacing);
138+
for (var targetMachinePosition : targetMachinePositions) {
139+
var rotatedPos = Geometry.rotatePosition(targetMachinePosition, ownFacing);
140140
var checkPos = pos.add(rotatedPos);
141141
var checkState = Objects.requireNonNull(world).getBlockState(checkPos);
142142

@@ -149,7 +149,7 @@ default boolean initMultiblock(BlockState state) {
149149
}
150150
}
151151

152-
if (targetPositions.size() == coreBlocks.size()) {
152+
if (targetMachinePositions.size() == coreBlocks.size()) {
153153
// valid
154154
for (var core : coreBlocks) {
155155
var newState = core.state.with(MachineCoreBlock.USED, true);
@@ -172,8 +172,8 @@ default boolean initMultiblock(BlockState state) {
172172

173173
default void onCoreBroken(BlockPos corePos) {
174174

175-
var world = getWorld();
176-
var pos = getPos();
175+
var world = getMachineWorld();
176+
var pos = getMachinePos();
177177
var coreBlocksConnected = getConnectedCores();
178178

179179
Objects.requireNonNull(world).setBlockState(pos, world.getBlockState(pos).with(MultiblockMachine.ASSEMBLED, false));
@@ -192,7 +192,7 @@ default void onCoreBroken(BlockPos corePos) {
192192

193193
default void onControllerBroken() {
194194

195-
var world = getWorld();
195+
var world = getMachineWorld();
196196
var coreBlocksConnected = getConnectedCores();
197197

198198
for (var core : coreBlocksConnected) {

src/main/resources/assets/oritech/lang/en_us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
"block.oritech.machine_inventory_proxy_addon": "Inventory Proxy Addon",
2525
"block.oritech.machine_extender": "Machine Extender",
2626
"block.oritech.machine_core_basic": "Basic Machine Core",
27-
"block.oritech.machine_core_good": "Good Machine Core"
27+
"block.oritech.machine_core_good": "Good Machine Core",
28+
"block.oritech.fuel_generator_block": "Combustion Generator"
2829
}

0 commit comments

Comments
 (0)