Merge remote-tracking branch 'origin/master' into master

This commit is contained in:
CocoTheOwner 2021-01-30 00:53:28 +01:00
commit 9ffd0dcdbe
14 changed files with 182 additions and 15 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.volmit</groupId> <groupId>com.volmit</groupId>
<artifactId>Iris</artifactId> <artifactId>Iris</artifactId>
<version>1.3</version> <version>1.3.1</version>
<name>Iris</name> <name>Iris</name>
<properties> <properties>
<skip.copy>false</skip.copy> <skip.copy>false</skip.copy>

View File

@ -127,6 +127,7 @@ public class IrisEngine extends BlockPopulator implements Engine
{ {
getWorldManager().spawnInitialEntities(c); getWorldManager().spawnInitialEntities(c);
updateChunk(c); updateChunk(c);
placeTiles(c);
} }
@Override @Override

View File

@ -9,6 +9,7 @@ import com.volmit.iris.util.J;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
@ -34,6 +35,18 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
@Override @Override
public void spawnInitialEntities(Chunk c) { public void spawnInitialEntities(Chunk c) {
RNG rng = new RNG(Cache.key(c)); RNG rng = new RNG(Cache.key(c));
getEngine().getParallaxAccess().getEntitiesR(c.getX(), c.getZ()).iterateSync((x,y,z,e) -> {
if(e != null)
{
IrisEntity en = getData().getEntityLoader().load(e);
if(en != null){
en.spawn(getEngine(), new Location(c.getWorld(), x+(c.getX()<<4),y,z+(c.getZ()<<4)));
}
}
});
int x = (c.getX() * 16) + rng.nextInt(15); int x = (c.getX() * 16) + rng.nextInt(15);
int z = (c.getZ() * 16) + rng.nextInt(15); int z = (c.getZ() * 16) + rng.nextInt(15);
int y = getEngine().getHeight(x, z) + 1; int y = getEngine().getHeight(x, z) + 1;
@ -43,6 +56,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
trySpawn(above.getEntityInitialSpawns(), c, rng); trySpawn(above.getEntityInitialSpawns(), c, rng);
trySpawn(region.getEntityInitialSpawns(), c, rng); trySpawn(region.getEntityInitialSpawns(), c, rng);
trySpawn(dim.getEntityInitialSpawns(), c, rng); trySpawn(dim.getEntityInitialSpawns(), c, rng);
} }
@Override @Override

View File

@ -279,11 +279,6 @@ public class IrisEntity extends IrisRegistrant
return Iris.linkMythicMobs.spawn(getMythicalType(), at); return Iris.linkMythicMobs.spawn(getMythicalType(), at);
} }
if(isCitizens())
{
// TODO: return Iris.linkCitizens.spawn(getType(), at); SPAWN SOME TYPE TOO
}
return at.getWorld().spawnEntity(at, getType()); return at.getWorld().spawnEntity(at, getType());
} }

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
@Data @Data
public class IrisEntityInitialSpawn public class IrisEntityInitialSpawn
{ {
@RegistryListEntity @RegistryListEntity
@Required @Required
@DontObfuscate @DontObfuscate

View File

@ -40,6 +40,11 @@ public class IrisJigsawPieceConnector
@Required @Required
private KList<String> pools = new KList<>(); private KList<String> pools = new KList<>();
@RegistryListEntity
@DontObfuscate
@Desc("Pick an entity to spawn on this connector")
private String spawnEntity;
@DontObfuscate @DontObfuscate
@Desc("The relative position this connector is located at for connecting to other pieces") @Desc("The relative position this connector is located at for connecting to other pieces")
@Required @Required
@ -63,6 +68,7 @@ public class IrisJigsawPieceConnector
c.setDirection(getDirection()); c.setDirection(getDirection());
c.setRotateConnector(isRotateConnector()); c.setRotateConnector(isRotateConnector());
c.setName(getName()); c.setName(getName());
c.setSpawnEntity(getSpawnEntity());
c.setPools(getPools().copy()); c.setPools(getPools().copy());
return c; return c;
} }

