forked from unimatrix/web
Fresh production baseline [skip ci]
This commit is contained in:
commit
0a11a18274
1 changed files with 229644 additions and 0 deletions
41
tools/OrdosSulfurProbe.java
Normal file
41
tools/OrdosSulfurProbe.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package com.example.duneterrain;
|
||||
|
||||
import java.nio.file.*;
|
||||
import com.google.gson.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.server.ServerLoadEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/** Disposable native-world probe, with no production credentials or database access. */
|
||||
public final class OrdosSulfurProbe extends JavaPlugin implements Listener {
|
||||
public void onEnable(){Bukkit.getPluginManager().registerEvents(this,this);}
|
||||
@EventHandler public void loaded(ServerLoadEvent event){Bukkit.getScheduler().runTaskLater(this,()->{try{verify();}catch(Throwable error){getLogger().severe("ORDOS_SULFUR_FAIL "+error);error.printStackTrace();}finally{Bukkit.shutdown();}},40);}
|
||||
private static void check(boolean condition,String message){if(!condition)throw new IllegalStateException(message);}
|
||||
private void verify()throws Exception{
|
||||
World world=Bukkit.getWorld("sigma_draconis_iv");check(world!=null,"Ordos legacy world alias missing");
|
||||
Biome sulfur=Registry.BIOME.get(NamespacedKey.minecraft("sulfur_caves"));check(sulfur!=null,"Native sulfur biome unavailable");
|
||||
Location found=null;
|
||||
for(int r=0;r<=1024&&found==null;r+=64)for(int x=-r;x<=r&&found==null;x+=64)for(int z=-r;z<=r;z+=64){
|
||||
if(r>0&&Math.abs(x)!=r&&Math.abs(z)!=r)continue;
|
||||
if(TemperateLandscape.biome(world,x,0,z,"sigma_draconis_iv").equals(sulfur)){found=new Location(world,x,0,z);break;}
|
||||
}
|
||||
check(found!=null,"Ordos profile contains no sulfur pockets");
|
||||
int sulfurBlocks=0;
|
||||
for(int cx=-1;cx<=1;cx++)for(int cz=-1;cz<=1;cz++)world.getChunkAt((found.getBlockX()>>4)+cx,(found.getBlockZ()>>4)+cz);
|
||||
for(int x=found.getBlockX()-16;x<found.getBlockX()+16;x++)for(int z=found.getBlockZ()-16;z<found.getBlockZ()+16;z++)for(int y=-40;y<=32;y++){
|
||||
if(world.getBlockAt(x,y,z).getType().name().contains("SULFUR"))sulfurBlocks++;
|
||||
}
|
||||
check(world.getBiome(found).equals(sulfur),"Generated chunk biome differs from profile");
|
||||
check(sulfurBlocks>0,"Sulfur biome has no native sulfur features");
|
||||
var cube=world.spawnEntity(found.clone().add(.5,1,.5),EntityType.valueOf("SULFUR_CUBE"));
|
||||
check(cube instanceof org.bukkit.entity.LivingEntity,"Native sulfur cube could not spawn");
|
||||
var natural=new CreatureSpawnEvent((org.bukkit.entity.LivingEntity)cube,CreatureSpawnEvent.SpawnReason.NATURAL);new PlanetMobs().spawning(natural);check(!natural.isCancelled(),"Ordos wildlife rules reject native sulfur cubes");cube.remove();
|
||||
JsonObject receipt=new JsonObject();receipt.addProperty("passed",true);receipt.addProperty("world",world.getName());receipt.addProperty("sulfurBlocks",sulfurBlocks);receipt.addProperty("nativeCube",true);receipt.addProperty("databaseConnected",false);
|
||||
receipt.addProperty("spawnX",world.getSpawnLocation().getX());receipt.addProperty("spawnY",world.getSpawnLocation().getY());receipt.addProperty("spawnZ",world.getSpawnLocation().getZ());
|
||||
Files.writeString(Path.of("sulfur-result.json"),new GsonBuilder().setPrettyPrinting().create().toJson(receipt));getLogger().info("ORDOS_SULFUR_SUCCESS "+receipt);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff