Skip to content

Commit 53a6954

Browse files
committed
Make pick block copy components, and remove some tags that get copied when doing a full copy that don't make sense to persist
1 parent ff3df36 commit 53a6954

File tree

8 files changed

+68
-4
lines changed

8 files changed

+68
-4
lines changed

src/main/java/mekanism/common/block/BlockMekanism.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,10 @@ protected boolean canBeReplaced(@NotNull BlockState state, @NotNull Fluid fluid)
8686
@Override
8787
public ItemStack getCloneItemStack(@NotNull BlockState state, @NotNull HitResult target, @NotNull LevelReader world, @NotNull BlockPos pos, @NotNull Player player) {
8888
ItemStack stack = super.getCloneItemStack(state, target, world, pos, player);
89-
//TODO - 1.20.5: Figure this out, we want to make sure we copy components
90-
/*TileEntityUpdateable tile = WorldUtils.getTileEntity(TileEntityUpdateable.class, world, pos);
89+
TileEntityUpdateable tile = WorldUtils.getTileEntity(TileEntityUpdateable.class, world, pos);
9190
if (tile != null) {
92-
tile.writeToStack(stack);
93-
}*/
91+
stack.applyComponents(tile.collectComponents());
92+
}
9493
return stack;
9594
}
9695

src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ public void loadAdditional(@NotNull CompoundTag nbt, @NotNull HolderLookup.Provi
175175
}
176176
}
177177

178+
@Override
179+
@Deprecated
180+
public void removeComponentsFromTag(@NotNull CompoundTag tag) {
181+
super.removeComponentsFromTag(tag);
182+
tag.remove(SerializationConstants.ROUND_ROBIN_TARGET);
183+
}
184+
178185
@Override
179186
protected boolean canPlaySound() {
180187
return false;//handle own sounds

src/main/java/mekanism/common/tile/base/TileEntityMekanism.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,26 @@ public List<DataComponentType<?>> getRemapEntries() {
861861
return remapEntries;
862862
}
863863

864+
@Override
865+
@Deprecated
866+
public void removeComponentsFromTag(@NotNull CompoundTag tag) {
867+
super.removeComponentsFromTag(tag);
868+
for (ITileComponent component : components) {
869+
tag.remove(component.getComponentKey());
870+
}
871+
tag.remove(SerializationConstants.REDSTONE);
872+
if (supportsComparator()) {
873+
tag.remove(SerializationConstants.CURRENT_REDSTONE);
874+
}
875+
if (isActivatable()) {
876+
tag.remove(SerializationConstants.ACTIVE_STATE);
877+
tag.remove(SerializationConstants.UPDATE_DELAY);
878+
}
879+
if (supportsRedstone()) {
880+
tag.remove(SerializationConstants.CONTROL_TYPE);
881+
}
882+
}
883+
864884
@Override//TODO - 1.20.5: Do we need to override removeComponentsFromTag??
865885
protected void collectImplicitComponents(@NotNull DataComponentMap.Builder builder) {
866886
super.collectImplicitComponents(builder);

src/main/java/mekanism/common/tile/laser/TileEntityBasicLaser.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ public void saveAdditional(@NotNull CompoundTag nbtTags, @NotNull HolderLookup.P
423423
nbtTags.putString(SerializationConstants.LAST_FIRED, lastFired.toString());
424424
}
425425

426+
@Override
427+
@Deprecated
428+
public void removeComponentsFromTag(@NotNull CompoundTag tag) {
429+
super.removeComponentsFromTag(tag);
430+
tag.remove(SerializationConstants.LAST_FIRED);
431+
}
432+
426433
@NotNull
427434
@Override
428435
public CompoundTag getReducedUpdateTag(@NotNull HolderLookup.Provider provider) {

src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,14 @@ public void loadAdditional(@NotNull CompoundTag nbt, @NotNull HolderLookup.Provi
864864
energyContainer.updateMinerEnergyPerTick();
865865
}
866866

867+
@Override
868+
@Deprecated
869+
public void removeComponentsFromTag(@NotNull CompoundTag tag) {
870+
super.removeComponentsFromTag(tag);
871+
tag.remove(SerializationConstants.NUM_POWERING);
872+
tag.remove(SerializationConstants.STATE);
873+
}
874+
867875
@Override
868876
public void setLevel(@NotNull Level world) {
869877
super.setLevel(world);

src/main/java/mekanism/common/tile/machine/TileEntityElectricPump.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,13 @@ public void loadAdditional(@NotNull CompoundTag nbt, @NotNull HolderLookup.Provi
338338
NBTUtils.readBlockPositions(nbt, SerializationConstants.RECURRING_NODES, recurringNodes);
339339
}
340340

341+
@Override
342+
@Deprecated
343+
public void removeComponentsFromTag(@NotNull CompoundTag tag) {
344+
super.removeComponentsFromTag(tag);
345+
tag.remove(SerializationConstants.RECURRING_NODES);
346+
}
347+
341348
@Override
342349
public InteractionResult onSneakRightClick(Player player) {
343350
reset();

src/main/java/mekanism/common/tile/machine/TileEntityFluidicPlenisher.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ public void loadAdditional(@NotNull CompoundTag nbt, @NotNull HolderLookup.Provi
255255
NBTUtils.readBlockPositions(nbt, SerializationConstants.USED_NODES, usedNodes);
256256
}
257257

258+
@Override
259+
@Deprecated
260+
public void removeComponentsFromTag(@NotNull CompoundTag tag) {
261+
super.removeComponentsFromTag(tag);
262+
tag.remove(SerializationConstants.ACTIVE_NODES);
263+
tag.remove(SerializationConstants.USED_NODES);
264+
tag.remove(SerializationConstants.FINISHED);
265+
}
266+
258267
public void reset() {
259268
activeNodes.clear();
260269
usedNodes.clear();

src/main/java/mekanism/common/tile/qio/TileEntityQIOExporter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ public void loadAdditional(@NotNull CompoundTag nbt, @NotNull HolderLookup.Provi
194194
}
195195
}
196196

197+
@Override
198+
@Deprecated
199+
public void removeComponentsFromTag(@NotNull CompoundTag tag) {
200+
super.removeComponentsFromTag(tag);
201+
tag.remove(SerializationConstants.ROUND_ROBIN_TARGET);
202+
}
203+
197204
@Override
198205
public void writeSustainedData(HolderLookup.Provider provider, CompoundTag dataMap) {
199206
super.writeSustainedData(provider, dataMap);

0 commit comments

Comments
 (0)