mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Setup a legacy mapper system. The file does not exist yet.
This commit is contained in:
@ -31,8 +31,6 @@ import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
@ -40,7 +38,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
@ -361,10 +359,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@Override
|
||||
public com.sk89q.worldedit.blocks.type.BlockState getBlock(Vector position) {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
BlockType blockType = BlockTypes.getBlockType(
|
||||
BundledBlockData.getInstance().fromLegacyId(bukkitBlock.getTypeId())
|
||||
);
|
||||
return blockType.getDefaultState(); // TODO Data
|
||||
return LegacyMapper.getInstance().getBlockFromLegacy(bukkitBlock.getTypeId(), bukkitBlock.getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -374,7 +369,11 @@ public class BukkitWorld extends AbstractWorld {
|
||||
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
|
||||
} else {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
return bukkitBlock.setTypeIdAndData(block.getBlockType().getLegacyId(), (byte) 0, notifyAndLight); // TODO Data
|
||||
int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(block.toImmutableState());
|
||||
if (datas == null) {
|
||||
throw new WorldEditException("Unknown block"){}; // TODO Remove.
|
||||
}
|
||||
return bukkitBlock.setTypeIdAndData(datas[0], (byte) datas[1], notifyAndLight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* Proxy class to catch calls to set blocks.
|
||||
@ -41,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
@Override
|
||||
public boolean setRawTypeId(int x, int y, int z, int typeId) {
|
||||
try {
|
||||
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId));
|
||||
return editSession.setBlock(new Vector(x, y, z), LegacyMapper.getInstance().getBlockFromLegacy(typeId));
|
||||
} catch (MaxChangedBlocksException ex) {
|
||||
return false;
|
||||
}
|
||||
@ -50,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
@Override
|
||||
public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
try {
|
||||
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId, data));
|
||||
return editSession.setBlock(new Vector(x, y, z), LegacyMapper.getInstance().getBlockFromLegacy(typeId, data));
|
||||
} catch (MaxChangedBlocksException ex) {
|
||||
return false;
|
||||
}
|
||||
@ -68,7 +67,8 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
|
||||
@Override
|
||||
public int getTypeId(int x, int y, int z) {
|
||||
return editSession.getBlock(new Vector(x, y, z)).getBlockType().getLegacyId();
|
||||
int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(editSession.getBlock(new Vector(x, y, z)));
|
||||
return datas[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user