mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-08 08:46:21 +00:00
Merge remote-tracking branch 'upstream/master' into saplingOverrides
This commit is contained in:
@@ -20,7 +20,7 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.core.gui.RenderType;
|
||||
import com.volmit.iris.core.gui.components.RenderType;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.data.B;
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.volmit.iris.engine.noise.CNG;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.math.ChunkPosition;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -341,7 +341,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@Desc("Define biome mutations for this dimension")
|
||||
private KList<IrisBiomeMutation> mutations = new KList<>();
|
||||
|
||||
private final transient AtomicCache<ChunkPosition> parallaxSize = new AtomicCache<>();
|
||||
private final transient AtomicCache<Position2> parallaxSize = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> rockLayerGenerator = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> fluidLayerGenerator = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> coordFracture = new AtomicCache<>();
|
||||
@@ -520,37 +520,28 @@ public class IrisDimension extends IrisRegistrant {
|
||||
|
||||
public boolean hasFeatures(DataProvider data) {
|
||||
return featuresUsed.aquire(() -> {
|
||||
if(getFeatures().isNotEmpty() || getSpecificFeatures().isNotEmpty())
|
||||
{
|
||||
if (getFeatures().isNotEmpty() || getSpecificFeatures().isNotEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(IrisRegion i : getAllRegions(data))
|
||||
{
|
||||
if(i.getFeatures().isNotEmpty())
|
||||
{
|
||||
for (IrisRegion i : getAllRegions(data)) {
|
||||
if (i.getFeatures().isNotEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(IrisObjectPlacement j : i.getObjects())
|
||||
{
|
||||
if(j.isVacuum())
|
||||
{
|
||||
for (IrisObjectPlacement j : i.getObjects()) {
|
||||
if (j.isVacuum()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisBiome j : i.getAllBiomes(data))
|
||||
{
|
||||
if(j.getFeatures().isNotEmpty())
|
||||
{
|
||||
for (IrisBiome j : i.getAllBiomes(data)) {
|
||||
if (j.getFeatures().isNotEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(IrisObjectPlacement k : i.getObjects())
|
||||
{
|
||||
if(k.isVacuum())
|
||||
{
|
||||
for (IrisObjectPlacement k : i.getObjects()) {
|
||||
if (k.isVacuum()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class IrisEntity extends IrisRegistrant {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
if (Iris.awareEntities && e instanceof Mob) {
|
||||
if (e instanceof Mob) {
|
||||
Mob m = (Mob) e;
|
||||
m.setAware(isAware());
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class IrisEntityInitialSpawn {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (rng.aquire(() -> new RNG(g.getTarget().getWorld().getSeed() + 4)).i(1, getRarity()) == 1) {
|
||||
if (rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)).i(1, getRarity()) == 1) {
|
||||
return spawn100(g, at);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,6 @@ public class IrisEntityInitialSpawn {
|
||||
}
|
||||
|
||||
private Entity spawn100(Engine g, Location at) {
|
||||
return getRealEntity(g).spawn(g, at.clone().add(0.5, 1, 0.5), rng.aquire(() -> new RNG(g.getTarget().getWorld().getSeed() + 4)));
|
||||
return getRealEntity(g).spawn(g, at.clone().add(0.5, 1, 0.5), rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ public class IrisEntitySpawnOverride {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (rng.aquire(() -> new RNG(g.getTarget().getWorld().getSeed() + 4)).i(1, getRarity()) == 1) {
|
||||
return getRealEntity(g).spawn(g, at, rng.aquire(() -> new RNG(g.getTarget().getWorld().getSeed() + 4)));
|
||||
if (rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)).i(1, getRarity()) == 1) {
|
||||
return getRealEntity(g).spawn(g, at, rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -142,10 +142,11 @@ public class IrisLoot {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
if (Iris.customModels) {
|
||||
try {
|
||||
m.setCustomModelData(getCustomModel());
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
@@ -226,8 +227,10 @@ public class IrisLoot {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
if (Iris.customModels) {
|
||||
try {
|
||||
m.setCustomModelData(getCustomModel());
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.math.AxisAlignedBB;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.math.ChunkPosition;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.IrisLock;
|
||||
import lombok.Data;
|
||||
@@ -44,6 +44,7 @@ import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.data.type.Leaves;
|
||||
import org.bukkit.entity.ThrownExpBottle;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -470,7 +471,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
boolean warped = !config.getWarp().isFlat();
|
||||
boolean stilting = (config.getMode().equals(ObjectPlaceMode.STILT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT));
|
||||
KMap<ChunkPosition, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
|
||||
KMap<Position2, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
|
||||
int spinx = rng.imax() / 1000;
|
||||
int spiny = rng.imax() / 1000;
|
||||
int spinz = rng.imax() / 1000;
|
||||
@@ -581,97 +582,109 @@ public class IrisObject extends IrisRegistrant {
|
||||
int lowest = Integer.MAX_VALUE;
|
||||
y += yrand;
|
||||
readLock.lock();
|
||||
for (BlockVector g : getBlocks().keySet()) {
|
||||
BlockData d;
|
||||
TileData<? extends TileState> tile = null;
|
||||
try
|
||||
{
|
||||
for (BlockVector g : getBlocks().keySet()) {
|
||||
BlockData d;
|
||||
TileData<? extends TileState> tile = null;
|
||||
|
||||
try {
|
||||
d = getBlocks().get(g);
|
||||
tile = getStates().get(g);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (cme)");
|
||||
d = AIR;
|
||||
}
|
||||
try {
|
||||
d = getBlocks().get(g);
|
||||
tile = getStates().get(g);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (cme)");
|
||||
d = AIR;
|
||||
}
|
||||
|
||||
if (d == null) {
|
||||
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (null)");
|
||||
d = AIR;
|
||||
}
|
||||
if (d == null) {
|
||||
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (null)");
|
||||
d = AIR;
|
||||
}
|
||||
|
||||
BlockVector i = g.clone();
|
||||
BlockData data = d.clone();
|
||||
i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone();
|
||||
i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone();
|
||||
BlockVector i = g.clone();
|
||||
BlockData data = d.clone();
|
||||
i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone();
|
||||
i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone();
|
||||
|
||||
if (stilting && i.getBlockY() < lowest && !B.isAir(data)) {
|
||||
lowest = i.getBlockY();
|
||||
}
|
||||
if (stilting && i.getBlockY() < lowest && !B.isAir(data)) {
|
||||
lowest = i.getBlockY();
|
||||
}
|
||||
|
||||
if (placer.isPreventingDecay() && (data) instanceof Leaves && !((Leaves) (data)).isPersistent()) {
|
||||
((Leaves) data).setPersistent(true);
|
||||
}
|
||||
if (placer.isPreventingDecay() && (data) instanceof Leaves && !((Leaves) (data)).isPersistent()) {
|
||||
((Leaves) data).setPersistent(true);
|
||||
}
|
||||
|
||||
for (IrisObjectReplace j : config.getEdit()) {
|
||||
if (rng.chance(j.getChance())) {
|
||||
for (BlockData k : j.getFind(rdata)) {
|
||||
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
||||
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
|
||||
for (IrisObjectReplace j : config.getEdit()) {
|
||||
if (rng.chance(j.getChance())) {
|
||||
for (BlockData k : j.getFind(rdata)) {
|
||||
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
||||
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
|
||||
|
||||
if (newData.getMaterial() == data.getMaterial())
|
||||
data = data.merge(newData);
|
||||
else
|
||||
data = newData;
|
||||
if (newData.getMaterial() == data.getMaterial())
|
||||
{
|
||||
data = data.merge(newData);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = newData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data = config.getRotation().rotate(data, spinx, spiny, spinz);
|
||||
xx = x + (int) Math.round(i.getX());
|
||||
int yy = y + (int) Math.round(i.getY());
|
||||
zz = z + (int) Math.round(i.getZ());
|
||||
data = config.getRotation().rotate(data, spinx, spiny, spinz);
|
||||
xx = x + (int) Math.round(i.getX());
|
||||
int yy = y + (int) Math.round(i.getY());
|
||||
zz = z + (int) Math.round(i.getZ());
|
||||
|
||||
if (warped) {
|
||||
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z);
|
||||
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x);
|
||||
}
|
||||
|
||||
if (yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) {
|
||||
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, config.isUnderwater());
|
||||
}
|
||||
|
||||
if (heightmap != null) {
|
||||
ChunkPosition pos = new ChunkPosition(xx, zz);
|
||||
|
||||
if (!heightmap.containsKey(pos)) {
|
||||
heightmap.put(pos, yy);
|
||||
if (warped) {
|
||||
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z);
|
||||
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x);
|
||||
}
|
||||
|
||||
if (heightmap.get(pos) < yy) {
|
||||
heightmap.put(pos, yy);
|
||||
if (yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) {
|
||||
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, config.isUnderwater());
|
||||
}
|
||||
|
||||
if (heightmap != null) {
|
||||
Position2 pos = new Position2(xx, zz);
|
||||
|
||||
if (!heightmap.containsKey(pos)) {
|
||||
heightmap.put(pos, yy);
|
||||
}
|
||||
|
||||
if (heightmap.get(pos) < yy) {
|
||||
heightmap.put(pos, yy);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.isMeld() && !placer.isSolid(xx, yy, zz)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged) {
|
||||
((Waterlogged) data).setWaterlogged(true);
|
||||
}
|
||||
|
||||
if (listener != null) {
|
||||
listener.accept(new BlockPosition(xx, yy, zz));
|
||||
}
|
||||
|
||||
if (!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
|
||||
placer.set(xx, yy, zz, data);
|
||||
|
||||
if (tile != null) {
|
||||
placer.setTile(xx, yy, zz, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.isMeld() && !placer.isSolid(xx, yy, zz)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged) {
|
||||
((Waterlogged) data).setWaterlogged(true);
|
||||
}
|
||||
|
||||
if (listener != null) {
|
||||
listener.accept(new BlockPosition(xx, yy, zz));
|
||||
}
|
||||
|
||||
if (!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
|
||||
placer.set(xx, yy, zz, data);
|
||||
|
||||
if (tile != null) {
|
||||
placer.setTile(xx, yy, zz, tile);
|
||||
}
|
||||
}
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.reportError(e);
|
||||
}
|
||||
readLock.unlock();
|
||||
|
||||
@@ -731,7 +744,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
if (heightmap != null) {
|
||||
RNG rngx = rng.nextParallelRNG(3468854);
|
||||
|
||||
for (ChunkPosition i : heightmap.k()) {
|
||||
for (Position2 i : heightmap.k()) {
|
||||
int vx = i.getX();
|
||||
int vy = heightmap.get(i);
|
||||
int vz = i.getZ();
|
||||
@@ -996,4 +1009,8 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
public int volume() {
|
||||
return blocks.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.core.gui.RenderType;
|
||||
import com.volmit.iris.core.gui.components.RenderType;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.data.DataProvider;
|
||||
import com.volmit.iris.engine.noise.CNG;
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object.common;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.tools.IrisWorlds;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@Accessors(chain = true, fluent = true)
|
||||
public class IrisWorld {
|
||||
private static final KList<Player> NO_PLAYERS = new KList<>();
|
||||
private static final KList<? extends Entity> NO_ENTITIES = new KList<>();
|
||||
private String name;
|
||||
private File worldFolder;
|
||||
private long seed;
|
||||
private World.Environment environment;
|
||||
private World realWorld;
|
||||
private int minHeight;
|
||||
private int maxHeight;
|
||||
|
||||
public static IrisWorld fromWorld(World world) {
|
||||
return bindWorld(IrisWorld.builder().build(), world);
|
||||
}
|
||||
|
||||
private static IrisWorld bindWorld(IrisWorld iw, World world) {
|
||||
return iw.name(world.getName())
|
||||
.worldFolder(world.getWorldFolder())
|
||||
.seed(world.getSeed())
|
||||
.minHeight(world.getMinHeight())
|
||||
.maxHeight(world.getMaxHeight())
|
||||
.realWorld(world)
|
||||
.environment(world.getEnvironment());
|
||||
}
|
||||
|
||||
public boolean hasRealWorld() {
|
||||
return realWorld != null;
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
|
||||
if (hasRealWorld()) {
|
||||
return realWorld().getPlayers();
|
||||
}
|
||||
|
||||
return NO_PLAYERS;
|
||||
}
|
||||
|
||||
public void evacuate() {
|
||||
if (hasRealWorld()) {
|
||||
IrisWorlds.evacuate(realWorld());
|
||||
}
|
||||
}
|
||||
|
||||
public void bind(World world) {
|
||||
bindWorld(this, world);
|
||||
}
|
||||
|
||||
public Location spawnLocation() {
|
||||
if (hasRealWorld()) {
|
||||
return realWorld().getSpawnLocation();
|
||||
}
|
||||
|
||||
Iris.error("This world is not real yet, cannot get spawn location! HEADLESS!");
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T extends Entity> Collection<? extends T> getEntitiesByClass(Class<T> t) {
|
||||
if (hasRealWorld()) {
|
||||
return realWorld().getEntitiesByClass(t);
|
||||
}
|
||||
|
||||
return (KList<? extends T>) NO_ENTITIES;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user