Skip to content

Commit

Permalink
prevent personal storage picked-item from crashing the game by not co…
Browse files Browse the repository at this point in the history
…pying inventory
  • Loading branch information
thiakil committed Dec 24, 2024
1 parent 092b3a0 commit f34ea72
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import mekanism.api.providers.IBlockProvider;
import mekanism.api.security.ISecurityUtils;
import mekanism.api.security.SecurityMode;
import mekanism.common.attachments.containers.ContainerType;
import mekanism.common.capabilities.holder.slot.IInventorySlotHolder;
import mekanism.common.capabilities.holder.slot.InventorySlotHelper;
import mekanism.common.inventory.container.tile.MekanismTileContainer;
@@ -128,4 +129,9 @@ protected void applyImplicitComponents(@NotNull BlockEntity.DataComponentInput i
}
}
}

@Override
public boolean persistsToItem(ContainerType<?, ?, ?> type) {
return type != ContainerType.ITEM && super.persistsToItem(type);
}
}
15 changes: 11 additions & 4 deletions src/main/java/mekanism/common/tile/base/TileEntityMekanism.java
Original file line number Diff line number Diff line change
@@ -367,12 +367,19 @@ public ResourceLocation getBlockTypeRegistryName() {
}

/**
* Should data related to the given type be persisted in this tile save and transferred to the item
* Should data related to the given type be persisted in this tile save
*/
public boolean persists(ContainerType<?, ?, ?> type) {
return type.canHandle(this);
}

/**
* Should data related to the given type be transferred to the item
*/
public boolean persistsToItem(ContainerType<?, ?, ?> type) {
return persists(type);
}

/**
* Should data related to the given type be synced to the client in the GUI
*/
@@ -813,7 +820,7 @@ protected void applyImplicitComponents(@NotNull BlockEntity.DataComponentInput i
}

for (ContainerType<?, ?, ?> type : ContainerType.TYPES) {
if (persists(type)) {
if (persistsToItem(type)) {
type.copyToTile(this, input);
}
}
@@ -836,7 +843,7 @@ public List<DataComponentType<?>> getRemapEntries() {
component.addRemapEntries(remapEntries);
}
for (ContainerType<?, ?, ?> type : ContainerType.TYPES) {
if (persists(type) && !remapEntries.contains(type.getComponentType().get())) {
if (persistsToItem(type) && !remapEntries.contains(type.getComponentType().get())) {
//Ensure we add any container types that we only conditionally added
remapEntries.add(type.getComponentType().get());
}
@@ -876,7 +883,7 @@ protected void collectImplicitComponents(@NotNull DataComponentMap.Builder build
component.collectImplicitComponents(builder);
}
for (ContainerType<?, ?, ?> type : ContainerType.TYPES) {
if (persists(type)) {
if (persistsToItem(type)) {
type.copyFromTile(this, builder);
}
}

0 comments on commit f34ea72

Please sign in to comment.