Skip to content

Commit e1b05e9

Browse files
authored
Make it so that structural multiblocks don't tick (structural glass and reactor glass) (#8051)
1 parent d5ef0eb commit e1b05e9

File tree

15 files changed

+173
-105
lines changed

15 files changed

+173
-105
lines changed

src/api/java/mekanism/api/MekanismAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private MekanismAPI() {
2929
/**
3030
* The version of the api classes - may not always match the mod's version
3131
*/
32-
public static final String API_VERSION = "10.5.15";
32+
public static final String API_VERSION = "10.5.18";
3333
/**
3434
* Mekanism's Mod ID
3535
*/

src/api/java/mekanism/api/NBTConstants.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ private NBTConstants() {
123123
public static final String FILTER = "filter";
124124
public static final String FILTERS = "filters";
125125
public static final String FINISHED = "finished";
126+
/**
127+
* @since 10.5.18
128+
*/
129+
public static final String FORMED = "formed";
126130
public static final String FLUID_STORED = "fluid";
127131
public static final String FLUID_TANKS = "FluidTanks";
128132
public static final String FOLLOW = "follow";
@@ -135,6 +139,10 @@ private NBTConstants() {
135139
public static final String GAS_STORED_ALT = "gas1";
136140
public static final String GAS_STORED_ALT_2 = "gas2";
137141
public static final String GAS_TANKS = "GasTanks";
142+
/**
143+
* @since 10.5.18
144+
*/
145+
public static final String GUI = "gui";
138146
public static final String HANDLE_SOUND = "handleSound";
139147
public static final String HEAT_CAPACITORS = "HeatCapacitors";
140148
public static final String HEAT_CAPACITY = "heatCapacity";

src/generators/java/mekanism/generators/common/content/fusion/FusionReactorMultiblockData.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import mekanism.common.lib.multiblock.IValveHandler.ValveData;
3434
import mekanism.common.lib.multiblock.MultiblockData;
3535
import mekanism.common.registries.MekanismGases;
36+
import mekanism.common.tile.prefab.TileEntityStructuralMultiblock;
3637
import mekanism.common.util.CableUtils;
3738
import mekanism.common.util.ChemicalUtil;
3839
import mekanism.common.util.HeatUtils;
@@ -170,6 +171,11 @@ public void onCreated(Level world) {
170171
deathZone = AABB.encapsulatingFullBlocks(getMinPos().offset(1, 1, 1), getMaxPos().offset(-1, -1, -1));
171172
}
172173

174+
@Override
175+
public boolean allowsStructuralGuiAccess(TileEntityStructuralMultiblock multiblock) {
176+
return false;
177+
}
178+
173179
@Override
174180
public void readUpdateTag(CompoundTag tag) {
175181
super.readUpdateTag(tag);

src/generators/java/mekanism/generators/common/registries/GeneratorsTileEntityTypes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ private GeneratorsTileEntityTypes() {
7474
//Misc
7575
public static final TileEntityTypeRegistryObject<TileEntityReactorGlass> REACTOR_GLASS = TILE_ENTITY_TYPES
7676
.mekBuilder(GeneratorsBlocks.REACTOR_GLASS, TileEntityReactorGlass::new)
77-
.serverTicker(TileEntityMekanism::tickServer)
7877
.withSimple(Capabilities.CONFIGURABLE)
7978
.build();
8079
//Fission Reactor

src/main/java/mekanism/common/block/basic/BlockStructuralGlass.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level world, @N
2929
if (tile == null) {
3030
return InteractionResult.PASS;
3131
} else if (world.isClientSide) {
32-
if (!MekanismUtils.canUseAsWrench(player.getItemInHand(hand))) {
33-
if (!tile.structuralGuiAccessAllowed() || !tile.hasFormedMultiblock()) {
34-
//If the block's multiblock doesn't allow gui access via structural multiblocks (for example the evaporation plant),
35-
// or if the multiblock is not formed then pass
36-
return InteractionResult.PASS;
37-
}
32+
if (!MekanismUtils.canUseAsWrench(player.getItemInHand(hand)) && !tile.structuralGuiAccessAllowed()) {
33+
//If the block's multiblock doesn't allow gui access via structural multiblocks (for example the evaporation plant),
34+
// or if the multiblock is not formed then pass
35+
return InteractionResult.PASS;
3836
}
3937
return InteractionResult.SUCCESS;
4038
}

src/main/java/mekanism/common/content/boiler/BoilerMultiblockData.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import mekanism.common.inventory.container.sync.dynamic.ContainerSync;
3131
import mekanism.common.lib.multiblock.IValveHandler;
3232
import mekanism.common.lib.multiblock.MultiblockData;
33+
import mekanism.common.lib.multiblock.Structure;
3334
import mekanism.common.registries.MekanismGases;
3435
import mekanism.common.tile.multiblock.TileEntityBoilerCasing;
3536
import mekanism.common.tile.multiblock.TileEntityBoilerValve;
@@ -136,9 +137,9 @@ public void onCreated(Level world) {
136137
}
137138

138139
@Override
139-
public void remove(Level world) {
140+
public void remove(Level world, Structure oldStructure) {
140141
hotMap.removeBoolean(inventoryID);
141-
super.remove(world);
142+
super.remove(world, oldStructure);
142143
}
143144

144145
@Override

src/main/java/mekanism/common/content/evaporation/EvaporationMultiblockData.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
import mekanism.common.inventory.slot.OutputInventorySlot;
3535
import mekanism.common.lib.multiblock.IValveHandler;
3636
import mekanism.common.lib.multiblock.MultiblockData;
37+
import mekanism.common.lib.multiblock.Structure;
3738
import mekanism.common.recipe.IMekanismRecipeTypeProvider;
3839
import mekanism.common.recipe.MekanismRecipeType;
3940
import mekanism.common.recipe.lookup.ISingleRecipeLookupHandler.FluidRecipeLookupHandler;
4041
import mekanism.common.recipe.lookup.cache.InputRecipeCache.SingleFluid;
4142
import mekanism.common.recipe.lookup.monitor.RecipeCacheLookupMonitor;
4243
import mekanism.common.tile.multiblock.TileEntityThermalEvaporationBlock;
4344
import mekanism.common.tile.prefab.TileEntityRecipeMachine;
45+
import mekanism.common.tile.prefab.TileEntityStructuralMultiblock;
4446
import mekanism.common.util.MekanismUtils;
4547
import mekanism.common.util.NBTUtils;
4648
import net.minecraft.core.BlockPos;
@@ -158,6 +160,11 @@ public boolean tick(Level world) {
158160
return needsPacket;
159161
}
160162

163+
@Override
164+
public boolean allowsStructuralGuiAccess(TileEntityStructuralMultiblock multiblock) {
165+
return false;
166+
}
167+
161168
@Override
162169
public void readUpdateTag(CompoundTag tag) {
163170
super.readUpdateTag(tag);
@@ -302,9 +309,9 @@ protected int getMultiblockRedstoneLevel() {
302309
}
303310

304311
@Override
305-
public void remove(Level world) {
312+
public void remove(Level world, Structure oldStructure) {
306313
//Clear the cached solar panels so that we don't hold references to them and prevent them from being able to be garbage collected
307314
cachedSolar.clear();
308-
super.remove(world);
315+
super.remove(world, oldStructure);
309316
}
310317
}

src/main/java/mekanism/common/content/matrix/MatrixMultiblockData.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import mekanism.common.lib.multiblock.IValveHandler.ValveData;
1313
import mekanism.common.lib.multiblock.MultiblockCache.CacheSubstance;
1414
import mekanism.common.lib.multiblock.MultiblockData;
15+
import mekanism.common.lib.multiblock.Structure;
1516
import mekanism.common.tile.multiblock.TileEntityInductionCasing;
1617
import mekanism.common.tile.multiblock.TileEntityInductionCell;
1718
import mekanism.common.tile.multiblock.TileEntityInductionPort;
@@ -112,9 +113,9 @@ public boolean tick(Level world) {
112113
}
113114

114115
@Override
115-
public void remove(Level world) {
116+
public void remove(Level world, Structure oldStructure) {
116117
energyContainer.invalidate();
117-
super.remove(world);
118+
super.remove(world, oldStructure);
118119
}
119120

120121
@Override

src/main/java/mekanism/common/lib/multiblock/FormationProtocol.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ public FormationResult doUpdate() {
9393
// In theory we could partially get around this issue by keeping track of all the positions for the multiblock in the cache and only
9494
// reuse the id if we contain all elements we previously had, but doing so is not currently worth all the extra checks
9595
UUID idToUse = manager.getUniqueInventoryID();
96-
if (!result.idsFound.isEmpty()) {
96+
if (!result.idsFound().isEmpty()) {
9797
RejectContents rejectContents = new RejectContents();
98-
for (Map.Entry<UUID, MultiblockCache<T>> entry : result.idsFound.entrySet()) {
98+
for (Map.Entry<UUID, MultiblockCache<T>> entry : result.idsFound().entrySet()) {
9999
if (cache == null) {
100100
cache = entry.getValue();
101101
} else {
@@ -105,6 +105,7 @@ public FormationResult doUpdate() {
105105
//Replace the caches for all the old ids with a singular merged cache with our desired id
106106
manager.replaceCaches(result.idsFound().keySet(), idToUse, cache);
107107
if (!rejectContents.rejectedItems.isEmpty()) {
108+
//TODO - 1.20.4: Don't drop it in the center if there is no nearest player, maybe drop it on top of the multiblock? Or to one of the sides
108109
Vec3 dropPosition = pointerPos.getCenter();
109110
//Try to see which player was nearest to multiblocks that have rejected items
110111
Player nearestPlayer = world.getNearestPlayer(dropPosition.x, dropPosition.y, dropPosition.z, 25, true);

src/main/java/mekanism/common/lib/multiblock/IStructuralMultiblock.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ public interface IStructuralMultiblock extends IMultiblockBase {
1515
* evaporation plant.
1616
*/
1717
boolean structuralGuiAccessAllowed();
18+
19+
void multiblockUnformed(Structure structure);
20+
21+
void multiblockFormed(MultiblockData multiblock);
1822
}

0 commit comments

Comments
 (0)