9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 03:29:06 +00:00
This commit is contained in:
cyberpwn
2021-08-26 06:12:32 -04:00
parent 3b61b87501
commit 44d75d9955
17 changed files with 117 additions and 182 deletions

View File

@@ -223,8 +223,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
private void spawnIn(Chunk c, boolean initial) {
if(initial)
{
if (initial) {
energy += 1.2;
}
@@ -370,13 +369,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
@Override
public void onChunkLoad(Chunk e, boolean generated) {
J.a(() -> getMantle().raiseFlag(e.getX(), e.getZ(), MantleFlag.INITIAL_SPAWNED,
() -> J.a(() -> spawnIn(e, true), RNG.r.i(5, 200))));
() -> J.a(() -> spawnIn(e, true), RNG.r.i(5, 200))));
energy += 0.3;
fixEnergy();
}
public Mantle getMantle()
{
public Mantle getMantle() {
return getEngine().getMantle().getMantle();
}
@@ -392,36 +390,14 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
Runnable drop = () -> J.s(() -> d.forEach((i) -> e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().clone().add(0.5, 0.5, 0.5), i)));
IrisBiome b = getEngine().getBiome(e.getBlock().getLocation());
for (IrisBlockDrops i : b.getBlockDrops()) {
if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
if (i.isReplaceVanillaDrops()) {
e.setDropItems(false);
}
i.fillDrops(false, d);
if (i.isSkipParents()) {
drop.run();
return;
}
}
if (dropItems(e, d, drop, b.getBlockDrops(), b)) {
return;
}
IrisRegion r = getEngine().getRegion(e.getBlock().getLocation());
for (IrisBlockDrops i : r.getBlockDrops()) {
if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
if (i.isReplaceVanillaDrops()) {
e.setDropItems(false);
}
i.fillDrops(false, d);
if (i.isSkipParents()) {
drop.run();
return;
}
}
if (dropItems(e, d, drop, r.getBlockDrops(), b)) {
return;
}
for (IrisBlockDrops i : getEngine().getDimension().getBlockDrops()) {
@@ -441,6 +417,24 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
}
private boolean dropItems(BlockBreakEvent e, KList<ItemStack> d, Runnable drop, KList<IrisBlockDrops> blockDrops, IrisBiome b) {
for (IrisBlockDrops i : blockDrops) {
if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
if (i.isReplaceVanillaDrops()) {
e.setDropItems(false);
}
i.fillDrops(false, d);
if (i.isSkipParents()) {
drop.run();
return true;
}
}
}
return false;
}
@Override
public void onBlockPlace(BlockPlaceEvent e) {

View File

@@ -56,9 +56,9 @@ public class LinkedTerrainChunk implements TerrainChunk {
@Override
public BiomeBaseInjector getBiomeBaseInjector() {
if(unsafe)
{
return (a,b,c,d) -> {};
if (unsafe) {
return (a, b, c, d) -> {
};
}
return (x, y, z, bb) -> INMS.get().forceBiomeInto(x, y, z, bb, storage);

View File

@@ -147,8 +147,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
double modifyZ(double z);
@BlockCoordinates
default void generate(int x, int z, TerrainChunk tc, boolean multicore) throws WrongEngineBroException
{
default void generate(int x, int z, TerrainChunk tc, boolean multicore) throws WrongEngineBroException {
generate(x, z, Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc), multicore);
}

View File

@@ -34,7 +34,6 @@ import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleChunk;
import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import org.bukkit.Chunk;
@@ -193,8 +192,7 @@ public interface EngineMantle extends IObjectPlacer {
burst.queue(() -> {
MantleChunk mc = getMantle().getChunk(xx, zz);
for(MantleComponent k : getComponents())
{
for (MantleComponent k : getComponents()) {
generateMantleComponent(writer, xx, zz, k, c, mc);
}
});
@@ -282,13 +280,11 @@ public interface EngineMantle extends IObjectPlacer {
return pos;
}
default boolean queueRegenerate(int x, int z)
{
return false; // TODO:
default boolean queueRegenerate(int x, int z) {
return false; // TODO:
}
default boolean dequeueRegenerate(int x, int z)
{
default boolean dequeueRegenerate(int x, int z) {
return false;// TODO:
}
}

View File

@@ -40,13 +40,11 @@ public enum StudioMode {
private final Consumer<BukkitChunkGenerator> injector;
StudioMode(Consumer<BukkitChunkGenerator> injector)
{
StudioMode(Consumer<BukkitChunkGenerator> injector) {
this.injector = injector;
}
public void inject(BukkitChunkGenerator c)
{
public void inject(BukkitChunkGenerator c) {
injector.accept(c);
}
}

View File

@@ -20,7 +20,6 @@ package com.volmit.iris.engine.object.entity;
import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisRegistrant;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.common.IrisScript;
@@ -46,10 +45,8 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.*;
import org.bukkit.attribute.Attributable;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.*;
import org.bukkit.entity.Panda.Gene;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.loot.LootContext;
@@ -176,7 +173,7 @@ public class IrisEntity extends IrisRegistrant {
}
public Entity spawn(Engine gen, Location at, RNG rng) {
if(isSpawnEffectRiseOutOfGround()) {
if (isSpawnEffectRiseOutOfGround()) {
Location b = at.clone();
double sy = b.getY() - 5;
Location start = new Location(b.getWorld(), b.getX(), sy, b.getZ());
@@ -334,8 +331,7 @@ public class IrisEntity extends IrisRegistrant {
}
}
if(isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity)
{
if (isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity) {
Location start = at.clone();
e.setInvulnerable(true);
((LivingEntity) e).setAI(false);
@@ -344,19 +340,14 @@ public class IrisEntity extends IrisRegistrant {
AtomicInteger v = new AtomicInteger(0);
v.set(J.sr(() -> {
if(e.getLocation().getBlock().getType().isSolid() || ((LivingEntity) e).getEyeLocation().getBlock().getType().isSolid())
{
if (e.getLocation().getBlock().getType().isSolid() || ((LivingEntity) e).getEyeLocation().getBlock().getType().isSolid()) {
e.teleport(start.add(new Vector(0, 0.1, 0)));
ItemStack itemCrackData = new ItemStack(((LivingEntity) e).getEyeLocation().clone().subtract(0, 2, 0).getBlock().getBlockData().getMaterial());
e.getWorld().spawnParticle(Particle.ITEM_CRACK, ((LivingEntity) e).getEyeLocation(), 6, 0.2, 0.4, 0.2, 0.06f, itemCrackData);
if(M.r(0.2))
{
if (M.r(0.2)) {
e.getWorld().playSound(e.getLocation(), Sound.BLOCK_CHORUS_FLOWER_GROW, 0.8f, 0.1f);
}
}
else
{
} else {
J.csr(v.get());
((LivingEntity) e).setNoDamageTicks(0);
((LivingEntity) e).setCollidable(true);
@@ -369,17 +360,14 @@ public class IrisEntity extends IrisRegistrant {
return e;
}
private int surfaceY(Location l)
{
private int surfaceY(Location l) {
int m = l.getBlockY();
while(m-- > 0)
{
while (m-- > 0) {
Location ll = l.clone();
ll.setY(m);
if(ll.getBlock().getType().isSolid())
{
if (ll.getBlock().getType().isSolid()) {
return m;
}
}

View File

@@ -34,7 +34,6 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.IrisBiomeStorage;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.io.ReactiveFolder;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Looper;
@@ -168,18 +167,14 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
Iris.debug("Regenerated " + x + " " + z);
int t = 0;
for(int i = getEngine().getHeight() >> 4; i >= 0; i--)
{
if(!world.isChunkLoaded(x, z))
{
for (int i = getEngine().getHeight() >> 4; i >= 0; i--) {
if (!world.isChunkLoaded(x, z)) {
continue;
}
Chunk c = world.getChunkAt(x, z);
for(Entity ee : c.getEntities())
{
if(ee instanceof Player)
{
for (Entity ee : c.getEntities()) {
if (ee instanceof Player) {
continue;
}
@@ -191,18 +186,14 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
int finalI = i;
jobs.accept(() -> {
for(int xx = 0; xx < 16; xx++)
{
for(int yy = 0; yy < 16; yy++)
{
for(int zz = 0; zz < 16; zz++)
{
if(yy + (finalI << 4) >= engine.getHeight() || yy + (finalI << 4) < 0)
{
for (int xx = 0; xx < 16; xx++) {
for (int yy = 0; yy < 16; yy++) {
for (int zz = 0; zz < 16; zz++) {
if (yy + (finalI << 4) >= engine.getHeight() || yy + (finalI << 4) < 0) {
continue;
}
c.getBlock(xx,yy + (finalI << 4),zz).setBlockData(tc.getBlockData(xx,yy + (finalI << 4),zz), false);
c.getBlock(xx, yy + (finalI << 4), zz).setBlockData(tc.getBlockData(xx, yy + (finalI << 4), zz), false);
}
}
}
@@ -284,13 +275,9 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
TerrainChunk tc = TerrainChunk.create(world, biome);
this.world.bind(world);
if(studioGenerator != null)
{
if (studioGenerator != null) {
studioGenerator.generateChunk(getEngine(), tc, x, z);
}
else
{
} else {
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
@@ -333,8 +320,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
}
private void computeStudioGenerator() {
if(!getEngine().getDimension().getStudioMode().equals(lastMode))
{
if (!getEngine().getDimension().getStudioMode().equals(lastMode)) {
lastMode = getEngine().getDimension().getStudioMode();
getEngine().getDimension().getStudioMode().inject(this);
}

View File

@@ -24,7 +24,7 @@ import com.volmit.iris.engine.framework.WrongEngineBroException;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public abstract class EnginedStudioGenerator implements StudioGenerator{
public abstract class EnginedStudioGenerator implements StudioGenerator {
private final Engine engine;
@Override

View File

@@ -44,24 +44,20 @@ public class BiomeBuffetGenerator extends EnginedStudioGenerator {
@Override
public void generateChunk(Engine engine, TerrainChunk tc, int x, int z) throws WrongEngineBroException {
int id = Cache.to1D(x/biomeSize, 0, z/biomeSize, width, 1);
int id = Cache.to1D(x / biomeSize, 0, z / biomeSize, width, 1);
if(id >= 0 && id < biomes.length)
{
if (id >= 0 && id < biomes.length) {
IrisBiome biome = biomes[id];
String foc = engine.getDimension().getFocus();
if(!Objects.equals(foc, biome.getLoadKey()))
{
if (!Objects.equals(foc, biome.getLoadKey())) {
engine.getDimension().setFocus(biome.getLoadKey());
engine.hotloadComplex();
}
engine.generate(x << 4, z << 4, tc, true);
}
else {
tc.setRegion(0,0,0,16, 1, 16, FLOOR);
} else {
tc.setRegion(0, 0, 0, 16, 1, 16, FLOOR);
}
}
}