Skip to content

Commit 8a8b358

Browse files
committed
Rename components variable and make them public instead of using getters
1 parent 62755b4 commit 8a8b358

File tree

6 files changed

+16
-24
lines changed

6 files changed

+16
-24
lines changed

src/main/java/aztech/modern_industrialization/machines/MachineBlockEntity.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
@SuppressWarnings("rawtypes")
7272
public abstract class MachineBlockEntity extends FastBlockEntity
7373
implements MenuProvider, WrenchableBlockEntity {
74-
protected final ComponentStorage.GuiServer guiComponents = new ComponentStorage.GuiServer();
75-
protected final ComponentStorage.Server icomponents = new ComponentStorage.Server();
74+
public final ComponentStorage.GuiServer guiComponents = new ComponentStorage.GuiServer();
75+
public final ComponentStorage.Server components = new ComponentStorage.Server();
7676
public final MachineGuiParameters guiParams;
7777
/**
7878
* Server-side only: true if the next call to sync() will trigger a remesh.
@@ -101,22 +101,14 @@ protected final void registerGuiComponent(GuiComponent.Server... components) {
101101
}
102102

103103
protected final void registerComponents(IComponent... components) {
104-
icomponents.register(components);
104+
this.components.register(components);
105105
}
106106

107107
/**
108108
* @return The inventory that will be synced with the client.
109109
*/
110110
public abstract MIInventory getInventory();
111111

112-
public final ComponentStorage.GuiServer getGuiComponents() {
113-
return guiComponents;
114-
}
115-
116-
public final ComponentStorage.Server getComponents() {
117-
return icomponents;
118-
}
119-
120112
@Override
121113
public final Component getDisplayName() {
122114
return Component.translatable(Util.makeDescriptionId("block", guiParams.blockId));
@@ -201,15 +193,15 @@ public CompoundTag getUpdateTag(HolderLookup.Provider registries) {
201193
CompoundTag tag = new CompoundTag();
202194
tag.putBoolean("remesh", syncCausesRemesh);
203195
syncCausesRemesh = false;
204-
for (IComponent component : icomponents) {
196+
for (IComponent component : components) {
205197
component.writeClientNbt(tag, registries);
206198
}
207199
return tag;
208200
}
209201

210202
@Override
211203
public final void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
212-
for (IComponent component : icomponents) {
204+
for (IComponent component : components) {
213205
component.writeNbt(tag, registries);
214206
}
215207
}
@@ -221,12 +213,12 @@ public final void loadAdditional(CompoundTag tag, HolderLookup.Provider registri
221213

222214
public final void load(CompoundTag tag, HolderLookup.Provider registries, boolean isUpgradingMachine) {
223215
if (!tag.contains("remesh")) {
224-
for (IComponent component : icomponents) {
216+
for (IComponent component : components) {
225217
component.readNbt(tag, registries, isUpgradingMachine);
226218
}
227219
} else {
228220
boolean forceChunkRemesh = tag.getBoolean("remesh");
229-
for (IComponent component : icomponents) {
221+
for (IComponent component : components) {
230222
component.readClientNbt(tag, registries);
231223
}
232224
if (forceChunkRemesh) {
@@ -263,7 +255,7 @@ public static void registerFluidApi(BlockEntityType<?> bet) {
263255

264256
public List<ItemStack> dropExtra() {
265257
List<ItemStack> drops = new ArrayList<>();
266-
icomponents.forType(DropableComponent.class, u -> drops.add(u.getDrop()));
258+
components.forType(DropableComponent.class, u -> drops.add(u.getDrop()));
267259
return drops;
268260
}
269261

src/main/java/aztech/modern_industrialization/machines/blockentities/multiblocks/AbstractElectricCraftingMultiblockBlockEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ protected ItemInteractionResult useItemOn(Player player, InteractionHand hand, D
7676
result = LubricantHelper.onUse(this.crafter, player, hand);
7777
}
7878
if (!result.consumesAction()) {
79-
result = icomponents.mapOrDefault(UpgradeComponent.class, upgrade -> upgrade.onUse(this, player, hand), result);
79+
result = components.mapOrDefault(UpgradeComponent.class, upgrade -> upgrade.onUse(this, player, hand), result);
8080
}
8181
if (!result.consumesAction()) {
8282
result = redstoneControl.onUse(this, player, hand);
8383
}
8484
if (!result.consumesAction()) {
85-
result = icomponents.mapOrDefault(OverdriveComponent.class, overdrive -> overdrive.onUse(this, player, hand), result);
85+
result = components.mapOrDefault(OverdriveComponent.class, overdrive -> overdrive.onUse(this, player, hand), result);
8686
}
8787
return result;
8888
}

src/main/java/aztech/modern_industrialization/machines/gui/MachineMenuServer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ public class MachineMenuServer extends MachineMenuCommon {
3939
protected final List trackedData;
4040

4141
public MachineMenuServer(int syncId, Inventory playerInventory, MachineBlockEntity blockEntity, MachineGuiParameters guiParams) {
42-
super(syncId, playerInventory, blockEntity.getInventory(), guiParams, blockEntity.getGuiComponents());
42+
super(syncId, playerInventory, blockEntity.getInventory(), guiParams, blockEntity.guiComponents);
4343
this.blockEntity = blockEntity;
4444
trackedData = new ArrayList<>();
45-
for (GuiComponent.Server component : blockEntity.getGuiComponents()) {
45+
for (GuiComponent.Server component : blockEntity.guiComponents) {
4646
trackedData.add(component.copyData());
4747
}
4848
}
4949

5050
@Override
5151
public void broadcastChanges() {
5252
super.broadcastChanges();
53-
blockEntity.getGuiComponents().forEachIndexed((i, component) -> {
53+
blockEntity.guiComponents.forEachIndexed((i, component) -> {
5454
if (component.needsSync(trackedData.get(i))) {
5555
var buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), blockEntity.getLevel().registryAccess());
5656
component.writeCurrentData(buf);

src/main/java/aztech/modern_industrialization/network/machines/ChangeShapePacket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void handle(Context ctx) {
5050

5151
AbstractContainerMenu menu = ctx.getPlayer().containerMenu;
5252
if (menu.containerId == syncId && menu instanceof MachineMenuServer machineMenu) {
53-
ShapeSelection.Server shapeSelection = machineMenu.blockEntity.getGuiComponents().get(GuiComponents.SHAPE_SELECTION);
53+
ShapeSelection.Server shapeSelection = machineMenu.blockEntity.guiComponents.get(GuiComponents.SHAPE_SELECTION);
5454
shapeSelection.behavior.handleClick(shapeLine, clickedLeftButton ? -1 : +1);
5555
}
5656
}

src/main/java/aztech/modern_industrialization/network/machines/ReiLockSlotsPacket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void handle(Context ctx) {
4848
AbstractContainerMenu sh = ctx.getPlayer().containerMenu;
4949
if (sh.containerId == containedId && sh instanceof MachineMenuServer screenHandler) {
5050
// Check that locking the slots is allowed in the first place
51-
ReiSlotLocking.Server slotLocking = screenHandler.blockEntity.getGuiComponents().get(GuiComponents.REI_SLOT_LOCKING);
51+
ReiSlotLocking.Server slotLocking = screenHandler.blockEntity.guiComponents.get(GuiComponents.REI_SLOT_LOCKING);
5252
if (!slotLocking.allowLocking.get())
5353
return;
5454

src/main/java/aztech/modern_industrialization/network/machines/SetAutoExtractPacket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void handle(Context ctx) {
5050

5151
if (ctx.getPlayer().containerMenu.containerId == syncId) {
5252
var screenHandler = (MachineMenuServer) ctx.getPlayer().containerMenu;
53-
AutoExtract.Server autoExtract = screenHandler.blockEntity.getGuiComponents().get(GuiComponents.AUTO_EXTRACT);
53+
AutoExtract.Server autoExtract = screenHandler.blockEntity.guiComponents.get(GuiComponents.AUTO_EXTRACT);
5454
OrientationComponent orientation = autoExtract.getOrientation();
5555
if (isItem) {
5656
orientation.extractItems = isExtract;

0 commit comments

Comments
 (0)