SPIGOT-5146: BlockDataMeta does not work

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-07-09 10:47:07 +10:00
parent 0117fb27e2
commit f3d1e78efe
3 changed files with 58 additions and 14 deletions

View File

@@ -22,6 +22,7 @@ import net.minecraft.server.IBlockData;
import net.minecraft.server.IBlockState;
import net.minecraft.server.INamable;
import net.minecraft.server.IRegistry;
import net.minecraft.server.NBTTagCompound;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
@@ -275,8 +276,16 @@ public class CraftBlockData implements BlockData {
return stateString.toString();
}
public String toStates() {
return ((BlockDataAbstract) state).getStateMap().entrySet().stream().map(BlockDataAbstract.STATE_TO_VALUE).collect(Collectors.joining(",")).toString();
public NBTTagCompound toStates() {
NBTTagCompound compound = new NBTTagCompound();
for (Map.Entry<IBlockState<?>, Comparable<?>> entry : state.getStateMap().entrySet()) {
IBlockState iblockstate = (IBlockState) entry.getKey();
compound.setString(iblockstate.a(), iblockstate.a(entry.getValue()));
}
return compound;
}
@Override