mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-30 12:29:20 +00:00
Parallax 2
This commit is contained in:
@@ -6,6 +6,7 @@ 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.RegistryListLoot;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -24,6 +25,11 @@ public class IrisLootReference
|
||||
@Desc("Add loot table registries here")
|
||||
private KList<String> tables = new KList<>();
|
||||
|
||||
@MinNumber(0)
|
||||
@DontObfuscate
|
||||
@Desc("Increase the chance of loot in this area")
|
||||
private double multiplier = 1D;
|
||||
|
||||
private transient AtomicCache<KList<IrisLootTable>> tt = new AtomicCache<>();
|
||||
|
||||
public IrisLootReference()
|
||||
|
||||
@@ -27,12 +27,17 @@ public class IrisLootTable extends IrisRegistrant
|
||||
@Desc("The rarity as in 1 in X chance")
|
||||
private int rarity = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@DontObfuscate
|
||||
@Desc("The maximum amount of loot that can be picked in this table at a time.")
|
||||
private int maxPicked = 3;
|
||||
|
||||
@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)
|
||||
public KList<ItemStack> getLoot(boolean debug, RNG rng, InventorySlotType slot, int x, int y, int z, int gg, int ffs)
|
||||
{
|
||||
KList<ItemStack> lootf = new KList<>();
|
||||
|
||||
@@ -42,7 +47,7 @@ public class IrisLootTable extends IrisRegistrant
|
||||
{
|
||||
if(i.getSlotTypes().equals(slot))
|
||||
{
|
||||
ItemStack item = i.get(debug, this, rng.nextParallelRNG(294788 + x + y - z * z + (m * -4125)), x, y, z);
|
||||
ItemStack item = i.get(debug, this, rng, x, y, z);
|
||||
|
||||
if(item != null)
|
||||
{
|
||||
@@ -51,6 +56,11 @@ public class IrisLootTable extends IrisRegistrant
|
||||
}
|
||||
|
||||
m++;
|
||||
|
||||
if(m > maxPicked)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return lootf;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -17,6 +18,7 @@ import org.bukkit.block.data.type.Leaves;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.BlockPosition;
|
||||
import com.volmit.iris.util.ChunkPosition;
|
||||
import com.volmit.iris.util.IObjectPlacer;
|
||||
import com.volmit.iris.util.KMap;
|
||||
@@ -127,7 +129,12 @@ public class IrisObject extends IrisRegistrant
|
||||
place(x, -1, z, placer, config, rng);
|
||||
}
|
||||
|
||||
public void place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng)
|
||||
public int place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng)
|
||||
{
|
||||
return place(x, yv, z, placer, config, rng, null);
|
||||
}
|
||||
|
||||
public int place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener)
|
||||
{
|
||||
int spinx = rng.imax() / 1000;
|
||||
int spiny = rng.imax() / 1000;
|
||||
@@ -135,7 +142,6 @@ public class IrisObject extends IrisRegistrant
|
||||
int rty = config.getRotation().rotate(new BlockVector(0, getCenter().getBlockY(), 0), spinx, spiny, spinz).getBlockY();
|
||||
int ty = config.getTranslate().translate(new BlockVector(0, getCenter().getBlockY(), 0), config.getRotation(), spinx, spiny, spinz).getBlockY();
|
||||
int y = -1;
|
||||
KMap<ChunkPosition, Integer> paintmap = null;
|
||||
|
||||
if(yv < 0)
|
||||
{
|
||||
@@ -233,7 +239,6 @@ public class IrisObject extends IrisRegistrant
|
||||
else if(config.getMode().equals(ObjectPlaceMode.PAINT))
|
||||
{
|
||||
y = placer.getHighest(x, z, config.isUnderwater()) + rty;
|
||||
paintmap = new KMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,18 +258,18 @@ public class IrisObject extends IrisRegistrant
|
||||
{
|
||||
if(!config.isUnderwater() && !config.isOnwater() && placer.isUnderwater(x, z))
|
||||
{
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(config.isUnderwater() && y + rty + ty >= placer.getFluidHeight())
|
||||
{
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!config.getClamp().canPlace(y + rty + ty, y - rty + ty))
|
||||
{
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(config.isBore())
|
||||
@@ -309,17 +314,9 @@ 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(yv < 0 && config.getMode().equals(ObjectPlaceMode.PAINT))
|
||||
{
|
||||
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + paintmap.compute(new ChunkPosition(xx, zz), (k, v) ->
|
||||
{
|
||||
if(k == null || v == null)
|
||||
{
|
||||
return placer.getHighest(xx, zz, config.isUnderwater());
|
||||
}
|
||||
|
||||
return v;
|
||||
});
|
||||
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, config.isUnderwater());
|
||||
}
|
||||
|
||||
if(heightmap != null)
|
||||
@@ -347,6 +344,11 @@ public class IrisObject extends IrisRegistrant
|
||||
((Waterlogged) data).setWaterlogged(true);
|
||||
}
|
||||
|
||||
if(listener != null)
|
||||
{
|
||||
listener.accept(new BlockPosition(xx, yy, zz));
|
||||
}
|
||||
|
||||
placer.set(xx, yy, zz, data);
|
||||
}
|
||||
|
||||
@@ -373,6 +375,8 @@ public class IrisObject extends IrisRegistrant
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
public void place(Location at)
|
||||
|
||||
@@ -147,7 +147,7 @@ public class IrisStructurePlacement
|
||||
}
|
||||
|
||||
o = o != null ? o : load(g, t.getTile().getObjects().get(rnp.nextInt(t.getTile().getObjects().size())));
|
||||
o.place(Math.floorDiv(i, s) * s, height == -1 ? -1 : h, Math.floorDiv(j, s) * s, g, t.getPlacement(), rng);
|
||||
o.place(Math.floorDiv(i, s) * s, height == -1 ? -1 : h, Math.floorDiv(j, s) * s, g, t.getPlacement(), rng, (gg) -> g.getParallaxChunk(gg.getChunkX(), gg.getChunkZ()).setStructure(gg.getY(), t.getStructure(), t.getTile()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ public class IrisStructureTile
|
||||
private KList<String> objects = new KList<>();
|
||||
|
||||
@RegistryListObject
|
||||
@Required
|
||||
@ArrayType(min = 1, type = IrisRareObject.class)
|
||||
@DontObfuscate
|
||||
@Desc("List of objects to place centered in this tile but with rarity. These items only place some of the time so specify objects for common stuff too.")
|
||||
|
||||
Reference in New Issue
Block a user