mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Dont lock objects (for now)
This commit is contained in:
parent
509c32db70
commit
72f86069a2
@ -44,6 +44,7 @@ import org.bukkit.block.TileState;
|
|||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.Waterlogged;
|
import org.bukkit.block.data.Waterlogged;
|
||||||
import org.bukkit.block.data.type.Leaves;
|
import org.bukkit.block.data.type.Leaves;
|
||||||
|
import org.bukkit.entity.ThrownExpBottle;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
private int w;
|
private int w;
|
||||||
private int d;
|
private int d;
|
||||||
private int h;
|
private int h;
|
||||||
private transient final IrisLock readLock = new IrisLock("read-conclock");
|
private transient final IrisLock readLock = new IrisLock("read-conclock").setDisabled(true);
|
||||||
private transient BlockVector center;
|
private transient BlockVector center;
|
||||||
private transient volatile boolean smartBored = false;
|
private transient volatile boolean smartBored = false;
|
||||||
private transient IrisLock lock = new IrisLock("Preloadcache");
|
private transient IrisLock lock = new IrisLock("Preloadcache");
|
||||||
@ -577,97 +578,109 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
int lowest = Integer.MAX_VALUE;
|
int lowest = Integer.MAX_VALUE;
|
||||||
y += yrand;
|
y += yrand;
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
for (BlockVector g : getBlocks().keySet()) {
|
try
|
||||||
BlockData d;
|
{
|
||||||
TileData<? extends TileState> tile = null;
|
for (BlockVector g : getBlocks().keySet()) {
|
||||||
|
BlockData d;
|
||||||
|
TileData<? extends TileState> tile = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
d = getBlocks().get(g);
|
d = getBlocks().get(g);
|
||||||
tile = getStates().get(g);
|
tile = getStates().get(g);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (cme)");
|
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (cme)");
|
||||||
d = AIR;
|
d = AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (null)");
|
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (null)");
|
||||||
d = AIR;
|
d = AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockVector i = g.clone();
|
BlockVector i = g.clone();
|
||||||
BlockData data = d.clone();
|
BlockData data = d.clone();
|
||||||
i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone();
|
i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone();
|
||||||
i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone();
|
i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone();
|
||||||
|
|
||||||
if (stilting && i.getBlockY() < lowest && !B.isAir(data)) {
|
if (stilting && i.getBlockY() < lowest && !B.isAir(data)) {
|
||||||
lowest = i.getBlockY();
|
lowest = i.getBlockY();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placer.isPreventingDecay() && (data) instanceof Leaves && !((Leaves) (data)).isPersistent()) {
|
if (placer.isPreventingDecay() && (data) instanceof Leaves && !((Leaves) (data)).isPersistent()) {
|
||||||
((Leaves) data).setPersistent(true);
|
((Leaves) data).setPersistent(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IrisObjectReplace j : config.getEdit()) {
|
for (IrisObjectReplace j : config.getEdit()) {
|
||||||
if (rng.chance(j.getChance())) {
|
if (rng.chance(j.getChance())) {
|
||||||
for (BlockData k : j.getFind(rdata)) {
|
for (BlockData k : j.getFind(rdata)) {
|
||||||
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
||||||
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
|
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
|
||||||
|
|
||||||
if (newData.getMaterial() == data.getMaterial())
|
if (newData.getMaterial() == data.getMaterial())
|
||||||
data = data.merge(newData);
|
{
|
||||||
else
|
data = data.merge(newData);
|
||||||
data = newData;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = newData;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
data = config.getRotation().rotate(data, spinx, spiny, spinz);
|
data = config.getRotation().rotate(data, spinx, spiny, spinz);
|
||||||
xx = x + (int) Math.round(i.getX());
|
xx = x + (int) Math.round(i.getX());
|
||||||
int yy = y + (int) Math.round(i.getY());
|
int yy = y + (int) Math.round(i.getY());
|
||||||
zz = z + (int) Math.round(i.getZ());
|
zz = z + (int) Math.round(i.getZ());
|
||||||
|
|
||||||
if (warped) {
|
if (warped) {
|
||||||
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z);
|
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z);
|
||||||
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x);
|
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x);
|
||||||
}
|
|
||||||
|
|
||||||
if (yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) {
|
|
||||||
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, config.isUnderwater());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (heightmap != null) {
|
|
||||||
Position2 pos = new Position2(xx, zz);
|
|
||||||
|
|
||||||
if (!heightmap.containsKey(pos)) {
|
|
||||||
heightmap.put(pos, yy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (heightmap.get(pos) < yy) {
|
if (yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) {
|
||||||
heightmap.put(pos, yy);
|
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, config.isUnderwater());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (heightmap != null) {
|
||||||
|
Position2 pos = new Position2(xx, zz);
|
||||||
|
|
||||||
|
if (!heightmap.containsKey(pos)) {
|
||||||
|
heightmap.put(pos, yy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (heightmap.get(pos) < yy) {
|
||||||
|
heightmap.put(pos, yy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.isMeld() && !placer.isSolid(xx, yy, zz)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged) {
|
||||||
|
((Waterlogged) data).setWaterlogged(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listener != null) {
|
||||||
|
listener.accept(new BlockPosition(xx, yy, zz));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
|
||||||
|
placer.set(xx, yy, zz, data);
|
||||||
|
|
||||||
|
if (tile != null) {
|
||||||
|
placer.setTile(xx, yy, zz, tile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (config.isMeld() && !placer.isSolid(xx, yy, zz)) {
|
catch(Throwable e)
|
||||||
continue;
|
{
|
||||||
}
|
Iris.reportError(e);
|
||||||
|
|
||||||
if (config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged) {
|
|
||||||
((Waterlogged) data).setWaterlogged(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listener != null) {
|
|
||||||
listener.accept(new BlockPosition(xx, yy, zz));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
|
|
||||||
placer.set(xx, yy, zz, data);
|
|
||||||
|
|
||||||
if (tile != null) {
|
|
||||||
placer.setTile(xx, yy, zz, tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
readLock.unlock();
|
readLock.unlock();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user