mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
some hasty refactoring
This commit is contained in:
@ -0,0 +1,147 @@
|
||||
package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
||||
|
||||
import com.sk89q.util.ReflectionUtil;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
||||
|
||||
public class BlockMaterial_1_13 implements BlockMaterial {
|
||||
private final Block block;
|
||||
private final IBlockData defaultState;
|
||||
private final Material material;
|
||||
private final boolean isTranslucent;
|
||||
private final CraftBlockData craftBlockData;
|
||||
|
||||
public BlockMaterial_1_13(Block block) {
|
||||
this(block, block.getBlockData());
|
||||
}
|
||||
|
||||
public BlockMaterial_1_13(Block block, IBlockData defaultState) {
|
||||
this.block = block;
|
||||
this.defaultState = defaultState;
|
||||
this.material = defaultState.getMaterial();
|
||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||
this.isTranslucent = ReflectionUtil.getField(Block.class, block, "n");
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public IBlockData getState() {
|
||||
return defaultState;
|
||||
}
|
||||
|
||||
public CraftBlockData getCraftBlockData() {
|
||||
return craftBlockData;
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir() {
|
||||
return defaultState.isAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube() {
|
||||
return defaultState.g();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaque() {
|
||||
return material.f();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSource() {
|
||||
return defaultState.isPowerSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiquid() {
|
||||
return material.isLiquid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
return material.isBuildable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHardness() {
|
||||
return block.strength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getResistance() {
|
||||
return block.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSlipperiness() {
|
||||
return block.n();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue() {
|
||||
return defaultState.e();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightOpacity() {
|
||||
return isTranslucent() ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFragileWhenPushed() {
|
||||
return material.getPushReaction() == EnumPistonReaction.DESTROY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnpushable() {
|
||||
return material.getPushReaction() == EnumPistonReaction.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTicksRandomly() {
|
||||
return block.isTicking(defaultState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMovementBlocker() {
|
||||
return material.isSolid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBurnable() {
|
||||
return material.isBurnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToolRequired() {
|
||||
return !material.isAlwaysDestroyable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplacedDuringPlacement() {
|
||||
return material.isReplaceable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTranslucent() {
|
||||
return isTranslucent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainer() {
|
||||
return block instanceof ITileEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMapColor() {
|
||||
return material.i().rgb;
|
||||
}
|
||||
}
|
@ -17,80 +17,41 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.boydti.fawe.bukkit.adapter;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.jnbt.ByteArrayTag;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.DoubleTag;
|
||||
import com.sk89q.jnbt.EndTag;
|
||||
import com.sk89q.jnbt.FloatTag;
|
||||
import com.sk89q.jnbt.IntArrayTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.LongTag;
|
||||
import com.sk89q.jnbt.NBTConstants;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.CachedBukkitAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.registry.state.EnumProperty;
|
||||
import com.sk89q.worldedit.registry.state.IntegerProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.registry.state.*;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import net.minecraft.server.v1_13_R1.BiomeBase;
|
||||
import net.minecraft.server.v1_13_R1.Block;
|
||||
import net.minecraft.server.v1_13_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_13_R1.BlockStateBoolean;
|
||||
import net.minecraft.server.v1_13_R1.BlockStateDirection;
|
||||
import net.minecraft.server.v1_13_R1.BlockStateEnum;
|
||||
import net.minecraft.server.v1_13_R1.BlockStateInteger;
|
||||
import net.minecraft.server.v1_13_R1.BlockStateList;
|
||||
import net.minecraft.server.v1_13_R1.Entity;
|
||||
import net.minecraft.server.v1_13_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_13_R1.IBlockData;
|
||||
import net.minecraft.server.v1_13_R1.IBlockState;
|
||||
import net.minecraft.server.v1_13_R1.INamable;
|
||||
import net.minecraft.server.v1_13_R1.MinecraftKey;
|
||||
import net.minecraft.server.v1_13_R1.NBTBase;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagByte;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagByteArray;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagDouble;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagEnd;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagFloat;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagInt;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagIntArray;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagLong;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagShort;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagString;
|
||||
import net.minecraft.server.v1_13_R1.TileEntity;
|
||||
import net.minecraft.server.v1_13_R1.World;
|
||||
import net.minecraft.server.v1_13_R1.WorldServer;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
@ -98,25 +59,25 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public final class Spigot_v1_13_R1 implements BukkitImplAdapter<NBTBase> {
|
||||
public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements BukkitImplAdapter<NBTBase>{
|
||||
|
||||
private final Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
||||
|
||||
private final Field nbtListTagListField;
|
||||
private final Method nbtCreateTagMethod;
|
||||
|
||||
static {
|
||||
// A simple test
|
||||
if (!Bukkit.getServer().getClass().getName().endsWith("DummyServer")) CraftServer.class.cast(Bukkit.getServer());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Code that may break between versions of Minecraft
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
public Spigot_v1_13_R1() throws NoSuchFieldException, NoSuchMethodException {
|
||||
// A simple test
|
||||
if (!Bukkit.getServer().getClass().getName().endsWith("DummyServer")) CraftServer.class.cast(Bukkit.getServer());
|
||||
// test between 1.12 and 1.12.1 since md_5 didn't update revision numbers
|
||||
TileEntity.class.getDeclaredMethod("load", NBTTagCompound.class);
|
||||
|
||||
public Spigot_v1_13_R2() throws NoSuchFieldException, NoSuchMethodException {
|
||||
// The list of tags on an NBTTagList
|
||||
nbtListTagListField = NBTTagList.class.getDeclaredField("list");
|
||||
nbtListTagListField.setAccessible(true);
|
||||
@ -194,6 +155,22 @@ public final class Spigot_v1_13_R1 implements BukkitImplAdapter<NBTBase> {
|
||||
entity.save(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockType blockType) {
|
||||
return new BlockMaterial_1_13(getBlock(blockType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockState state) {
|
||||
BlockTypes type = state.getBlockType();
|
||||
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
||||
return new BlockMaterial_1_13(bs.getBlock(), bs);
|
||||
}
|
||||
|
||||
public Block getBlock(BlockType blockType) {
|
||||
return IRegistry.BLOCK.getOrDefault(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Code that is less likely to break
|
||||
// ------------------------------------------------------------------------
|
||||
@ -201,12 +178,12 @@ public final class Spigot_v1_13_R1 implements BukkitImplAdapter<NBTBase> {
|
||||
@Override
|
||||
public int getBiomeId(Biome biome) {
|
||||
BiomeBase mcBiome = CraftBlock.biomeToBiomeBase(biome);
|
||||
return mcBiome != null ? BiomeBase.a(mcBiome) : 0;
|
||||
return mcBiome != null ? IRegistry.BIOME.a(mcBiome) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int id) {
|
||||
BiomeBase mcBiome = BiomeBase.getBiome(id);
|
||||
BiomeBase mcBiome = IRegistry.BIOME.fromId(id);
|
||||
return CraftBlock.biomeBaseToBiome(mcBiome); // Defaults to ocean if it's an invalid ID
|
||||
}
|
||||
|
||||
@ -236,32 +213,62 @@ public final class Spigot_v1_13_R1 implements BukkitImplAdapter<NBTBase> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) {
|
||||
checkNotNull(location);
|
||||
checkNotNull(state);
|
||||
public boolean isChunkInUse(org.bukkit.Chunk chunk) {
|
||||
CraftChunk craftChunk = (CraftChunk) chunk;
|
||||
PlayerChunkMap chunkMap = ((WorldServer) craftChunk.getHandle().getWorld()).getPlayerChunkMap();
|
||||
return chunkMap.isChunkInUse(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
@Override
|
||||
public boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, BlockStateHolder state, boolean update) {
|
||||
CraftChunk craftChunk = (CraftChunk) chunk;
|
||||
Chunk nmsChunk = craftChunk.getHandle();
|
||||
World nmsWorld = nmsChunk.getWorld();
|
||||
|
||||
// Two pass update:
|
||||
// Note, this will notify blocks BEFORE the tile entity is set
|
||||
location.getBlock().setBlockData(BukkitAdapter.adapt(state), false);
|
||||
IBlockData blockData = ((BlockMaterial_1_13) state.getMaterial()).getState();
|
||||
ChunkSection[] sections = nmsChunk.getSections();
|
||||
int y4 = y >> 4;
|
||||
ChunkSection section = sections[y4];
|
||||
|
||||
// Copy NBT data for the block
|
||||
CompoundTag nativeTag = state.getNbtData();
|
||||
if (nativeTag != null) {
|
||||
// We will assume that the tile entity was created for us,
|
||||
// though we do not do this on the Forge version
|
||||
TileEntity tileEntity = craftWorld.getHandle().getTileEntity(new BlockPosition(x, y, z));
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) fromNative(nativeTag);
|
||||
tag.set("x", new NBTTagInt(x));
|
||||
tag.set("y", new NBTTagInt(y));
|
||||
tag.set("z", new NBTTagInt(z));
|
||||
readTagIntoTileEntity(tag, tileEntity); // Load data
|
||||
IBlockData existing;
|
||||
if (section == null) {
|
||||
existing = ((BlockMaterial_1_13) BlockTypes.AIR.getDefaultState().getMaterial()).getState();
|
||||
} else {
|
||||
existing = section.getType(x & 15, y & 15, z & 15);
|
||||
}
|
||||
BlockPosition pos = null;
|
||||
if (existing instanceof TileEntityBlock || blockData instanceof TileEntityBlock) {
|
||||
pos = new BlockPosition(x, y, z);
|
||||
nmsWorld.setTypeAndData(pos, blockData, 0);
|
||||
// remove tile
|
||||
CompoundTag nativeTag = state.getNbtData();
|
||||
if (nativeTag != null) {
|
||||
// We will assume that the tile entity was created for us,
|
||||
// though we do not do this on the Forge version
|
||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) fromNative(nativeTag);
|
||||
tag.set("x", new NBTTagInt(x));
|
||||
tag.set("y", new NBTTagInt(y));
|
||||
tag.set("z", new NBTTagInt(z));
|
||||
readTagIntoTileEntity(tag, tileEntity); // Load data
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (existing == blockData) return true;
|
||||
if (section == null) {
|
||||
if (blockData.isAir()) return true;
|
||||
sections[y4] = new ChunkSection(y4 << 4, nmsWorld.worldProvider.g());
|
||||
}
|
||||
if (existing.e() != blockData.e() || existing.getMaterial().f() != blockData.getMaterial().f()) {
|
||||
nmsChunk.a(pos = new BlockPosition(x, y, z), blockData, false);
|
||||
} else {
|
||||
section.setType(x & 15, y & 15, z & 15, blockData);
|
||||
}
|
||||
}
|
||||
if (update) {
|
||||
if (pos == null) pos = new BlockPosition(x, y, z);
|
||||
nmsWorld.getMinecraftWorld().notify(pos, existing, blockData, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -320,8 +327,9 @@ public final class Spigot_v1_13_R1 implements BukkitImplAdapter<NBTBase> {
|
||||
public Map<String, ? extends Property> getProperties(BlockType blockType) {
|
||||
Block block;
|
||||
try {
|
||||
block = Block.getByName(blockType.getId());
|
||||
block = IRegistry.BLOCK.getOrDefault(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
if (block == null) {
|
||||
@ -484,4 +492,36 @@ public final class Spigot_v1_13_R1 implements BukkitImplAdapter<NBTBase> {
|
||||
}
|
||||
}
|
||||
|
||||
private int[] idbToStateOrdinal;
|
||||
|
||||
private boolean init() {
|
||||
if (idbToStateOrdinal != null) return false;
|
||||
idbToStateOrdinal = new int[Block.REGISTRY_ID.a()]; // size
|
||||
for (int i = 0; i < idbToStateOrdinal.length; i++) {
|
||||
BlockState state = BlockTypes.states[i];
|
||||
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
|
||||
int id = Block.REGISTRY_ID.getId(material.getState());
|
||||
idbToStateOrdinal[id] = state.getOrdinal();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState adapt(BlockData blockData) {
|
||||
try {
|
||||
CraftBlockData cbd = ((CraftBlockData) blockData);
|
||||
IBlockData ibd = cbd.getState();
|
||||
int id = Block.REGISTRY_ID.getId(ibd);
|
||||
return BlockTypes.states[idbToStateOrdinal[id]];
|
||||
} catch (NullPointerException e) {
|
||||
if (init()) return adapt(blockData);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData adapt(BlockStateHolder state) {
|
||||
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
|
||||
return material.getCraftBlockData();
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -36,7 +38,7 @@ public class StructureCUI extends CUI {
|
||||
|
||||
private Vector remove;
|
||||
private NbtCompound removeTag;
|
||||
private int combined;
|
||||
private BlockState state;
|
||||
|
||||
public StructureCUI(FawePlayer player) {
|
||||
super(player);
|
||||
@ -151,7 +153,7 @@ public class StructureCUI extends CUI {
|
||||
map.put("sizeX", NbtFactory.of("sizeX", 0));
|
||||
sendNbt(remove, removeTag);
|
||||
Location removeLoc = new Location(player.getWorld(), remove.getX(), remove.getY(), remove.getZ());
|
||||
player.sendBlockChange(removeLoc, BukkitAdapter.getBlockData(combined));
|
||||
player.sendBlockChange(removeLoc, BukkitAdapter.adapt(state));
|
||||
}
|
||||
remove = null;
|
||||
}
|
||||
@ -186,7 +188,7 @@ public class StructureCUI extends CUI {
|
||||
|
||||
Block block = player.getWorld().getBlockAt(x, y, z);
|
||||
remove = new Vector(x, y, z);
|
||||
combined = BukkitAdapter.adapt(block.getBlockData()).getInternalId();
|
||||
state = BukkitAdapter.adapt(block.getBlockData());
|
||||
removeTag = compound;
|
||||
|
||||
Location blockLoc = new Location(player.getWorld(), x, y, z);
|
||||
|
@ -96,13 +96,13 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
boolean more = true;
|
||||
final BukkitQueue_All parent = (BukkitQueue_All) getParent();
|
||||
BukkitImplAdapter adapter = BukkitQueue_0.getAdapter();
|
||||
|
||||
final Chunk chunk = getChunk();
|
||||
Object[] disableResult = parent.disableLighting(chunk);
|
||||
final World world = chunk.getWorld();
|
||||
int[][] sections = getCombinedIdArrays();
|
||||
final int bx = getX() << 4;
|
||||
final int bz = getZ() << 4;
|
||||
boolean update = adapter != null ? adapter.isChunkInUse(chunk) : true;
|
||||
if (layer == -1) {
|
||||
if (adapter != null)
|
||||
{
|
||||
@ -241,7 +241,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
mutableLoc.setX(xx);
|
||||
mutableLoc.setY(yy);
|
||||
mutableLoc.setZ(zz);
|
||||
setBlock(adapter, mutableLoc, combined);
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
@ -249,25 +249,22 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
if (type.getMaterial().hasContainer() && adapter != null) {
|
||||
CompoundTag nbt = getTile(x, yy, z);
|
||||
if (nbt != null) {
|
||||
mutableLoc.setX(xx);
|
||||
mutableLoc.setY(yy);
|
||||
mutableLoc.setZ(zz);
|
||||
synchronized (BukkitChunk_All.this) {
|
||||
BaseBlock state = BaseBlock.getFromInternalId(combined, nbt);
|
||||
adapter.setBlock(mutableLoc, state, false);
|
||||
adapter.setBlock(chunk, xx, yy, zz, state, update);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (type.getMaterial().isTicksRandomly()) {
|
||||
synchronized (BukkitChunk_All.this) {
|
||||
setBlock(adapter, mutableLoc, combined);
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
} else {
|
||||
mutableLoc.setX(xx);
|
||||
mutableLoc.setY(yy);
|
||||
mutableLoc.setZ(zz);
|
||||
setBlock(adapter, mutableLoc, combined);
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@ -292,7 +289,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
mutableLoc.setX(bx + x);
|
||||
mutableLoc.setY(y);
|
||||
mutableLoc.setZ(bz + z);
|
||||
setBlock(adapter, mutableLoc, combined);
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -316,7 +313,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
if (tile != null) {
|
||||
synchronized (BukkitChunk_All.this) {
|
||||
BaseBlock state = BaseBlock.getFromInternalId(combined, tile);
|
||||
adapter.setBlock(new Location(world, bx + x, y, bz + z), state, false);
|
||||
adapter.setBlock(chunk, bx + x, y, bz + z, state, update);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -326,13 +323,13 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
mutableLoc.setX(bx + x);
|
||||
mutableLoc.setY(y);
|
||||
mutableLoc.setZ(bz + z);
|
||||
setBlock(adapter, mutableLoc, combined);
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
} else {
|
||||
mutableLoc.setX(bx + x);
|
||||
mutableLoc.setY(y);
|
||||
mutableLoc.setZ(bz + z);
|
||||
setBlock(adapter, mutableLoc, combined);
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
if (light) {
|
||||
parent.disableLighting(disableResult);
|
||||
@ -357,20 +354,13 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setBlock(BukkitImplAdapter adapter, Block block, BlockStateHolder state) {
|
||||
public void setBlock(BukkitImplAdapter adapter, Chunk chunk, Location location, int combinedId, boolean update) {
|
||||
com.sk89q.worldedit.world.block.BlockState state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combinedId);
|
||||
if (adapter != null) {
|
||||
adapter.setBlock(block.getLocation(), state, false);
|
||||
adapter.setBlock(chunk, (int) location.getX(), (int) location.getY(), (int) location.getZ(), state, update);
|
||||
} else {
|
||||
Block block = location.getWorld().getBlockAt(location);
|
||||
block.setBlockData(BukkitAdapter.adapt(state), false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlock(BukkitImplAdapter adapter, Location location, int combinedId) {
|
||||
if (adapter != null) {
|
||||
adapter.setBlock(location, com.sk89q.worldedit.world.block.BlockState.get(combinedId), false);
|
||||
} else {
|
||||
Block block = location.getWorld().getBlockAt(location);
|
||||
block.setBlockData(BukkitAdapter.getBlockData(combinedId), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@ -392,7 +391,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
Location loc = new Location(world, bx + localX, y, bz + localZ);
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
if (send[i]) {
|
||||
((BukkitPlayer) players[i]).parent.sendBlockChange(loc, BukkitAdapter.adapt(BlockState.get(combined)));
|
||||
((BukkitPlayer) players[i]).parent.sendBlockChange(loc, BukkitAdapter.adapt(BlockState.getFromInternalId(combined)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.v0;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.example.NullRelighter;
|
||||
@ -22,7 +20,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -32,7 +29,6 @@ import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot, ChunkSnapshot> {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.wrapper;
|
||||
|
||||
import com.bekvon.bukkit.residence.commands.tool;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.wrapper.state.AsyncSign;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
@ -8,18 +7,14 @@ import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.PistonMoveReaction;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.boydti.fawe.bukkit.wrapper;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
@ -16,7 +14,6 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -270,9 +267,9 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
@Override
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
for (int y = getMaxHeight() - 1; y >= 0; y--) {
|
||||
if (queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId()) != 0) {
|
||||
return y;
|
||||
}
|
||||
int stateId = queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId());
|
||||
BlockTypes type = BlockTypes.getFromStateId(stateId);
|
||||
if (!type.getMaterial().isAir()) return y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -308,6 +305,11 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
return getChunkAt(block.getX(), block.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkGenerated(int x, int z) {
|
||||
return parent.isChunkGenerated(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getChunkAtAsync(int x, int z, ChunkLoadCallback cb) {
|
||||
parent.getChunkAtAsync(x, z, cb);
|
||||
|
Reference in New Issue
Block a user