Potential fix for crash
This commit is contained in:
parent
d5ea46a29c
commit
8e91d8a6ad
3
.gitignore
vendored
3
.gitignore
vendored
@ -22,4 +22,5 @@ gradle.log
|
|||||||
/bukkit19/build
|
/bukkit19/build
|
||||||
/bukkit18/build
|
/bukkit18/build
|
||||||
build
|
build
|
||||||
/mvn
|
/mvn
|
||||||
|
spigot-1.10
|
@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.v1_10;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||||
import com.boydti.fawe.example.CharFaweChunk;
|
import com.boydti.fawe.example.CharFaweChunk;
|
||||||
import com.boydti.fawe.object.BytePair;
|
import com.boydti.fawe.object.BytePair;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
@ -9,35 +10,12 @@ 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.CompoundTag;
|
import com.sk89q.jnbt.*;
|
||||||
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.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
import net.minecraft.server.v1_10_R1.*;
|
||||||
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;
|
||||||
@ -180,70 +158,86 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
|
|||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
continue;
|
continue;
|
||||||
} else if (count >= 4096) {
|
} else if (count >= 4096) {
|
||||||
entities[i].clear();
|
Collection<Entity> ents = entities[i];
|
||||||
|
if (!ents.isEmpty()) {
|
||||||
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
|
ents.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
char[] array = this.getIdArray(i);
|
Collection<Entity> ents = entities[i];
|
||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
if (!ents.isEmpty()) {
|
||||||
for (Entity entity : ents) {
|
char[] array = this.getIdArray(i);
|
||||||
if (entity instanceof EntityPlayer) {
|
ents = new ArrayList<>(entities[i]);
|
||||||
continue;
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
}
|
for (Entity entity : ents) {
|
||||||
int x = ((int) Math.round(entity.locX) & 15);
|
if (entity instanceof EntityPlayer) {
|
||||||
int z = ((int) Math.round(entity.locZ) & 15);
|
continue;
|
||||||
int y = (int) Math.round(entity.locY);
|
}
|
||||||
if (array == null || y < 0 || y > 255) {
|
int x = ((int) Math.round(entity.locX) & 15);
|
||||||
continue;
|
int z = ((int) Math.round(entity.locZ) & 15);
|
||||||
}
|
int y = (int) Math.round(entity.locY);
|
||||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
if (array == null || y < 0 || y > 255) {
|
||||||
nmsWorld.removeEntity(entity);
|
continue;
|
||||||
|
}
|
||||||
|
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||||
|
nmsWorld.removeEntity(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
||||||
if (entsToRemove.size() > 0) {
|
if (!entsToRemove.isEmpty()) {
|
||||||
for (int i = 0; i < entities.length; i++) {
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
for (int i = 0; i < entities.length; i++) {
|
||||||
for (Entity entity : ents) {
|
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||||
if (entsToRemove.contains(entity.getUniqueID())) {
|
for (Entity entity : ents) {
|
||||||
nmsWorld.removeEntity(entity);
|
if (entsToRemove.contains(entity.getUniqueID())) {
|
||||||
|
nmsWorld.removeEntity(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set entities
|
// Set entities
|
||||||
Set<UUID> createdEntities = new HashSet<>();
|
|
||||||
Set<CompoundTag> entitiesToSpawn = this.getEntities();
|
Set<CompoundTag> entitiesToSpawn = this.getEntities();
|
||||||
for (CompoundTag nativeTag : entitiesToSpawn) {
|
Set<UUID> createdEntities = new HashSet<>();
|
||||||
Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
|
if (!entitiesToSpawn.isEmpty()) {
|
||||||
StringTag idTag = (StringTag) entityTagMap.get("Id");
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
for (CompoundTag nativeTag : entitiesToSpawn) {
|
||||||
ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
|
||||||
if (idTag == null || posTag == null || rotTag == null) {
|
StringTag idTag = (StringTag) entityTagMap.get("Id");
|
||||||
Fawe.debug("Unknown entity tag: " + nativeTag);
|
ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
||||||
continue;
|
ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
||||||
}
|
if (idTag == null || posTag == null || rotTag == null) {
|
||||||
double x = posTag.getDouble(0);
|
Fawe.debug("Unknown entity tag: " + nativeTag);
|
||||||
double y = posTag.getDouble(1);
|
continue;
|
||||||
double z = posTag.getDouble(2);
|
}
|
||||||
float yaw = rotTag.getFloat(0);
|
double x = posTag.getDouble(0);
|
||||||
float pitch = rotTag.getFloat(1);
|
double y = posTag.getDouble(1);
|
||||||
String id = idTag.getValue();
|
double z = posTag.getDouble(2);
|
||||||
Entity entity = EntityTypes.createEntityByName(id, nmsWorld);
|
float yaw = rotTag.getFloat(0);
|
||||||
if (entity != null) {
|
float pitch = rotTag.getFloat(1);
|
||||||
UUID uuid = entity.getUniqueID();
|
String id = idTag.getValue();
|
||||||
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
|
Entity entity = EntityTypes.createEntityByName(id, nmsWorld);
|
||||||
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
|
if (entity != null) {
|
||||||
if (nativeTag != null) {
|
UUID uuid = entity.getUniqueID();
|
||||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_10.methodFromNative.invoke(BukkitQueue_1_10.adapter, nativeTag);
|
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
|
||||||
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
|
||||||
tag.remove(name);
|
if (nativeTag != null) {
|
||||||
|
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_10.methodFromNative.invoke(BukkitQueue_1_10.adapter, nativeTag);
|
||||||
|
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||||
|
tag.remove(name);
|
||||||
|
}
|
||||||
|
entity.f(tag);
|
||||||
|
}
|
||||||
|
entity.setLocation(x, y, z, yaw, pitch);
|
||||||
|
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
createdEntities.add(entity.getUniqueID());
|
||||||
}
|
}
|
||||||
entity.f(tag);
|
|
||||||
}
|
}
|
||||||
entity.setLocation(x, y, z, yaw, pitch);
|
|
||||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
createdEntities.add(entity.getUniqueID());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Change task?
|
// Change task?
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.v1_7;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||||
import com.boydti.fawe.example.CharFaweChunk;
|
import com.boydti.fawe.example.CharFaweChunk;
|
||||||
import com.boydti.fawe.object.BytePair;
|
import com.boydti.fawe.object.BytePair;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
@ -161,22 +162,45 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
|||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
continue;
|
continue;
|
||||||
} else if (count >= 4096) {
|
} else if (count >= 4096) {
|
||||||
entities[i].clear();
|
Collection<Entity> ents = entities[i];
|
||||||
|
if (!ents.isEmpty()) {
|
||||||
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
|
ents.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
char[] array = this.getIdArray(i);
|
Collection<Entity> ents = entities[i];
|
||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
if (!ents.isEmpty()) {
|
||||||
for (Entity entity : ents) {
|
char[] array = this.getIdArray(i);
|
||||||
if (entity instanceof EntityPlayer) {
|
ents = new ArrayList<>(entities[i]);
|
||||||
continue;
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
|
for (Entity entity : ents) {
|
||||||
|
if (entity instanceof EntityPlayer) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int x = ((int) Math.round(entity.locX) & 15);
|
||||||
|
int z = ((int) Math.round(entity.locZ) & 15);
|
||||||
|
int y = (int) Math.round(entity.locY);
|
||||||
|
if (array == null || y < 0 || y > 255) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||||
|
nmsWorld.removeEntity(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int x = ((int) Math.round(entity.locX) & 15);
|
}
|
||||||
int z = ((int) Math.round(entity.locZ) & 15);
|
}
|
||||||
int y = (int) Math.round(entity.locY);
|
}
|
||||||
if (array == null) {
|
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
||||||
continue;
|
if (!entsToRemove.isEmpty()) {
|
||||||
}
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
for (int i = 0; i < entities.length; i++) {
|
||||||
nmsWorld.removeEntity(entity);
|
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||||
|
for (Entity entity : ents) {
|
||||||
|
if (entsToRemove.contains(entity.getUniqueID())) {
|
||||||
|
nmsWorld.removeEntity(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,33 +208,37 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
|||||||
// Set entities
|
// Set entities
|
||||||
Set<UUID> createdEntities = new HashSet<>();
|
Set<UUID> createdEntities = new HashSet<>();
|
||||||
Set<CompoundTag> entitiesToSpawn = this.getEntities();
|
Set<CompoundTag> entitiesToSpawn = this.getEntities();
|
||||||
for (CompoundTag nativeTag : entitiesToSpawn) {
|
if (!entitiesToSpawn.isEmpty()) {
|
||||||
Map<String, Tag> entityTagMap = nativeTag.getValue();
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
StringTag idTag = (StringTag) entityTagMap.get("Id");
|
for (CompoundTag nativeTag : entitiesToSpawn) {
|
||||||
ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
Map<String, Tag> entityTagMap = nativeTag.getValue();
|
||||||
ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
StringTag idTag = (StringTag) entityTagMap.get("Id");
|
||||||
if (idTag == null || posTag == null || rotTag == null) {
|
ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
||||||
Fawe.debug("Unknown entity tag: " + nativeTag);
|
ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
||||||
continue;
|
if (idTag == null || posTag == null || rotTag == null) {
|
||||||
}
|
Fawe.debug("Unknown entity tag: " + nativeTag);
|
||||||
double x = posTag.getDouble(0);
|
continue;
|
||||||
double y = posTag.getDouble(1);
|
}
|
||||||
double z = posTag.getDouble(2);
|
double x = posTag.getDouble(0);
|
||||||
float yaw = rotTag.getFloat(0);
|
double y = posTag.getDouble(1);
|
||||||
float pitch = rotTag.getFloat(1);
|
double z = posTag.getDouble(2);
|
||||||
String id = idTag.getValue();
|
float yaw = rotTag.getFloat(0);
|
||||||
Entity entity = EntityTypes.createEntityByName(id, nmsWorld);
|
float pitch = rotTag.getFloat(1);
|
||||||
if (entity != null) {
|
String id = idTag.getValue();
|
||||||
if (nativeTag != null) {
|
Entity entity = EntityTypes.createEntityByName(id, nmsWorld);
|
||||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue17.methodFromNative.invoke(BukkitQueue17.adapter, nativeTag);
|
if (entity != null) {
|
||||||
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
if (nativeTag != null) {
|
||||||
tag.remove(name);
|
NBTTagCompound tag = (NBTTagCompound) BukkitQueue17.methodFromNative.invoke(BukkitQueue17.adapter, nativeTag);
|
||||||
|
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||||
|
tag.remove(name);
|
||||||
|
}
|
||||||
|
entity.f(tag);
|
||||||
|
}
|
||||||
|
entity.setLocation(x, y, z, yaw, pitch);
|
||||||
|
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
createdEntities.add(entity.getUniqueID());
|
||||||
}
|
}
|
||||||
entity.f(tag);
|
|
||||||
}
|
}
|
||||||
entity.setLocation(x, y, z, yaw, pitch);
|
|
||||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
createdEntities.add(entity.getUniqueID());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Run change task if applicable
|
// Run change task if applicable
|
||||||
@ -251,17 +279,6 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
|
||||||
if (entsToRemove.size() > 0) {
|
|
||||||
for (int i = 0; i < entities.length; i++) {
|
|
||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
|
||||||
for (Entity entity : ents) {
|
|
||||||
if (entsToRemove.contains(entity.getUniqueID())) {
|
|
||||||
nmsWorld.removeEntity(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Set blocks
|
// Set blocks
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
if (this.getCount(j) == 0) {
|
if (this.getCount(j) == 0) {
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.v1_8;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||||
import com.boydti.fawe.example.CharFaweChunk;
|
import com.boydti.fawe.example.CharFaweChunk;
|
||||||
import com.boydti.fawe.object.BytePair;
|
import com.boydti.fawe.object.BytePair;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
@ -75,22 +76,45 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
|
|||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
continue;
|
continue;
|
||||||
} else if (count >= 4096) {
|
} else if (count >= 4096) {
|
||||||
entities[i].clear();
|
Collection<Entity> ents = entities[i];
|
||||||
|
if (!ents.isEmpty()) {
|
||||||
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
|
ents.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
char[] array = this.getIdArray(i);
|
Collection<Entity> ents = entities[i];
|
||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
if (!ents.isEmpty()) {
|
||||||
for (Entity entity : ents) {
|
char[] array = this.getIdArray(i);
|
||||||
if (entity instanceof EntityPlayer) {
|
ents = new ArrayList<>(entities[i]);
|
||||||
continue;
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
|
for (Entity entity : ents) {
|
||||||
|
if (entity instanceof EntityPlayer) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int x = ((int) Math.round(entity.locX) & 15);
|
||||||
|
int z = ((int) Math.round(entity.locZ) & 15);
|
||||||
|
int y = (int) Math.round(entity.locY);
|
||||||
|
if (array == null || y < 0 || y > 255) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||||
|
nmsWorld.removeEntity(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int x = ((int) Math.round(entity.locX) & 15);
|
}
|
||||||
int z = ((int) Math.round(entity.locZ) & 15);
|
}
|
||||||
int y = (int) Math.round(entity.locY);
|
}
|
||||||
if (array == null) {
|
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
||||||
continue;
|
if (!entsToRemove.isEmpty()) {
|
||||||
}
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
for (int i = 0; i < entities.length; i++) {
|
||||||
nmsWorld.removeEntity(entity);
|
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||||
|
for (Entity entity : ents) {
|
||||||
|
if (entsToRemove.contains(entity.getUniqueID())) {
|
||||||
|
nmsWorld.removeEntity(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,33 +122,37 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
|
|||||||
// Set entities
|
// Set entities
|
||||||
Set<UUID> createdEntities = new HashSet<>();
|
Set<UUID> createdEntities = new HashSet<>();
|
||||||
Set<CompoundTag> entitiesToSpawn = this.getEntities();
|
Set<CompoundTag> entitiesToSpawn = this.getEntities();
|
||||||
for (CompoundTag nativeTag : entitiesToSpawn) {
|
if (!entitiesToSpawn.isEmpty()) {
|
||||||
Map<String, Tag> entityTagMap = nativeTag.getValue();
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
StringTag idTag = (StringTag) entityTagMap.get("Id");
|
for (CompoundTag nativeTag : entitiesToSpawn) {
|
||||||
ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
Map<String, Tag> entityTagMap = nativeTag.getValue();
|
||||||
ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
StringTag idTag = (StringTag) entityTagMap.get("Id");
|
||||||
if (idTag == null || posTag == null || rotTag == null) {
|
ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
||||||
Fawe.debug("Unknown entity tag: " + nativeTag);
|
ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
||||||
continue;
|
if (idTag == null || posTag == null || rotTag == null) {
|
||||||
}
|
Fawe.debug("Unknown entity tag: " + nativeTag);
|
||||||
double x = posTag.getDouble(0);
|
continue;
|
||||||
double y = posTag.getDouble(1);
|
}
|
||||||
double z = posTag.getDouble(2);
|
double x = posTag.getDouble(0);
|
||||||
float yaw = rotTag.getFloat(0);
|
double y = posTag.getDouble(1);
|
||||||
float pitch = rotTag.getFloat(1);
|
double z = posTag.getDouble(2);
|
||||||
String id = idTag.getValue();
|
float yaw = rotTag.getFloat(0);
|
||||||
Entity entity = EntityTypes.createEntityByName(id, nmsWorld);
|
float pitch = rotTag.getFloat(1);
|
||||||
if (entity != null) {
|
String id = idTag.getValue();
|
||||||
if (nativeTag != null) {
|
Entity entity = EntityTypes.createEntityByName(id, nmsWorld);
|
||||||
NBTTagCompound tag = (NBTTagCompound)BukkitQueue18R3.methodFromNative.invoke(BukkitQueue18R3.adapter, nativeTag);
|
if (entity != null) {
|
||||||
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
if (nativeTag != null) {
|
||||||
tag.remove(name);
|
NBTTagCompound tag = (NBTTagCompound) BukkitQueue18R3.methodFromNative.invoke(BukkitQueue18R3.adapter, nativeTag);
|
||||||
|
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||||
|
tag.remove(name);
|
||||||
|
}
|
||||||
|
entity.f(tag);
|
||||||
|
}
|
||||||
|
entity.setLocation(x, y, z, yaw, pitch);
|
||||||
|
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
createdEntities.add(entity.getUniqueID());
|
||||||
}
|
}
|
||||||
entity.f(tag);
|
|
||||||
}
|
}
|
||||||
entity.setLocation(x, y, z, yaw, pitch);
|
|
||||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
createdEntities.add(entity.getUniqueID());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Run change task if applicable
|
// Run change task if applicable
|
||||||
@ -165,17 +193,6 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
|
||||||
if (entsToRemove.size() > 0) {
|
|
||||||
for (int i = 0; i < entities.length; i++) {
|
|
||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
|
||||||
for (Entity entity : ents) {
|
|
||||||
if (entsToRemove.contains(entity.getUniqueID())) {
|
|
||||||
nmsWorld.removeEntity(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Set blocks
|
// Set blocks
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
if (this.getCount(j) == 0) {
|
if (this.getCount(j) == 0) {
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.v1_9;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||||
import com.boydti.fawe.example.CharFaweChunk;
|
import com.boydti.fawe.example.CharFaweChunk;
|
||||||
import com.boydti.fawe.object.BytePair;
|
import com.boydti.fawe.object.BytePair;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
@ -9,36 +10,12 @@ 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.CompoundTag;
|
import com.sk89q.jnbt.*;
|
||||||
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.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
import net.minecraft.server.v1_9_R2.*;
|
||||||
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;
|
||||||
@ -183,70 +160,86 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
|
|||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
continue;
|
continue;
|
||||||
} else if (count >= 4096) {
|
} else if (count >= 4096) {
|
||||||
entities[i].clear();
|
Collection<Entity> ents = entities[i];
|
||||||
|
if (!ents.isEmpty()) {
|
||||||
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
|
ents.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
char[] array = this.getIdArray(i);
|
Collection<Entity> ents = entities[i];
|
||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
if (!ents.isEmpty()) {
|
||||||
for (Entity entity : ents) {
|
char[] array = this.getIdArray(i);
|
||||||
if (entity instanceof EntityPlayer) {
|
ents = new ArrayList<>(entities[i]);
|
||||||
continue;
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
}
|
for (Entity entity : ents) {
|
||||||
int x = ((int) Math.round(entity.locX) & 15);
|
if (entity instanceof EntityPlayer) {
|
||||||
int z = ((int) Math.round(entity.locZ) & 15);
|
continue;
|
||||||
int y = (int) Math.round(entity.locY);
|
}
|
||||||
if (array == null || y < 0 || y > 255) {
|
int x = ((int) Math.round(entity.locX) & 15);
|
||||||
continue;
|
int z = ((int) Math.round(entity.locZ) & 15);
|
||||||
}
|
int y = (int) Math.round(entity.locY);
|
||||||
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
if (array == null || y < 0 || y > 255) {
|
||||||
nmsWorld.removeEntity(entity);
|
continue;
|
||||||
|
}
|
||||||
|
if (y < 0 || y > 255 || array[FaweCache.CACHE_J[y][z][x]] != 0) {
|
||||||
|
nmsWorld.removeEntity(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
||||||
if (entsToRemove.size() > 0) {
|
if (!entsToRemove.isEmpty()) {
|
||||||
for (int i = 0; i < entities.length; i++) {
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
for (int i = 0; i < entities.length; i++) {
|
||||||
for (Entity entity : ents) {
|
Collection<Entity> ents = new ArrayList<>(entities[i]);
|
||||||
if (entsToRemove.contains(entity.getUniqueID())) {
|
for (Entity entity : ents) {
|
||||||
nmsWorld.removeEntity(entity);
|
if (entsToRemove.contains(entity.getUniqueID())) {
|
||||||
|
nmsWorld.removeEntity(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set entities
|
// Set entities
|
||||||
Set<UUID> createdEntities = new HashSet<>();
|
|
||||||
Set<CompoundTag> entitiesToSpawn = this.getEntities();
|
Set<CompoundTag> entitiesToSpawn = this.getEntities();
|
||||||
for (CompoundTag nativeTag : entitiesToSpawn) {
|
Set<UUID> createdEntities = new HashSet<>();
|
||||||
Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
|
if (!entitiesToSpawn.isEmpty()) {
|
||||||
StringTag idTag = (StringTag) entityTagMap.get("Id");
|
synchronized (BukkitQueue_0.adapter) {
|
||||||
ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
for (CompoundTag nativeTag : entitiesToSpawn) {
|
||||||
ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
|
||||||
if (idTag == null || posTag == null || rotTag == null) {
|
StringTag idTag = (StringTag) entityTagMap.get("Id");
|
||||||
Fawe.debug("Unknown entity tag: " + nativeTag);
|
ListTag posTag = (ListTag) entityTagMap.get("Pos");
|
||||||
continue;
|
ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
||||||
}
|
if (idTag == null || posTag == null || rotTag == null) {
|
||||||
double x = posTag.getDouble(0);
|
Fawe.debug("Unknown entity tag: " + nativeTag);
|
||||||
double y = posTag.getDouble(1);
|
continue;
|
||||||
double z = posTag.getDouble(2);
|
}
|
||||||
float yaw = rotTag.getFloat(0);
|
double x = posTag.getDouble(0);
|
||||||
float pitch = rotTag.getFloat(1);
|
double y = posTag.getDouble(1);
|
||||||
String id = idTag.getValue();
|
double z = posTag.getDouble(2);
|
||||||
Entity entity = EntityTypes.createEntityByName(id, nmsWorld);
|
float yaw = rotTag.getFloat(0);
|
||||||
if (entity != null) {
|
float pitch = rotTag.getFloat(1);
|
||||||
UUID uuid = entity.getUniqueID();
|
String id = idTag.getValue();
|
||||||
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
|
Entity entity = EntityTypes.createEntityByName(id, nmsWorld);
|
||||||
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
|
if (entity != null) {
|
||||||
if (nativeTag != null) {
|
UUID uuid = entity.getUniqueID();
|
||||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_9_R1.methodFromNative.invoke(BukkitQueue_1_9_R1.adapter, nativeTag);
|
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
|
||||||
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
|
||||||
tag.remove(name);
|
if (nativeTag != null) {
|
||||||
|
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_9_R1.methodFromNative.invoke(BukkitQueue_1_9_R1.adapter, nativeTag);
|
||||||
|
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||||
|
tag.remove(name);
|
||||||
|
}
|
||||||
|
entity.f(tag);
|
||||||
|
}
|
||||||
|
entity.setLocation(x, y, z, yaw, pitch);
|
||||||
|
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
createdEntities.add(entity.getUniqueID());
|
||||||
}
|
}
|
||||||
entity.f(tag);
|
|
||||||
}
|
}
|
||||||
entity.setLocation(x, y, z, yaw, pitch);
|
|
||||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
createdEntities.add(entity.getUniqueID());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Change task?
|
// Change task?
|
||||||
|
@ -67,6 +67,8 @@ public class FaweTimer implements Runnable {
|
|||||||
if (skip > 0) {
|
if (skip > 0) {
|
||||||
if (skipTick != tick) {
|
if (skipTick != tick) {
|
||||||
skip--;
|
skip--;
|
||||||
|
skipTick = tick;
|
||||||
|
return true; // Run once per tick
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,14 @@ public class SetQueue {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
double targetTPS = 18 - Math.max(Settings.QUEUE.EXTRA_TIME_MS * 0.05, 0);
|
double targetTPS = 18 - Math.max(Settings.QUEUE.EXTRA_TIME_MS * 0.05, 0);
|
||||||
while (!tasks.isEmpty() && Fawe.get().getTimer().isAbove(targetTPS)) {
|
do {
|
||||||
tasks.poll().run();
|
Runnable task = tasks.poll();
|
||||||
}
|
if (task != null) {
|
||||||
|
task.run();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (Fawe.get().getTimer().isAbove(targetTPS));
|
||||||
if (inactiveQueues.isEmpty() && activeQueues.isEmpty()) {
|
if (inactiveQueues.isEmpty() && activeQueues.isEmpty()) {
|
||||||
lastSuccess = System.currentTimeMillis();
|
lastSuccess = System.currentTimeMillis();
|
||||||
runEmptyTasks();
|
runEmptyTasks();
|
||||||
|
Loading…
Reference in New Issue
Block a user