mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-29 12:37:53 +01:00
Some minor fixes
This commit is contained in:
parent
7df6f2d54f
commit
e16bcae071
@ -31,6 +31,27 @@ public class BukkitChunk_All extends CharFaweChunk<Chunk, BukkitQueue_All> {
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BukkitChunk_All(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
|
BukkitChunk_All copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new BukkitChunk_All(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new BukkitChunk_All(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk getNewChunk() {
|
public Chunk getNewChunk() {
|
||||||
return Bukkit.getWorld(getParent().getWorldName()).getChunkAt(getX(), getZ());
|
return Bukkit.getWorld(getParent().getWorldName()).getChunkAt(getX(), getZ());
|
||||||
|
@ -38,7 +38,7 @@ public class BukkitQueue_All extends BukkitQueue_0<Chunk, Chunk, Chunk> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,219 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.WorldVector;
|
||||||
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
|
import com.sk89q.worldedit.session.SessionKey;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
public class BukkitCommandSender_unused_for_now extends AbstractPlayerActor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One time generated ID.
|
||||||
|
*/
|
||||||
|
private static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be");
|
||||||
|
|
||||||
|
private CommandSender player;
|
||||||
|
private WorldEditPlugin plugin;
|
||||||
|
|
||||||
|
public BukkitCommandSender_unused_for_now(WorldEditPlugin plugin, CommandSender sender) {
|
||||||
|
checkNotNull(plugin);
|
||||||
|
checkNotNull(sender);
|
||||||
|
checkArgument(!(sender instanceof Player), "Cannot wrap a player");
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.player = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUniqueId() {
|
||||||
|
return DEFAULT_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printRaw(String msg) {
|
||||||
|
for (String part : msg.split("\n")) {
|
||||||
|
player.sendMessage(part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void print(String msg) {
|
||||||
|
for (String part : msg.split("\n")) {
|
||||||
|
player.sendMessage("\u00A7d" + part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printDebug(String msg) {
|
||||||
|
for (String part : msg.split("\n")) {
|
||||||
|
player.sendMessage("\u00A77" + part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printError(String msg) {
|
||||||
|
for (String part : msg.split("\n")) {
|
||||||
|
player.sendMessage("\u00A7c" + part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDestroyBedrock() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getGroups() {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(String perm) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkPermission(String permission) throws AuthorizationException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPlayer() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File openFileOpenDialog(String[] extensions) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File openFileSaveDialog(String[] extensions) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispatchCUIEvent(CUIEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SessionKey getSessionKey() {
|
||||||
|
return new SessionKey() {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPersistent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUniqueId() {
|
||||||
|
return DEFAULT_ID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public World getWorld() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemInHand() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void giveItem(int type, int amount) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockBag getInventoryBlockBag() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorldVector getPosition() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getPitch() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getYaw() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BaseEntity getState() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public <T> T getFacet(Class<? extends T> cls) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -10,12 +10,35 @@ import com.boydti.fawe.object.FaweQueue;
|
|||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.sk89q.jnbt.*;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.ListTag;
|
||||||
|
import com.sk89q.jnbt.LongTag;
|
||||||
|
import com.sk89q.jnbt.StringTag;
|
||||||
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.internal.Constants;
|
import com.sk89q.worldedit.internal.Constants;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import net.minecraft.server.v1_10_R1.*;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import net.minecraft.server.v1_10_R1.Block;
|
||||||
|
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_10_R1.ChunkSection;
|
||||||
|
import net.minecraft.server.v1_10_R1.DataBits;
|
||||||
|
import net.minecraft.server.v1_10_R1.DataPalette;
|
||||||
|
import net.minecraft.server.v1_10_R1.DataPaletteBlock;
|
||||||
|
import net.minecraft.server.v1_10_R1.DataPaletteGlobal;
|
||||||
|
import net.minecraft.server.v1_10_R1.Entity;
|
||||||
|
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_10_R1.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_10_R1.TileEntity;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
|
||||||
@ -36,16 +59,26 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public BukkitChunk_1_10(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
public Chunk getNewChunk() {
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
return ((com.boydti.fawe.bukkit.v1_10.BukkitQueue_1_10) getParent()).getWorld().getChunkAt(getX(), getZ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharFaweChunk<Chunk, BukkitQueue_1_10> copy(boolean shallow) {
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
BukkitChunk_1_10 value = (BukkitChunk_1_10) super.copy(shallow);
|
BukkitChunk_1_10 copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new BukkitChunk_1_10(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new BukkitChunk_1_10(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
if (sectionPalettes != null) {
|
if (sectionPalettes != null) {
|
||||||
value.sectionPalettes = new DataPaletteBlock[16];
|
copy.sectionPalettes = new DataPaletteBlock[16];
|
||||||
try {
|
try {
|
||||||
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
||||||
fieldBits.setAccessible(true);
|
fieldBits.setAccessible(true);
|
||||||
@ -83,13 +116,18 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
|
|||||||
field.set(newBits, currentValue);
|
field.set(newBits, currentValue);
|
||||||
}
|
}
|
||||||
fieldBits.set(paletteBlock, newBits);
|
fieldBits.set(paletteBlock, newBits);
|
||||||
value.sectionPalettes[i] = paletteBlock;
|
copy.sectionPalettes[i] = paletteBlock;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getNewChunk() {
|
||||||
|
return ((com.boydti.fawe.bukkit.v1_10.BukkitQueue_1_10) getParent()).getWorld().getChunkAt(getX(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataPaletteBlock newDataPaletteBlock() {
|
public DataPaletteBlock newDataPaletteBlock() {
|
||||||
@ -152,6 +190,8 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
|
|||||||
Class<? extends net.minecraft.server.v1_10_R1.Chunk> clazzChunk = nmsChunk.getClass();
|
Class<? extends net.minecraft.server.v1_10_R1.Chunk> clazzChunk = nmsChunk.getClass();
|
||||||
final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk);
|
final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk);
|
||||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < entities.length; i++) {
|
for (int i = 0; i < entities.length; i++) {
|
||||||
int count = this.getCount(i);
|
int count = this.getCount(i);
|
||||||
|
@ -81,13 +81,14 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
if (craftChunk != null) {
|
if (craftChunk != null) {
|
||||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,7 +289,7 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
}
|
}
|
||||||
// Send chunks
|
// Send chunks
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
||||||
for (EntityPlayer player : playerChunk.c) {
|
for (EntityPlayer player : playerChunk.c) {
|
||||||
player.playerConnection.sendPacket(packet);
|
player.playerConnection.sendPacket(packet);
|
||||||
@ -429,7 +430,7 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
BukkitChunk_1_10 previous = getFaweChunk(fs.getX(), fs.getZ());
|
BukkitChunk_1_10 previous = getFaweChunk(fs.getX(), fs.getZ());
|
||||||
// Copy blocks
|
// Copy blocks
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ChunkSection section = sections[layer];
|
ChunkSection section = sections[layer];
|
||||||
@ -459,7 +460,6 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
// Copy tiles
|
// Copy tiles
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
||||||
|
@ -62,16 +62,26 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public BukkitChunk_1_11(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
public Chunk getNewChunk() {
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
return ((com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11) getParent()).getWorld().getChunkAt(getX(), getZ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharFaweChunk<Chunk, com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11> copy(boolean shallow) {
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
BukkitChunk_1_11 value = (BukkitChunk_1_11) super.copy(shallow);
|
BukkitChunk_1_11 copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new BukkitChunk_1_11(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new BukkitChunk_1_11(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
if (sectionPalettes != null) {
|
if (sectionPalettes != null) {
|
||||||
value.sectionPalettes = new DataPaletteBlock[16];
|
copy.sectionPalettes = new DataPaletteBlock[16];
|
||||||
try {
|
try {
|
||||||
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
||||||
fieldBits.setAccessible(true);
|
fieldBits.setAccessible(true);
|
||||||
@ -109,13 +119,18 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
|||||||
field.set(newBits, currentValue);
|
field.set(newBits, currentValue);
|
||||||
}
|
}
|
||||||
fieldBits.set(paletteBlock, newBits);
|
fieldBits.set(paletteBlock, newBits);
|
||||||
value.sectionPalettes[i] = paletteBlock;
|
copy.sectionPalettes[i] = paletteBlock;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getNewChunk() {
|
||||||
|
return ((com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11) getParent()).getWorld().getChunkAt(getX(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataPaletteBlock newDataPaletteBlock() {
|
public DataPaletteBlock newDataPaletteBlock() {
|
||||||
@ -178,6 +193,8 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
|||||||
Class<? extends net.minecraft.server.v1_11_R1.Chunk> clazzChunk = nmsChunk.getClass();
|
Class<? extends net.minecraft.server.v1_11_R1.Chunk> clazzChunk = nmsChunk.getClass();
|
||||||
final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk);
|
final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk);
|
||||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < entities.length; i++) {
|
for (int i = 0; i < entities.length; i++) {
|
||||||
int count = this.getCount(i);
|
int count = this.getCount(i);
|
||||||
|
@ -55,13 +55,14 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
if (craftChunk != null) {
|
if (craftChunk != null) {
|
||||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,7 +263,7 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
}
|
}
|
||||||
// Send chunks
|
// Send chunks
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
||||||
for (EntityPlayer player : playerChunk.c) {
|
for (EntityPlayer player : playerChunk.c) {
|
||||||
player.playerConnection.sendPacket(packet);
|
player.playerConnection.sendPacket(packet);
|
||||||
@ -403,7 +404,7 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
BukkitChunk_1_11 previous = getFaweChunk(fs.getX(), fs.getZ());
|
BukkitChunk_1_11 previous = getFaweChunk(fs.getX(), fs.getZ());
|
||||||
// Copy blocks
|
// Copy blocks
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ChunkSection section = sections[layer];
|
ChunkSection section = sections[layer];
|
||||||
@ -433,7 +434,6 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
// Copy tiles
|
// Copy tiles
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
||||||
|
@ -43,8 +43,8 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
|||||||
return Bukkit.getWorld(getParent().getWorldName()).getChunkAt(getX(), getZ());
|
return Bukkit.getWorld(getParent().getWorldName()).getChunkAt(getX(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[][] byteIds;
|
public final byte[][] byteIds;
|
||||||
public NibbleArray[] datas;
|
public final NibbleArray[] datas;
|
||||||
|
|
||||||
public BukkitChunk_1_7(FaweQueue parent, int x, int z) {
|
public BukkitChunk_1_7(FaweQueue parent, int x, int z) {
|
||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
@ -52,6 +52,29 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
|||||||
this.datas = new NibbleArray[16];
|
this.datas = new NibbleArray[16];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BukkitChunk_1_7(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap, byte[][] byteIds, NibbleArray[] datas) {
|
||||||
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
|
this.byteIds = byteIds;
|
||||||
|
this.datas = datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
|
BukkitChunk_1_7 copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new BukkitChunk_1_7(getParent(), getX(), getZ(), ids, count, air, relight, heightMap, byteIds, datas);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new BukkitChunk_1_7(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone(), (byte[][]) MainUtil.copyNd(byteIds), datas.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] getByteIdArray(int i) {
|
public byte[] getByteIdArray(int i) {
|
||||||
return this.byteIds[i];
|
return this.byteIds[i];
|
||||||
}
|
}
|
||||||
@ -114,29 +137,6 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BukkitChunk_1_7 copy(boolean shallow) {
|
|
||||||
BukkitChunk_1_7 copy = new BukkitChunk_1_7(getParent(), getX(), getZ());
|
|
||||||
if (shallow) {
|
|
||||||
copy.byteIds = byteIds;
|
|
||||||
copy.datas = datas;
|
|
||||||
copy.air = air;
|
|
||||||
copy.biomes = biomes;
|
|
||||||
copy.chunk = chunk;
|
|
||||||
copy.count = count;
|
|
||||||
copy.relight = relight;
|
|
||||||
} else {
|
|
||||||
copy.byteIds = (byte[][]) MainUtil.copyNd(byteIds);
|
|
||||||
copy.datas = datas.clone();
|
|
||||||
copy.air = air.clone();
|
|
||||||
copy.biomes = biomes.clone();
|
|
||||||
copy.chunk = chunk;
|
|
||||||
copy.count = count.clone();
|
|
||||||
copy.relight = relight.clone();
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
getChunk().load(true);
|
getChunk().load(true);
|
||||||
@ -155,7 +155,8 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
|||||||
ChunkSection[] sections = nmsChunk.getSections();
|
ChunkSection[] sections = nmsChunk.getSections();
|
||||||
Map<ChunkPosition, TileEntity> tiles = nmsChunk.tileEntities;
|
Map<ChunkPosition, TileEntity> tiles = nmsChunk.tileEntities;
|
||||||
Collection<Entity>[] entities = nmsChunk.entitySlices;
|
Collection<Entity>[] entities = nmsChunk.entitySlices;
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
int count = this.getCount(i);
|
int count = this.getCount(i);
|
||||||
|
@ -87,13 +87,14 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
if (craftChunk != null) {
|
if (craftChunk != null) {
|
||||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,7 +166,6 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
|||||||
Map<ChunkPosition, TileEntity> tiles = (Map<ChunkPosition, TileEntity>) tilesGeneric;
|
Map<ChunkPosition, TileEntity> tiles = (Map<ChunkPosition, TileEntity>) tilesGeneric;
|
||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ChunkSection section = sections[layer];
|
ChunkSection section = sections[layer];
|
||||||
@ -184,7 +184,6 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<ChunkPosition, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<ChunkPosition, TileEntity> entry : tiles.entrySet()) {
|
||||||
TileEntity tile = entry.getValue();
|
TileEntity tile = entry.getValue();
|
||||||
@ -298,7 +297,7 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
|||||||
}
|
}
|
||||||
// Send chunks
|
// Send chunks
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, 65280, 5);
|
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, 65280, 5);
|
||||||
for (EntityPlayer player : players) {
|
for (EntityPlayer player : players) {
|
||||||
player.playerConnection.sendPacket(packet);
|
player.playerConnection.sendPacket(packet);
|
||||||
|
@ -46,6 +46,27 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BukkitChunk_1_8(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
|
BukkitChunk_1_8 copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new BukkitChunk_1_8(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new BukkitChunk_1_8(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk getNewChunk() {
|
public Chunk getNewChunk() {
|
||||||
return Bukkit.getWorld(getParent().getWorldName()).getChunkAt(getX(), getZ());
|
return Bukkit.getWorld(getParent().getWorldName()).getChunkAt(getX(), getZ());
|
||||||
@ -69,7 +90,8 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
|
|||||||
ChunkSection[] sections = nmsChunk.getSections();
|
ChunkSection[] sections = nmsChunk.getSections();
|
||||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||||
Collection<Entity>[] entities = nmsChunk.getEntitySlices();
|
Collection<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
int count = this.getCount(i);
|
int count = this.getCount(i);
|
||||||
|
@ -85,13 +85,14 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
if (craftChunk != null) {
|
if (craftChunk != null) {
|
||||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +161,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
|||||||
Map<BlockPosition, TileEntity> tiles = (Map<BlockPosition, TileEntity>) tilesGeneric;
|
Map<BlockPosition, TileEntity> tiles = (Map<BlockPosition, TileEntity>) tilesGeneric;
|
||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ChunkSection section = sections[layer];
|
ChunkSection section = sections[layer];
|
||||||
@ -177,7 +178,6 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
||||||
TileEntity tile = entry.getValue();
|
TileEntity tile = entry.getValue();
|
||||||
@ -286,7 +286,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
|||||||
}
|
}
|
||||||
// Send chunks
|
// Send chunks
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, 65280);
|
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, 65280);
|
||||||
for (EntityPlayer player : players) {
|
for (EntityPlayer player : players) {
|
||||||
player.playerConnection.sendPacket(packet);
|
player.playerConnection.sendPacket(packet);
|
||||||
|
@ -10,12 +10,36 @@ import com.boydti.fawe.object.FaweQueue;
|
|||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.sk89q.jnbt.*;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.ListTag;
|
||||||
|
import com.sk89q.jnbt.LongTag;
|
||||||
|
import com.sk89q.jnbt.StringTag;
|
||||||
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.internal.Constants;
|
import com.sk89q.worldedit.internal.Constants;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import net.minecraft.server.v1_9_R2.*;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import net.minecraft.server.v1_9_R2.Block;
|
||||||
|
import net.minecraft.server.v1_9_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_9_R2.Blocks;
|
||||||
|
import net.minecraft.server.v1_9_R2.ChunkSection;
|
||||||
|
import net.minecraft.server.v1_9_R2.DataBits;
|
||||||
|
import net.minecraft.server.v1_9_R2.DataPalette;
|
||||||
|
import net.minecraft.server.v1_9_R2.DataPaletteBlock;
|
||||||
|
import net.minecraft.server.v1_9_R2.DataPaletteGlobal;
|
||||||
|
import net.minecraft.server.v1_9_R2.Entity;
|
||||||
|
import net.minecraft.server.v1_9_R2.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_9_R2.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_9_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_9_R2.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_9_R2.TileEntity;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -37,16 +61,26 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public BukkitChunk_1_9(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
public Chunk getNewChunk() {
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
return ((BukkitQueue_1_9_R1) getParent()).getWorld().getChunkAt(getX(), getZ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BukkitChunk_1_9 copy(boolean shallow) {
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
BukkitChunk_1_9 value = (BukkitChunk_1_9) super.copy(shallow);
|
BukkitChunk_1_9 copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new BukkitChunk_1_9(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new BukkitChunk_1_9(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
if (sectionPalettes != null) {
|
if (sectionPalettes != null) {
|
||||||
value.sectionPalettes = new DataPaletteBlock[16];
|
copy.sectionPalettes = new DataPaletteBlock[16];
|
||||||
try {
|
try {
|
||||||
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
||||||
fieldBits.setAccessible(true);
|
fieldBits.setAccessible(true);
|
||||||
@ -84,13 +118,18 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
|
|||||||
field.set(newBits, currentValue);
|
field.set(newBits, currentValue);
|
||||||
}
|
}
|
||||||
fieldBits.set(paletteBlock, newBits);
|
fieldBits.set(paletteBlock, newBits);
|
||||||
value.sectionPalettes[i] = paletteBlock;
|
copy.sectionPalettes[i] = paletteBlock;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getNewChunk() {
|
||||||
|
return ((BukkitQueue_1_9_R1) getParent()).getWorld().getChunkAt(getX(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataPaletteBlock newDataPaletteBlock() {
|
public DataPaletteBlock newDataPaletteBlock() {
|
||||||
@ -154,6 +193,8 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
|
|||||||
final Field ef = clazzChunk.getDeclaredField("entitySlices");
|
final Field ef = clazzChunk.getDeclaredField("entitySlices");
|
||||||
final Collection<Entity>[] entities = (Collection<Entity>[]) ef.get(nmsChunk);
|
final Collection<Entity>[] entities = (Collection<Entity>[]) ef.get(nmsChunk);
|
||||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < entities.length; i++) {
|
for (int i = 0; i < entities.length; i++) {
|
||||||
int count = this.getCount(i);
|
int count = this.getCount(i);
|
||||||
|
@ -97,13 +97,14 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
if (craftChunk != null) {
|
if (craftChunk != null) {
|
||||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +155,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
|||||||
}
|
}
|
||||||
// Send chunks
|
// Send chunks
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
||||||
for (EntityPlayer player : playerChunk.c) {
|
for (EntityPlayer player : playerChunk.c) {
|
||||||
player.playerConnection.sendPacket(packet);
|
player.playerConnection.sendPacket(packet);
|
||||||
@ -381,7 +382,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
|||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
// Copy blocks
|
// Copy blocks
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ChunkSection section = sections[layer];
|
ChunkSection section = sections[layer];
|
||||||
@ -411,7 +412,6 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
// Copy tiles
|
// Copy tiles
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
||||||
|
@ -652,8 +652,26 @@ public class FaweCache {
|
|||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178:
|
case 178:
|
||||||
|
case 209:
|
||||||
case 210:
|
case 210:
|
||||||
case 211:
|
case 211:
|
||||||
|
case 255:
|
||||||
|
case 219:
|
||||||
|
case 220:
|
||||||
|
case 221:
|
||||||
|
case 222:
|
||||||
|
case 223:
|
||||||
|
case 224:
|
||||||
|
case 225:
|
||||||
|
case 226:
|
||||||
|
case 227:
|
||||||
|
case 228:
|
||||||
|
case 229:
|
||||||
|
case 230:
|
||||||
|
case 231:
|
||||||
|
case 232:
|
||||||
|
case 233:
|
||||||
|
case 234:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.FaweCache;
|
|||||||
import com.boydti.fawe.object.BytePair;
|
import com.boydti.fawe.object.BytePair;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
@ -17,21 +16,28 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T> {
|
public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T> {
|
||||||
|
|
||||||
public char[][] ids;
|
public final char[][] ids;
|
||||||
public short[] count;
|
public final short[] count;
|
||||||
public short[] air;
|
public final short[] air;
|
||||||
public short[] relight;
|
public final short[] relight;
|
||||||
|
public final byte[] heightMap;
|
||||||
|
|
||||||
public int[][] biomes;
|
public int[][] biomes;
|
||||||
private int bitMask = -1;
|
|
||||||
|
|
||||||
public HashMap<BytePair, CompoundTag> tiles;
|
public HashMap<BytePair, CompoundTag> tiles;
|
||||||
|
|
||||||
public HashSet<CompoundTag> entities;
|
public HashSet<CompoundTag> entities;
|
||||||
|
|
||||||
public HashSet<UUID> entityRemoves;
|
public HashSet<UUID> entityRemoves;
|
||||||
|
|
||||||
public T chunk;
|
public T chunk;
|
||||||
|
|
||||||
|
public CharFaweChunk(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
|
super(parent, x, z);
|
||||||
|
this.ids = ids;
|
||||||
|
this.count = count;
|
||||||
|
this.air = air;
|
||||||
|
this.relight = relight;
|
||||||
|
this.heightMap = heightMap;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
||||||
*
|
*
|
||||||
@ -45,6 +51,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
|||||||
this.count = new short[HEIGHT >> 4];
|
this.count = new short[HEIGHT >> 4];
|
||||||
this.air = new short[HEIGHT >> 4];
|
this.air = new short[HEIGHT >> 4];
|
||||||
this.relight = new short[HEIGHT >> 4];
|
this.relight = new short[HEIGHT >> 4];
|
||||||
|
this.heightMap = new byte[256];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -117,21 +124,15 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBitMask() {
|
public int getBitMask() {
|
||||||
if (bitMask == -1) {
|
int bitMask = 0;
|
||||||
this.bitMask = 0;
|
|
||||||
for (int section = 0; section < ids.length; section++) {
|
for (int section = 0; section < ids.length; section++) {
|
||||||
if (ids[section] != null) {
|
if (ids[section] != null) {
|
||||||
bitMask += 1 << section;
|
bitMask += 1 << section;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return bitMask;
|
return bitMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBitMask(int value) {
|
|
||||||
this.bitMask = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the raw data for a section
|
* Get the raw data for a section
|
||||||
* @param i
|
* @param i
|
||||||
@ -247,6 +248,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
|||||||
this.relight[i]++;
|
this.relight[i]++;
|
||||||
default:
|
default:
|
||||||
vs[j] = (char) (id << 4);
|
vs[j] = (char) (id << 4);
|
||||||
|
heightMap[z << 4 | x] = (byte) y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,6 +334,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
|||||||
case 191:
|
case 191:
|
||||||
case 192:
|
case 192:
|
||||||
vs[j] = (char) (id << 4);
|
vs[j] = (char) (id << 4);
|
||||||
|
heightMap[z << 4 | x] = (byte) y;
|
||||||
return;
|
return;
|
||||||
case 130:
|
case 130:
|
||||||
case 76:
|
case 76:
|
||||||
@ -346,6 +349,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
|||||||
case 68: // removed
|
case 68: // removed
|
||||||
default:
|
default:
|
||||||
vs[j] = (char) ((id << 4) + data);
|
vs[j] = (char) ((id << 4) + data);
|
||||||
|
heightMap[z << 4 | x] = (byte) y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,23 +367,5 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharFaweChunk<T, V> copy(boolean shallow) {
|
public abstract CharFaweChunk<T, V> copy(boolean shallow);
|
||||||
CharFaweChunk<T, V> copy = (CharFaweChunk<T, V>) getParent().getFaweChunk(getX(), getZ());
|
|
||||||
if (shallow) {
|
|
||||||
copy.ids = ids;
|
|
||||||
copy.air = air;
|
|
||||||
copy.biomes = biomes;
|
|
||||||
copy.chunk = chunk;
|
|
||||||
copy.count = count;
|
|
||||||
copy.relight = relight;
|
|
||||||
} else {
|
|
||||||
copy.ids = (char[][]) MainUtil.copyNd(ids);
|
|
||||||
copy.air = air.clone();
|
|
||||||
copy.biomes = biomes.clone();
|
|
||||||
copy.chunk = chunk;
|
|
||||||
copy.count = count.clone();
|
|
||||||
copy.relight = relight.clone();
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
|||||||
refreshChunk(fc);
|
refreshChunk(fc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void setHeightMap(FaweChunk chunk, int[] heightMap);
|
public abstract void setHeightMap(FaweChunk chunk, byte[] heightMap);
|
||||||
|
|
||||||
public abstract void setFullbright(CHUNKSECTION sections);
|
public abstract void setFullbright(CHUNKSECTION sections);
|
||||||
|
|
||||||
|
@ -3,9 +3,7 @@ package com.boydti.fawe.example;
|
|||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@ -130,21 +128,8 @@ public class NMSRelighter {
|
|||||||
for (Map.Entry<Long, RelightSkyEntry> entry : skyToRelight.entrySet()) {
|
for (Map.Entry<Long, RelightSkyEntry> entry : skyToRelight.entrySet()) {
|
||||||
RelightSkyEntry chunk = entry.getValue();
|
RelightSkyEntry chunk = entry.getValue();
|
||||||
CharFaweChunk fc = (CharFaweChunk) queue.getFaweChunk(chunk.x, chunk.z);
|
CharFaweChunk fc = (CharFaweChunk) queue.getFaweChunk(chunk.x, chunk.z);
|
||||||
fcs.put(fc, chunk.heightMap);
|
|
||||||
fc.setBitMask(chunk.bitmask);
|
|
||||||
queue.sendChunk(fc);
|
queue.sendChunk(fc);
|
||||||
}
|
}
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
|
||||||
@Override
|
|
||||||
public void run(Object value) {
|
|
||||||
for (Map.Entry<FaweChunk, int[]> entry : fcs.entrySet()) {
|
|
||||||
FaweChunk chunk = entry.getKey();
|
|
||||||
if (queue.isChunkLoaded(chunk.getX(), chunk.getZ())) {
|
|
||||||
queue.setHeightMap(chunk, entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTransparent(int x, int y, int z) {
|
private boolean isTransparent(int x, int y, int z) {
|
||||||
@ -248,7 +233,6 @@ public class NMSRelighter {
|
|||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
if (opacity > 1) {
|
if (opacity > 1) {
|
||||||
chunk.heightMap[z << 4 | x] = y;
|
|
||||||
value -= opacity;
|
value -= opacity;
|
||||||
mask[j] = value;
|
mask[j] = value;
|
||||||
}
|
}
|
||||||
@ -347,7 +331,6 @@ public class NMSRelighter {
|
|||||||
public final int x;
|
public final int x;
|
||||||
public final int z;
|
public final int z;
|
||||||
public final byte[] mask;
|
public final byte[] mask;
|
||||||
public int[] heightMap = new int[256];
|
|
||||||
public final boolean[] fix;
|
public final boolean[] fix;
|
||||||
public int bitmask;
|
public int bitmask;
|
||||||
public boolean smooth;
|
public boolean smooth;
|
||||||
|
@ -163,13 +163,14 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
MCAChunk mca = (MCAChunk) chunk;
|
MCAChunk mca = (MCAChunk) chunk;
|
||||||
if (mca != null) {
|
if (mca != null) {
|
||||||
int[] otherMap = mca.getHeightMapArray();
|
int[] otherMap = mca.getHeightMapArray();
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,26 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
|||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178:
|
case 178:
|
||||||
|
case 209:
|
||||||
|
case 210:
|
||||||
|
case 211:
|
||||||
|
case 255:
|
||||||
|
case 219:
|
||||||
|
case 220:
|
||||||
|
case 221:
|
||||||
|
case 222:
|
||||||
|
case 223:
|
||||||
|
case 224:
|
||||||
|
case 225:
|
||||||
|
case 226:
|
||||||
|
case 227:
|
||||||
|
case 228:
|
||||||
|
case 229:
|
||||||
|
case 230:
|
||||||
|
case 231:
|
||||||
|
case 232:
|
||||||
|
case 233:
|
||||||
|
case 234:
|
||||||
// Tile
|
// Tile
|
||||||
return queue.setBlock(x, y, z, id, (byte) block.getData(), block.getNbtData());
|
return queue.setBlock(x, y, z, id, (byte) block.getData(), block.getNbtData());
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class MemUtil {
|
public class MemUtil {
|
||||||
@ -42,8 +42,8 @@ public class MemUtil {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BlockingQueue<Runnable> memoryLimitedTasks = new LinkedBlockingQueue<>();
|
private static Queue<Runnable> memoryLimitedTasks = new ConcurrentLinkedQueue<>();
|
||||||
private static BlockingQueue<Runnable> memoryPlentifulTasks = new LinkedBlockingQueue<>();
|
private static Queue<Runnable> memoryPlentifulTasks = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
public static void addMemoryLimitedTask(Runnable run) {
|
public static void addMemoryLimitedTask(Runnable run) {
|
||||||
if (run != null)
|
if (run != null)
|
||||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.config.BBC;
|
|||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.object.extent.NullExtent;
|
import com.boydti.fawe.object.extent.NullExtent;
|
||||||
import com.boydti.fawe.regions.FaweMask;
|
import com.boydti.fawe.regions.FaweMask;
|
||||||
@ -73,14 +72,10 @@ public class WEManager {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RegionWrapper[] getMask(final FawePlayer<?> player, FaweMaskManager.MaskType type) {
|
public RegionWrapper[] getMask(final FawePlayer<?> player, FaweMaskManager.MaskType type) {
|
||||||
// HashSet<RegionWrapper> mask = TaskManager.IMP.sync(new RunnableVal<HashSet<RegionWrapper>>() {
|
|
||||||
if (player.hasPermission("fawe.bypass") || !Settings.REGION_RESTRICTIONS) {
|
if (player.hasPermission("fawe.bypass") || !Settings.REGION_RESTRICTIONS) {
|
||||||
return new RegionWrapper[] {new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE)};
|
return new RegionWrapper[] {new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE)};
|
||||||
}
|
}
|
||||||
HashSet<RegionWrapper> mask = new RunnableVal<HashSet<RegionWrapper>>() {
|
HashSet<RegionWrapper> mask = new HashSet<>();
|
||||||
@Override
|
|
||||||
public void run(HashSet<RegionWrapper> ignore) {
|
|
||||||
this.value = new HashSet<>();
|
|
||||||
String world = player.getLocation().world;
|
String world = player.getLocation().world;
|
||||||
if (!world.equals(player.getMeta("lastMaskWorld"))) {
|
if (!world.equals(player.getMeta("lastMaskWorld"))) {
|
||||||
player.deleteMeta("lastMaskWorld");
|
player.deleteMeta("lastMaskWorld");
|
||||||
@ -89,22 +84,13 @@ public class WEManager {
|
|||||||
player.setMeta("lastMaskWorld", world);
|
player.setMeta("lastMaskWorld", world);
|
||||||
for (final FaweMaskManager manager : managers) {
|
for (final FaweMaskManager manager : managers) {
|
||||||
if (player.hasPermission("fawe." + manager.getKey())) {
|
if (player.hasPermission("fawe." + manager.getKey())) {
|
||||||
final FaweMask mask = manager.getMask(player);
|
final FaweMask fm = manager.getMask(player);
|
||||||
if (mask != null) {
|
if (fm != null) {
|
||||||
TaskManager.IMP.async(new Runnable() {
|
mask.addAll(fm.getRegions());
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
value.addAll(mask.getRegions());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (mask.isEmpty()) {
|
||||||
// }, 1000);
|
|
||||||
}.runAndGet();
|
|
||||||
if (mask == null || mask.isEmpty()) {
|
|
||||||
mask = player.getMeta("lastMask");
|
mask = player.getMeta("lastMask");
|
||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
mask = new HashSet<>();
|
mask = new HashSet<>();
|
||||||
|
@ -95,14 +95,14 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
Vector pivot = from.round().add(0.5, 0.5, 0.5);
|
Vector pivot = from.round().add(0.5, 0.5, 0.5);
|
||||||
Vector newPosition = transform.apply(location.toVector().subtract(pivot));
|
Vector newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||||
Vector newDirection;
|
Vector newDirection;
|
||||||
|
if (transform.isIdentity()) {
|
||||||
newDirection = transform.isIdentity() ?
|
newDirection = entity.getLocation().getDirection();
|
||||||
entity.getLocation().getDirection()
|
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||||
: new Vector(transform.apply(location.getDirection())).subtract(transform.apply(Vector.ZERO)).normalize();
|
} else {
|
||||||
|
newDirection = new Vector(transform.apply(location.getDirection())).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||||
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||||
|
|
||||||
// Some entities store their position data in NBT
|
|
||||||
state = transformNbtData(state);
|
state = transformNbtData(state);
|
||||||
|
}
|
||||||
|
|
||||||
boolean success = destination.createEntity(newLocation, state) != null;
|
boolean success = destination.createEntity(newLocation, state) != null;
|
||||||
|
|
||||||
|
@ -51,17 +51,26 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public ForgeChunk_All(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
public Chunk getNewChunk() {
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
World world = ((ForgeQueue_All) getParent()).getWorld();
|
|
||||||
return world.getChunkProvider().provideChunk(getX(), getZ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForgeChunk_All copy(boolean shallow) {
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
ForgeChunk_All value = (ForgeChunk_All) super.copy(shallow);
|
ForgeChunk_All copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
if (sectionPalettes != null) {
|
if (sectionPalettes != null) {
|
||||||
value.sectionPalettes = new BlockStateContainer[16];
|
copy.sectionPalettes = new BlockStateContainer[16];
|
||||||
try {
|
try {
|
||||||
Field fieldBits = BlockStateContainer.class.getDeclaredField("storage");
|
Field fieldBits = BlockStateContainer.class.getDeclaredField("storage");
|
||||||
fieldBits.setAccessible(true);
|
fieldBits.setAccessible(true);
|
||||||
@ -99,13 +108,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
field.set(newBits, currentValue);
|
field.set(newBits, currentValue);
|
||||||
}
|
}
|
||||||
fieldBits.set(paletteBlock, newBits);
|
fieldBits.set(paletteBlock, newBits);
|
||||||
value.sectionPalettes[i] = paletteBlock;
|
copy.sectionPalettes[i] = paletteBlock;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getNewChunk() {
|
||||||
|
World world = ((ForgeQueue_All) getParent()).getWorld();
|
||||||
|
return world.getChunkProvider().provideChunk(getX(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void optimize() {
|
public void optimize() {
|
||||||
@ -146,6 +161,10 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
ExtendedBlockStorage[] sections = nmsChunk.getBlockStorageArray();
|
ExtendedBlockStorage[] sections = nmsChunk.getBlockStorageArray();
|
||||||
Map<BlockPos, TileEntity> tiles = nmsChunk.getTileEntityMap();
|
Map<BlockPos, TileEntity> tiles = nmsChunk.getTileEntityMap();
|
||||||
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
||||||
|
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
|
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
int count = this.getCount(i);
|
int count = this.getCount(i);
|
||||||
|
@ -79,13 +79,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||||
if (forgeChunk != null) {
|
if (forgeChunk != null) {
|
||||||
int[] otherMap = forgeChunk.getHeightMap();
|
int[] otherMap = forgeChunk.getHeightMap();
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,7 +236,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
||||||
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ExtendedBlockStorage section = sections[layer];
|
ExtendedBlockStorage section = sections[layer];
|
||||||
@ -265,7 +266,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
||||||
TileEntity tile = entry.getValue();
|
TileEntity tile = entry.getValue();
|
||||||
@ -339,7 +339,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65280);
|
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65280);
|
||||||
for (EntityPlayerMP player : players) {
|
for (EntityPlayerMP player : players) {
|
||||||
player.connection.sendPacket(packet);
|
player.connection.sendPacket(packet);
|
||||||
|
@ -32,8 +32,8 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||||||
|
|
||||||
public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||||
|
|
||||||
public byte[][] byteIds;
|
public final byte[][] byteIds;
|
||||||
public NibbleArray[] datas;
|
public final NibbleArray[] datas;
|
||||||
|
|
||||||
public ForgeChunk_All(FaweQueue parent, int x, int z) {
|
public ForgeChunk_All(FaweQueue parent, int x, int z) {
|
||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
@ -41,6 +41,29 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
this.datas = new NibbleArray[16];
|
this.datas = new NibbleArray[16];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ForgeChunk_All(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap, byte[][] byteIds, NibbleArray[] datas) {
|
||||||
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
|
this.byteIds = byteIds;
|
||||||
|
this.datas = datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
|
ForgeChunk_All copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), ids, count, air, relight, heightMap, byteIds, datas);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone(), (byte[][]) MainUtil.copyNd(byteIds), datas.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk getNewChunk() {
|
public Chunk getNewChunk() {
|
||||||
World world = ((ForgeQueue_All) getParent()).getWorld();
|
World world = ((ForgeQueue_All) getParent()).getWorld();
|
||||||
@ -104,29 +127,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ForgeChunk_All copy(boolean shallow) {
|
|
||||||
ForgeChunk_All copy = new ForgeChunk_All(getParent(), getX(), getZ());
|
|
||||||
if (shallow) {
|
|
||||||
copy.byteIds = byteIds;
|
|
||||||
copy.datas = datas;
|
|
||||||
copy.air = air;
|
|
||||||
copy.biomes = biomes;
|
|
||||||
copy.chunk = chunk;
|
|
||||||
copy.count = count;
|
|
||||||
copy.relight = relight;
|
|
||||||
} else {
|
|
||||||
copy.byteIds = (byte[][]) MainUtil.copyNd(byteIds);
|
|
||||||
copy.datas = datas.clone();
|
|
||||||
copy.air = air.clone();
|
|
||||||
copy.biomes = biomes.clone();
|
|
||||||
copy.chunk = chunk;
|
|
||||||
copy.count = count.clone();
|
|
||||||
copy.relight = relight.clone();
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForgeChunk_All call() {
|
public ForgeChunk_All call() {
|
||||||
net.minecraft.world.chunk.Chunk nmsChunk = this.getChunk();
|
net.minecraft.world.chunk.Chunk nmsChunk = this.getChunk();
|
||||||
@ -140,6 +140,9 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
Map<ChunkPosition, TileEntity> tiles = nmsChunk.chunkTileEntityMap;
|
Map<ChunkPosition, TileEntity> tiles = nmsChunk.chunkTileEntityMap;
|
||||||
List<Entity>[] entities = nmsChunk.entityLists;
|
List<Entity>[] entities = nmsChunk.entityLists;
|
||||||
|
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
|
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
int count = this.getCount(i);
|
int count = this.getCount(i);
|
||||||
|
@ -76,13 +76,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||||
if (forgeChunk != null) {
|
if (forgeChunk != null) {
|
||||||
int[] otherMap = forgeChunk.heightMap;
|
int[] otherMap = forgeChunk.heightMap;
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,7 +256,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
S21PacketChunkData packet = new S21PacketChunkData(nmsChunk, false, 65280);
|
S21PacketChunkData packet = new S21PacketChunkData(nmsChunk, false, 65280);
|
||||||
for (EntityPlayerMP player : players) {
|
for (EntityPlayerMP player : players) {
|
||||||
player.playerNetServerHandler.sendPacket(packet);
|
player.playerNetServerHandler.sendPacket(packet);
|
||||||
@ -296,7 +297,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
Map<ChunkPosition, TileEntity> tiles = (Map<ChunkPosition, TileEntity>) tilesGeneric;
|
Map<ChunkPosition, TileEntity> tiles = (Map<ChunkPosition, TileEntity>) tilesGeneric;
|
||||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ExtendedBlockStorage section = sections[layer];
|
ExtendedBlockStorage section = sections[layer];
|
||||||
@ -315,7 +315,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<ChunkPosition, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<ChunkPosition, TileEntity> entry : tiles.entrySet()) {
|
||||||
TileEntity tile = entry.getValue();
|
TileEntity tile = entry.getValue();
|
||||||
|
@ -41,6 +41,27 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ForgeChunk_All(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
|
ForgeChunk_All copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk getNewChunk() {
|
public Chunk getNewChunk() {
|
||||||
World world = ((ForgeQueue_All) getParent()).getWorld();
|
World world = ((ForgeQueue_All) getParent()).getWorld();
|
||||||
@ -60,6 +81,8 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
Map<BlockPos, TileEntity> tiles = nmsChunk.getTileEntityMap();
|
Map<BlockPos, TileEntity> tiles = nmsChunk.getTileEntityMap();
|
||||||
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
||||||
|
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
|
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
|
@ -73,13 +73,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||||
if (forgeChunk != null) {
|
if (forgeChunk != null) {
|
||||||
int[] otherMap = forgeChunk.getHeightMap();
|
int[] otherMap = forgeChunk.getHeightMap();
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +199,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
||||||
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ExtendedBlockStorage section = sections[layer];
|
ExtendedBlockStorage section = sections[layer];
|
||||||
@ -215,7 +216,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
||||||
TileEntity tile = entry.getValue();
|
TileEntity tile = entry.getValue();
|
||||||
@ -285,7 +285,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
S21PacketChunkData packet = new S21PacketChunkData(nmsChunk, false, 65280);
|
S21PacketChunkData packet = new S21PacketChunkData(nmsChunk, false, 65280);
|
||||||
for (EntityPlayerMP player : players) {
|
for (EntityPlayerMP player : players) {
|
||||||
player.playerNetServerHandler.sendPacket(packet);
|
player.playerNetServerHandler.sendPacket(packet);
|
||||||
|
@ -51,17 +51,26 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public ForgeChunk_All(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
public Chunk getNewChunk() {
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
World world = ((ForgeQueue_All) getParent()).getWorld();
|
|
||||||
return world.getChunkProvider().provideChunk(getX(), getZ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForgeChunk_All copy(boolean shallow) {
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
ForgeChunk_All value = (ForgeChunk_All) super.copy(shallow);
|
ForgeChunk_All copy;
|
||||||
if (sectionPalettes != null) {
|
if (shallow) {
|
||||||
value.sectionPalettes = new BlockStateContainer[16];
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new ForgeChunk_All(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
|
if (copy != null) {
|
||||||
|
copy.sectionPalettes = new BlockStateContainer[16];
|
||||||
try {
|
try {
|
||||||
Field fieldBits = BlockStateContainer.class.getDeclaredField("storage");
|
Field fieldBits = BlockStateContainer.class.getDeclaredField("storage");
|
||||||
fieldBits.setAccessible(true);
|
fieldBits.setAccessible(true);
|
||||||
@ -99,13 +108,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
field.set(newBits, currentValue);
|
field.set(newBits, currentValue);
|
||||||
}
|
}
|
||||||
fieldBits.set(paletteBlock, newBits);
|
fieldBits.set(paletteBlock, newBits);
|
||||||
value.sectionPalettes[i] = paletteBlock;
|
copy.sectionPalettes[i] = paletteBlock;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getNewChunk() {
|
||||||
|
World world = ((ForgeQueue_All) getParent()).getWorld();
|
||||||
|
return world.getChunkProvider().provideChunk(getX(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void optimize() {
|
public void optimize() {
|
||||||
@ -147,6 +162,8 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
|||||||
Map<BlockPos, TileEntity> tiles = nmsChunk.getTileEntityMap();
|
Map<BlockPos, TileEntity> tiles = nmsChunk.getTileEntityMap();
|
||||||
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
||||||
|
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
|
|
||||||
// Remove entities
|
// Remove entities
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
|
@ -81,13 +81,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||||
if (forgeChunk != null) {
|
if (forgeChunk != null) {
|
||||||
int[] otherMap = forgeChunk.getHeightMap();
|
int[] otherMap = forgeChunk.getHeightMap();
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,7 +235,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
Map<BlockPos, TileEntity> tiles = (Map<BlockPos, TileEntity>) tilesGeneric;
|
||||||
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
||||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||||
char[][] idPrevious = new char[16][];
|
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||||
for (int layer = 0; layer < sections.length; layer++) {
|
for (int layer = 0; layer < sections.length; layer++) {
|
||||||
if (fs.getCount(layer) != 0 || all) {
|
if (fs.getCount(layer) != 0 || all) {
|
||||||
ExtendedBlockStorage section = sections[layer];
|
ExtendedBlockStorage section = sections[layer];
|
||||||
@ -264,7 +265,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous.ids = idPrevious;
|
|
||||||
if (tiles != null) {
|
if (tiles != null) {
|
||||||
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
||||||
TileEntity tile = entry.getValue();
|
TileEntity tile = entry.getValue();
|
||||||
@ -338,7 +338,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65280);
|
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65280);
|
||||||
for (EntityPlayerMP player : players) {
|
for (EntityPlayerMP player : players) {
|
||||||
player.connection.sendPacket(packet);
|
player.connection.sendPacket(packet);
|
||||||
|
@ -10,6 +10,7 @@ import com.boydti.fawe.example.CharFaweChunk;
|
|||||||
import com.boydti.fawe.nukkit.core.NBTConverter;
|
import com.boydti.fawe.nukkit.core.NBTConverter;
|
||||||
import com.boydti.fawe.nukkit.core.NukkitUtil;
|
import com.boydti.fawe.nukkit.core.NukkitUtil;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
@ -30,9 +31,30 @@ public class NukkitChunk extends CharFaweChunk<BaseFullChunk, NukkitQueue> {
|
|||||||
super(parent, x, z);
|
super(parent, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NukkitChunk(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, short[] relight, byte[] heightMap) {
|
||||||
|
super(parent, x, z, ids, count, air, relight, heightMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharFaweChunk copy(boolean shallow) {
|
||||||
|
NukkitChunk copy;
|
||||||
|
if (shallow) {
|
||||||
|
copy = new NukkitChunk(getParent(), getX(), getZ(), ids, count, air, relight, heightMap);
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
} else {
|
||||||
|
copy = new NukkitChunk(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), relight.clone(), heightMap.clone());
|
||||||
|
copy.biomes = biomes;
|
||||||
|
copy.chunk = chunk;
|
||||||
|
copy.biomes = biomes.clone();
|
||||||
|
copy.chunk = chunk;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseFullChunk getNewChunk() {
|
public BaseFullChunk getNewChunk() {
|
||||||
return ((NukkitQueue) getParent()).getWorld().getChunk(getX(), getZ());
|
return ((NukkitQueue) getParent()).getWorld().getChunk(getX(), getZ(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int layer = -1;
|
private int layer = -1;
|
||||||
@ -41,10 +63,12 @@ public class NukkitChunk extends CharFaweChunk<BaseFullChunk, NukkitQueue> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NukkitChunk call() {
|
public NukkitChunk call() {
|
||||||
|
// Set heightmap
|
||||||
|
getParent().setHeightMap(this, heightMap);
|
||||||
NukkitQueue parent = (NukkitQueue) getParent();
|
NukkitQueue parent = (NukkitQueue) getParent();
|
||||||
Level world = ((NukkitQueue) getParent()).getWorld();
|
Level world = ((NukkitQueue) getParent()).getWorld();
|
||||||
world.clearCache(true);
|
world.clearCache(true);
|
||||||
final BaseFullChunk chunk = (world.getChunk(getX(), getZ(), true));
|
final BaseFullChunk chunk = getChunk();
|
||||||
char[][] sections = getCombinedIdArrays();
|
char[][] sections = getCombinedIdArrays();
|
||||||
final int[][] biomes = getBiomeArray();
|
final int[][] biomes = getBiomeArray();
|
||||||
final int X = getX() << 4;
|
final int X = getX() << 4;
|
||||||
|
@ -50,13 +50,14 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||||
BaseFullChunk forgeChunk = (BaseFullChunk) chunk.getChunk();
|
BaseFullChunk forgeChunk = (BaseFullChunk) chunk.getChunk();
|
||||||
if (forgeChunk != null) {
|
if (forgeChunk != null) {
|
||||||
int[] otherMap = forgeChunk.getHeightMapArray();
|
int[] otherMap = forgeChunk.getHeightMapArray();
|
||||||
for (int i = 0; i < heightMap.length; i++) {
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
if (heightMap[i] > otherMap[i]) {
|
int value = heightMap[i] & 0xFF;
|
||||||
otherMap[i] = heightMap[i];
|
if (value > value) {
|
||||||
|
otherMap[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user