Compare commits

...

15 Commits

Author SHA1 Message Date
Brian Neumann-Fopiano
7a94f53735 V+ 2023-04-20 00:12:20 -04:00
Brian Neumann-Fopiano
a9efe146ba Probably fixed * 2023-04-13 21:28:46 -04:00
Vatuu
956e2f6b06 Fixed Oraxen integration. 2023-04-13 23:24:12 +02:00
Brian Neumann-Fopiano
72623e0acf V+ 2023-04-12 18:05:47 -04:00
Brian Neumann-Fopiano
e0f673bc3c Overworld Tag update to 3001 2023-04-12 18:05:08 -04:00
Brian Neumann-Fopiano
fe40f12d2e Merge remote-tracking branch 'origin/master' 2023-04-12 18:02:18 -04:00
Brian Fopiano
0fda7a8506 Merge pull request #990 from CrazyDev05/oraxen_implementation_fix 2023-04-11 00:06:06 -04:00
Brian Neumann-Fopiano
22887da769 Added IPECTER's nms line
should fix compiling
2023-04-10 18:14:57 -04:00
Vatuu
a1e0a8ffc1 Fixed ItemsAdder integration. 2023-04-10 19:26:29 +02:00
CrazyDev22
62010116d7 change split limit from '1' to '2' 2023-04-10 13:05:09 +02:00
Brian Neumann-Fopiano
6ebcd02ae6 Fixed the pregen error! 2023-04-08 00:26:05 -04:00
Brian Fopiano
051015656a Merge pull request #986 from CocoTheOwner/re-slope-condition
Patches an issue with slope conditions when placing with commands
2023-04-04 14:00:19 -04:00
Sjoerd van de Goor
ee082762c6 Update object placer to ignore some stuff when using commands 2023-04-03 21:22:08 +02:00
Brian Fopiano
e967b5e052 Merge pull request #982 from CocoTheOwner/re-slope-condition
Reimplement slope condition
2023-04-02 15:39:42 -04:00
Sjoerd van de Goor
cc5a880fd7 reimplement slope condition 2023-03-29 21:36:18 +02:00
13 changed files with 92 additions and 54 deletions

View File

@@ -24,7 +24,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}
version '2.5.0-1.19.4'
version '2.6.1-1.19.4'
def nmsVersion = "1.19.4" //[NMS]
def apiVersion = '1.19'
def specialSourceVersion = '1.11.0' //[NMS]

View File

