mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-05 07:16:10 +00:00
Carving
This commit is contained in:
@@ -12,4 +12,6 @@ public interface MaterialData extends Handle {
|
||||
boolean isAir();
|
||||
|
||||
double getMaxDurability();
|
||||
|
||||
BlockData createBlockData();
|
||||
}
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.gaea.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.generator.TerraBlockPopulator;
|
||||
import com.dfsek.terra.api.generic.world.Chunk;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.api.generic.world.block.Block;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
import com.dfsek.terra.util.PopulationUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class CavePopulator implements TerraBlockPopulator {
|
||||
private final TerraPlugin main;
|
||||
@@ -23,9 +34,9 @@ public class CavePopulator implements TerraBlockPopulator {
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
||||
/*
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
WorldHandle handle = main.getWorldHandle();
|
||||
BlockData AIR = handle.createBlockData("minecraft:air");
|
||||
try(ProfileFuture ignored = tw.getProfiler().measure("CaveTime")) {
|
||||
Random random = PopulationUtil.getRandom(chunk);
|
||||
if(!tw.isSafe()) return;
|
||||
@@ -33,7 +44,7 @@ public class CavePopulator implements TerraBlockPopulator {
|
||||
|
||||
for(UserDefinedCarver c : config.getCarvers()) {
|
||||
CarverTemplate template = c.getConfig();
|
||||
Map<Location, BlockData> shiftCandidate = new HashMap<>();
|
||||
Map<Location, MaterialData> shiftCandidate = new HashMap<>();
|
||||
Set<Block> updateNeeded = new HashSet<>();
|
||||
c.carve(chunk.getX(), chunk.getZ(), world, (v, type) -> {
|
||||
Block b = chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
@@ -69,15 +80,15 @@ public class CavePopulator implements TerraBlockPopulator {
|
||||
break;
|
||||
}
|
||||
});
|
||||
for(Map.Entry<Location, Material> entry : shiftCandidate.entrySet()) {
|
||||
for(Map.Entry<Location, MaterialData> entry : shiftCandidate.entrySet()) {
|
||||
Location l = entry.getKey();
|
||||
Location mut = l.clone();
|
||||
Material orig = handle.getType(l.getBlock());
|
||||
MaterialData orig = handle.getType(l.getBlock());
|
||||
do mut.subtract(0, 1, 0);
|
||||
while(handle.getType(mut.getBlock()).equals(orig));
|
||||
try {
|
||||
if(template.getShift().get(entry.getValue()).contains(mut.getBlock().getType())) {
|
||||
handle.setBlockData(mut.getBlock(), shiftStorage.computeIfAbsent(entry.getValue(), Material::createBlockData), false);
|
||||
handle.setBlockData(mut.getBlock(), shiftStorage.computeIfAbsent(entry.getValue(), MaterialData::createBlockData), false);
|
||||
}
|
||||
} catch(NullPointerException ignore) {
|
||||
}
|
||||
@@ -90,7 +101,5 @@ public class CavePopulator implements TerraBlockPopulator {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@ public class BukkitMaterialData implements MaterialData {
|
||||
return delegate.getMaxDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData createBlockData() {
|
||||
return new BukkitBlockData(delegate.createBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHandle() {
|
||||
return delegate;
|
||||
|
||||
@@ -17,4 +17,16 @@ dependencies {
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||
implementation(project(":common"))
|
||||
implementation("org.apache.commons:commons-rng-core:1.3")
|
||||
|
||||
|
||||
implementation("com.scireum:parsii:1.2.1")
|
||||
implementation("com.dfsek:Tectonic:1.0.3")
|
||||
implementation("net.jafama:jafama:2.3.2")
|
||||
|
||||
compileOnly("com.googlecode.json-simple:json-simple:1.1")
|
||||
|
||||
implementation("com.google.guava:guava:30.0-jre")
|
||||
|
||||
compileOnly("org.jetbrains:annotations:20.1.0")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.dfsek.terra.fabric;
|
||||
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.gaea.lang.Language;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.inventory.ItemHandle;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.config.base.PluginConfig;
|
||||
import com.dfsek.terra.registry.ConfigRegistry;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class TerraFabricPlugin implements TerraPlugin {
|
||||
@Override
|
||||
public WorldHandle getWorldHandle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraWorld getWorld(World world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginConfig getTerraConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRegistry getRegistry() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemHandle getItemHandle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user