View File

@ -155,6 +155,9 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
} }
} }
public default void placeTiles(Chunk c) {
}
@Override @Override
public default void updateChunk(Chunk c) public default void updateChunk(Chunk c)

View File

@ -1425,4 +1425,13 @@ public interface Hunk<T>
} }
} }
} }
/**
* Acts like fill, however if used by a mapped hunk, will simply clear it
* @param b the data to use for fill
*/
default void empty(T b)
{
fill(b);
}
} }

View File

@ -53,6 +53,12 @@ public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T>
return this; return this;
} }
@Override
public void empty(T b)
{
data.clear();
}
@Override @Override
public T getRaw(int x, int y, int z) public T getRaw(int x, int y, int z)
{ {

View File

@ -2,11 +2,15 @@ package com.volmit.iris.scaffold.jigsaw;
import com.volmit.iris.manager.IrisDataManager; import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.object.*; import com.volmit.iris.object.*;
import com.volmit.iris.object.tile.TileData;
import com.volmit.iris.util.AxisAlignedBB; import com.volmit.iris.util.AxisAlignedBB;
import com.volmit.iris.util.IObjectPlacer;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG;
import lombok.Data; import lombok.Data;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.TileState;
import org.bukkit.block.data.BlockData;
import org.bukkit.util.BlockVector; import org.bukkit.util.BlockVector;
@Data @Data
@ -129,6 +133,58 @@ public class PlannedPiece {
} }
public void place(World world) { public void place(World world) {
getObject().placeCenterY(new Location(world, position.getX(), position.getY(), position.getZ()));
getPiece().getPlacementOptions().getRotation().setEnabled(false);
getObject().place(position.getX()+getObject().getCenter().getBlockX(), position.getY()+getObject().getCenter().getBlockY(), position.getZ()+getObject().getCenter().getBlockZ(), new IObjectPlacer() {
@Override
public int getHighest(int x, int z) {
return position.getY();
}
@Override
public int getHighest(int x, int z, boolean ignoreFluid) {
return position.getY();
}
@Override
public void set(int x, int y, int z, BlockData d) {
world.getBlockAt(x,y,z).setBlockData(d);
}
@Override
public BlockData get(int x, int y, int z) {
return world.getBlockAt(x,y,z).getBlockData();
}
@Override
public boolean isPreventingDecay() {
return false;
}
@Override
public boolean isSolid(int x, int y, int z) {
return false;
}
@Override
public boolean isUnderwater(int x, int z) {
return false;
}
@Override
public int getFluidHeight() {
return 0;
}
@Override
public boolean isDebugSmartBore() {
return false;
}
@Override
public void setTile(int xx, int yy, int zz, TileData<? extends TileState> tile) {
}
}, piece.getPlacementOptions(), new RNG(), getData());
} }
} }

View File