@@ -88,7 +88,7 @@ import java.util.Map;
@SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener {
public static final String OVERWORLD_TAG = "2100";
public static final String OVERWORLD_TAG = "3002";
private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();

View File

@@ -3,7 +3,6 @@ package com.volmit.iris.core.link;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
@@ -20,8 +19,8 @@ public abstract class ExternalDataProvider {
return Bukkit.getPluginManager().getPlugin(pluginId);
}
public boolean isPresent() {
return getPlugin() != null;
public boolean isReady() {
return getPlugin() != null && getPlugin().isEnabled();
}
public abstract void init();

View File

@@ -7,7 +7,7 @@ public record Identifier(String namespace, String key) {
private static final String DEFAULT_NAMESPACE = "minecraft";
public static Identifier fromString(String id) {
String[] strings = id.split(":", 1);
String[] strings = id.split(":", 2);
if(strings.length == 1) {
return new Identifier(DEFAULT_NAMESPACE, strings[0]);
} else {

View File

@@ -1,11 +1,13 @@
package com.volmit.iris.core.link;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
import dev.lone.itemsadder.api.CustomBlock;
import dev.lone.itemsadder.api.CustomStack;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.MissingResourceException;
public class ItemAdderDataProvider extends ExternalDataProvider {
@@ -21,11 +23,12 @@ public class ItemAdderDataProvider extends ExternalDataProvider {
this.itemNamespaces = new KList<>();
this.blockNamespaces = new KList<>();
for(Identifier i : getItemTypes()) {
for (Identifier i : getItemTypes()) {
itemNamespaces.addIfMissing(i.namespace());
}
for(Identifier i : getBlockTypes()) {
for (Identifier i : getBlockTypes()) {
blockNamespaces.addIfMissing(i.namespace());
Iris.info("Found ItemAdder Block: " + i);
}
}

View File

@@ -35,7 +35,6 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Optional;
@@ -52,6 +51,7 @@ public class OraxenDataProvider extends ExternalDataProvider {
@Override
public void init() {
Iris.info("Setting up Oraxen Link...");
this.factories = new WrappedField<>(MechanicsManager.class, FIELD_FACTORIES_MAP);
if(this.factories.hasFailed()) {
Iris.error("Failed to set up Oraxen Link: Unable to fetch MechanicFactoriesMap!");
@@ -108,8 +108,14 @@ public class OraxenDataProvider extends ExternalDataProvider {
}
@Override
public boolean isPresent() {
return super.isPresent() && factories != null;
public boolean isReady() {
if(super.isReady()) {
if(factories == null) {
this.factories = new WrappedField<>(MechanicsManager.class, FIELD_FACTORIES_MAP);
}
return super.isReady() && !factories.hasFailed();
}
return false;
}
@Override

View File

@@ -42,6 +42,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import org.bukkit.*;
import org.bukkit.block.Biome;
@@ -434,7 +435,7 @@ public class NMSBinding19_4 implements INMSBinding {
@Override
public void injectBiomesFromMantle(Chunk e, Mantle mantle) {
LevelChunk chunk = ((CraftChunk) e).getHandle();
ChunkAccess chunk = ((CraftChunk) e).getHandle(ChunkStatus.FULL);
AtomicInteger c = new AtomicInteger();
AtomicInteger r = new AtomicInteger();
mantle.iterateChunk(e.getX(), e.getZ(), MatterBiomeInject.class, (x, y, z, b) -> {

View File

@@ -101,7 +101,8 @@ public class IrisPregenerator {
eta, M.ms() - startTime.get(), currentGeneratorMethod.get());
if (cl.flip()) {
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (" + Form.pc((double) generated.get() / (double) totalChunks.get(), 0) + ") " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2));
double percentage = ((double) generated.get() / (double) totalChunks.get()) * 100;
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2), percentage);
}
return 1000;

View File

@@ -22,9 +22,12 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.link.*;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.IrisService;
import io.th0rgal.oraxen.api.OraxenBlocks;
import lombok.Data;
import org.bukkit.NamespacedKey;
import org.bukkit.Bukkit;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.inventory.ItemStack;
import java.util.MissingResourceException;
@@ -33,31 +36,47 @@ import java.util.Optional;
@Data
public class ExternalDataSVC implements IrisService {
private KList<ExternalDataProvider> providers = new KList<>();
private KList<ExternalDataProvider> providers = new KList<>(), activeProviders = new KList<>();
@Override
public void onEnable() {
addProvider(
// new CustomItemsDataProvider(), //need this to be gradelized before i can add it to the master repo
new OraxenDataProvider(),
new ItemAdderDataProvider());
}
Iris.info("Loading ExternalDataProvider...");
Bukkit.getPluginManager().registerEvents(this, Iris.instance);
@Override
public void onDisable() {
}
providers.add(new OraxenDataProvider());
if (Bukkit.getPluginManager().getPlugin("Oraxen") != null){
Iris.info("Oraxen found, loading OraxenDataProvider...");
}
providers.add(new ItemAdderDataProvider());
if (Bukkit.getPluginManager().getPlugin("ItemAdder") != null){
Iris.info("ItemAdder found, loading ItemAdderDataProvider...");
}
public void addProvider(ExternalDataProvider... provider) {
for (ExternalDataProvider p : provider) {
if (p.getPlugin() != null) {
providers.add(p);
for (ExternalDataProvider p : providers) {
if (p.isReady()) {
activeProviders.add(p);
p.init();
Iris.info("Enabled ExternalDataProvider for %s.", p.getPluginId());
}
}
}
@Override
public void onDisable() { }
@EventHandler
public void onPluginEnable(PluginEnableEvent e) {
if(activeProviders.stream().noneMatch(p -> p.getPlugin().equals(e.getPlugin()))) {
providers.stream().filter(p -> p.isReady() && p.getPlugin().equals(e.getPlugin())).findFirst().ifPresent(edp -> {
activeProviders.add(edp);
edp.init();
Iris.info("Enabled ExternalDataProvider for %s.", edp.getPluginId());
});
}
}
public Optional<BlockData> getBlockData(Identifier key) {
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key, false)).findFirst();
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(key, false)).findFirst();
if (provider.isEmpty())
return Optional.empty();
try {
@@ -69,7 +88,7 @@ public class ExternalDataSVC implements IrisService {
}
public Optional<ItemStack> getItemStack(Identifier key) {
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key, true)).findFirst();
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(key, true)).findFirst();
if (provider.isEmpty()) {
Iris.warn("No matching Provider found for modded material \"%s\"!", key);
return Optional.empty();
@@ -84,13 +103,13 @@ public class ExternalDataSVC implements IrisService {
public Identifier[] getAllBlockIdentifiers() {
KList<Identifier> names = new KList<>();
providers.stream().filter(ExternalDataProvider::isPresent).forEach(p -> names.add(p.getBlockTypes()));
activeProviders.forEach(p -> names.add(p.getBlockTypes()));
return names.toArray(new Identifier[0]);
}
public Identifier[] getAllItemIdentifiers() {
KList<Identifier> names = new KList<>();
providers.stream().filter(ExternalDataProvider::isPresent).forEach(p -> names.add(p.getItemTypes()));
activeProviders.forEach(p -> names.add(p.getItemTypes()));
return names.toArray(new Identifier[0]);
}
}

View File

@@ -494,29 +494,37 @@ public class IrisObject extends IrisRegistrant {
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, BiConsumer<BlockPosition, BlockData> listener, CarveResult c, IrisData rdata) {
IObjectPlacer placer = (config.getHeightmap() != null) ? new HeightmapObjectPlacer(oplacer.getEngine() == null ? IrisContext.get().getEngine() : oplacer.getEngine(), rng, x, yv, z, config, oplacer) : oplacer;
// Rotation calculation
int slopeRotationY = 0;
ProceduralStream<Double> heightStream = rdata.getEngine().getComplex().getHeightStream();
if (config.isRotateTowardsSlope()) {
// Whichever side of the rectangle that bounds the object is lowest is the 'direction' of the slope (simply said).
double hNorth = heightStream.get(x, z + ((float)d) / 2);
double hEast = heightStream.get(x + ((float)w) / 2, z);
double hSouth = heightStream.get(x, z - ((float)d) / 2);
double hWest = heightStream.get(x - ((float)w) / 2, z);
double min = Math.min(Math.min(hNorth, hEast), Math.min(hSouth, hWest));
if (min == hNorth) {
slopeRotationY = 0;
} else if (min == hEast) {
slopeRotationY = 90;
} else if (min == hSouth) {
slopeRotationY = 180;
} else if (min == hWest) {
slopeRotationY = 270;
if (rdata != null) {
// Slope condition
if (!config.getSlopeCondition().isDefault() &&
!config.getSlopeCondition().isValid(rdata.getEngine().getComplex().getSlopeStream().get(x, z))) {
return -1;
}
// Rotation calculation
int slopeRotationY = 0;
ProceduralStream<Double> heightStream = rdata.getEngine().getComplex().getHeightStream();
if (config.isRotateTowardsSlope()) {
// Whichever side of the rectangle that bounds the object is lowest is the 'direction' of the slope (simply said).
double hNorth = heightStream.get(x, z + ((float) d) / 2);
double hEast = heightStream.get(x + ((float) w) / 2, z);
double hSouth = heightStream.get(x, z - ((float) d) / 2);
double hWest = heightStream.get(x - ((float) w) / 2, z);
double min = Math.min(Math.min(hNorth, hEast), Math.min(hSouth, hWest));
if (min == hNorth) {
slopeRotationY = 0;
} else if (min == hEast) {
slopeRotationY = 90;
} else if (min == hSouth) {
slopeRotationY = 180;
} else if (min == hWest) {
slopeRotationY = 270;
}
}
double newRotation = config.getRotation().getYAxis().getMin() + slopeRotationY;
config.getRotation().setYAxis(new IrisAxisRotationClamp(true, false, newRotation, newRotation, 360));
config.getRotation().setEnabled(true);
}
double newRotation = config.getRotation().getYAxis().getMin() + slopeRotationY;
config.getRotation().setYAxis(new IrisAxisRotationClamp(true, false, newRotation, newRotation, 360));
config.getRotation().setEnabled(true);
if (config.isSmartBore()) {
ensureSmartBored(placer.isDebugSmartBore());

View File

@@ -62,6 +62,8 @@ public class IrisObjectPlacement {
private double snow = 0;
@Desc("Whether or not this object can be targeted by a dolphin.")
private boolean isDolphinTarget = false;
@Desc("The slope at which this object can be placed. Range from 0 to 10 by default. Calculated from a 3-block radius from the center of the object placement.")
private IrisSlopeClip slopeCondition = new IrisSlopeClip();
@Desc("Set to true to add the rotation of the direction of the slope of the terrain (wherever the slope is going down) to the y-axis rotation of the object." +
"Rounded to 90 degrees. Adds the *min* rotation of the y axis as well (to still allow you to rotate objects nicely). Discards *max* and *interval* on *yaxis*")
private boolean rotateTowardsSlope = false;

View File

@@ -473,6 +473,7 @@ public class B {
if (!ix.startsWith("minecraft:") && ix.contains(":")) {
Identifier key = Identifier.fromString(ix);
Optional<BlockData> bd = Iris.service(ExternalDataSVC.class).getBlockData(key);
Iris.info("Loading block data " + key);
if (bd.isPresent())
bx = bd.get();
}

View File

@@ -21,6 +21,4 @@ commands:
iris:
aliases: [ ir, irs ]
api-version: ${apiversion}
softdepend:
- ItemsAdder
hotload-dependencies: false