mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-19 23:00:19 +00:00
implement world api changes
This commit is contained in:
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.WorldAccess;
|
||||
|
||||
|
||||
public class BufferedEntity implements BufferedItem {
|
||||
@@ -27,7 +27,7 @@ public class BufferedEntity implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
public void paste(Vector3 origin, WorldAccess world) {
|
||||
Entity entity = world.spawnEntity(origin.clone().add(0.5, 0, 0.5), type);
|
||||
platform.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getConfig().getPack(), entity));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
|
||||
import com.dfsek.terra.api.world.access.WorldAccess;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -37,7 +38,7 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
public void paste(Vector3 origin, WorldAccess world) {
|
||||
try {
|
||||
BlockEntity data = world.getBlockState(origin);
|
||||
if(!(data instanceof Container container)) {
|
||||
|
||||
@@ -10,7 +10,7 @@ package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.WorldAccess;
|
||||
|
||||
|
||||
public class BufferedPulledBlock implements BufferedItem {
|
||||
@@ -21,7 +21,7 @@ public class BufferedPulledBlock implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
public void paste(Vector3 origin, WorldAccess world) {
|
||||
Vector3 mutable = origin.clone();
|
||||
while(mutable.getY() > world.getMinHeight()) {
|
||||
if(!world.getBlockData(mutable).isAir()) {
|
||||
|
||||
@@ -10,7 +10,8 @@ package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
|
||||
import com.dfsek.terra.api.world.access.WorldAccess;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -26,7 +27,7 @@ public class BufferedStateManipulator implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
public void paste(Vector3 origin, WorldAccess world) {
|
||||
try {
|
||||
BlockEntity state = world.getBlockState(origin);
|
||||
state.applyState(data);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script;
|
||||
|
||||
import com.dfsek.terra.api.world.access.WorldAccess;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import net.jafama.FastMath;
|
||||
@@ -136,7 +138,7 @@ public class StructureScript implements Structure {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean generate(Vector3 location, World world, Chunk chunk, Random random, Rotation rotation) {
|
||||
public boolean generate(Vector3 location, WorldAccess world, Chunk chunk, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_chunk:" + id)) {
|
||||
StructureBuffer buffer = computeBuffer(location, world, random, rotation);
|
||||
buffer.paste(location, chunk);
|
||||
@@ -146,7 +148,7 @@ public class StructureScript implements Structure {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean generate(Buffer buffer, World world, Random random, Rotation rotation, int recursions) {
|
||||
public boolean generate(Buffer buffer, WorldAccess world, Random random, Rotation rotation, int recursions) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_recursive:" + id)) {
|
||||
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, recursions));
|
||||
}
|
||||
@@ -154,7 +156,7 @@ public class StructureScript implements Structure {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean generate(Vector3 location, World world, Random random, Rotation rotation) {
|
||||
public boolean generate(Vector3 location, WorldAccess world, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_direct:" + id)) {
|
||||
DirectBuffer buffer = new DirectBuffer(location, world);
|
||||
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, 0));
|
||||
@@ -169,7 +171,7 @@ public class StructureScript implements Structure {
|
||||
}
|
||||
}
|
||||
|
||||
private StructureBuffer computeBuffer(Vector3 location, World world, Random random, Rotation rotation) {
|
||||
private StructureBuffer computeBuffer(Vector3 location, WorldAccess world, Random random, Rotation rotation) {
|
||||
try {
|
||||
return cache.get(location, () -> {
|
||||
StructureBuffer buf = new StructureBuffer(location);
|
||||
|
||||
@@ -13,17 +13,18 @@ import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.WorldAccess;
|
||||
|
||||
|
||||
public class TerraImplementationArguments implements ImplementationArguments {
|
||||
private final Buffer buffer;
|
||||
private final Rotation rotation;
|
||||
private final Random random;
|
||||
private final World world;
|
||||
private final WorldAccess world;
|
||||
private final int recursions;
|
||||
private boolean waterlog = false;
|
||||
|
||||
public TerraImplementationArguments(Buffer buffer, Rotation rotation, Random random, World world, int recursions) {
|
||||
public TerraImplementationArguments(Buffer buffer, Rotation rotation, Random random, WorldAccess world, int recursions) {
|
||||
this.buffer = buffer;
|
||||
this.rotation = rotation;
|
||||
this.random = random;
|
||||
@@ -55,7 +56,7 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
||||
this.waterlog = waterlog;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
public WorldAccess getWorld() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.world.access.WorldAccess;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -68,7 +70,7 @@ public class CheckFunction implements Function<String> {
|
||||
return ReturnType.STRING;
|
||||
}
|
||||
|
||||
private String apply(Vector3 vector, World world) {
|
||||
private String apply(Vector3 vector, WorldAccess world) {
|
||||
int y = vector.getBlockY();
|
||||
if(y >= world.getMaxHeight() || y < 0) return "AIR";
|
||||
SamplerCache cache = world.getConfig().getSamplerCache();
|
||||
|
||||
Reference in New Issue
Block a user