@ -3,11 +3,17 @@ package com.volmit.iris.scaffold.jigsaw;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.manager.IrisDataManager; import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.object.*; import com.volmit.iris.object.*;
import com.volmit.iris.scaffold.IrisWorlds;
import com.volmit.iris.scaffold.engine.EngineParallaxManager; import com.volmit.iris.scaffold.engine.EngineParallaxManager;
import com.volmit.iris.scaffold.engine.IrisAccess;
import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta; import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta;
import com.volmit.iris.util.*; import com.volmit.iris.util.IObjectPlacer;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.RNG;
import lombok.Data; import lombok.Data;
import org.bukkit.Axis; import org.bukkit.Axis;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@Data @Data
@ -105,6 +111,27 @@ public class PlannedStructure {
meta.setMaxObject(Math.max(Math.max(meta.getMaxObject(), 0), yf)); meta.setMaxObject(Math.max(Math.max(meta.getMaxObject(), 0), yf));
}, null, getData()); }, null, getData());
for(IrisJigsawPieceConnector j : i.getAvailableConnectors())
{
if(j.getSpawnEntity() != null)
{
IrisPosition p = i.getWorldPosition(j).add(new IrisPosition(j.getDirection().toVector().multiply(2)));
if(options.getMode().equals(ObjectPlaceMode.PAINT) || options.isVacuum())
{
p.setY(placer.getHighest(xx, zz) + offset + (v.getH() / 2));
}
else
{
p.setY(height);
}
e.getParallaxAccess().setEntity(p.getX(), p.getY(), p.getZ(), j.getSpawnEntity());
}
}
if(options.isVacuum()) if(options.isVacuum())
{ {
int dx = xx; int dx = xx;
@ -126,6 +153,23 @@ public class PlannedStructure {
{ {
for(PlannedPiece i : pieces) for(PlannedPiece i : pieces)
{ {
Iris.sq(() -> {
for(IrisJigsawPieceConnector j : i.getAvailableConnectors())
{
if(j.getSpawnEntity() != null)
{
IrisPosition p = i.getWorldPosition(j).add(new IrisPosition(j.getDirection().toVector().multiply(2)));
IrisEntity e = getData().getEntityLoader().load(j.getSpawnEntity());
IrisAccess a = IrisWorlds.access(world);
if(a != null)
{
e.spawn(a.getCompound().getEngineForHeight(p.getY()), new Location(world, p.getX(), p.getY(), p.getZ()), rng);
}
}
}
});
Iris.sq(() -> i.place(world)); Iris.sq(() -> i.place(world));
} }
} }

View File

@ -30,6 +30,14 @@ public interface ParallaxAccess {
getObjectsRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d); getObjectsRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
} }
default String getEntity(int x, int y, int z) {
return getEntitiesR(x >> 4, z >> 4).get(x & 15, y, z & 15);
}
default void setEntity(int x, int y, int z, String d) {
getEntitiesRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
}
default Boolean isUpdate(int x, int y, int z) { default Boolean isUpdate(int x, int y, int z) {
return getUpdatesR(x >> 4, z >> 4).get(x & 15, y, z & 15); return getUpdatesR(x >> 4, z >> 4).get(x & 15, y, z & 15);
} }
@ -109,6 +117,10 @@ public interface ParallaxAccess {
public Hunk<String> getObjectsRW(int x, int z); public Hunk<String> getObjectsRW(int x, int z);
public Hunk<String> getEntitiesRW(int x, int z);
public Hunk<String> getEntitiesR(int x, int z);
public Hunk<Boolean> getUpdatesR(int x, int z); public Hunk<Boolean> getUpdatesR(int x, int z);
public Hunk<Boolean> getUpdatesRW(int x, int z); public Hunk<Boolean> getUpdatesRW(int x, int z);
@ -131,9 +143,10 @@ public interface ParallaxAccess {
public default void delete(int x, int z) public default void delete(int x, int z)
{ {
getUpdatesRW(x, z).fill(false); getUpdatesRW(x, z).empty(false);
getBlocksRW(x, z).fill(null); getBlocksRW(x, z).empty(null);
getTilesRW(x, z).fill(null); getTilesRW(x, z).empty(null);
getObjectsRW(x, z).fill(null); getEntitiesRW(x, z).empty(null);
getObjectsRW(x, z).empty(null);
} }
} }

View File

@ -24,6 +24,7 @@ public class ParallaxRegion extends HunkRegion
private HunkRegionSlice<BlockData> blockSlice; private HunkRegionSlice<BlockData> blockSlice;
private HunkRegionSlice<TileData<? extends TileState>> tileSlice; private HunkRegionSlice<TileData<? extends TileState>> tileSlice;
private HunkRegionSlice<String> objectSlice; private HunkRegionSlice<String> objectSlice;
private HunkRegionSlice<String> entitySlice;
private HunkRegionSlice<Boolean> updateSlice; private HunkRegionSlice<Boolean> updateSlice;
private final GridLock lock; private final GridLock lock;
private long lastUse; private long lastUse;
@ -50,6 +51,7 @@ public class ParallaxRegion extends HunkRegion
blockSlice = HunkRegionSlice.BLOCKDATA.apply(height, getCompound()); blockSlice = HunkRegionSlice.BLOCKDATA.apply(height, getCompound());
tileSlice = HunkRegionSlice.TILE.apply(height, getCompound()); tileSlice = HunkRegionSlice.TILE.apply(height, getCompound());
objectSlice = HunkRegionSlice.STRING.apply(height, getCompound(), "objects"); objectSlice = HunkRegionSlice.STRING.apply(height, getCompound(), "objects");
entitySlice = HunkRegionSlice.STRING.apply(height, getCompound(), "entities");
updateSlice = HunkRegionSlice.BOOLEAN.apply(height, getCompound(), "updates"); updateSlice = HunkRegionSlice.BOOLEAN.apply(height, getCompound(), "updates");
metaAdapter = ParallaxChunkMeta.adapter.apply(getCompound()); metaAdapter = ParallaxChunkMeta.adapter.apply(getCompound());
dirtyMeta = false; dirtyMeta = false;
@ -152,6 +154,7 @@ public class ParallaxRegion extends HunkRegion
{ {
blockSlice.save(); blockSlice.save();
objectSlice.save(); objectSlice.save();
entitySlice.save();
tileSlice.save(); tileSlice.save();
updateSlice.save(); updateSlice.save();
saveMetaHunk(); saveMetaHunk();
@ -163,6 +166,7 @@ public class ParallaxRegion extends HunkRegion
unloadMetaHunk(); unloadMetaHunk();
return blockSlice.unloadAll()+ return blockSlice.unloadAll()+
objectSlice.unloadAll()+ objectSlice.unloadAll()+
entitySlice.unloadAll()+
tileSlice.unloadAll()+ tileSlice.unloadAll()+
updateSlice.unloadAll(); updateSlice.unloadAll();
} }
@ -172,6 +176,11 @@ public class ParallaxRegion extends HunkRegion
return blockSlice; return blockSlice;
} }
public HunkRegionSlice<String> getEntitySlice() {
lastUse = M.ms();
return entitySlice;
}
public HunkRegionSlice<TileData<? extends TileState>> getTileSlice() { public HunkRegionSlice<TileData<? extends TileState>> getTileSlice() {
lastUse = M.ms(); lastUse = M.ms();
return tileSlice; return tileSlice;
@ -190,11 +199,12 @@ public class ParallaxRegion extends HunkRegion
public synchronized int cleanup(long c) { public synchronized int cleanup(long c) {
return blockSlice.cleanup(c) + return blockSlice.cleanup(c) +
objectSlice.cleanup(c) + objectSlice.cleanup(c) +
entitySlice.cleanup(c) +
tileSlice.cleanup(c) + tileSlice.cleanup(c) +
updateSlice.cleanup(c); updateSlice.cleanup(c);
} }
public int getChunkCount() { public int getChunkCount() {
return blockSlice.getLoadCount() + objectSlice.getLoadCount() + tileSlice.getLoadCount() + updateSlice.getLoadCount(); return blockSlice.getLoadCount() + objectSlice.getLoadCount() + entitySlice.getLoadCount() + tileSlice.getLoadCount() + updateSlice.getLoadCount();
} }
} }

View File

@ -187,6 +187,16 @@ public class ParallaxWorld implements ParallaxAccess
return getRW(x >> 5, z >> 5).getObjectSlice().getRW(x & 31, z & 31); return getRW(x >> 5, z >> 5).getObjectSlice().getRW(x & 31, z & 31);
} }
@Override
public Hunk<String> getEntitiesRW(int x, int z) {
return getRW(x >> 5, z >> 5).getEntitySlice().getRW(x & 31, z & 31);
}
@Override
public Hunk<String> getEntitiesR(int x, int z) {
return getRW(x >> 5, z >> 5).getEntitySlice().getR(x & 31, z & 31);
}
@Override @Override
public Hunk<Boolean> getUpdatesR(int x, int z) public Hunk<Boolean> getUpdatesR(int x, int z)
{ {