mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 18:55:30 +01:00
revert back to using Material for compatibility with old saves.
This commit is contained in:
parent
ddc2f026e5
commit
415715d952
@ -177,7 +177,7 @@ public final class StructureUtil {
|
||||
BlockUtil.convertBlockDataToBlock(blockLocation.getBlock(), blockDataList);
|
||||
} catch (Exception e) {
|
||||
SkyBlock.getInstance().getLogger()
|
||||
.warning("Unable to convert BlockData to Block for type {" + blockDataList.getCompatibleMaterial() + ":" + blockDataList.getData() + "} in structure {" + structure.getStructureFile() + "}");
|
||||
.warning("Unable to convert BlockData to Block for type {" + blockDataList.getMaterial() + ":" + blockDataList.getData() + "} in structure {" + structure.getStructureFile() + "}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import java.util.Map;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BlockData {
|
||||
|
||||
private CompatibleMaterial compatibleMaterial;
|
||||
private String material;
|
||||
private String biome;
|
||||
private String stateType = BlockStateType.NORMAL.toString();
|
||||
@ -55,8 +54,8 @@ public class BlockData {
|
||||
|
||||
private boolean exactTeleport = true;
|
||||
|
||||
public BlockData(CompatibleMaterial material, int x, int y, int z, String biome) {
|
||||
this.compatibleMaterial = material;
|
||||
public BlockData(String material, int x, int y, int z, String biome) {
|
||||
this.material = material;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
@ -64,14 +63,12 @@ public class BlockData {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
public CompatibleMaterial getCompatibleMaterial() {
|
||||
if (compatibleMaterial == null)
|
||||
return CompatibleMaterial.getMaterial(material);
|
||||
return compatibleMaterial;
|
||||
public String getMaterial() {
|
||||
return this.material;
|
||||
}
|
||||
|
||||
public void setMaterial(CompatibleMaterial material) {
|
||||
this.compatibleMaterial = material;
|
||||
public void setMaterial(Material material) {
|
||||
this.material = material.name();
|
||||
}
|
||||
|
||||
public String getBiome() {
|
||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||
public final class BlockUtil extends BlockUtils {
|
||||
|
||||
public static BlockData convertBlockToBlockData(Block block, int x, int y, int z) {
|
||||
BlockData blockData = new BlockData(CompatibleMaterial.getMaterial(block), x, y, z, block.getBiome().toString());
|
||||
BlockData blockData = new BlockData(block.getType().name(), x, y, z, block.getBiome().toString());
|
||||
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
blockData.setVersion(NMSVersion);
|
||||
@ -246,10 +246,10 @@ public final class BlockUtil extends BlockUtils {
|
||||
public static void convertBlockDataToBlock(Block block, BlockData blockData) {
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
|
||||
CompatibleMaterial material = blockData.getCompatibleMaterial();
|
||||
String material = blockData.getMaterial();
|
||||
if (material == null) return;
|
||||
|
||||
setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData());
|
||||
setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.valueOf(material), blockData.getData());
|
||||
|
||||
// TODO Create a class to support biome changes
|
||||
// block.setBiome(Biome.valueOf(blockData.getBiome().toUpperCase()));
|
||||
@ -424,10 +424,10 @@ public final class BlockUtil extends BlockUtils {
|
||||
String[] flower = blockData.getFlower().split(":");
|
||||
int materialData = Integer.parseInt(flower[1]);
|
||||
|
||||
material = CompatibleMaterial.getMaterial(flower[0].toUpperCase());
|
||||
material = flower[0].toUpperCase();
|
||||
|
||||
if (material != null) {
|
||||
ItemStack is = new ItemStack(material.getMaterial(), 1, (byte) materialData);
|
||||
ItemStack is = new ItemStack(Material.getMaterial(material), 1, (byte) materialData);
|
||||
|
||||
World world = block.getWorld();
|
||||
|
||||
@ -462,16 +462,16 @@ public final class BlockUtil extends BlockUtils {
|
||||
|
||||
if (blockData.getVersion() > 12) {
|
||||
if (NMSVersion > 12) {
|
||||
material = CompatibleMaterial.valueOf(flower[0].toUpperCase());
|
||||
material = flower[0].toUpperCase();
|
||||
}
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
material = CompatibleMaterial.valueOf(flower[0].toUpperCase());
|
||||
material = flower[0].toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
if (material != null) {
|
||||
flowerPot.setContents(new MaterialData(material.getMaterial(), (byte) Integer.parseInt(flower[1])));
|
||||
flowerPot.setContents(new MaterialData(Material.getMaterial(material), (byte) Integer.parseInt(flower[1])));
|
||||
}
|
||||
|
||||
state.setData(flowerPot);
|
||||
@ -479,7 +479,7 @@ public final class BlockUtil extends BlockUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if (blockData.getCompatibleMaterial().equals("DOUBLE_PLANT")) {
|
||||
if (material.equals("DOUBLE_PLANT")) {
|
||||
Block topBlock = block.getLocation().add(0.0D, 1.0D, 0.0D).getBlock();
|
||||
Block bottomBlock = block.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user