3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Further work on snapshot restores

Dieser Commit ist enthalten in:
Wyatt Childers 2016-02-02 18:15:10 -05:00
Ursprung c3c787bc9a
Commit 81960c6b54

Datei anzeigen

@ -38,6 +38,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderServer; import net.minecraft.world.gen.ChunkProviderServer;
@ -47,12 +48,15 @@ import org.spongepowered.api.block.BlockSnapshot;
import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.entity.EntitySnapshot; import org.spongepowered.api.entity.EntitySnapshot;
import org.spongepowered.api.entity.EntityType; import org.spongepowered.api.entity.EntityType;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.channel.MessageChannel;
import org.spongepowered.api.world.Location; import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import org.spongepowered.common.block.SpongeBlockSnapshot; import org.spongepowered.common.block.SpongeBlockSnapshot;
import org.spongepowered.common.block.SpongeBlockSnapshotBuilder; import org.spongepowered.common.block.SpongeBlockSnapshotBuilder;
import org.spongepowered.common.entity.SpongeEntitySnapshot; import org.spongepowered.common.entity.SpongeEntitySnapshot;
import org.spongepowered.common.entity.SpongeEntitySnapshotBuilder; import org.spongepowered.common.entity.SpongeEntitySnapshotBuilder;
import scala.xml.Null;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.*;
@ -81,29 +85,40 @@ public class SpongeForgeWorld extends SpongeWorld {
@Override @Override
protected BlockSnapshot createBlockSnapshot(Vector position, BaseBlock block) { protected BlockSnapshot createBlockSnapshot(Vector position, BaseBlock block) {
this.blockBuilder.reset(); this.blockBuilder.reset();
Location<World> location = new Location<>(getWorld(), new Vector3i(position.getX(), position.getY(), position.getZ()));
this.blockBuilder.blockState((BlockState) Block.getBlockById(block.getId()).getStateFromMeta(block.getData())); Location<World> location = new Location<>(getWorld(), new Vector3i(position.getX(), position.getY(), position.getZ()));
this.blockBuilder.worldId(location.getExtent().getUniqueId()); IBlockState baseState = Block.getBlockById(block.getId()).getStateFromMeta(block.getData());
this.blockBuilder.blockState((BlockState) baseState);
this.blockBuilder.worldId(getWorld().getUniqueId());
this.blockBuilder.position(location.getBlockPosition()); this.blockBuilder.position(location.getBlockPosition());
if (block.hasNbtData()) { if (block.hasNbtData()) {
this.blockBuilder.unsafeNbt(NBTConverter.toNative(block.getNbtData())); NBTTagCompound tag = NBTConverter.toNative(block.getNbtData());
tag.setString("id", block.getNbtId());
this.blockBuilder.unsafeNbt(tag);
} }
return new SpongeBlockSnapshot(this.blockBuilder, 0); return this.blockBuilder.build();
} }
@Override @Override
protected EntitySnapshot createEntitySnapshot(com.sk89q.worldedit.util.Location location, BaseEntity entity) { protected EntitySnapshot createEntitySnapshot(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
this.entityBuilder.reset(); this.entityBuilder.reset();
this.entityBuilder.worldId(getWorld().getUniqueId());
this.entityBuilder.position(new Vector3d(location.getX(), location.getY(), location.getZ())); this.entityBuilder.position(new Vector3d(location.getX(), location.getY(), location.getZ()));
// TODO Rotation code // TODO Rotation code
// this.entityBuilder.rotation() // this.entityBuilder.rotation()
this.entityBuilder.type(Sponge.getRegistry().getType(EntityType.class, entity.getTypeId()).get()); this.entityBuilder.type(Sponge.getRegistry().getType(EntityType.class, entity.getTypeId()).get());
if (entity.hasNbtData()) { if (entity.hasNbtData()) {
this.entityBuilder.unsafeCompound(NBTConverter.toNative(entity.getNbtData())); NBTTagCompound tag = NBTConverter.toNative(entity.getNbtData());
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.removeTag(name);
}
this.entityBuilder.unsafeCompound(tag);
} }
return this.entityBuilder.build(); return this.entityBuilder.build();
} }