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);
|
||||
}
|
||||
|
||||
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
|
||||
public Chunk getNewChunk() {
|
||||
return Bukkit.getWorld(getParent().getWorldName()).getChunkAt(getX(), getZ());
|
||||
|
@ -38,7 +38,7 @@ public class BukkitQueue_All extends BukkitQueue_0<Chunk, Chunk, Chunk> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
// 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.MathMan;
|
||||
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 java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import net.minecraft.server.v1_10_R1.*;
|
||||
import java.util.ArrayList;
|
||||
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.World;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getNewChunk() {
|
||||
return ((com.boydti.fawe.bukkit.v1_10.BukkitQueue_1_10) getParent()).getWorld().getChunkAt(getX(), getZ());
|
||||
public BukkitChunk_1_10(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<Chunk, BukkitQueue_1_10> copy(boolean shallow) {
|
||||
BukkitChunk_1_10 value = (BukkitChunk_1_10) super.copy(shallow);
|
||||
public CharFaweChunk copy(boolean 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) {
|
||||
value.sectionPalettes = new DataPaletteBlock[16];
|
||||
copy.sectionPalettes = new DataPaletteBlock[16];
|
||||
try {
|
||||
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
||||
fieldBits.setAccessible(true);
|
||||
@ -83,13 +116,18 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
|
||||
field.set(newBits, currentValue);
|
||||
}
|
||||
fieldBits.set(paletteBlock, newBits);
|
||||
value.sectionPalettes[i] = paletteBlock;
|
||||
copy.sectionPalettes[i] = paletteBlock;
|
||||
}
|
||||
} catch (Throwable 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() {
|
||||
@ -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();
|
||||
final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk);
|
||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
// Remove entities
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
int count = this.getCount(i);
|
||||
|
@ -81,13 +81,14 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||
if (craftChunk != null) {
|
||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
if (value > value) {
|
||||
otherMap[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -288,7 +289,7 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
||||
}
|
||||
// Send chunks
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
||||
for (EntityPlayer player : playerChunk.c) {
|
||||
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;
|
||||
BukkitChunk_1_10 previous = getFaweChunk(fs.getX(), fs.getZ());
|
||||
// Copy blocks
|
||||
char[][] idPrevious = new char[16][];
|
||||
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||
for (int layer = 0; layer < sections.length; layer++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
ChunkSection section = sections[layer];
|
||||
@ -459,7 +460,6 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
||||
}
|
||||
}
|
||||
}
|
||||
previous.ids = idPrevious;
|
||||
// Copy tiles
|
||||
if (tiles != null) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getNewChunk() {
|
||||
return ((com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11) getParent()).getWorld().getChunkAt(getX(), getZ());
|
||||
public BukkitChunk_1_11(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<Chunk, com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11> copy(boolean shallow) {
|
||||
BukkitChunk_1_11 value = (BukkitChunk_1_11) super.copy(shallow);
|
||||
public CharFaweChunk copy(boolean 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) {
|
||||
value.sectionPalettes = new DataPaletteBlock[16];
|
||||
copy.sectionPalettes = new DataPaletteBlock[16];
|
||||
try {
|
||||
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
||||
fieldBits.setAccessible(true);
|
||||
@ -109,13 +119,18 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
|
||||
field.set(newBits, currentValue);
|
||||
}
|
||||
fieldBits.set(paletteBlock, newBits);
|
||||
value.sectionPalettes[i] = paletteBlock;
|
||||
copy.sectionPalettes[i] = paletteBlock;
|
||||
}
|
||||
} catch (Throwable 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() {
|
||||
@ -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();
|
||||
final Collection<Entity>[] entities = (Collection<Entity>[]) getParent().getEntitySlices.invoke(nmsChunk);
|
||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
// Remove entities
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
int count = this.getCount(i);
|
||||
|
@ -55,13 +55,14 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||
if (craftChunk != null) {
|
||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
if (value > value) {
|
||||
otherMap[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,7 +263,7 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
||||
}
|
||||
// Send chunks
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
||||
for (EntityPlayer player : playerChunk.c) {
|
||||
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;
|
||||
BukkitChunk_1_11 previous = getFaweChunk(fs.getX(), fs.getZ());
|
||||
// Copy blocks
|
||||
char[][] idPrevious = new char[16][];
|
||||
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||
for (int layer = 0; layer < sections.length; layer++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
ChunkSection section = sections[layer];
|
||||
@ -433,7 +434,6 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
||||
}
|
||||
}
|
||||
}
|
||||
previous.ids = idPrevious;
|
||||
// Copy tiles
|
||||
if (tiles != null) {
|
||||
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());
|
||||
}
|
||||
|
||||
public byte[][] byteIds;
|
||||
public NibbleArray[] datas;
|
||||
public final byte[][] byteIds;
|
||||
public final NibbleArray[] datas;
|
||||
|
||||
public BukkitChunk_1_7(FaweQueue parent, int x, int z) {
|
||||
super(parent, x, z);
|
||||
@ -52,6 +52,29 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
||||
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) {
|
||||
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
|
||||
public void start() {
|
||||
getChunk().load(true);
|
||||
@ -155,7 +155,8 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
||||
ChunkSection[] sections = nmsChunk.getSections();
|
||||
Map<ChunkPosition, TileEntity> tiles = nmsChunk.tileEntities;
|
||||
Collection<Entity>[] entities = nmsChunk.entitySlices;
|
||||
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
// Remove entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int count = this.getCount(i);
|
||||
|
@ -87,13 +87,14 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||
if (craftChunk != null) {
|
||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
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;
|
||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||
char[][] idPrevious = new char[16][];
|
||||
for (int layer = 0; layer < sections.length; layer++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
ChunkSection section = sections[layer];
|
||||
@ -184,7 +184,6 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
||||
}
|
||||
}
|
||||
}
|
||||
previous.ids = idPrevious;
|
||||
if (tiles != null) {
|
||||
for (Map.Entry<ChunkPosition, TileEntity> entry : tiles.entrySet()) {
|
||||
TileEntity tile = entry.getValue();
|
||||
@ -298,7 +297,7 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
||||
}
|
||||
// Send chunks
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, 65280, 5);
|
||||
for (EntityPlayer player : players) {
|
||||
player.playerConnection.sendPacket(packet);
|
||||
|
@ -46,6 +46,27 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
|
||||
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
|
||||
public Chunk getNewChunk() {
|
||||
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();
|
||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||
Collection<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
// Remove entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int count = this.getCount(i);
|
||||
|
@ -85,13 +85,14 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||
if (craftChunk != null) {
|
||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
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;
|
||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||
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++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
ChunkSection section = sections[layer];
|
||||
@ -177,7 +178,6 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
||||
}
|
||||
}
|
||||
}
|
||||
previous.ids = idPrevious;
|
||||
if (tiles != null) {
|
||||
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
||||
TileEntity tile = entry.getValue();
|
||||
@ -286,7 +286,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
||||
}
|
||||
// Send chunks
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, 65280);
|
||||
for (EntityPlayer player : players) {
|
||||
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.MathMan;
|
||||
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 java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import net.minecraft.server.v1_9_R2.*;
|
||||
import java.util.ArrayList;
|
||||
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.World;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getNewChunk() {
|
||||
return ((BukkitQueue_1_9_R1) getParent()).getWorld().getChunkAt(getX(), getZ());
|
||||
public BukkitChunk_1_9(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 BukkitChunk_1_9 copy(boolean shallow) {
|
||||
BukkitChunk_1_9 value = (BukkitChunk_1_9) super.copy(shallow);
|
||||
public CharFaweChunk copy(boolean 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) {
|
||||
value.sectionPalettes = new DataPaletteBlock[16];
|
||||
copy.sectionPalettes = new DataPaletteBlock[16];
|
||||
try {
|
||||
Field fieldBits = DataPaletteBlock.class.getDeclaredField("b");
|
||||
fieldBits.setAccessible(true);
|
||||
@ -84,13 +118,18 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
|
||||
field.set(newBits, currentValue);
|
||||
}
|
||||
fieldBits.set(paletteBlock, newBits);
|
||||
value.sectionPalettes[i] = paletteBlock;
|
||||
copy.sectionPalettes[i] = paletteBlock;
|
||||
}
|
||||
} catch (Throwable 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() {
|
||||
@ -154,6 +193,8 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
|
||||
final Field ef = clazzChunk.getDeclaredField("entitySlices");
|
||||
final Collection<Entity>[] entities = (Collection<Entity>[]) ef.get(nmsChunk);
|
||||
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
// Remove entities
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
int count = this.getCount(i);
|
||||
|
@ -97,13 +97,14 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||
if (craftChunk != null) {
|
||||
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
if (value > value) {
|
||||
otherMap[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,7 +155,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
||||
}
|
||||
// Send chunks
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
||||
for (EntityPlayer player : playerChunk.c) {
|
||||
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;
|
||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||
// Copy blocks
|
||||
char[][] idPrevious = new char[16][];
|
||||
char[][] idPrevious = previous.getCombinedIdArrays();
|
||||
for (int layer = 0; layer < sections.length; layer++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
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
|
||||
if (tiles != null) {
|
||||
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
|
||||
|
@ -652,8 +652,26 @@ public class FaweCache {
|
||||
case 33:
|
||||
case 151:
|
||||
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:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.BytePair;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
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 char[][] ids;
|
||||
public short[] count;
|
||||
public short[] air;
|
||||
public short[] relight;
|
||||
public final char[][] ids;
|
||||
public final short[] count;
|
||||
public final short[] air;
|
||||
public final short[] relight;
|
||||
public final byte[] heightMap;
|
||||
|
||||
public int[][] biomes;
|
||||
private int bitMask = -1;
|
||||
|
||||
public HashMap<BytePair, CompoundTag> tiles;
|
||||
|
||||
public HashSet<CompoundTag> entities;
|
||||
|
||||
public HashSet<UUID> entityRemoves;
|
||||
|
||||
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.
|
||||
*
|
||||
@ -45,6 +51,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
this.count = new short[HEIGHT >> 4];
|
||||
this.air = new short[HEIGHT >> 4];
|
||||
this.relight = new short[HEIGHT >> 4];
|
||||
this.heightMap = new byte[256];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,21 +124,15 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
|
||||
@Override
|
||||
public int getBitMask() {
|
||||
if (bitMask == -1) {
|
||||
this.bitMask = 0;
|
||||
int bitMask = 0;
|
||||
for (int section = 0; section < ids.length; section++) {
|
||||
if (ids[section] != null) {
|
||||
bitMask += 1 << section;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bitMask;
|
||||
}
|
||||
|
||||
public void setBitMask(int value) {
|
||||
this.bitMask = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw data for a section
|
||||
* @param i
|
||||
@ -247,6 +248,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
this.relight[i]++;
|
||||
default:
|
||||
vs[j] = (char) (id << 4);
|
||||
heightMap[z << 4 | x] = (byte) y;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -332,6 +334,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
case 191:
|
||||
case 192:
|
||||
vs[j] = (char) (id << 4);
|
||||
heightMap[z << 4 | x] = (byte) y;
|
||||
return;
|
||||
case 130:
|
||||
case 76:
|
||||
@ -346,6 +349,7 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
case 68: // removed
|
||||
default:
|
||||
vs[j] = (char) ((id << 4) + data);
|
||||
heightMap[z << 4 | x] = (byte) y;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -363,23 +367,5 @@ public abstract class CharFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
public 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;
|
||||
}
|
||||
public abstract CharFaweChunk<T, V> copy(boolean shallow);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
refreshChunk(fc);
|
||||
}
|
||||
|
||||
public abstract void setHeightMap(FaweChunk chunk, int[] heightMap);
|
||||
public abstract void setHeightMap(FaweChunk chunk, byte[] heightMap);
|
||||
|
||||
public abstract void setFullbright(CHUNKSECTION sections);
|
||||
|
||||
|
@ -3,9 +3,7 @@ package com.boydti.fawe.example;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -130,21 +128,8 @@ public class NMSRelighter {
|
||||
for (Map.Entry<Long, RelightSkyEntry> entry : skyToRelight.entrySet()) {
|
||||
RelightSkyEntry chunk = entry.getValue();
|
||||
CharFaweChunk fc = (CharFaweChunk) queue.getFaweChunk(chunk.x, chunk.z);
|
||||
fcs.put(fc, chunk.heightMap);
|
||||
fc.setBitMask(chunk.bitmask);
|
||||
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) {
|
||||
@ -248,7 +233,6 @@ public class NMSRelighter {
|
||||
break;
|
||||
case 15:
|
||||
if (opacity > 1) {
|
||||
chunk.heightMap[z << 4 | x] = y;
|
||||
value -= opacity;
|
||||
mask[j] = value;
|
||||
}
|
||||
@ -347,7 +331,6 @@ public class NMSRelighter {
|
||||
public final int x;
|
||||
public final int z;
|
||||
public final byte[] mask;
|
||||
public int[] heightMap = new int[256];
|
||||
public final boolean[] fix;
|
||||
public int bitmask;
|
||||
public boolean smooth;
|
||||
|
@ -163,13 +163,14 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
MCAChunk mca = (MCAChunk) chunk;
|
||||
if (mca != null) {
|
||||
int[] otherMap = mca.getHeightMapArray();
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
if (value > value) {
|
||||
otherMap[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +169,26 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
||||
case 33:
|
||||
case 151:
|
||||
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
|
||||
return queue.setBlock(x, y, z, id, (byte) block.getData(), block.getNbtData());
|
||||
case 0:
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class MemUtil {
|
||||
@ -42,8 +42,8 @@ public class MemUtil {
|
||||
return size;
|
||||
}
|
||||
|
||||
private static BlockingQueue<Runnable> memoryLimitedTasks = new LinkedBlockingQueue<>();
|
||||
private static BlockingQueue<Runnable> memoryPlentifulTasks = new LinkedBlockingQueue<>();
|
||||
private static Queue<Runnable> memoryLimitedTasks = new ConcurrentLinkedQueue<>();
|
||||
private static Queue<Runnable> memoryPlentifulTasks = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public static void addMemoryLimitedTask(Runnable run) {
|
||||
if (run != null)
|
||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
@ -73,14 +72,10 @@ public class WEManager {
|
||||
* @return
|
||||
*/
|
||||
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) {
|
||||
return new RegionWrapper[] {new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE)};
|
||||
}
|
||||
HashSet<RegionWrapper> mask = new RunnableVal<HashSet<RegionWrapper>>() {
|
||||
@Override
|
||||
public void run(HashSet<RegionWrapper> ignore) {
|
||||
this.value = new HashSet<>();
|
||||
HashSet<RegionWrapper> mask = new HashSet<>();
|
||||
String world = player.getLocation().world;
|
||||
if (!world.equals(player.getMeta("lastMaskWorld"))) {
|
||||
player.deleteMeta("lastMaskWorld");
|
||||
@ -89,22 +84,13 @@ public class WEManager {
|
||||
player.setMeta("lastMaskWorld", world);
|
||||
for (final FaweMaskManager manager : managers) {
|
||||
if (player.hasPermission("fawe." + manager.getKey())) {
|
||||
final FaweMask mask = manager.getMask(player);
|
||||
if (mask != null) {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
value.addAll(mask.getRegions());
|
||||
final FaweMask fm = manager.getMask(player);
|
||||
if (fm != null) {
|
||||
mask.addAll(fm.getRegions());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }, 1000);
|
||||
}.runAndGet();
|
||||
if (mask == null || mask.isEmpty()) {
|
||||
if (mask.isEmpty()) {
|
||||
mask = player.getMeta("lastMask");
|
||||
if (mask == null) {
|
||||
mask = new HashSet<>();
|
||||
|
@ -95,14 +95,14 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
Vector pivot = from.round().add(0.5, 0.5, 0.5);
|
||||
Vector newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||
Vector newDirection;
|
||||
|
||||
newDirection = transform.isIdentity() ?
|
||||
entity.getLocation().getDirection()
|
||||
: new Vector(transform.apply(location.getDirection())).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
if (transform.isIdentity()) {
|
||||
newDirection = entity.getLocation().getDirection();
|
||||
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||
} 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);
|
||||
|
||||
// Some entities store their position data in NBT
|
||||
state = transformNbtData(state);
|
||||
}
|
||||
|
||||
boolean success = destination.createEntity(newLocation, state) != null;
|
||||
|
||||
|
@ -51,17 +51,26 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
super(parent, x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getNewChunk() {
|
||||
World world = ((ForgeQueue_All) getParent()).getWorld();
|
||||
return world.getChunkProvider().provideChunk(getX(), getZ());
|
||||
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 ForgeChunk_All copy(boolean shallow) {
|
||||
ForgeChunk_All value = (ForgeChunk_All) super.copy(shallow);
|
||||
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;
|
||||
}
|
||||
if (sectionPalettes != null) {
|
||||
value.sectionPalettes = new BlockStateContainer[16];
|
||||
copy.sectionPalettes = new BlockStateContainer[16];
|
||||
try {
|
||||
Field fieldBits = BlockStateContainer.class.getDeclaredField("storage");
|
||||
fieldBits.setAccessible(true);
|
||||
@ -99,13 +108,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
field.set(newBits, currentValue);
|
||||
}
|
||||
fieldBits.set(paletteBlock, newBits);
|
||||
value.sectionPalettes[i] = paletteBlock;
|
||||
copy.sectionPalettes[i] = paletteBlock;
|
||||
}
|
||||
} catch (Throwable 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() {
|
||||
@ -146,6 +161,10 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
ExtendedBlockStorage[] sections = nmsChunk.getBlockStorageArray();
|
||||
Map<BlockPos, TileEntity> tiles = nmsChunk.getTileEntityMap();
|
||||
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
||||
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
|
||||
// Remove entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int count = this.getCount(i);
|
||||
|
@ -79,13 +79,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||
if (forgeChunk != null) {
|
||||
int[] otherMap = forgeChunk.getHeightMap();
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
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;
|
||||
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
||||
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++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
ExtendedBlockStorage section = sections[layer];
|
||||
@ -265,7 +266,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
}
|
||||
}
|
||||
}
|
||||
previous.ids = idPrevious;
|
||||
if (tiles != null) {
|
||||
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
||||
TileEntity tile = entry.getValue();
|
||||
@ -339,7 +339,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
return false;
|
||||
});
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65280);
|
||||
for (EntityPlayerMP player : players) {
|
||||
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 byte[][] byteIds;
|
||||
public NibbleArray[] datas;
|
||||
public final byte[][] byteIds;
|
||||
public final NibbleArray[] datas;
|
||||
|
||||
public ForgeChunk_All(FaweQueue parent, int x, int z) {
|
||||
super(parent, x, z);
|
||||
@ -41,6 +41,29 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
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
|
||||
public Chunk getNewChunk() {
|
||||
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
|
||||
public ForgeChunk_All call() {
|
||||
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;
|
||||
List<Entity>[] entities = nmsChunk.entityLists;
|
||||
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
|
||||
// Remove entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int count = this.getCount(i);
|
||||
|
@ -76,13 +76,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||
if (forgeChunk != null) {
|
||||
int[] otherMap = forgeChunk.heightMap;
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
if (value > value) {
|
||||
otherMap[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -255,7 +256,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
return;
|
||||
}
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
S21PacketChunkData packet = new S21PacketChunkData(nmsChunk, false, 65280);
|
||||
for (EntityPlayerMP player : players) {
|
||||
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;
|
||||
Collection<Entity>[] entities = (Collection<Entity>[]) entitiesGeneric;
|
||||
CharFaweChunk previous = (CharFaweChunk) getFaweChunk(fs.getX(), fs.getZ());
|
||||
char[][] idPrevious = new char[16][];
|
||||
for (int layer = 0; layer < sections.length; layer++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
ExtendedBlockStorage section = sections[layer];
|
||||
@ -315,7 +315,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
}
|
||||
}
|
||||
}
|
||||
previous.ids = idPrevious;
|
||||
if (tiles != null) {
|
||||
for (Map.Entry<ChunkPosition, TileEntity> entry : tiles.entrySet()) {
|
||||
TileEntity tile = entry.getValue();
|
||||
|
@ -41,6 +41,27 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
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
|
||||
public Chunk getNewChunk() {
|
||||
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();
|
||||
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
||||
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
|
||||
// Remove entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
@ -73,13 +73,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||
if (forgeChunk != null) {
|
||||
int[] otherMap = forgeChunk.getHeightMap();
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
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;
|
||||
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
||||
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++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
ExtendedBlockStorage section = sections[layer];
|
||||
@ -215,7 +216,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
}
|
||||
}
|
||||
}
|
||||
previous.ids = idPrevious;
|
||||
if (tiles != null) {
|
||||
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
||||
TileEntity tile = entry.getValue();
|
||||
@ -285,7 +285,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
return;
|
||||
}
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
S21PacketChunkData packet = new S21PacketChunkData(nmsChunk, false, 65280);
|
||||
for (EntityPlayerMP player : players) {
|
||||
player.playerNetServerHandler.sendPacket(packet);
|
||||
|
@ -51,17 +51,26 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
super(parent, x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getNewChunk() {
|
||||
World world = ((ForgeQueue_All) getParent()).getWorld();
|
||||
return world.getChunkProvider().provideChunk(getX(), getZ());
|
||||
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 ForgeChunk_All copy(boolean shallow) {
|
||||
ForgeChunk_All value = (ForgeChunk_All) super.copy(shallow);
|
||||
if (sectionPalettes != null) {
|
||||
value.sectionPalettes = new BlockStateContainer[16];
|
||||
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;
|
||||
}
|
||||
if (copy != null) {
|
||||
copy.sectionPalettes = new BlockStateContainer[16];
|
||||
try {
|
||||
Field fieldBits = BlockStateContainer.class.getDeclaredField("storage");
|
||||
fieldBits.setAccessible(true);
|
||||
@ -99,13 +108,19 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
field.set(newBits, currentValue);
|
||||
}
|
||||
fieldBits.set(paletteBlock, newBits);
|
||||
value.sectionPalettes[i] = paletteBlock;
|
||||
copy.sectionPalettes[i] = paletteBlock;
|
||||
}
|
||||
} catch (Throwable 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() {
|
||||
@ -147,6 +162,8 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
|
||||
Map<BlockPos, TileEntity> tiles = nmsChunk.getTileEntityMap();
|
||||
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
||||
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
|
||||
// Remove entities
|
||||
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);
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||
if (forgeChunk != null) {
|
||||
int[] otherMap = forgeChunk.getHeightMap();
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
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;
|
||||
ClassInheritanceMultiMap<Entity>[] entities = (ClassInheritanceMultiMap<Entity>[]) entitiesGeneric;
|
||||
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++) {
|
||||
if (fs.getCount(layer) != 0 || all) {
|
||||
ExtendedBlockStorage section = sections[layer];
|
||||
@ -264,7 +265,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
}
|
||||
}
|
||||
}
|
||||
previous.ids = idPrevious;
|
||||
if (tiles != null) {
|
||||
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
|
||||
TileEntity tile = entry.getValue();
|
||||
@ -338,7 +338,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
return false;
|
||||
});
|
||||
int mask = fc.getBitMask();
|
||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65280);
|
||||
for (EntityPlayerMP player : players) {
|
||||
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.NukkitUtil;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
@ -30,9 +31,30 @@ public class NukkitChunk extends CharFaweChunk<BaseFullChunk, NukkitQueue> {
|
||||
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
|
||||
public BaseFullChunk getNewChunk() {
|
||||
return ((NukkitQueue) getParent()).getWorld().getChunk(getX(), getZ());
|
||||
return ((NukkitQueue) getParent()).getWorld().getChunk(getX(), getZ(), true);
|
||||
}
|
||||
|
||||
private int layer = -1;
|
||||
@ -41,10 +63,12 @@ public class NukkitChunk extends CharFaweChunk<BaseFullChunk, NukkitQueue> {
|
||||
|
||||
@Override
|
||||
public NukkitChunk call() {
|
||||
// Set heightmap
|
||||
getParent().setHeightMap(this, heightMap);
|
||||
NukkitQueue parent = (NukkitQueue) getParent();
|
||||
Level world = ((NukkitQueue) getParent()).getWorld();
|
||||
world.clearCache(true);
|
||||
final BaseFullChunk chunk = (world.getChunk(getX(), getZ(), true));
|
||||
final BaseFullChunk chunk = getChunk();
|
||||
char[][] sections = getCombinedIdArrays();
|
||||
final int[][] biomes = getBiomeArray();
|
||||
final int X = getX() << 4;
|
||||
|
@ -50,13 +50,14 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
BaseFullChunk forgeChunk = (BaseFullChunk) chunk.getChunk();
|
||||
if (forgeChunk != null) {
|
||||
int[] otherMap = forgeChunk.getHeightMapArray();
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
if (heightMap[i] > otherMap[i]) {
|
||||
otherMap[i] = heightMap[i];
|
||||
int value = heightMap[i] & 0xFF;
|
||||
if (value > value) {
|
||||
otherMap[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user