SPIGOT-5123: Snapshot tile entities can end up with a non-null world
By: md_5 <git@md-5.net>
This commit is contained in:
@@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.block;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.BlockBannerAbstract;
|
||||
import net.minecraft.server.EnumColor;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
@@ -31,9 +32,7 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
|
||||
public void load(TileEntityBanner banner) {
|
||||
super.load(banner);
|
||||
|
||||
if (banner.color != null) {
|
||||
base = DyeColor.getByWoolData((byte) banner.color.getColorIndex());
|
||||
}
|
||||
base = DyeColor.getByWoolData((byte) ((BlockBannerAbstract) this.data.getBlock()).b().getColorIndex()); // PAIL
|
||||
patterns = new ArrayList<Pattern>();
|
||||
|
||||
if (banner.patterns != null) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.TileEntity;
|
||||
import net.minecraft.server.World;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.TileState;
|
||||
@@ -28,7 +27,7 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
||||
Preconditions.checkState(this.tileEntity != null, "Tile is null, asynchronous access? " + block);
|
||||
|
||||
// copy tile entity data:
|
||||
this.snapshot = this.createSnapshot(tileEntity, world.getHandle());
|
||||
this.snapshot = this.createSnapshot(tileEntity);
|
||||
this.load(snapshot);
|
||||
}
|
||||
|
||||
@@ -39,17 +38,17 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
||||
this.tileEntity = tileEntity;
|
||||
|
||||
// copy tile entity data:
|
||||
this.snapshot = this.createSnapshot(tileEntity, null);
|
||||
this.snapshot = this.createSnapshot(tileEntity);
|
||||
this.load(snapshot);
|
||||
}
|
||||
|
||||
private T createSnapshot(T tileEntity, World world) {
|
||||
private T createSnapshot(T tileEntity) {
|
||||
if (tileEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
NBTTagCompound nbtTagCompound = tileEntity.save(new NBTTagCompound());
|
||||
T snapshot = (T) TileEntity.create(nbtTagCompound, world);
|
||||
T snapshot = (T) TileEntity.create(nbtTagCompound);
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user