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-29 14:30:12 -04:00
parent ed9ddc0825
commit 20b715f7cb
41 changed files with 17273 additions and 14829 deletions

View File

@@ -1,5 +1,7 @@
package com.volmit.iris.object;
import java.awt.Color;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
@@ -45,6 +47,11 @@ 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();
@ArrayType(min = 1, type = IrisBlockDrops.class)
@DontObfuscate
@Desc("Define custom block drops for this biome")
private KList<IrisBlockDrops> blockDrops = new KList<>();
@DontObfuscate
@Desc("Reference loot tables in this area")
private IrisLootReference loot = new IrisLootReference();
@@ -69,6 +76,10 @@ public class IrisBiome extends IrisRegistrant implements IRare
@Desc("The rarity of this biome (integer)")
private int rarity = 1;
@DontObfuscate
@Desc("A debug color for visualizing this biome with a color. I.e. #F13AF5")
private String debugColor = "";
@Required
@DontObfuscate
@Desc("The raw derivative of this biome. This is required or the terrain will not properly generate. Use any vanilla biome type. Look in examples/biome-list.txt")
@@ -146,6 +157,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
private KList<IrisDepositGenerator> deposits = new KList<>();
private transient InferredType inferredType;
private transient AtomicCache<Color> cacheColor = new AtomicCache<>(true);
private transient AtomicCache<CNG> childrenCell = new AtomicCache<>();
private transient AtomicCache<CNG> biomeGenerator = new AtomicCache<>();
private transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
@@ -158,6 +170,19 @@ public class IrisBiome extends IrisRegistrant implements IRare
}
public Color getCachedColor()
{
return cacheColor.aquire(() ->
{
if(getDebugColor() == null || getDebugColor().isEmpty())
{
return null;
}
return Color.getColor(getDebugColor().substring(1));
});
}
public double getHeight(ContextualChunkGenerator xg, double x, double z, long seed)
{
double height = 0;

View File

@@ -0,0 +1,90 @@
package com.volmit.iris.object;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.util.ArrayType;
import com.volmit.iris.util.B;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG;
import com.volmit.iris.util.Required;
import lombok.Data;
@Desc("Represents a block drop list")
@Data
public class IrisBlockDrops
{
@Required
@ArrayType(min = 1, type = String.class)
@Desc("The blocks that drop loot")
private KList<String> blocks = new KList<String>();
@DontObfuscate
@Desc("If exact blocks is set to true, minecraft:barrel[axis=x] will only drop for that axis. When exact is false (default) any barrel will drop the defined drops.")
private boolean exactBlocks = false;
@DontObfuscate
@Desc("Add in specific items to drop")
@ArrayType(min = 1, type = IrisLoot.class)
private KList<IrisLoot> drops = new KList<>();
@DontObfuscate
@Desc("If this is in a biome, setting skipParents to true will ignore the drops in the region and dimension for this block type. The default (false) will allow all three nodes to fire and add to a list of drops.")
private boolean skipParents = false;
@DontObfuscate
@Desc("Removes the default vanilla block drops and only drops the given items & any parent loot tables specified for this block type.")
private boolean replaceVanillaDrops = false;
private transient AtomicCache<KList<BlockData>> data = new AtomicCache<>();
public IrisBlockDrops()
{
}
public boolean shouldDropFor(BlockData data)
{
KList<BlockData> list = this.data.aquire(() ->
{
KList<BlockData> b = new KList<>();
for(String i : getBlocks())
{
BlockData dd = B.get(i);
if(dd != null)
{
b.add(dd);
}
}
return b.removeDuplicates();
});
for(BlockData i : list)
{
if(exactBlocks ? i.equals(data) : i.getMaterial().equals(data.getMaterial()))
{
return true;
}
}
return false;
}
public void fillDrops(boolean debug, KList<ItemStack> d)
{
for(IrisLoot i : getDrops())
{
if(RNG.r.i(1, i.getRarity()) == i.getRarity())
{
d.add(i.get(debug, RNG.r));
}
}
}
}

View File

@@ -61,6 +61,11 @@ public class IrisDimension extends IrisRegistrant
@Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).")
private int version = 1;
@ArrayType(min = 1, type = IrisBlockDrops.class)
@DontObfuscate
@Desc("Define custom block drops for this dimension")
private KList<IrisBlockDrops> blockDrops = new KList<>();
@MinNumber(0)
@MaxNumber(1)
@DontObfuscate

View File

