World of Tags

- Tile Entities in ponder are now backed up as their nbt compound instead of a cloned instance
This commit is contained in:
simibubi 2022-10-07 18:43:39 +02:00
parent c7a75f8ffd
commit c4eb62c862

View file

@ -34,6 +34,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.BlockParticleOption;
import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -54,7 +55,7 @@ public class PonderWorld extends SchematicWorld {
public PonderScene scene; public PonderScene scene;
protected Map<BlockPos, BlockState> originalBlocks; protected Map<BlockPos, BlockState> originalBlocks;
protected Map<BlockPos, BlockEntity> originalTileEntities; protected Map<BlockPos, CompoundTag> originalTileEntities;
protected Map<BlockPos, Integer> blockBreakingProgressions; protected Map<BlockPos, Integer> blockBreakingProgressions;
protected List<Entity> originalEntities; protected List<Entity> originalEntities;
private Supplier<ClientLevel> asClientWorld = Suppliers.memoize(() -> WrappedClientWorld.of(this)); private Supplier<ClientLevel> asClientWorld = Suppliers.memoize(() -> WrappedClientWorld.of(this));
@ -79,8 +80,7 @@ public class PonderWorld extends SchematicWorld {
originalBlocks.clear(); originalBlocks.clear();
originalTileEntities.clear(); originalTileEntities.clear();
blocks.forEach((k, v) -> originalBlocks.put(k, v)); blocks.forEach((k, v) -> originalBlocks.put(k, v));
tileEntities.forEach( tileEntities.forEach((k, v) -> originalTileEntities.put(k, v.saveWithFullMetadata()));
(k, v) -> originalTileEntities.put(k, BlockEntity.loadStatic(k, blocks.get(k), v.saveWithFullMetadata())));
entities.forEach(e -> EntityType.create(e.serializeNBT(), this) entities.forEach(e -> EntityType.create(e.serializeNBT(), this)
.ifPresent(originalEntities::add)); .ifPresent(originalEntities::add));
} }
@ -93,7 +93,7 @@ public class PonderWorld extends SchematicWorld {
renderedTileEntities.clear(); renderedTileEntities.clear();
originalBlocks.forEach((k, v) -> blocks.put(k, v)); originalBlocks.forEach((k, v) -> blocks.put(k, v));
originalTileEntities.forEach((k, v) -> { originalTileEntities.forEach((k, v) -> {
BlockEntity te = BlockEntity.loadStatic(k, originalBlocks.get(k), v.saveWithFullMetadata()); BlockEntity te = BlockEntity.loadStatic(k, originalBlocks.get(k), v);
onTEadded(te, te.getBlockPos()); onTEadded(te, te.getBlockPos());
tileEntities.put(k, te); tileEntities.put(k, te);
renderedTileEntities.add(te); renderedTileEntities.add(te);
@ -109,8 +109,7 @@ public class PonderWorld extends SchematicWorld {
if (originalBlocks.containsKey(p)) if (originalBlocks.containsKey(p))
blocks.put(p, originalBlocks.get(p)); blocks.put(p, originalBlocks.get(p));
if (originalTileEntities.containsKey(p)) { if (originalTileEntities.containsKey(p)) {
BlockEntity te = BlockEntity.loadStatic(p, originalBlocks.get(p), originalTileEntities.get(p) BlockEntity te = BlockEntity.loadStatic(p, originalBlocks.get(p), originalTileEntities.get(p));
.saveWithFullMetadata());
onTEadded(te, te.getBlockPos()); onTEadded(te, te.getBlockPos());
tileEntities.put(p, te); tileEntities.put(p, te);
} }