mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Remove saplings, update debug, improve object placing functions
This commit is contained in:
parent
6932e468cf
commit
c48c74a0cf
@ -8,6 +8,7 @@ import com.volmit.iris.util.collection.KList;
|
|||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.StructureGrowEvent;
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
@ -73,21 +74,25 @@ public class TreeManager implements Listener {
|
|||||||
|
|
||||||
// Find best object placement based on sizes
|
// Find best object placement based on sizes
|
||||||
IrisObjectPlacement placement = null;
|
IrisObjectPlacement placement = null;
|
||||||
|
IrisTreeSize bestSize = null;
|
||||||
while (placement == null && keys.isNotEmpty()){
|
while (placement == null && keys.isNotEmpty()){
|
||||||
IrisTreeSize bestSize = IrisTreeSize.bestSizeInSizes(keys);
|
bestSize = IrisTreeSize.bestSizeInSizes(keys);
|
||||||
keys.remove(bestSize);
|
keys.remove(bestSize);
|
||||||
placement = getObjectPlacement(worldAccess, event.getLocation(), type, bestSize);
|
placement = getObjectPlacement(worldAccess, event.getLocation(), type, bestSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If none were found, just exit
|
// If none were found, just exit
|
||||||
if (placement == null) {
|
if (placement == null) {
|
||||||
Iris.debug(this.getClass().getName() + " had options but did not manage to find objectplacements for them");
|
Iris.debug(this.getClass().getName() + " had options but did not manage to find objectPlacements for them");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel the placement
|
// Cancel the placement
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
// Delete existing saplings
|
||||||
|
sizes.get(bestSize).forEach(row -> row.forEach(location -> location.getBlock().setType(Material.AIR)));
|
||||||
|
|
||||||
// Get object from placer
|
// Get object from placer
|
||||||
IrisObject f = worldAccess.getData().getObjectLoader().load(placement.getPlace().getRandom(RNG.r));
|
IrisObject f = worldAccess.getData().getObjectLoader().load(placement.getPlace().getRandom(RNG.r));
|
||||||
|
|
||||||
@ -153,17 +158,14 @@ public class TreeManager implements Listener {
|
|||||||
// Place the object with the placer
|
// Place the object with the placer
|
||||||
/*
|
/*
|
||||||
f.place(
|
f.place(
|
||||||
event.getLocation().getBlockX(),
|
event.getLocation() // TODO: Place the object at the right location (one of the center positions)
|
||||||
event.getLocation().getBlockY(),
|
|
||||||
event.getLocation().getBlockZ(),
|
|
||||||
placer,
|
placer,
|
||||||
placement,
|
placement,
|
||||||
RNG.r,
|
RNG.r,
|
||||||
Objects.requireNonNull(IrisWorlds.access(event.getWorld())).getData()
|
Objects.requireNonNull(IrisWorlds.access(event.getWorld())).getData()
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
// TODO: Place the object at the right location (one of the center positions)
|
//f.place(event.getLocation());
|
||||||
f.place(event.getLocation());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -415,6 +415,10 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
return place(x, yv, z, placer, config, rng, null, null, rdata);
|
return place(x, yv, z, placer, config, rng, null, null, rdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int place(Location loc, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, IrisDataManager rdata) {
|
||||||
|
return place(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), placer, config, rng, rdata);
|
||||||
|
}
|
||||||
|
|
||||||
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener, CarveResult c, IrisDataManager rdata) {
|
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener, CarveResult c, IrisDataManager rdata) {
|
||||||
IObjectPlacer placer = (config.getHeightmap() != null) ? new IObjectPlacer() {
|
IObjectPlacer placer = (config.getHeightmap() != null) ? new IObjectPlacer() {
|
||||||
final long s = rng.nextLong() + yv + z - x;
|
final long s = rng.nextLong() + yv + z - x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user