mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Loot
This commit is contained in:
parent
7b94d753b8
commit
39b7563d3a
@ -10,6 +10,7 @@ import com.volmit.iris.object.IrisBiome;
|
|||||||
import com.volmit.iris.object.IrisBiomeDecorator;
|
import com.volmit.iris.object.IrisBiomeDecorator;
|
||||||
import com.volmit.iris.object.IrisDimension;
|
import com.volmit.iris.object.IrisDimension;
|
||||||
import com.volmit.iris.object.IrisGenerator;
|
import com.volmit.iris.object.IrisGenerator;
|
||||||
|
import com.volmit.iris.object.IrisLootTable;
|
||||||
import com.volmit.iris.object.IrisNoiseGenerator;
|
import com.volmit.iris.object.IrisNoiseGenerator;
|
||||||
import com.volmit.iris.object.IrisObjectPlacement;
|
import com.volmit.iris.object.IrisObjectPlacement;
|
||||||
import com.volmit.iris.object.IrisRegion;
|
import com.volmit.iris.object.IrisRegion;
|
||||||
@ -28,6 +29,7 @@ public class IrisDataManager
|
|||||||
private File packs;
|
private File packs;
|
||||||
private boolean prod;
|
private boolean prod;
|
||||||
private ResourceLoader<IrisBiome> biomeLoader;
|
private ResourceLoader<IrisBiome> biomeLoader;
|
||||||
|
private ResourceLoader<IrisLootTable> lootLoader;
|
||||||
private ResourceLoader<IrisRegion> regionLoader;
|
private ResourceLoader<IrisRegion> regionLoader;
|
||||||
private ResourceLoader<IrisDimension> dimensionLoader;
|
private ResourceLoader<IrisDimension> dimensionLoader;
|
||||||
private ResourceLoader<IrisGenerator> generatorLoader;
|
private ResourceLoader<IrisGenerator> generatorLoader;
|
||||||
@ -43,14 +45,14 @@ public class IrisDataManager
|
|||||||
|
|
||||||
File packs = this.packs.getName().equals("packs") ? this.packs : dataFolder;
|
File packs = this.packs.getName().equals("packs") ? this.packs : dataFolder;
|
||||||
packs.mkdirs();
|
packs.mkdirs();
|
||||||
|
this.lootLoader = new ResourceLoader<>(packs, "loot", "Loot", IrisLootTable.class);
|
||||||
this.regionLoader = new ResourceLoader<>(packs, "regions", "Region", IrisRegion.class);
|
this.regionLoader = new ResourceLoader<>(packs, "regions", "Region", IrisRegion.class);
|
||||||
this.biomeLoader = new ResourceLoader<>(packs, "biomes", "Biome", IrisBiome.class);
|
this.biomeLoader = new ResourceLoader<>(packs, "biomes", "Biome", IrisBiome.class);
|
||||||
this.dimensionLoader = new ResourceLoader<>(packs, "dimensions", "Dimension", IrisDimension.class);
|
this.dimensionLoader = new ResourceLoader<>(packs, "dimensions", "Dimension", IrisDimension.class);
|
||||||
this.structureLoader = new ResourceLoader<>(packs, "structures", "Structure", IrisStructure.class);
|
this.structureLoader = new ResourceLoader<>(packs, "structures", "Structure", IrisStructure.class);
|
||||||
this.generatorLoader = new ResourceLoader<>(packs, "generators", "Generator", IrisGenerator.class);
|
this.generatorLoader = new ResourceLoader<>(packs, "generators", "Generator", IrisGenerator.class);
|
||||||
this.objectLoader = new ObjectResourceLoader(packs, "objects", "Object");
|
this.objectLoader = new ObjectResourceLoader(packs, "objects", "Object");
|
||||||
|
|
||||||
if(packs.getName().equals("packs"))
|
if(packs.getName().equals("packs"))
|
||||||
{
|
{
|
||||||
writeExamples();
|
writeExamples();
|
||||||
@ -78,6 +80,7 @@ public class IrisDataManager
|
|||||||
public void dump()
|
public void dump()
|
||||||
{
|
{
|
||||||
biomeLoader.clearCache();
|
biomeLoader.clearCache();
|
||||||
|
lootLoader.clearCache();
|
||||||
regionLoader.clearCache();
|
regionLoader.clearCache();
|
||||||
dimensionLoader.clearCache();
|
dimensionLoader.clearCache();
|
||||||
generatorLoader.clearCache();
|
generatorLoader.clearCache();
|
||||||
@ -161,6 +164,7 @@ public class IrisDataManager
|
|||||||
public void preferFolder(String name)
|
public void preferFolder(String name)
|
||||||
{
|
{
|
||||||
biomeLoader.preferFolder(name);
|
biomeLoader.preferFolder(name);
|
||||||
|
lootLoader.preferFolder(name);
|
||||||
regionLoader.preferFolder(name);
|
regionLoader.preferFolder(name);
|
||||||
dimensionLoader.preferFolder(name);
|
dimensionLoader.preferFolder(name);
|
||||||
generatorLoader.preferFolder(name);
|
generatorLoader.preferFolder(name);
|
||||||
@ -169,6 +173,7 @@ public class IrisDataManager
|
|||||||
|
|
||||||
public void clearLists()
|
public void clearLists()
|
||||||
{
|
{
|
||||||
|
lootLoader.clearList();
|
||||||
biomeLoader.clearList();
|
biomeLoader.clearList();
|
||||||
regionLoader.clearList();
|
regionLoader.clearList();
|
||||||
dimensionLoader.clearList();
|
dimensionLoader.clearList();
|
||||||
|
@ -10,6 +10,7 @@ public class IrisMetrics
|
|||||||
private final RollingSequence parallax;
|
private final RollingSequence parallax;
|
||||||
private final RollingSequence terrain;
|
private final RollingSequence terrain;
|
||||||
private final RollingSequence post;
|
private final RollingSequence post;
|
||||||
|
private final RollingSequence update;
|
||||||
private final RollingSequence total;
|
private final RollingSequence total;
|
||||||
private final RollingSequence perSecond;
|
private final RollingSequence perSecond;
|
||||||
public int generators = 0;
|
public int generators = 0;
|
||||||
@ -20,6 +21,7 @@ public class IrisMetrics
|
|||||||
parallax = new RollingSequence(memory);
|
parallax = new RollingSequence(memory);
|
||||||
terrain = new RollingSequence(memory);
|
terrain = new RollingSequence(memory);
|
||||||
post = new RollingSequence(memory);
|
post = new RollingSequence(memory);
|
||||||
|
update = new RollingSequence(memory);
|
||||||
total = new RollingSequence(memory);
|
total = new RollingSequence(memory);
|
||||||
perSecond = new RollingSequence(5);
|
perSecond = new RollingSequence(5);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import com.volmit.iris.object.IrisBiomeGeneratorLink;
|
|||||||
import com.volmit.iris.object.IrisBiomeMutation;
|
import com.volmit.iris.object.IrisBiomeMutation;
|
||||||
import com.volmit.iris.object.IrisDimension;
|
import com.volmit.iris.object.IrisDimension;
|
||||||
import com.volmit.iris.object.IrisGenerator;
|
import com.volmit.iris.object.IrisGenerator;
|
||||||
|
import com.volmit.iris.object.IrisLootTable;
|
||||||
import com.volmit.iris.object.IrisNoiseGenerator;
|
import com.volmit.iris.object.IrisNoiseGenerator;
|
||||||
import com.volmit.iris.object.IrisObjectPlacement;
|
import com.volmit.iris.object.IrisObjectPlacement;
|
||||||
import com.volmit.iris.object.IrisRegion;
|
import com.volmit.iris.object.IrisRegion;
|
||||||
@ -60,6 +61,7 @@ import com.volmit.iris.util.O;
|
|||||||
import com.volmit.iris.util.RegistryListBiome;
|
import com.volmit.iris.util.RegistryListBiome;
|
||||||
import com.volmit.iris.util.RegistryListDimension;
|
import com.volmit.iris.util.RegistryListDimension;
|
||||||
import com.volmit.iris.util.RegistryListGenerator;
|
import com.volmit.iris.util.RegistryListGenerator;
|
||||||
|
import com.volmit.iris.util.RegistryListLoot;
|
||||||
import com.volmit.iris.util.RegistryListObject;
|
import com.volmit.iris.util.RegistryListObject;
|
||||||
import com.volmit.iris.util.RegistryListRegion;
|
import com.volmit.iris.util.RegistryListRegion;
|
||||||
import com.volmit.iris.util.RegistryListStructure;
|
import com.volmit.iris.util.RegistryListStructure;
|
||||||
@ -635,6 +637,7 @@ public class ProjectManager
|
|||||||
g.queue(() -> ex(schemas, IrisRegion.class, dat, "/regions/*.json"));
|
g.queue(() -> ex(schemas, IrisRegion.class, dat, "/regions/*.json"));
|
||||||
g.queue(() -> ex(schemas, IrisGenerator.class, dat, "/generators/*.json"));
|
g.queue(() -> ex(schemas, IrisGenerator.class, dat, "/generators/*.json"));
|
||||||
g.queue(() -> ex(schemas, IrisStructure.class, dat, "/structures/*.json"));
|
g.queue(() -> ex(schemas, IrisStructure.class, dat, "/structures/*.json"));
|
||||||
|
g.queue(() -> ex(schemas, IrisLootTable.class, dat, "/loot/*.json"));
|
||||||
g.execute();
|
g.execute();
|
||||||
|
|
||||||
return schemas;
|
return schemas;
|
||||||
@ -756,6 +759,11 @@ public class ProjectManager
|
|||||||
prop.put("enum", new JSONArray(getBiomeList(dat)));
|
prop.put("enum", new JSONArray(getBiomeList(dat)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(k.isAnnotationPresent(RegistryListLoot.class))
|
||||||
|
{
|
||||||
|
prop.put("enum", new JSONArray(getLootList(dat)));
|
||||||
|
}
|
||||||
|
|
||||||
if(k.isAnnotationPresent(RegistryListDimension.class))
|
if(k.isAnnotationPresent(RegistryListDimension.class))
|
||||||
{
|
{
|
||||||
prop.put("enum", new JSONArray(getDimensionList(dat)));
|
prop.put("enum", new JSONArray(getDimensionList(dat)));
|
||||||
@ -894,6 +902,26 @@ public class ProjectManager
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(k.isAnnotationPresent(RegistryListLoot.class))
|
||||||
|
{
|
||||||
|
String name = "enloot" + t.type().getSimpleName().toLowerCase();
|
||||||
|
if(!def.containsKey(name))
|
||||||
|
{
|
||||||
|
JSONObject deff = new JSONObject();
|
||||||
|
deff.put("type", tx);
|
||||||
|
deff.put("enum", new JSONArray(getLootList(dat)));
|
||||||
|
def.put(name, deff);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject items = new JSONObject();
|
||||||
|
items.put("$ref", "#/definitions/" + name);
|
||||||
|
prop.put("items", items);
|
||||||
|
prop.put("description", k.getAnnotation(Desc.class).value());
|
||||||
|
prop.put("type", tp);
|
||||||
|
properties.put(k.getName(), prop);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(k.isAnnotationPresent(RegistryListDimension.class))
|
if(k.isAnnotationPresent(RegistryListDimension.class))
|
||||||
{
|
{
|
||||||
String name = "endim" + t.type().getSimpleName().toLowerCase();
|
String name = "endim" + t.type().getSimpleName().toLowerCase();
|
||||||
@ -1100,6 +1128,11 @@ public class ProjectManager
|
|||||||
return data.getBiomeLoader().getPossibleKeys();
|
return data.getBiomeLoader().getPossibleKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String[] getLootList(IrisDataManager data)
|
||||||
|
{
|
||||||
|
return data.getLootLoader().getPossibleKeys();
|
||||||
|
}
|
||||||
|
|
||||||
private String[] getDimensionList(IrisDataManager data)
|
private String[] getDimensionList(IrisDataManager data)
|
||||||
{
|
{
|
||||||
return data.getDimensionLoader().getPossibleKeys();
|
return data.getDimensionLoader().getPossibleKeys();
|
||||||
|
99
src/main/java/com/volmit/iris/command/CommandIrisLoot.java
Normal file
99
src/main/java/com/volmit/iris/command/CommandIrisLoot.java
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.object.InventorySlotType;
|
||||||
|
import com.volmit.iris.object.IrisLootTable;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.KMap;
|
||||||
|
import com.volmit.iris.util.KSet;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
import com.volmit.iris.util.O;
|
||||||
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
|
public class CommandIrisLoot extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisLoot()
|
||||||
|
{
|
||||||
|
super("loot");
|
||||||
|
setDescription("Show loot if a chest were right here");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setCategory("Loot");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if(sender.isPlayer())
|
||||||
|
{
|
||||||
|
Player p = sender.player();
|
||||||
|
KSet<IrisLootTable> tables = Iris.proj.getCurrentProject().getGlUpdate().getLootTables(p.getLocation().getBlock());
|
||||||
|
Inventory inv = Bukkit.createInventory(null, 27 * 2);
|
||||||
|
Iris.proj.getCurrentProject().getGlUpdate().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ());
|
||||||
|
p.openInventory(inv);
|
||||||
|
|
||||||
|
for(IrisLootTable i : tables)
|
||||||
|
{
|
||||||
|
sender.sendMessage("- " + i.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ffast = false;
|
||||||
|
boolean fadd = false;
|
||||||
|
|
||||||
|
for(String i : args)
|
||||||
|
{
|
||||||
|
if(i.equals("--fast"))
|
||||||
|
{
|
||||||
|
ffast = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i.equals("--add"))
|
||||||
|
{
|
||||||
|
fadd = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean fast = ffast;
|
||||||
|
boolean add = fadd;
|
||||||
|
O<Integer> ta = new O<Integer>();
|
||||||
|
ta.set(-1);
|
||||||
|
|
||||||
|
ta.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () ->
|
||||||
|
{
|
||||||
|
if(!p.getOpenInventory().getType().equals(InventoryType.CHEST))
|
||||||
|
{
|
||||||
|
Bukkit.getScheduler().cancelTask(ta.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!add)
|
||||||
|
{
|
||||||
|
inv.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.proj.getCurrentProject().getGlUpdate().addItems(true, inv, new RNG(RNG.r.imax()), tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ());
|
||||||
|
}, 0, fast ? 5 : 35));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Players only.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "[width]";
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,7 @@ public class CommandIrisMetrics extends MortarCommand
|
|||||||
sender.sendMessage(" Terrain : " + ChatColor.BOLD + "" + ChatColor.WHITE + Form.duration(m.getTerrain().getAverage(), 2));
|
sender.sendMessage(" Terrain : " + ChatColor.BOLD + "" + ChatColor.WHITE + Form.duration(m.getTerrain().getAverage(), 2));
|
||||||
sender.sendMessage(" Parallax: " + ChatColor.BOLD + "" + ChatColor.WHITE + Form.duration(m.getParallax().getAverage(), 2));
|
sender.sendMessage(" Parallax: " + ChatColor.BOLD + "" + ChatColor.WHITE + Form.duration(m.getParallax().getAverage(), 2));
|
||||||
sender.sendMessage(" Post : " + ChatColor.BOLD + "" + ChatColor.WHITE + Form.duration(m.getPost().getAverage(), 2));
|
sender.sendMessage(" Post : " + ChatColor.BOLD + "" + ChatColor.WHITE + Form.duration(m.getPost().getAverage(), 2));
|
||||||
|
sender.sendMessage("Updates : " + ChatColor.BOLD + "" + ChatColor.WHITE + Form.duration(m.getUpdate().getAverage(), 2));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,9 @@ public class CommandIrisWorld extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisTC tc;
|
private CommandIrisTC tc;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisLoot loot;
|
||||||
|
|
||||||
public CommandIrisWorld()
|
public CommandIrisWorld()
|
||||||
{
|
{
|
||||||
super("world", "wrld", "w");
|
super("world", "wrld", "w");
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package com.volmit.iris.gen;
|
package com.volmit.iris.gen;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
|
||||||
import com.volmit.iris.gen.atomics.AtomicSliver;
|
import com.volmit.iris.gen.atomics.AtomicSliver;
|
||||||
import com.volmit.iris.gen.atomics.AtomicSliverMap;
|
import com.volmit.iris.gen.atomics.AtomicSliverMap;
|
||||||
import com.volmit.iris.gen.atomics.AtomicWorldData;
|
import com.volmit.iris.gen.atomics.AtomicWorldData;
|
||||||
import com.volmit.iris.gen.atomics.MasterLock;
|
import com.volmit.iris.gen.atomics.MasterLock;
|
||||||
|
import com.volmit.iris.gen.layer.GenLayerUpdate;
|
||||||
import com.volmit.iris.object.IrisBiome;
|
import com.volmit.iris.object.IrisBiome;
|
||||||
import com.volmit.iris.object.IrisBiomeMutation;
|
import com.volmit.iris.object.IrisBiomeMutation;
|
||||||
import com.volmit.iris.object.IrisObjectPlacement;
|
import com.volmit.iris.object.IrisObjectPlacement;
|
||||||
@ -40,6 +43,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
|||||||
private MasterLock masterLock;
|
private MasterLock masterLock;
|
||||||
private IrisLock lock = new IrisLock("ParallaxLock");
|
private IrisLock lock = new IrisLock("ParallaxLock");
|
||||||
private IrisLock lockq = new IrisLock("ParallaxQueueLock");
|
private IrisLock lockq = new IrisLock("ParallaxQueueLock");
|
||||||
|
private GenLayerUpdate glUpdate;
|
||||||
private int sliverBuffer;
|
private int sliverBuffer;
|
||||||
|
|
||||||
public ParallaxChunkGenerator(String dimensionName, int threads)
|
public ParallaxChunkGenerator(String dimensionName, int threads)
|
||||||
@ -82,6 +86,12 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
|||||||
return getHighest(x, z, false);
|
return getHighest(x, z, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHotload()
|
||||||
|
{
|
||||||
|
super.onHotload();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHighest(int x, int z, boolean ignoreFluid)
|
public int getHighest(int x, int z, boolean ignoreFluid)
|
||||||
{
|
{
|
||||||
@ -163,6 +173,20 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
|||||||
return new AtomicSliverMap();
|
return new AtomicSliverMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||||
|
{
|
||||||
|
List<BlockPopulator> g = super.getDefaultPopulators(world);
|
||||||
|
|
||||||
|
if(glUpdate == null)
|
||||||
|
{
|
||||||
|
glUpdate = new GenLayerUpdate(this, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.add(glUpdate);
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
|
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
|
||||||
{
|
{
|
||||||
@ -178,11 +202,13 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
|||||||
{
|
{
|
||||||
onGenerateParallax(random, x, z);
|
onGenerateParallax(random, x, z);
|
||||||
getParallaxChunk(x, z).inject(data);
|
getParallaxChunk(x, z).inject(data);
|
||||||
setSliverBuffer(getSliverCache().size());
|
|
||||||
getParallaxChunk(x, z).setWorldGenerated(true);
|
|
||||||
getMasterLock().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getParallaxChunk(x, z).injectUpdates(map);
|
||||||
|
setSliverBuffer(getSliverCache().size());
|
||||||
|
getParallaxChunk(x, z).setWorldGenerated(true);
|
||||||
|
getMasterLock().clear();
|
||||||
|
|
||||||
p.end();
|
p.end();
|
||||||
getMetrics().getParallax().put(p.getMilliseconds());
|
getMetrics().getParallax().put(p.getMilliseconds());
|
||||||
super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap, map);
|
super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap, map);
|
||||||
|
@ -101,7 +101,7 @@ public class AtomicSliver
|
|||||||
modified = true;
|
modified = true;
|
||||||
block.put(h, d);
|
block.put(h, d);
|
||||||
|
|
||||||
if(B.isLit(d))
|
if(B.isUpdatable(d))
|
||||||
{
|
{
|
||||||
update(h);
|
update(h);
|
||||||
}
|
}
|
||||||
@ -293,4 +293,9 @@ public class AtomicSliver
|
|||||||
{
|
{
|
||||||
return M.ms() - last > m;
|
return M.ms() - last > m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void inject(KSet<Integer> updatables)
|
||||||
|
{
|
||||||
|
update.addAll(updatables);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,4 +114,15 @@ public class AtomicSliverMap
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void injectUpdates(AtomicSliverMap map)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < 16; j++)
|
||||||
|
{
|
||||||
|
getSliver(i, j).inject(map.getSliver(i, j).getUpdatables());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
164
src/main/java/com/volmit/iris/gen/layer/GenLayerUpdate.java
Normal file
164
src/main/java/com/volmit/iris/gen/layer/GenLayerUpdate.java
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
package com.volmit.iris.gen.layer;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.ParallaxChunkGenerator;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicSliverMap;
|
||||||
|
import com.volmit.iris.object.InventorySlotType;
|
||||||
|
import com.volmit.iris.object.IrisBiome;
|
||||||
|
import com.volmit.iris.object.IrisLootReference;
|
||||||
|
import com.volmit.iris.object.IrisLootTable;
|
||||||
|
import com.volmit.iris.object.IrisRegion;
|
||||||
|
import com.volmit.iris.object.LootMode;
|
||||||
|
import com.volmit.iris.util.B;
|
||||||
|
import com.volmit.iris.util.IrisStructureResult;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.KSet;
|
||||||
|
import com.volmit.iris.util.PrecisionStopwatch;
|
||||||
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
|
public class GenLayerUpdate extends BlockPopulator
|
||||||
|
{
|
||||||
|
private ParallaxChunkGenerator gen;
|
||||||
|
private RNG rng;
|
||||||
|
|
||||||
|
public GenLayerUpdate(ParallaxChunkGenerator gen, World w)
|
||||||
|
{
|
||||||
|
this.gen = gen;
|
||||||
|
this.rng = new RNG(w.getSeed() + 4996788).nextParallelRNG(-98618289);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(World w, Random r, Chunk c)
|
||||||
|
{
|
||||||
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
|
AtomicSliverMap map = gen.getParallaxChunk(c.getX(), c.getZ());
|
||||||
|
RNG rx = rng.nextParallelRNG(c.getX()).nextParallelRNG(c.getZ());
|
||||||
|
|
||||||
|
for(int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < 16; j++)
|
||||||
|
{
|
||||||
|
for(int k : map.getSliver(i, j).getUpdatables())
|
||||||
|
{
|
||||||
|
if(k > 255 || k < 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(c, i, k, j, i + (c.getX() << 4), i + (c.getZ() << 4), rx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.end();
|
||||||
|
gen.getMetrics().getUpdate().put(p.getMilliseconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(Chunk c, int x, int y, int z, int rx, int rz, RNG rng)
|
||||||
|
{
|
||||||
|
Block b = c.getBlock(x, y, z);
|
||||||
|
BlockData d = b.getBlockData();
|
||||||
|
|
||||||
|
if(B.isLit(d.getMaterial()))
|
||||||
|
{
|
||||||
|
updateLight(b, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(B.isStorage(d.getMaterial()))
|
||||||
|
{
|
||||||
|
updateStorage(b, d, rx, rz, rng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void injectTables(KSet<IrisLootTable> list, IrisLootReference r)
|
||||||
|
{
|
||||||
|
if(r.getMode().equals(LootMode.CLEAR) || r.getMode().equals(LootMode.REPLACE))
|
||||||
|
{
|
||||||
|
list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
list.addAll(r.getLootTables(gen));
|
||||||
|
}
|
||||||
|
|
||||||
|
public KSet<IrisLootTable> getLootTables(Block b)
|
||||||
|
{
|
||||||
|
int rx = b.getX();
|
||||||
|
int rz = b.getZ();
|
||||||
|
IrisRegion region = gen.sampleRegion(rx, rz);
|
||||||
|
IrisBiome biomeSurface = gen.sampleTrueBiome(rx, rz).getBiome();
|
||||||
|
IrisBiome biomeUnder = gen.sampleTrueBiome(rx, b.getY(), rz).getBiome();
|
||||||
|
KSet<IrisLootTable> tables = new KSet<>();
|
||||||
|
IrisStructureResult structure = gen.getStructure(rx, b.getY(), rz);
|
||||||
|
injectTables(tables, gen.getDimension().getLoot());
|
||||||
|
injectTables(tables, region.getLoot());
|
||||||
|
injectTables(tables, biomeSurface.getLoot());
|
||||||
|
injectTables(tables, biomeUnder.getLoot());
|
||||||
|
|
||||||
|
if(structure != null && structure.getTile() != null)
|
||||||
|
{
|
||||||
|
injectTables(tables, structure.getStructure().getLoot());
|
||||||
|
injectTables(tables, structure.getTile().getLoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
return tables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItems(boolean debug, Inventory inv, RNG rng, KSet<IrisLootTable> tables, InventorySlotType slot, int x, int y, int z)
|
||||||
|
{
|
||||||
|
KList<ItemStack> items = new KList<>();
|
||||||
|
|
||||||
|
for(IrisLootTable i : tables)
|
||||||
|
{
|
||||||
|
items.addAll(i.getLoot(debug, rng, slot, x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ItemStack i : items)
|
||||||
|
{
|
||||||
|
inv.addItem(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateStorage(Block b, BlockData data, int rx, int rz, RNG rng)
|
||||||
|
{
|
||||||
|
InventorySlotType slot = null;
|
||||||
|
|
||||||
|
if(B.isStorageChest(data.getMaterial()))
|
||||||
|
{
|
||||||
|
slot = InventorySlotType.STORAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(slot != null)
|
||||||
|
{
|
||||||
|
KSet<IrisLootTable> tables = getLootTables(b);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InventoryHolder m = (InventoryHolder) b.getState();
|
||||||
|
addItems(false, m.getInventory(), rng, tables, slot, rx, b.getY(), rz);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
Iris.error("NOT INVENTORY: " + data.getMaterial().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLight(Block b, BlockData data)
|
||||||
|
{
|
||||||
|
b.setType(Material.AIR, false);
|
||||||
|
b.setBlockData(data, false);
|
||||||
|
}
|
||||||
|
}
|
21
src/main/java/com/volmit/iris/object/InventorySlotType.java
Normal file
21
src/main/java/com/volmit/iris/object/InventorySlotType.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
|
|
||||||
|
public enum InventorySlotType
|
||||||
|
{
|
||||||
|
@DontObfuscate
|
||||||
|
STORAGE,
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
FUEL,
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
FURNACE,
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
BLAST_FURNACE,
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
SMOKER,
|
||||||
|
}
|
@ -45,6 +45,10 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
|||||||
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
|
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
|
||||||
private IrisGeneratorStyle biomeStyle = NoiseStyle.SIMPLEX.style();
|
private IrisGeneratorStyle biomeStyle = NoiseStyle.SIMPLEX.style();
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Reference loot tables in this area")
|
||||||
|
private IrisLootReference loot = new IrisLootReference();
|
||||||
|
|
||||||
@MinNumber(0.0001)
|
@MinNumber(0.0001)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"})
|
@DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"})
|
||||||
|
@ -174,21 +174,14 @@ public class IrisBiomeDecorator
|
|||||||
return getBlockData().get(0);
|
return getBlockData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getVarianceGenerator(
|
CNG v = getVarianceGenerator(rng.nextParallelRNG(44));
|
||||||
|
|
||||||
rng.nextParallelRNG(44)
|
if(v == null)
|
||||||
|
{
|
||||||
)
|
getBlockData().get(0);
|
||||||
|
}
|
||||||
.fit(
|
|
||||||
|
v.fit(getBlockData(), xx, zz);
|
||||||
getBlockData()
|
|
||||||
|
|
||||||
,
|
|
||||||
|
|
||||||
xx,
|
|
||||||
|
|
||||||
zz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -42,6 +42,10 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
@Desc("The human readable name of this dimension")
|
@Desc("The human readable name of this dimension")
|
||||||
private String name = "A Dimension";
|
private String name = "A Dimension";
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Reference loot tables in this area")
|
||||||
|
private IrisLootReference loot = new IrisLootReference();
|
||||||
|
|
||||||
@Required
|
@Required
|
||||||
@MinNumber(0)
|
@MinNumber(0)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
|
115
src/main/java/com/volmit/iris/object/IrisLoot.java
Normal file
115
src/main/java/com/volmit/iris/object/IrisLoot.java
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
|
import com.volmit.iris.noise.CNG;
|
||||||
|
import com.volmit.iris.util.B;
|
||||||
|
import com.volmit.iris.util.Desc;
|
||||||
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
|
import com.volmit.iris.util.Form;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.MaxNumber;
|
||||||
|
import com.volmit.iris.util.MinNumber;
|
||||||
|
import com.volmit.iris.util.RNG;
|
||||||
|
import com.volmit.iris.util.Required;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
@Desc("Represents a loot entry")
|
||||||
|
@Data
|
||||||
|
public class IrisLoot
|
||||||
|
{
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The target inventory slot types to fill this loot with")
|
||||||
|
private InventorySlotType slotTypes = InventorySlotType.STORAGE;
|
||||||
|
|
||||||
|
@MinNumber(1)
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The sub rarity of this loot. Calculated after this loot table has been picked.")
|
||||||
|
private int rarity = 1;
|
||||||
|
|
||||||
|
@MinNumber(1)
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Minimum amount of this loot")
|
||||||
|
private int minAmount = 1;
|
||||||
|
|
||||||
|
@MinNumber(1)
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Maximum amount of this loot")
|
||||||
|
private int maxAmount = 1;
|
||||||
|
|
||||||
|
@MinNumber(0)
|
||||||
|
@MaxNumber(1)
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Minimum durability percent")
|
||||||
|
private double minDurability = 0;
|
||||||
|
|
||||||
|
@MinNumber(0)
|
||||||
|
@MaxNumber(1)
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Maximum durability percent")
|
||||||
|
private double maxDurability = 1;
|
||||||
|
|
||||||
|
@Required
|
||||||
|
@Desc("This is the item or block type. Does not accept minecraft:*. Only materials such as DIAMOND_SWORD or DIRT.")
|
||||||
|
private String type = "";
|
||||||
|
|
||||||
|
private transient AtomicCache<CNG> chance = new AtomicCache<>();
|
||||||
|
|
||||||
|
public IrisLoot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getType()
|
||||||
|
{
|
||||||
|
return B.getMaterial(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack get(boolean debug, IrisLootTable table, RNG rng, int x, int y, int z)
|
||||||
|
{
|
||||||
|
if(debug)
|
||||||
|
{
|
||||||
|
chance.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1)
|
||||||
|
{
|
||||||
|
if(getType() == null)
|
||||||
|
{
|
||||||
|
Iris.warn("Cant find item type " + type);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||||
|
ItemMeta m = is.getItemMeta();
|
||||||
|
|
||||||
|
if(getType().getMaxDurability() > 0 && m instanceof Damageable)
|
||||||
|
{
|
||||||
|
Damageable d = (Damageable) m;
|
||||||
|
int max = getType().getMaxDurability();
|
||||||
|
d.setDamage((int) Math.round(Math.max(0, Math.min(max, rng.d(getMinDurability(), getMaxDurability()) * max))));
|
||||||
|
}
|
||||||
|
|
||||||
|
KList<String> lore = new KList<>();
|
||||||
|
|
||||||
|
if(debug)
|
||||||
|
{
|
||||||
|
lore.add("From Table: " + table.getName() + " (" + Form.pc(1D / table.getRarity(), 5) + ")");
|
||||||
|
lore.add(ChatColor.GRAY + "1 in " + (table.getRarity() * getRarity()) + " Chance (" + Form.pc(1D / (table.getRarity() * getRarity()), 5) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
m.setLore(lore);
|
||||||
|
is.setItemMeta(m);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
48
src/main/java/com/volmit/iris/object/IrisLootReference.java
Normal file
48
src/main/java/com/volmit/iris/object/IrisLootReference.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.DimensionChunkGenerator;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
|
import com.volmit.iris.util.ArrayType;
|
||||||
|
import com.volmit.iris.util.Desc;
|
||||||
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.RegistryListLoot;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Desc("Represents a loot entry")
|
||||||
|
@Data
|
||||||
|
public class IrisLootReference
|
||||||
|
{
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Add = add on top of parent tables, Replace = clear first then add these. Clear = Remove all and dont add loot from this or parent.")
|
||||||
|
private LootMode mode = LootMode.ADD;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@RegistryListLoot
|
||||||
|
@ArrayType(min = 1, type = String.class)
|
||||||
|
@Desc("Add loot table registries here")
|
||||||
|
private KList<String> tables = new KList<>();
|
||||||
|
|
||||||
|
private transient AtomicCache<KList<IrisLootTable>> tt = new AtomicCache<>();
|
||||||
|
|
||||||
|
public IrisLootReference()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public KList<IrisLootTable> getLootTables(DimensionChunkGenerator g)
|
||||||
|
{
|
||||||
|
return tt.aquire(() ->
|
||||||
|
{
|
||||||
|
KList<IrisLootTable> t = new KList<>();
|
||||||
|
|
||||||
|
for(String i : tables)
|
||||||
|
{
|
||||||
|
t.add(g.getData().getLootLoader().load(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
63
src/main/java/com/volmit/iris/object/IrisLootTable.java
Normal file
63
src/main/java/com/volmit/iris/object/IrisLootTable.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.ArrayType;
|
||||||
|
import com.volmit.iris.util.Desc;
|
||||||
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.MinNumber;
|
||||||
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Desc("Represents a loot table. Biomes, Regions & Objects can add or replace the virtual table with these loot tables")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class IrisLootTable extends IrisRegistrant
|
||||||
|
{
|
||||||
|
@Desc("The name of this loot table")
|
||||||
|
@DontObfuscate
|
||||||
|
@MinNumber(2)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@MinNumber(1)
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The rarity as in 1 in X chance")
|
||||||
|
private int rarity = 1;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The loot in this table")
|
||||||
|
@ArrayType(min = 1, type = IrisLoot.class)
|
||||||
|
private KList<IrisLoot> loot = new KList<>();
|
||||||
|
|
||||||
|
public KList<ItemStack> getLoot(boolean debug, RNG rng, InventorySlotType slot, int x, int y, int z)
|
||||||
|
{
|
||||||
|
KList<ItemStack> lootf = new KList<>();
|
||||||
|
|
||||||
|
int m = 0;
|
||||||
|
|
||||||
|
for(IrisLoot i : loot)
|
||||||
|
{
|
||||||
|
if(i.getSlotTypes().equals(slot))
|
||||||
|
{
|
||||||
|
ItemStack item = i.get(debug, this, rng.nextParallelRNG(294788 + x + y - z * z + (m * -4125)), x, y, z);
|
||||||
|
|
||||||
|
if(item != null)
|
||||||
|
{
|
||||||
|
lootf.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lootf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IrisLootTable()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -309,7 +309,7 @@ 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(config.getMode().equals(ObjectPlaceMode.PAINT))
|
if(config.getMode().equals(ObjectPlaceMode.PAINT) && paintmap != null)
|
||||||
{
|
{
|
||||||
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + paintmap.compute(new ChunkPosition(xx, zz), (k, v) ->
|
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + paintmap.compute(new ChunkPosition(xx, zz), (k, v) ->
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,10 @@ public class IrisRegion extends IrisRegistrant implements IRare
|
|||||||
@Desc("The min shore height")
|
@Desc("The min shore height")
|
||||||
private double shoreHeightMin = 1.2;
|
private double shoreHeightMin = 1.2;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Reference loot tables in this area")
|
||||||
|
private IrisLootReference loot = new IrisLootReference();
|
||||||
|
|
||||||
@MinNumber(0)
|
@MinNumber(0)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The the max shore height")
|
@Desc("The the max shore height")
|
||||||
|
@ -38,6 +38,10 @@ public class IrisStructure extends IrisRegistrant
|
|||||||
@Desc("This is the x and z size of each grid cell")
|
@Desc("This is the x and z size of each grid cell")
|
||||||
private int gridSize = 11;
|
private int gridSize = 11;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Reference loot tables in this area")
|
||||||
|
private IrisLootReference loot = new IrisLootReference();
|
||||||
|
|
||||||
@Required
|
@Required
|
||||||
@MinNumber(1)
|
@MinNumber(1)
|
||||||
@MaxNumber(255)
|
@MaxNumber(255)
|
||||||
|
@ -17,6 +17,10 @@ import lombok.EqualsAndHashCode;
|
|||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class IrisStructureTile
|
public class IrisStructureTile
|
||||||
{
|
{
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("Reference loot tables in this area")
|
||||||
|
private IrisLootReference loot = new IrisLootReference();
|
||||||
|
|
||||||
@Required
|
@Required
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("Is this structure allowed to place if there is supposed to be a ceiling?")
|
@Desc("Is this structure allowed to place if there is supposed to be a ceiling?")
|
||||||
|
15
src/main/java/com/volmit/iris/object/LootMode.java
Normal file
15
src/main/java/com/volmit/iris/object/LootMode.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
|
|
||||||
|
public enum LootMode
|
||||||
|
{
|
||||||
|
@DontObfuscate
|
||||||
|
ADD,
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
CLEAR,
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
REPLACE;
|
||||||
|
}
|
@ -14,12 +14,36 @@ public class B
|
|||||||
private static final KList<String> nulls = new KList<>();
|
private static final KList<String> nulls = 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<>();
|
||||||
|
|
||||||
public static BlockData get(String bd)
|
public static BlockData get(String bd)
|
||||||
{
|
{
|
||||||
return getBlockData(bd);
|
return getBlockData(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Material getMaterial(String bd)
|
||||||
|
{
|
||||||
|
return types.compute(bd, (k, v) ->
|
||||||
|
{
|
||||||
|
if(k != null && v != null)
|
||||||
|
{
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Material.valueOf(k);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSolid(Material mat)
|
public static boolean isSolid(Material mat)
|
||||||
{
|
{
|
||||||
if(!solid.containsKey(mat))
|
if(!solid.containsKey(mat))
|
||||||
@ -114,19 +138,101 @@ public class B
|
|||||||
return AIR;
|
return AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLit(BlockData mat)
|
public static boolean isUpdatable(BlockData mat)
|
||||||
{
|
{
|
||||||
return isLit(mat.getMaterial());
|
return isUpdatable(mat.getMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isStorage(Material mat)
|
||||||
|
{
|
||||||
|
//@builder
|
||||||
|
return mat.equals(B.mat("CHEST"))
|
||||||
|
|| mat.equals(B.mat("TRAPPED_CHEST"))
|
||||||
|
|| mat.equals(B.mat("SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("WHITE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("ORANGE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("MAGENTA_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("LIGHT_BLUE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("YELLOW_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("LIME_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("PINK_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("GRAY_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("LIGHT_GRAY_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("CYAN_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("PURPLE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("BLUE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("BROWN_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("GREEN_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("RED_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("BLACK_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("BARREL"))
|
||||||
|
|| mat.equals(B.mat("DISPENSER"))
|
||||||
|
|| mat.equals(B.mat("DROPPER"))
|
||||||
|
|| mat.equals(B.mat("HOPPER"))
|
||||||
|
|| mat.equals(B.mat("FURNACE"))
|
||||||
|
|| mat.equals(B.mat("BLAST_FURNACE"))
|
||||||
|
|| mat.equals(B.mat("SMOKER"));
|
||||||
|
//@done
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isStorageChest(Material mat)
|
||||||
|
{
|
||||||
|
//@builder
|
||||||
|
return mat.equals(B.mat("CHEST"))
|
||||||
|
|| mat.equals(B.mat("TRAPPED_CHEST"))
|
||||||
|
|| mat.equals(B.mat("SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("WHITE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("ORANGE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("MAGENTA_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("LIGHT_BLUE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("YELLOW_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("LIME_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("PINK_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("GRAY_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("LIGHT_GRAY_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("CYAN_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("PURPLE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("BLUE_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("BROWN_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("GREEN_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("RED_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("BLACK_SHULKER_BOX"))
|
||||||
|
|| mat.equals(B.mat("BARREL"))
|
||||||
|
|| mat.equals(B.mat("DISPENSER"))
|
||||||
|
|| mat.equals(B.mat("DROPPER"))
|
||||||
|
|| mat.equals(B.mat("HOPPER"));
|
||||||
|
//@done
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLit(Material mat)
|
public static boolean isLit(Material mat)
|
||||||
{
|
{
|
||||||
if(mat.equals(B.mat("GLOWSTONE")) || mat.equals(B.mat("TORCH")) || mat.equals(Material.REDSTONE_TORCH) || mat.equals(B.mat("SOUL_TORCH")) || mat.equals(Material.REDSTONE_WALL_TORCH) || mat.equals(Material.WALL_TORCH) || mat.equals(B.mat("SOUL_WALL_TORCH")) || mat.equals(B.mat("LANTERN")) || mat.equals(Material.JACK_O_LANTERN) || mat.equals(Material.REDSTONE_LAMP) || mat.equals(Material.MAGMA_BLOCK) || mat.equals(B.mat("SEA_LANTERN")) || mat.equals(B.mat("SOUL_LANTERN")) || mat.equals(Material.FIRE) || mat.equals(B.mat("SOUL_FIRE")) || mat.equals(B.mat("SEA_PICKLE")) || mat.equals(Material.BREWING_STAND) || mat.equals(Material.REDSTONE_ORE))
|
//@builder
|
||||||
{
|
return mat.equals(B.mat("GLOWSTONE"))
|
||||||
return true;
|
|| mat.equals(B.mat("END_ROD"))
|
||||||
}
|
|| mat.equals(B.mat("SOUL_SAND"))
|
||||||
|
|| mat.equals(B.mat("TORCH"))
|
||||||
|
|| mat.equals(Material.REDSTONE_TORCH)
|
||||||
|
|| mat.equals(B.mat("SOUL_TORCH"))
|
||||||
|
|| mat.equals(Material.REDSTONE_WALL_TORCH)
|
||||||
|
|| mat.equals(Material.WALL_TORCH)
|
||||||
|
|| mat.equals(B.mat("SOUL_WALL_TORCH"))
|
||||||
|
|| mat.equals(B.mat("LANTERN"))
|
||||||
|
|| mat.equals(Material.JACK_O_LANTERN)
|
||||||
|
|| mat.equals(Material.REDSTONE_LAMP)
|
||||||
|
|| mat.equals(Material.MAGMA_BLOCK)
|
||||||
|
|| mat.equals(B.mat("SEA_LANTERN"))
|
||||||
|
|| mat.equals(B.mat("SOUL_LANTERN"))
|
||||||
|
|| mat.equals(Material.FIRE)
|
||||||
|
|| mat.equals(B.mat("SOUL_FIRE"))
|
||||||
|
|| mat.equals(B.mat("SEA_PICKLE"))
|
||||||
|
|| mat.equals(Material.BREWING_STAND)
|
||||||
|
|| mat.equals(Material.REDSTONE_ORE);
|
||||||
|
//@done
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
public static boolean isUpdatable(Material mat)
|
||||||
|
{
|
||||||
|
return isLit(mat) || isStorage(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canPlaceOnto(Material mat, Material onto)
|
public static boolean canPlaceOnto(Material mat, Material onto)
|
||||||
|
14
src/main/java/com/volmit/iris/util/RegistryListLoot.java
Normal file
14
src/main/java/com/volmit/iris/util/RegistryListLoot.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.volmit.iris.util;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.*;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.*;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Target({PARAMETER, TYPE, FIELD})
|
||||||
|
public @interface RegistryListLoot
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user