9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-30 12:29:20 +00:00
This commit is contained in:
Daniel Mills
2020-08-21 03:48:53 -04:00
parent 7b94d753b8
commit 39b7563d3a
24 changed files with 773 additions and 29 deletions

View 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,
}

View File

@@ -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.")
private IrisGeneratorStyle biomeStyle = NoiseStyle.SIMPLEX.style();
@DontObfuscate
@Desc("Reference loot tables in this area")
private IrisLootReference loot = new IrisLootReference();
@MinNumber(0.0001)
@DontObfuscate
@DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"})

View File

@@ -174,21 +174,14 @@ public class IrisBiomeDecorator
return getBlockData().get(0);
}
return getVarianceGenerator(
rng.nextParallelRNG(44)
)
.fit(
getBlockData()
,
xx,
zz);
CNG v = getVarianceGenerator(rng.nextParallelRNG(44));
if(v == null)
{
getBlockData().get(0);
}
v.fit(getBlockData(), xx, zz);
}
return null;

View File

@@ -42,6 +42,10 @@ public class IrisDimension extends IrisRegistrant
@Desc("The human readable name of this dimension")
private String name = "A Dimension";
@DontObfuscate
@Desc("Reference loot tables in this area")
private IrisLootReference loot = new IrisLootReference();
@Required
@MinNumber(0)
@DontObfuscate

View 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;
}
}

View 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;
});
}
}

View 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()
{
}
}

View File

@@ -309,7 +309,7 @@ public class IrisObject extends IrisRegistrant
int yy = y + (int) Math.round(i.getY());
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) ->
{

View File

@@ -52,6 +52,10 @@ public class IrisRegion extends IrisRegistrant implements IRare
@Desc("The min shore height")
private double shoreHeightMin = 1.2;
@DontObfuscate
@Desc("Reference loot tables in this area")
private IrisLootReference loot = new IrisLootReference();
@MinNumber(0)
@DontObfuscate
@Desc("The the max shore height")

View File

@@ -38,6 +38,10 @@ public class IrisStructure extends IrisRegistrant
@Desc("This is the x and z size of each grid cell")
private int gridSize = 11;
@DontObfuscate
@Desc("Reference loot tables in this area")
private IrisLootReference loot = new IrisLootReference();
@Required
@MinNumber(1)
@MaxNumber(255)

View File

@@ -17,6 +17,10 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = false)
public class IrisStructureTile
{
@DontObfuscate
@Desc("Reference loot tables in this area")
private IrisLootReference loot = new IrisLootReference();
@Required
@DontObfuscate
@Desc("Is this structure allowed to place if there is supposed to be a ceiling?")

View 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;
}