@@ -108,6 +108,73 @@ public class IrisLoot
return B.getMaterial(type);
}
public ItemStack get(boolean debug, RNG rng)
{
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, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
}
for(IrisEnchantment i : getEnchantments())
{
i.apply(rng, m);
}
for(IrisAttributeModifier i : getAttributes())
{
i.apply(rng, m);
}
m.setCustomModelData(getCustomModel());
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
m.setUnbreakable(isUnbreakable());
for(ItemFlag i : getItemFlags())
{
m.addItemFlags(i);
}
KList<String> lore = new KList<>();
getLore().forEach((i) ->
{
String mf = C.translateAlternateColorCodes('&', i);
if(mf.length() > 24)
{
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E"))
{
lore.add(g.trim());
}
}
else
{
lore.add(mf);
}
});
if(debug)
{
if(lore.isNotEmpty())
{
lore.add(C.GRAY + "--------------------");
}
lore.add(C.GRAY + "1 in " + (getRarity()) + " Chance (" + Form.pc(1D / (getRarity()), 5) + ")");
}
m.setLore(lore);
is.setItemMeta(m);
return is;
}
public ItemStack get(boolean debug, IrisLootTable table, RNG rng, int x, int y, int z)
{
if(debug)
@@ -144,8 +211,8 @@ public class IrisLoot
}
m.setCustomModelData(getCustomModel());
m.setLocalizedName(displayName);
m.setDisplayName(displayName);
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
m.setUnbreakable(isUnbreakable());
for(ItemFlag i : getItemFlags())
@@ -155,7 +222,23 @@ public class IrisLoot
KList<String> lore = new KList<>();
lore.addAll(getLore());
getLore().forEach((i) ->
{
String mf = C.translateAlternateColorCodes('&', i);
if(mf.length() > 24)
{
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E"))
{
lore.add(g.trim());
}
}
else
{
lore.add(mf);
}
});
if(debug)
{

View File

@@ -34,6 +34,7 @@ public class IrisObject extends IrisRegistrant
private static final Material SNOW = Material.SNOW;
private static final BlockData AIR = B.getBlockData("CAVE_AIR");
private static final BlockData[] SNOW_LAYERS = new BlockData[] {B.getBlockData("minecraft:snow[layers=1]"), B.getBlockData("minecraft:snow[layers=2]"), B.getBlockData("minecraft:snow[layers=3]"), B.getBlockData("minecraft:snow[layers=4]"), B.getBlockData("minecraft:snow[layers=5]"), B.getBlockData("minecraft:snow[layers=6]"), B.getBlockData("minecraft:snow[layers=7]"), B.getBlockData("minecraft:snow[layers=8]")};
public static boolean shitty = false;
private KMap<BlockVector, BlockData> blocks;
private int w;
private int d;
@@ -74,6 +75,11 @@ public class IrisObject extends IrisRegistrant
public void read(InputStream in) throws IOException
{
if(shitty)
{
return;
}
DataInputStream din = new DataInputStream(in);
this.w = din.readInt();
this.h = din.readInt();
@@ -89,6 +95,10 @@ public class IrisObject extends IrisRegistrant
public void read(File file) throws IOException
{
if(shitty)
{
return;
}
FileInputStream fin = new FileInputStream(file);
read(fin);
fin.close();
@@ -96,6 +106,10 @@ public class IrisObject extends IrisRegistrant
public void write(File file) throws IOException
{
if(shitty)
{
return;
}
file.getParentFile().mkdirs();
FileOutputStream out = new FileOutputStream(file);
write(out);
@@ -104,6 +118,10 @@ public class IrisObject extends IrisRegistrant
public void write(OutputStream o) throws IOException
{
if(shitty)
{
return;
}
DataOutputStream dos = new DataOutputStream(o);
dos.writeInt(w);
dos.writeInt(h);
@@ -120,6 +138,10 @@ public class IrisObject extends IrisRegistrant
public void clean()
{
if(shitty)
{
return;
}
KMap<BlockVector, BlockData> d = blocks.copy();
blocks.clear();
@@ -131,6 +153,10 @@ public class IrisObject extends IrisRegistrant
public void setUnsigned(int x, int y, int z, BlockData block)
{
if(shitty)
{
return;
}
if(x >= w || y >= h || z >= d)
{
throw new RuntimeException(x + " " + y + " " + z + " exceeds limit of " + w + " " + h + " " + d);
@@ -151,6 +177,10 @@ public class IrisObject extends IrisRegistrant
public void place(int x, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng)
{
if(shitty)
{
return;
}
place(x, -1, z, placer, config, rng);
}
@@ -161,6 +191,10 @@ public class IrisObject extends IrisRegistrant
public int place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener)
{
boolean stilting = (config.getMode().equals(ObjectPlaceMode.STILT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT));
KMap<ChunkPosition, Integer> lowmap = stilting ? new KMap<>() : null;
KMap<ChunkPosition, BlockData> lowmapData = stilting ? new KMap<>() : null;
KMap<ChunkPosition, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
int spinx = rng.imax() / 1000;
int spiny = rng.imax() / 1000;
int spinz = rng.imax() / 1000;
@@ -170,12 +204,12 @@ public class IrisObject extends IrisRegistrant
if(yv < 0)
{
if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT_RIGID))
if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT))
{
y = placer.getHighest(x, z, config.isUnderwater()) + rty;
}
else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT_RIGID_ACCURATE))
else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT))
{
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
@@ -194,7 +228,7 @@ public class IrisObject extends IrisRegistrant
}
}
else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT_RIGID))
else if(config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT))
{
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
@@ -213,7 +247,7 @@ public class IrisObject extends IrisRegistrant
}
}
else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT_RIGID_ACCURATE))
else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT))
{
y = 257;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
@@ -233,7 +267,7 @@ public class IrisObject extends IrisRegistrant
}
}
else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT_RIGID))
else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT))
{
y = 257;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
@@ -269,8 +303,6 @@ public class IrisObject extends IrisRegistrant
y += Math.floorDiv(h, 2);
}
KMap<ChunkPosition, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
if(yv < 0)
{
if(!config.isUnderwater() && !config.isOnwater() && placer.isUnderwater(x, z))
@@ -289,15 +321,18 @@ public class IrisObject extends IrisRegistrant
return -1;
}
if(config.isBore())
if(config.isBore() && !config.getMode().equals(ObjectPlaceMode.PAINT))
{
for(int i = x - Math.floorDiv(w, 2); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0); i++)
{
for(int j = y - Math.floorDiv(h, 2); j <= y + Math.floorDiv(h, 2) - (h % 2 == 0 ? 1 : 0); j++)
for(int j = y - Math.floorDiv(h, 2) - config.getBoarExtendMinY(); j <= y + Math.floorDiv(h, 2) + config.getBoarExtendMaxY() - (h % 2 == 0 ? 1 : 0); j++)
{
for(int k = z - Math.floorDiv(d, 2); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0); k++)
{
placer.set(i, j, k, AIR);
if(!B.isAir(placer.get(i, j, k)))
{
placer.set(i, j, k, AIR);
}
}
}
}
@@ -367,6 +402,49 @@ public class IrisObject extends IrisRegistrant
}
placer.set(xx, yy, zz, data);
if(stilting)
{
BlockData bdata = data;
int yyy = yy;
ChunkPosition ck = new ChunkPosition(xx, zz);
lowmap.compute(ck, (k, v) ->
{
if(v == null)
{
lowmapData.put(ck, bdata);
return yyy;
}
if(v > yyy)
{
lowmapData.put(ck, bdata);
return yyy;
}
return v;
});
}
}
if(stilting)
{
for(ChunkPosition i : lowmap.keySet())
{
int xf = i.getX();
int yf = lowmap.get(i);
int zf = i.getZ();
int yg = Math.floorDiv(h, 2) + placer.getHighest(xf, zf, config.isUnderwater());
BlockData d = lowmapData.get(i);
if(d != null)
{
for(int j = yf; j > yg - config.getOverStilt(); j--)
{
placer.set(xf, j, zf, d);
}
}
}
}
if(heightmap != null)
@@ -398,6 +476,11 @@ public class IrisObject extends IrisRegistrant
public void rotate(IrisObjectRotation r, int spinx, int spiny, int spinz)
{
if(shitty)
{
return;
}
KMap<BlockVector, BlockData> v = blocks.copy();
blocks.clear();
@@ -409,6 +492,11 @@ public class IrisObject extends IrisRegistrant
public void place(Location at)
{
if(shitty)
{
return;
}
for(BlockVector i : blocks.keySet())
{
at.clone().add(0, getCenter().getY(), 0).add(i).getBlock().setBlockData(blocks.get(i), false);

View File

@@ -31,7 +31,7 @@ public class IrisObjectPlacement
@DontObfuscate
@Desc("The placement mode")
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT_RIGID;
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
@ArrayType(min = 1, type = IrisObjectReplace.class)
@DontObfuscate
@@ -68,6 +68,24 @@ public class IrisObjectPlacement
@Desc("If the chance check passes, place this many in a single chunk")
private int density = 1;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
private int overStilt = 0;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("When boar is enabled, expand max-y of the cuboid it removes")
private int boarExtendMaxY = 0;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("When boar is enabled, lower min-y of the cuboid it removes")
private int boarExtendMinY = 0;
@DontObfuscate
@Desc("If set to true, objects will place on the terrain height, ignoring the water surface.")
private boolean underwater = false;

View File

@@ -41,6 +41,11 @@ public class IrisRegion extends IrisRegistrant implements IRare
@DontObfuscate
@Desc("The rarity of the region")
private int rarity = 1;
@ArrayType(min = 1, type = IrisBlockDrops.class)
@DontObfuscate
@Desc("Define custom block drops for this region")
private KList<IrisBlockDrops> blockDrops = new KList<>();
@MinNumber(0.0001)
@MaxNumber(1)

View File

@@ -5,19 +5,25 @@ import com.volmit.iris.util.DontObfuscate;
public enum ObjectPlaceMode
{
@DontObfuscate
CENTER_HEIGHT_RIGID,
CENTER_HEIGHT,
@DontObfuscate
MAX_HEIGHT_RIGID_ACCURATE,
MAX_HEIGHT,
@DontObfuscate
MAX_HEIGHT_RIGID,
FAST_MAX_HEIGHT,
@DontObfuscate
MIN_HEIGHT_RIGID_ACCURATE,
MIN_HEIGHT,
@DontObfuscate
MIN_HEIGHT_RIGID,
FAST_MIN_HEIGHT,
@DontObfuscate
STILT,
@DontObfuscate
FAST_STILT,
@DontObfuscate
PAINT;