Performance

This commit is contained in:
Daniel Mills
2020-09-01 20:41:26 -04:00
parent 683becabda
commit e8addbc954
12 changed files with 235 additions and 81 deletions
@@ -42,6 +42,7 @@ import com.volmit.iris.object.IrisStructureTile;
import com.volmit.iris.object.NoiseStyle; import com.volmit.iris.object.NoiseStyle;
import com.volmit.iris.object.StructureTileCondition; import com.volmit.iris.object.StructureTileCondition;
import com.volmit.iris.util.ArrayType; import com.volmit.iris.util.ArrayType;
import com.volmit.iris.util.C;
import com.volmit.iris.util.ChronoLatch; import com.volmit.iris.util.ChronoLatch;
import com.volmit.iris.util.DependsOn; import com.volmit.iris.util.DependsOn;
import com.volmit.iris.util.Desc; import com.volmit.iris.util.Desc;
@@ -121,6 +122,7 @@ public class ProjectManager
public void open(MortarSender sender, String dimm, Runnable onDone) public void open(MortarSender sender, String dimm, Runnable onDone)
{ {
Iris.globaldata.dump(); Iris.globaldata.dump();
Iris.globaldata.preferFolder(null);
IrisDimension d = Iris.globaldata.getDimensionLoader().load(dimm); IrisDimension d = Iris.globaldata.getDimensionLoader().load(dimm);
J.attemptAsync(() -> J.attemptAsync(() ->
{ {
@@ -179,10 +181,16 @@ public class ProjectManager
{ {
double last = 0; double last = 0;
int req = 740; int req = 740;
double lpc = 0;
boolean c = false;
while(!done.get()) while(!done.get())
{ {
boolean derp = false; boolean derp = false;
double v = (double) gx.getGenerated() / (double) req; double v = (double) gx.getGenerated() / (double) req;
c = lpc != v;
lpc = v;
if(last > v || v > 1) if(last > v || v > 1)
{ {
@@ -195,7 +203,11 @@ public class ProjectManager
last = v; last = v;
} }
sender.sendMessage("Generating " + Form.pc(v) + (derp ? " (Waiting on Server...)" : "")); if(c)
{
sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + (derp ? (C.GRAY + " (Waiting on Server...)") : (C.GRAY + " (" + (req - gx.getGenerated()) + " Left)")));
}
J.sleep(3000); J.sleep(3000);
if(gx.isFailing()) if(gx.isFailing())
@@ -237,6 +249,7 @@ public class ProjectManager
Bukkit.unloadWorld(currentProject.getWorld(), false); Bukkit.unloadWorld(currentProject.getWorld(), false);
currentProject = null; currentProject = null;
Iris.globaldata.dump(); Iris.globaldata.dump();
Iris.globaldata.preferFolder(null);
J.attemptAsync(() -> IO.delete(folder)); J.attemptAsync(() -> IO.delete(folder));
} }
} }
@@ -244,6 +257,7 @@ public class ProjectManager
public File compilePackage(MortarSender sender, String dim, boolean obfuscate) public File compilePackage(MortarSender sender, String dim, boolean obfuscate)
{ {
Iris.globaldata.dump(); Iris.globaldata.dump();
Iris.globaldata.preferFolder(null);
String dimm = dim; String dimm = dim;
IrisDimension dimension = Iris.globaldata.getDimensionLoader().load(dimm); IrisDimension dimension = Iris.globaldata.getDimensionLoader().load(dimm);
File folder = new File(Iris.instance.getDataFolder(), "exports/" + dimension.getLoadKey()); File folder = new File(Iris.instance.getDataFolder(), "exports/" + dimension.getLoadKey());
@@ -61,7 +61,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
public void onInit(World world, RNG rng) public void onInit(World world, RNG rng)
{ {
super.onInit(world, rng); super.onInit(world, rng);
parallaxMap = new AtomicWorldData(world, "floor"); parallaxMap = new AtomicWorldData(world);
glText = new GenLayerText(this, rng.nextParallelRNG(32485)); glText = new GenLayerText(this, rng.nextParallelRNG(32485));
} }
@@ -59,6 +59,8 @@ public abstract class ParallelChunkGenerator extends DimensionChunkGenerator
protected abstract void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map); protected abstract void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map);
protected abstract void onPreGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map);
protected int sampleHeight(int x, int z) protected int sampleHeight(int x, int z)
{ {
return onSampleColumnHeight(x >> 4, z >> 4, x, z, x & 15, z & 15); return onSampleColumnHeight(x >> 4, z >> 4, x, z, x & 15, z & 15);
@@ -76,6 +78,8 @@ public abstract class ParallelChunkGenerator extends DimensionChunkGenerator
BiomeMap biomeMap = new BiomeMap(); BiomeMap biomeMap = new BiomeMap();
int ii, jj; int ii, jj;
onPreGenerate(random, x, z, data, grid, height, biomeMap, map);
for(ii = 0; ii < 16; ii++) for(ii = 0; ii < 16; ii++)
{ {
int i = ii; int i = ii;
@@ -82,6 +82,12 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
return glCave.genCaves(x, z, x & 15, z & 15, null); return glCave.genCaves(x, z, x & 15, z & 15, null);
} }
@Override
protected void onPreGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
{
}
@Override @Override
protected void onGenerateColumn(int cx, int cz, int rx, int rz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap, boolean sampled) protected void onGenerateColumn(int cx, int cz, int rx, int rz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap, boolean sampled)
{ {
@@ -51,7 +51,7 @@ public class AtomicMulticache
return -5784; return -5784;
} }
Long pos = pos(x, z); long pos = pos(x, z);
Double r = height.get(pos); Double r = height.get(pos);
if(r == null) if(r == null)
@@ -65,7 +65,7 @@ public class AtomicMulticache
public IrisRegion getRegion(int x, int z, Supplier<IrisRegion> g) public IrisRegion getRegion(int x, int z, Supplier<IrisRegion> g)
{ {
Long pos = pos(x, z); long pos = pos(x, z);
IrisRegion r = region.get(pos); IrisRegion r = region.get(pos);
if(r == null) if(r == null)
@@ -79,7 +79,7 @@ public class AtomicMulticache
public BiomeResult getBiome(int x, int z, Supplier<BiomeResult> g) public BiomeResult getBiome(int x, int z, Supplier<BiomeResult> g)
{ {
Long pos = pos(x, z); long pos = pos(x, z);
BiomeResult r = biome.get(pos); BiomeResult r = biome.get(pos);
if(r == null) if(r == null)
@@ -97,7 +97,7 @@ public class AtomicMulticache
{ {
return null; return null;
} }
Long pos = pos(x, z); long pos = pos(x, z);
BiomeResult r = rawBiome.get(pos); BiomeResult r = rawBiome.get(pos);
if(r == null) if(r == null)
@@ -23,9 +23,8 @@ public class AtomicWorldData
private KList<ChunkPosition> unloadRegions; private KList<ChunkPosition> unloadRegions;
private KList<ChunkPosition> unloadChunks; private KList<ChunkPosition> unloadChunks;
private long last = M.ms(); private long last = M.ms();
private String prefix;
public AtomicWorldData(World world, String prefix) public AtomicWorldData(World world)
{ {
this.world = world; this.world = world;
loadedSections = new KMap<>(); loadedSections = new KMap<>();
@@ -34,7 +33,6 @@ public class AtomicWorldData
lastChunk = new KMap<>(); lastChunk = new KMap<>();
unloadRegions = new KList<>(); unloadRegions = new KList<>();
unloadChunks = new KList<>(); unloadChunks = new KList<>();
this.prefix = prefix;
getSubregionFolder().mkdirs(); getSubregionFolder().mkdirs();
} }
@@ -256,7 +254,7 @@ public class AtomicWorldData
public File getSubregionFolder() public File getSubregionFolder()
{ {
return new File(world.getWorldFolder(), "subregion-" + prefix); return new File(world.getWorldFolder(), "region-parallax");
} }
public KMap<ChunkPosition, AtomicSliverMap> getLoadedChunks() public KMap<ChunkPosition, AtomicSliverMap> getLoadedChunks()
@@ -23,7 +23,8 @@ import lombok.Data;
@Desc("An iris effect") @Desc("An iris effect")
@Data @Data
public class IrisEffect { public class IrisEffect
{
@DontObfuscate @DontObfuscate
@Desc("The potion effect to apply in this area") @Desc("The potion effect to apply in this area")
private String potionEffect = ""; private String potionEffect = "";
@@ -174,25 +175,33 @@ public class IrisEffect {
private transient AtomicCache<PotionEffectType> pt = new AtomicCache<>(); private transient AtomicCache<PotionEffectType> pt = new AtomicCache<>();
private transient AtomicCache<ChronoLatch> latch = new AtomicCache<>(); private transient AtomicCache<ChronoLatch> latch = new AtomicCache<>();
public IrisEffect() { public IrisEffect()
{
} }
public boolean canTick() { public boolean canTick()
{
return latch.aquire(() -> new ChronoLatch(interval)).flip(); return latch.aquire(() -> new ChronoLatch(interval)).flip();
} }
public PotionEffectType getRealType() { public PotionEffectType getRealType()
return pt.aquire(() -> { {
return pt.aquire(() ->
{
PotionEffectType t = PotionEffectType.LUCK; PotionEffectType t = PotionEffectType.LUCK;
if (getPotionEffect().isEmpty()) { if(getPotionEffect().isEmpty())
{
return t; return t;
} }
try { try
for (PotionEffectType i : PotionEffectType.values()) { {
if (i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) { for(PotionEffectType i : PotionEffectType.values())
{
if(i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect()))
{
t = i; t = i;
return t; return t;
@@ -200,7 +209,8 @@ public class IrisEffect {
} }
} }
catch (Throwable e) { catch(Throwable e)
{
} }
@@ -210,57 +220,55 @@ public class IrisEffect {
}); });
} }
public void apply(Player p, IrisChunkGenerator g) { public void apply(Player p, IrisChunkGenerator g)
if (!canTick()) { {
if(!canTick())
{
return; return;
} }
if (RNG.r.nextInt(chance) != 0) { if(RNG.r.nextInt(chance) != 0)
{
return; return;
} }
if (sound != null) { if(sound != null)
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), {
RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance)); Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch)); p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch));
} }
if (particleEffect != null) { if(particleEffect != null)
Location part = p.getLocation().clone() {
.add(p.getLocation().getDirection().clone().multiply(RNG.r.i(particleDistance) + particleAway)) Location part = p.getLocation().clone().add(p.getLocation().getDirection().clone().multiply(RNG.r.i(particleDistance) + particleAway)).clone().add(p.getLocation().getDirection().clone().rotateAroundY(Math.toRadians(90)).multiply(RNG.r.d(-particleDistanceWidth, particleDistanceWidth)));
.clone().add(p.getLocation().getDirection().clone().rotateAroundY(Math.toRadians(90))
.multiply(RNG.r.d(-particleDistanceWidth, particleDistanceWidth)));
part.setY(Math.round(g.getTerrainHeight(part.getBlockX(), part.getBlockZ())) + 1); part.setY(Math.round(g.getTerrainHeight(part.getBlockX(), part.getBlockZ())) + 1);
part.add(RNG.r.d(), 0, RNG.r.d()); part.add(RNG.r.d(), 0, RNG.r.d());
if (extra != 0) { if(extra != 0)
p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), {
particleCount, randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), particleCount, randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, extra);
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, extra);
} }
else { else
p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), {
particleCount, randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), particleCount, randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ);
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ);
} }
} }
if (potionStrength > -1) { if(potionStrength > -1)
if (p.hasPotionEffect(getRealType())) { {
if(p.hasPotionEffect(getRealType()))
{
PotionEffect e = p.getPotionEffect(getRealType()); PotionEffect e = p.getPotionEffect(getRealType());
if (e.getAmplifier() > getPotionStrength()) { if(e.getAmplifier() > getPotionStrength())
{
return; return;
} }
p.removePotionEffect(getRealType()); p.removePotionEffect(getRealType());
} }
p.addPotionEffect(new PotionEffect(getRealType(), p.addPotionEffect(new PotionEffect(getRealType(), RNG.r.i(Math.min(potionTicksMax, potionTicksMin), Math.max(potionTicksMax, potionTicksMin)), getPotionStrength(), true, false, false));
RNG.r.i(Math.min(potionTicksMax, potionTicksMin), Math.max(potionTicksMax, potionTicksMin)),
getPotionStrength(), true, false, false));
} }
} }
} }
@@ -13,7 +13,8 @@ import lombok.Data;
@Desc("A gen style") @Desc("A gen style")
@Data @Data
public class IrisGeneratorStyle { public class IrisGeneratorStyle
{
@Required @Required
@DontObfuscate @DontObfuscate
@@ -42,23 +43,33 @@ public class IrisGeneratorStyle {
private final transient AtomicCache<CNG> cng = new AtomicCache<CNG>(); private final transient AtomicCache<CNG> cng = new AtomicCache<CNG>();
public IrisGeneratorStyle() { public IrisGeneratorStyle()
{
} }
public IrisGeneratorStyle(NoiseStyle s) { public IrisGeneratorStyle(NoiseStyle s)
{
this.style = s; this.style = s;
} }
public CNG create(RNG rng) { public CNG create(RNG rng)
return cng.aquire(() -> { {
return cng.aquire(() ->
{
CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake(); CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake();
if (fracture != null) { if(fracture != null)
{
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934)), fracture.getMultiplier()); cng.fractureWith(fracture.create(rng.nextParallelRNG(2934)), fracture.getMultiplier());
} }
return cng; return cng;
}); });
} }
public boolean isFlat()
{
return style.equals(NoiseStyle.FLAT);
}
} }
@@ -191,6 +191,7 @@ public class IrisObject extends IrisRegistrant
public int place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener) public int place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener)
{ {
boolean warped = !config.getWarp().isFlat();
boolean stilting = (config.getMode().equals(ObjectPlaceMode.STILT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)); boolean stilting = (config.getMode().equals(ObjectPlaceMode.STILT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT));
KMap<ChunkPosition, Integer> lowmap = stilting ? new KMap<>() : null; KMap<ChunkPosition, Integer> lowmap = stilting ? new KMap<>() : null;
KMap<ChunkPosition, BlockData> lowmapData = stilting ? new KMap<>() : null; KMap<ChunkPosition, BlockData> lowmapData = stilting ? new KMap<>() : null;
@@ -366,6 +367,12 @@ public class IrisObject extends IrisRegistrant
int yy = y + (int) Math.round(i.getY()); int yy = y + (int) Math.round(i.getY());
int zz = z + (int) Math.round(i.getZ()); int zz = z + (int) Math.round(i.getZ());
if(warped)
{
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);
}
if(yv < 0 && config.getMode().equals(ObjectPlaceMode.PAINT)) if(yv < 0 && config.getMode().equals(ObjectPlaceMode.PAINT))
{ {
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, config.isUnderwater()); yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, config.isUnderwater());
@@ -2,6 +2,8 @@ package com.volmit.iris.object;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualChunkGenerator; import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.noise.CNG;
import com.volmit.iris.util.ArrayType; import com.volmit.iris.util.ArrayType;
import com.volmit.iris.util.Desc; import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate; import com.volmit.iris.util.DontObfuscate;
@@ -110,11 +112,30 @@ public class IrisObjectPlacement
@Desc("If set to true, air will be placed before the schematic places.") @Desc("If set to true, air will be placed before the schematic places.")
private boolean bore = false; private boolean bore = false;
@DontObfuscate
@Desc("Use a generator to warp the field of coordinates. Using simplex for example would make a square placement warp like a flag")
private IrisGeneratorStyle warp = new IrisGeneratorStyle(NoiseStyle.FLAT);
private transient AtomicCache<CNG> surfaceWarp = new AtomicCache<>();
public IrisObjectPlacement() public IrisObjectPlacement()
{ {
} }
public CNG getSurfaceWarp(RNG rng)
{
return surfaceWarp.aquire(() ->
{
return getWarp().create(rng);
});
}
public double warp(RNG rng, double x, double y, double z)
{
return getSurfaceWarp(rng).fitDouble(-(getWarp().getMultiplier() / 2D), (getWarp().getMultiplier() / 2D), x, y, z);
}
public IrisObject getSchematic(ContextualChunkGenerator g, RNG random) public IrisObject getSchematic(ContextualChunkGenerator g, RNG random)
{ {
if(place.isEmpty()) if(place.isEmpty())
@@ -49,10 +49,6 @@ public class IrisTextRenderer
@Desc("The palette of blocks to use when drawing text") @Desc("The palette of blocks to use when drawing text")
private IrisMaterialPalette blockPalette = new IrisMaterialPalette(); private IrisMaterialPalette blockPalette = new IrisMaterialPalette();
@DontObfuscate
@Desc("Use a generator to shuffle the surface field of coordinates. Using simplex for example would make the text rendered wavy. Use the multiplier to stretch further.")
private IrisGeneratorStyle surfaceField = new IrisGeneratorStyle(NoiseStyle.FLAT);
private transient AtomicCache<KList<IrisObject>> objects = new AtomicCache<>(); private transient AtomicCache<KList<IrisObject>> objects = new AtomicCache<>();
private transient AtomicCache<Font> fontData = new AtomicCache<>(); private transient AtomicCache<Font> fontData = new AtomicCache<>();
private transient AtomicCache<FontMetrics> fontMetrics = new AtomicCache<>(); private transient AtomicCache<FontMetrics> fontMetrics = new AtomicCache<>();
+94 -5
View File
@@ -12,6 +12,13 @@ public class B
private static final BlockData AIR = Material.AIR.createBlockData(); private static final BlockData AIR = Material.AIR.createBlockData();
private static final KMap<String, BlockData> bdc = new KMap<>(); private static final KMap<String, BlockData> bdc = new KMap<>();
private static final KList<String> nulls = new KList<>(); private static final KList<String> nulls = new KList<>();
private static final KList<Material> storage = new KList<>();
private static final KList<Material> storageChest = new KList<>();
private static final KList<Material> lit = new KList<>();
private static final KList<Material> updatable = new KList<>();
private static final KList<Material> notUpdatable = new KList<>();
private static final KList<String> canPlaceOn = new KList<>();
private static final KList<Material> decorant = new KList<>();
private static final IrisDimension defaultCompat = new IrisDimension(); private static final IrisDimension defaultCompat = new IrisDimension();
private static final KMap<Material, Boolean> solid = new KMap<>(); private static final KMap<Material, Boolean> solid = new KMap<>();
private static final KMap<String, Material> types = new KMap<>(); private static final KMap<String, Material> types = new KMap<>();
@@ -145,8 +152,13 @@ public class B
public static boolean isStorage(Material mat) public static boolean isStorage(Material mat)
{ {
if(storage.contains(mat))
{
return true;
}
//@builder //@builder
return mat.equals(B.mat("CHEST")) boolean str = mat.equals(B.mat("CHEST"))
|| mat.equals(B.mat("TRAPPED_CHEST")) || mat.equals(B.mat("TRAPPED_CHEST"))
|| mat.equals(B.mat("SHULKER_BOX")) || mat.equals(B.mat("SHULKER_BOX"))
|| mat.equals(B.mat("WHITE_SHULKER_BOX")) || mat.equals(B.mat("WHITE_SHULKER_BOX"))
@@ -173,12 +185,25 @@ public class B
|| mat.equals(B.mat("BLAST_FURNACE")) || mat.equals(B.mat("BLAST_FURNACE"))
|| mat.equals(B.mat("SMOKER")); || mat.equals(B.mat("SMOKER"));
//@done //@done
if(str)
{
storage.add(mat);
return true;
}
return false;
} }
public static boolean isStorageChest(Material mat) public static boolean isStorageChest(Material mat)
{ {
if(storageChest.contains(mat))
{
return true;
}
//@builder //@builder
return mat.equals(B.mat("CHEST")) boolean str = mat.equals(B.mat("CHEST"))
|| mat.equals(B.mat("TRAPPED_CHEST")) || mat.equals(B.mat("TRAPPED_CHEST"))
|| mat.equals(B.mat("SHULKER_BOX")) || mat.equals(B.mat("SHULKER_BOX"))
|| mat.equals(B.mat("WHITE_SHULKER_BOX")) || mat.equals(B.mat("WHITE_SHULKER_BOX"))
@@ -202,12 +227,25 @@ public class B
|| mat.equals(B.mat("DROPPER")) || mat.equals(B.mat("DROPPER"))
|| mat.equals(B.mat("HOPPER")); || mat.equals(B.mat("HOPPER"));
//@done //@done
if(str)
{
storageChest.add(mat);
return true;
}
return false;
} }
public static boolean isLit(Material mat) public static boolean isLit(Material mat)
{ {
if(lit.contains(mat))
{
return true;
}
//@builder //@builder
return mat.equals(B.mat("GLOWSTONE")) boolean str = mat.equals(B.mat("GLOWSTONE"))
|| mat.equals(B.mat("END_ROD")) || mat.equals(B.mat("END_ROD"))
|| mat.equals(B.mat("SOUL_SAND")) || mat.equals(B.mat("SOUL_SAND"))
|| mat.equals(B.mat("TORCH")) || mat.equals(B.mat("TORCH"))
@@ -229,22 +267,57 @@ public class B
|| mat.equals(Material.BREWING_STAND) || mat.equals(Material.BREWING_STAND)
|| mat.equals(Material.REDSTONE_ORE); || mat.equals(Material.REDSTONE_ORE);
//@done //@done
if(str)
{
lit.add(mat);
return true;
}
return false;
} }
public static boolean isUpdatable(Material mat) public static boolean isUpdatable(Material mat)
{ {
return isLit(mat) || isStorage(mat); if(updatable.contains(mat))
{
return true;
}
if(notUpdatable.contains(mat))
{
return false;
}
boolean str = isLit(mat) || isStorage(mat);
if(str)
{
updatable.add(mat);
return true;
}
notUpdatable.add(mat);
return false;
} }
public static boolean canPlaceOnto(Material mat, Material onto) public static boolean canPlaceOnto(Material mat, Material onto)
{ {
String key = mat.name() + "" + onto.name();
if(canPlaceOn.contains(key))
{
return false;
}
if(onto.equals(Material.AIR) || onto.equals(B.mat("CAVE_AIR"))) if(onto.equals(Material.AIR) || onto.equals(B.mat("CAVE_AIR")))
{ {
canPlaceOn.add(key);
return false; return false;
} }
if(onto.equals(Material.GRASS_BLOCK) && mat.equals(Material.DEAD_BUSH)) if(onto.equals(Material.GRASS_BLOCK) && mat.equals(Material.DEAD_BUSH))
{ {
canPlaceOn.add(key);
return false; return false;
} }
@@ -252,6 +325,7 @@ public class B
{ {
if(!mat.isSolid()) if(!mat.isSolid())
{ {
canPlaceOn.add(key);
return false; return false;
} }
} }
@@ -260,6 +334,7 @@ public class B
{ {
if(mat.equals(Material.POPPY) || mat.equals(Material.DANDELION) || mat.equals(B.mat("CORNFLOWER")) || mat.equals(Material.ORANGE_TULIP) || mat.equals(Material.PINK_TULIP) || mat.equals(Material.RED_TULIP) || mat.equals(Material.WHITE_TULIP) || mat.equals(Material.FERN) || mat.equals(Material.LARGE_FERN) || mat.equals(Material.GRASS) || mat.equals(Material.TALL_GRASS)) if(mat.equals(Material.POPPY) || mat.equals(Material.DANDELION) || mat.equals(B.mat("CORNFLOWER")) || mat.equals(Material.ORANGE_TULIP) || mat.equals(Material.PINK_TULIP) || mat.equals(Material.RED_TULIP) || mat.equals(Material.WHITE_TULIP) || mat.equals(Material.FERN) || mat.equals(Material.LARGE_FERN) || mat.equals(Material.GRASS) || mat.equals(Material.TALL_GRASS))
{ {
canPlaceOn.add(key);
return false; return false;
} }
} }
@@ -268,6 +343,7 @@ public class B
{ {
if(!mat.isSolid()) if(!mat.isSolid())
{ {
canPlaceOn.add(key);
return false; return false;
} }
} }
@@ -277,8 +353,13 @@ public class B
public static boolean isDecorant(Material m) public static boolean isDecorant(Material m)
{ {
if(decorant.contains(m))
{
return true;
}
//@builder //@builder
return m.equals(Material.GRASS) boolean str = m.equals(Material.GRASS)
|| m.equals(Material.TALL_GRASS) || m.equals(Material.TALL_GRASS)
|| m.equals(B.mat("CORNFLOWER")) || m.equals(B.mat("CORNFLOWER"))
|| m.equals(Material.SUNFLOWER) || m.equals(Material.SUNFLOWER)
@@ -331,6 +412,14 @@ public class B
|| m.equals(Material.TORCH) || m.equals(Material.TORCH)
|| m.equals(B.mat("SOUL_TORCH")); || m.equals(B.mat("SOUL_TORCH"));
//@done //@done
if(str)
{
decorant.add(m);
return true;
}
return false;
} }
public static KList<BlockData> getBlockData(KList<String> find) public static KList<BlockData> getBlockData(KList<String> find)