mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Cleanup and prevent some potential NPEs
This commit is contained in:
parent
c20a2ecd9a
commit
41d1714d28
@ -11,7 +11,6 @@ import com.volmit.iris.scaffold.engine.EngineCompound;
|
||||
import com.volmit.iris.scaffold.engine.EngineData;
|
||||
import com.volmit.iris.scaffold.engine.EngineTarget;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Getter;
|
||||
@ -54,7 +53,7 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
private final IrisDimension rootDimension;
|
||||
|
||||
@Getter
|
||||
private int threadCount;
|
||||
private final int threadCount = -1;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ -83,31 +82,29 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
Class<?> clazz = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".ChunkGenerator");
|
||||
Class<?> clazzSG = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".StructureGenerator");
|
||||
Class<?> clazzBP = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".BlockPosition");
|
||||
CompletableFuture<Object> cf = new CompletableFuture<>();
|
||||
Object BP = null;
|
||||
getBPSafe(clazz, clazzSG, clazzBP, nmsWorld, chunkGenerator).thenAccept(bp -> {
|
||||
if (bp == null){
|
||||
throw new NullPointerException();
|
||||
}
|
||||
strongholds.add(new IrisPosition((int) new V(bp, false).invoke("getX"), (int) new V(bp, false).invoke("getY"), (int) new V(bp, false).invoke("getZ")));
|
||||
String positions = "";
|
||||
StringBuilder positions = new StringBuilder();
|
||||
for (IrisPosition pos : strongholds){
|
||||
positions += "(" + pos.getX() + "," + pos.getY() + "," + pos.getZ() + ") ";
|
||||
positions.append("(").append(pos.getX()).append(",").append(pos.getY()).append(",").append(pos.getZ()).append(") ");
|
||||
}
|
||||
Iris.info("Strongholds (" + engineMetadata.getStrongholdPositions().size() + ") found at [" + positions + "]");
|
||||
});
|
||||
|
||||
engineMetadata.setStrongholdPositions(strongholds);
|
||||
} catch (Throwable ignored) {
|
||||
strongholds.add( new IrisPosition(10337, 32, -1337) );
|
||||
} catch (Throwable e) {
|
||||
strongholds.add( new IrisPosition(1337, 32, -1337) );
|
||||
engineMetadata.setStrongholdPositions(strongholds);
|
||||
Iris.warn("Couldn't properly find the stronghold position for this world. Is this headless mode? Are you not using 1.16 or higher?");
|
||||
Iris.warn(" -> Setting default stronghold position");
|
||||
ignored.printStackTrace();
|
||||
e.printStackTrace();
|
||||
Iris.info("Got this far (3)");
|
||||
String positions = "";
|
||||
StringBuilder positions = new StringBuilder();
|
||||
for (IrisPosition pos : strongholds){
|
||||
positions += "(" + pos.getX() + "," + pos.getY() + "," + pos.getZ() + ") ";
|
||||
positions.append("(").append(pos.getX()).append(",").append(pos.getY()).append(",").append(pos.getZ()).append(") ");
|
||||
}
|
||||
Iris.info("Strongholds (" + engineMetadata.getStrongholdPositions().size() + ") found at [" + positions + "]");
|
||||
}
|
||||
@ -303,8 +300,6 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
{
|
||||
int i;
|
||||
int offset = 0;
|
||||
BurstExecutor e = burster.burst();
|
||||
Runnable[] insert = new Runnable[engines.length];
|
||||
|
||||
for(i = 0; i < engines.length; i++)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ public class CommandIrisWhatBiome extends MortarCommand
|
||||
{
|
||||
|
||||
IrisAccess g = IrisWorlds.access(w);
|
||||
assert g != null;
|
||||
IrisBiome b = g.getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ());
|
||||
sender.sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")");
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ public class CommandIrisWhatObjects extends MortarCommand
|
||||
stop.add(i);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.block.data.type.Leaves;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@ -103,8 +104,8 @@ public class IrisObject extends IrisRegistrant
|
||||
{
|
||||
if(getBlocks().containsKey(new BlockVector(ray, rayY, rayZ)))
|
||||
{
|
||||
start = ray < start ? ray : start;
|
||||
end = ray > end ? ray : end;
|
||||
start = Math.min(ray, start);
|
||||
end = Math.max(ray, end);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,8 +137,8 @@ public class IrisObject extends IrisRegistrant
|
||||
{
|
||||
if(getBlocks().containsKey(new BlockVector(rayX, ray, rayZ)))
|
||||
{
|
||||
start = ray < start ? ray : start;
|
||||
end = ray > end ? ray : end;
|
||||
start = Math.min(ray, start);
|
||||
end = Math.max(ray, end);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,8 +170,8 @@ public class IrisObject extends IrisRegistrant
|
||||
{
|
||||
if(getBlocks().containsKey(new BlockVector(rayX, rayY, ray)))
|
||||
{
|
||||
start = ray < start ? ray : start;
|
||||
end = ray > end ? ray : end;
|
||||
start = Math.min(ray, start);
|
||||
end = Math.max(ray, end);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,12 +205,12 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
for(BlockVector i : getBlocks().keySet())
|
||||
{
|
||||
o.getBlocks().put(i.clone(), getBlocks().get(i).clone());
|
||||
o.getBlocks().put(i.clone(), Objects.requireNonNull(getBlocks().get(i)).clone());
|
||||
}
|
||||
|
||||
for(BlockVector i : getStates().keySet())
|
||||
{
|
||||
o.getStates().put(i.clone(), getStates().get(i).clone());
|
||||
o.getStates().put(i.clone(), Objects.requireNonNull(getStates().get(i)).clone());
|
||||
}
|
||||
|
||||
return o;
|
||||
@ -266,7 +267,7 @@ public class IrisObject extends IrisRegistrant
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
@ -335,7 +336,7 @@ public class IrisObject extends IrisRegistrant
|
||||
dos.writeShort(i.getBlockX());
|
||||
dos.writeShort(i.getBlockY());
|
||||
dos.writeShort(i.getBlockZ());
|
||||
dos.writeShort(palette.indexOf(getBlocks().get(i).getAsString()));
|
||||
dos.writeShort(palette.indexOf(Objects.requireNonNull(getBlocks().get(i)).getAsString()));
|
||||
}
|
||||
|
||||
dos.writeInt(getStates().size());
|
||||
@ -344,7 +345,7 @@ public class IrisObject extends IrisRegistrant
|
||||
dos.writeShort(i.getBlockX());
|
||||
dos.writeShort(i.getBlockY());
|
||||
dos.writeShort(i.getBlockZ());
|
||||
getStates().get(i).toBinary(dos);
|
||||
Objects.requireNonNull(getStates().get(i)).toBinary(dos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,7 +390,7 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
for(BlockVector i : getBlocks().keySet())
|
||||
{
|
||||
d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), getBlocks().get(i));
|
||||
d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i)));
|
||||
}
|
||||
|
||||
SmoothieMap<BlockVector, TileData<? extends TileState>> dx = SmoothieMap.<BlockVector, TileData<? extends TileState>>newBuilder()
|
||||
@ -400,12 +401,12 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
for(BlockVector i : getBlocks().keySet())
|
||||
{
|
||||
d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), getBlocks().get(i));
|
||||
d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i)));
|
||||
}
|
||||
|
||||
for(BlockVector i : getStates().keySet())
|
||||
{
|
||||
dx.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), getStates().get(i));
|
||||
dx.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getStates().get(i)));
|
||||
}
|
||||
|
||||
blocks = d;
|
||||
@ -627,7 +628,7 @@ public class IrisObject extends IrisRegistrant
|
||||
{
|
||||
for(int j = y - Math.floorDiv(h, 2) - config.getBoreExtendMinY() + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) + config.getBoreExtendMaxY() - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++)
|
||||
{
|
||||
for(int k = (int) (z - Math.floorDiv(d, 2) + (int) offset.getZ()); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++)
|
||||
for(int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++)
|
||||
{
|
||||
placer.set(i, j, k, AIR);
|
||||
}
|
||||
@ -640,7 +641,7 @@ public class IrisObject extends IrisRegistrant
|
||||
readLock.lock();
|
||||
for(BlockVector g : getBlocks().keySet())
|
||||
{
|
||||
BlockData d = null;
|
||||
BlockData d;
|
||||
TileData<? extends TileState> tile = null;
|
||||
|
||||
try
|
||||
@ -751,7 +752,7 @@ public class IrisObject extends IrisRegistrant
|
||||
readLock.lock();
|
||||
for(BlockVector g : getBlocks().keySet())
|
||||
{
|
||||
BlockData d = null;
|
||||
BlockData d;
|
||||
|
||||
try
|
||||
{
|
||||
@ -847,7 +848,7 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
for(BlockVector i : getBlocks().keySet())
|
||||
{
|
||||
d.put(r.rotate(i.clone(), spinx, spiny, spinz), r.rotate(getBlocks().get(i).clone(), spinx, spiny, spinz));
|
||||
d.put(r.rotate(i.clone(), spinx, spiny, spinz), r.rotate(Objects.requireNonNull(getBlocks().get(i)).clone(), spinx, spiny, spinz));
|
||||
}
|
||||
|
||||
SmoothieMap<BlockVector, TileData<? extends TileState>> dx = SmoothieMap.<BlockVector, TileData<? extends TileState>>newBuilder()
|
||||
@ -858,7 +859,7 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
for(BlockVector i : getStates().keySet())
|
||||
{
|
||||
dx.put(r.rotate(i.clone(), spinx, spiny, spinz), getStates().get(i));
|
||||
dx.put(r.rotate(i.clone(), spinx, spiny, spinz), Objects.requireNonNull(getStates().get(i)));
|
||||
}
|
||||
|
||||
blocks = d;
|
||||
@ -870,13 +871,13 @@ public class IrisObject extends IrisRegistrant
|
||||
for(BlockVector i : getBlocks().keySet())
|
||||
{
|
||||
Block b = at.clone().add(0, getCenter().getY(), 0).add(i).getBlock();
|
||||
b.setBlockData(getBlocks().get(i), false);
|
||||
b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false);
|
||||
|
||||
if(getStates().containsKey(i))
|
||||
{
|
||||
Iris.info(states.get(i).toString());
|
||||
Iris.info(Objects.requireNonNull(states.get(i)).toString());
|
||||
BlockState st = b.getState();
|
||||
getStates().get(i).toBukkitTry(st);
|
||||
Objects.requireNonNull(getStates().get(i)).toBukkitTry(st);
|
||||
st.update();
|
||||
}
|
||||
}
|
||||
@ -887,11 +888,11 @@ public class IrisObject extends IrisRegistrant
|
||||
for(BlockVector i : getBlocks().keySet())
|
||||
{
|
||||
Block b = at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock();
|
||||
b.setBlockData(getBlocks().get(i), false);
|
||||
b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false);
|
||||
|
||||
if(getStates().containsKey(i))
|
||||
{
|
||||
getStates().get(i).toBukkitTry(b.getState());
|
||||
Objects.requireNonNull(getStates().get(i)).toBukkitTry(b.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class PlannedStructure {
|
||||
|
||||
for(int i = 0; i < structure.getMaxDepth(); i++)
|
||||
{
|
||||
generateOutwards(i);
|
||||
generateOutwards();
|
||||
}
|
||||
|
||||
generateTerminators();
|
||||
@ -116,7 +116,7 @@ public class PlannedStructure {
|
||||
{
|
||||
if(j.getSpawnEntity() != null && h != -1)
|
||||
{
|
||||
IrisPosition p = null;
|
||||
IrisPosition p;
|
||||
if (j.getEntityPosition() == null){
|
||||
p = new IrisPosition(j.getDirection().toVector().multiply(2));
|
||||
} else {
|
||||
@ -139,8 +139,6 @@ public class PlannedStructure {
|
||||
|
||||
if(options.isVacuum())
|
||||
{
|
||||
int dx = xx;
|
||||
int dz = zz;
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
IrisFeature f = new IrisFeature();
|
||||
f.setConvergeToHeight(h - (v.getH() >> 1)-1);
|
||||
@ -148,9 +146,9 @@ public class PlannedStructure {
|
||||
f.setInterpolationRadius(a/4);
|
||||
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
||||
f.setStrength(1D);
|
||||
e.getParallaxAccess().getMetaRW(dx>>4, dz>>4)
|
||||
e.getParallaxAccess().getMetaRW(xx >>4, zz >>4)
|
||||
.getFeatures()
|
||||
.add(new IrisFeaturePositional(dx, dz, f));
|
||||
.add(new IrisFeaturePositional(xx, zz, f));
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +177,7 @@ public class PlannedStructure {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateOutwards(int layer) {
|
||||
private void generateOutwards() {
|
||||
for(PlannedPiece i : getPiecesWithAvailableConnectors().shuffleCopy(rng))
|
||||
{
|
||||
if(!generatePieceOutwards(i))
|
||||
@ -221,18 +219,17 @@ public class PlannedStructure {
|
||||
|
||||
for(Integer i : forder1)
|
||||
{
|
||||
if(pieceConnector.isRotateConnector() && !pieceConnector.getDirection().getAxis().equals(Axis.Y))
|
||||
{
|
||||
for(Integer j : forder2)
|
||||
{
|
||||
if(pieceConnector.getDirection().getAxis().equals(Axis.X) && generateRotatedPiece(piece, pieceConnector, idea, j, i, 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(pieceConnector.isRotateConnector()) {
|
||||
assert pieceConnector.getDirection().getAxis() != null;
|
||||
if (!pieceConnector.getDirection().getAxis().equals(Axis.Y)) {
|
||||
for (Integer j : forder2) {
|
||||
if (pieceConnector.getDirection().getAxis().equals(Axis.X) && generateRotatedPiece(piece, pieceConnector, idea, j, i, 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(pieceConnector.getDirection().getAxis().equals(Axis.Z) && generateRotatedPiece(piece, pieceConnector, idea, 0, i, j))
|
||||
{
|
||||
return true;
|
||||
if (pieceConnector.getDirection().getAxis().equals(Axis.Z) && generateRotatedPiece(piece, pieceConnector, idea, 0, i, j)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,7 +336,7 @@ public class PlannedStructure {
|
||||
if(getStructure().isTerminate())
|
||||
{
|
||||
terminating = true;
|
||||
generateOutwards(structure.getMaxDepth());
|
||||
generateOutwards();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user