Update favs

This commit is contained in:
Jesse Boyd
2018-08-23 06:02:04 +10:00
parent 9927cde616
commit f43faae917
178 changed files with 24721 additions and 32 deletions

View File

@ -26,6 +26,7 @@ import java.util.function.Supplier;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Location;
@ -237,7 +238,7 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
@Override
public int getCombinedId4Data(ChunkSnapshot chunk, int x, int y, int z) {
if (chunk.isSectionEmpty(y >> 4)) {
return 0;
return BlockTypes.AIR.getInternalId();
}
BlockData blockData = chunk.getBlockData(x & 15, y, z & 15);
return BukkitAdapter.adapt(blockData).getInternalId();

View File

@ -48,18 +48,30 @@ public class AsyncBlock implements Block {
return (byte) (queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId()) & 0xF);
}
public int getPropertyId() {
return (queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId()) >> BlockTypes.BIT_OFFSET);
}
public int getCombinedId() {
return queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId());
}
public int getTypeId() {
return (queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId()) & BlockTypes.BIT_MASK);
}
@Override
public Block getRelative(int modX, int modY, int modZ) {
public AsyncBlock getRelative(int modX, int modY, int modZ) {
return new AsyncBlock(world, queue, x + modX, y + modY, z + modZ);
}
@Override
public Block getRelative(BlockFace face) {
public AsyncBlock getRelative(BlockFace face) {
return this.getRelative(face.getModX(), face.getModY(), face.getModZ());
}
@Override
public Block getRelative(BlockFace face, int distance) {
public AsyncBlock getRelative(BlockFace face, int distance) {
return this.getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
}
@ -73,6 +85,31 @@ public class AsyncBlock implements Block {
return BukkitAdapter.getBlockData(queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId()));
}
@Deprecated
public boolean setTypeIdAndPropertyId(int id, int propertyId, boolean physics) {
return setTypeIdAndPropertyId(id, propertyId);
}
@Deprecated
public boolean setCombinedId(int combinedId) {
return queue.setBlock(x, y, z, combinedId);
}
@Deprecated
public boolean setTypeIdAndPropertyId(int id, int propertyId) {
return setCombinedId(id + (propertyId << BlockTypes.BIT_OFFSET));
}
@Deprecated
public boolean setTypeId(int typeId) {
return queue.setBlock(x, y, z, BlockTypes.get(typeId).getDefaultState());
}
@Deprecated
public boolean setPropertyId(int propertyId) {
return setTypeIdAndPropertyId(getTypeId(), propertyId);
}
@Override
public byte getLightLevel() {
return (byte) queue.getLight(x, y, z);
@ -89,7 +126,7 @@ public class AsyncBlock implements Block {
}
@Override
public World getWorld() {
public AsyncWorld getWorld() {
return world;
}
@ -125,7 +162,7 @@ public class AsyncBlock implements Block {
}
@Override
public Chunk getChunk() {
public AsyncChunk getChunk() {
return world.getChunkAt(x >> 4, z >> 4);
}
@ -170,7 +207,7 @@ public class AsyncBlock implements Block {
}
@Override
public BlockState getState() {
public AsyncBlockState getState() {
int combined = queue.getCombinedId4Data(x, y, z, 0);
BlockTypes type = BlockTypes.getFromStateId(combined);
switch (type) {
@ -182,7 +219,7 @@ public class AsyncBlock implements Block {
}
@Override
public BlockState getState(boolean useSnapshot) {
public AsyncBlockState getState(boolean useSnapshot) {
return getState();
}

View File

@ -38,6 +38,14 @@ public class AsyncBlockState implements BlockState {
}
}
public int getTypeId() {
return combinedId & BlockTypes.BIT_MASK;
}
public int getPropertyId() {
return combinedId >> BlockTypes.BIT_OFFSET;
}
@Override
public Block getBlock() {
return block;
@ -64,7 +72,7 @@ public class AsyncBlockState implements BlockState {
}
@Override
public World getWorld() {
public AsyncWorld getWorld() {
return block.world;
}
@ -152,7 +160,7 @@ public class AsyncBlockState implements BlockState {
@Override
public void setRawData(byte data) {
this.combinedId = (combinedId & BlockTypes.BIT_MASK) + data;
this.combinedId = (combinedId & BlockTypes.BIT_MASK) + (data << BlockTypes.BIT_OFFSET);
this.blockData = BukkitAdapter.getBlockData(this.combinedId);
}

View File

@ -52,12 +52,12 @@ public class AsyncChunk implements Chunk {
}
@Override
public World getWorld() {
public AsyncWorld getWorld() {
return world;
}
@Override
public Block getBlock(int x, int y, int z) {
public AsyncBlock getBlock(int x, int y, int z) {
return new AsyncBlock(world, queue, (this.x << 4) + x, y, (this.z << 4) + z);
}

View File

@ -258,12 +258,12 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
}
@Override
public Block getBlockAt(final int x, final int y, final int z) {
public AsyncBlock getBlockAt(final int x, final int y, final int z) {
return new AsyncBlock(this, queue, x, y, z);
}
@Override
public Block getBlockAt(Location loc) {
public AsyncBlock getBlockAt(Location loc) {
return getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
@ -283,28 +283,28 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
}
@Override
public Block getHighestBlockAt(int x, int z) {
public AsyncBlock getHighestBlockAt(int x, int z) {
int y = getHighestBlockYAt(x, z);
return getBlockAt(x, y, z);
}
@Override
public Block getHighestBlockAt(Location loc) {
public AsyncBlock getHighestBlockAt(Location loc) {
return getHighestBlockAt(loc.getBlockX(), loc.getBlockZ());
}
@Override
public Chunk getChunkAt(int x, int z) {
public AsyncChunk getChunkAt(int x, int z) {
return new AsyncChunk(this, queue, x, z);
}
@Override
public Chunk getChunkAt(Location location) {
public AsyncChunk getChunkAt(Location location) {
return getChunkAt(location.getBlockX(), location.getBlockZ());
}
@Override
public Chunk getChunkAt(Block block) {
public AsyncChunk getChunkAt(Block block) {
return getChunkAt(block.getX(), block.getZ());
}

View File

@ -36,6 +36,7 @@ public class CachedBukkitAdapter {
itemTypes[i] = ItemTypes.get(id);
}
}
blockDataCache[0] = new BlockData[] {Material.AIR.createBlockData()};
}
/**