From aa7a1ddd4eb2211daf4a3bf344bd9402be778d52 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Wed, 28 Oct 2020 02:10:59 -0400 Subject: [PATCH] Bugfixes --- .../iris/command/CommandIrisStudioGoto.java | 162 ++++++++++-------- .../iris/gen/ContextualTerrainProvider.java | 5 + .../volmit/iris/gen/layer/GenLayerUpdate.java | 13 +- .../iris/object/IrisObjectRotation.java | 69 +++++++- 4 files changed, 168 insertions(+), 81 deletions(-) diff --git a/src/main/java/com/volmit/iris/command/CommandIrisStudioGoto.java b/src/main/java/com/volmit/iris/command/CommandIrisStudioGoto.java index 061c35e2b..cd34c8344 100644 --- a/src/main/java/com/volmit/iris/command/CommandIrisStudioGoto.java +++ b/src/main/java/com/volmit/iris/command/CommandIrisStudioGoto.java @@ -25,104 +25,114 @@ public class CommandIrisStudioGoto extends MortarCommand @Override public boolean handle(MortarSender sender, String[] args) { - if(args.length < 1) + try { - sender.sendMessage("/iris std goto " + getArgsUsage()); - return true; - } - - if(sender.isPlayer()) - { - Player p = sender.player(); - World world = p.getWorld(); - - if(!IrisWorlds.isIrisWorld(world)) + if(args.length < 1) { - sender.sendMessage("You must be in an iris world."); + sender.sendMessage("/iris std goto " + getArgsUsage()); return true; } - IrisTerrainProvider g = IrisWorlds.getProvider(world); - int tries = 10000; - boolean cave = false; - IrisBiome biome2 = null; - if(args.length > 1) + if(sender.isPlayer()) { - if(args[1].equalsIgnoreCase("-cave")) + Player p = sender.player(); + World world = p.getWorld(); + + if(!IrisWorlds.isIrisWorld(world)) { - cave = true; + sender.sendMessage("You must be in an iris world."); + return true; } - else + IrisTerrainProvider g = IrisWorlds.getProvider(world); + int tries = 10000; + boolean cave = false; + IrisBiome biome2 = null; + if(args.length > 1) { - biome2 = g.loadBiome(args[1]); - - if(biome2 == null) + if(args[1].equalsIgnoreCase("-cave")) { - sender.sendMessage(args[1] + " is not a biome. Use the file name (without extension)"); - return true; - } - } - } - - for(String i : args) - { - if(i.equalsIgnoreCase("-cave")) - { - cave = true; - } - } - - IrisBiome biome = args[0].equals("this") ? g.sampleTrueBiome(p.getLocation().getBlockX(), p.getLocation().getBlockZ()) : g.loadBiome(args[0]); - - if(biome == null) - { - sender.sendMessage(args[0] + " is not a biome. Use the file name (without extension)"); - return true; - } - - while(tries > 0) - { - tries--; - - int xx = (int) (RNG.r.i(-29999970, 29999970)); - int zz = (int) (RNG.r.i(-29999970, 29999970)); - if((cave ? g.sampleCaveBiome(xx, zz) : g.sampleTrueBiome(xx, zz)).getLoadKey().equals(biome.getLoadKey())) - { - if(biome2 != null) - { - for(int i = 0; i < 64; i++) - { - int ax = xx + RNG.r.i(-64, 32); - int az = zz + RNG.r.i(-64, 32); - - if((cave ? g.sampleCaveBiome(ax, az) : g.sampleTrueBiome(ax, az)).getLoadKey().equals(biome2.getLoadKey())) - { - tries--; - p.teleport(new Location(world, xx, world.getHighestBlockYAt(xx, zz), zz)); - sender.sendMessage("Found border in " + (10000 - tries) + " tries!"); - return true; - } - } + cave = true; } else { - p.teleport(new Location(world, xx, world.getHighestBlockYAt(xx, zz), zz)); - sender.sendMessage("Found in " + (10000 - tries) + " tries!"); - return true; + biome2 = g.loadBiome(args[1]); + + if(biome2 == null) + { + sender.sendMessage(args[1] + " is not a biome. Use the file name (without extension)"); + return true; + } } } + + for(String i : args) + { + if(i.equalsIgnoreCase("-cave")) + { + cave = true; + } + } + + IrisBiome biome = args[0].equals("this") ? g.sampleTrueBiome(p.getLocation().getBlockX(), p.getLocation().getBlockZ()) : g.loadBiome(args[0]); + + if(biome == null) + { + sender.sendMessage(args[0] + " is not a biome. Use the file name (without extension)"); + return true; + } + + while(tries > 0) + { + tries--; + + int xx = (int) (RNG.r.i(-29999970, 29999970)); + int zz = (int) (RNG.r.i(-29999970, 29999970)); + if((cave ? g.sampleCaveBiome(xx, zz) : g.sampleTrueBiome(xx, zz)).getLoadKey().equals(biome.getLoadKey())) + { + if(biome2 != null) + { + for(int i = 0; i < 64; i++) + { + int ax = xx + RNG.r.i(-64, 32); + int az = zz + RNG.r.i(-64, 32); + + if((cave ? g.sampleCaveBiome(ax, az) : g.sampleTrueBiome(ax, az)).getLoadKey().equals(biome2.getLoadKey())) + { + tries--; + p.teleport(new Location(world, xx, world.getHighestBlockYAt(xx, zz), zz)); + sender.sendMessage("Found border in " + (10000 - tries) + " tries!"); + return true; + } + } + } + + else + { + p.teleport(new Location(world, xx, world.getHighestBlockYAt(xx, zz), zz)); + sender.sendMessage("Found in " + (10000 - tries) + " tries!"); + return true; + } + } + } + + sender.sendMessage("Tried to find " + biome.getName() + " looked in 10,000 places no dice."); + + return true; } - sender.sendMessage("Tried to find " + biome.getName() + " looked in 10,000 places no dice."); - - return true; + else + { + sender.sendMessage("Players only."); + } } - else + catch(Throwable e) { - sender.sendMessage("Players only."); + Iris.error("Failed goto!"); + e.printStackTrace(); + sender.sendMessage("We cant seem to aquire a lock on the biome cache. Please report the error in the console to our github. Thanks!"); } return true; diff --git a/src/main/java/com/volmit/iris/gen/ContextualTerrainProvider.java b/src/main/java/com/volmit/iris/gen/ContextualTerrainProvider.java index 3222c9c4f..1ee81b400 100644 --- a/src/main/java/com/volmit/iris/gen/ContextualTerrainProvider.java +++ b/src/main/java/com/volmit/iris/gen/ContextualTerrainProvider.java @@ -139,6 +139,11 @@ public abstract class ContextualTerrainProvider implements TerrainProvider, List public IrisBiome loadBiome(String i) { + if(getData() == null) + { + return Iris.globaldata.getBiomeLoader().load(i); + } + return getData().getBiomeLoader().load(i); } diff --git a/src/main/java/com/volmit/iris/gen/layer/GenLayerUpdate.java b/src/main/java/com/volmit/iris/gen/layer/GenLayerUpdate.java index eb464e06f..8044cad68 100644 --- a/src/main/java/com/volmit/iris/gen/layer/GenLayerUpdate.java +++ b/src/main/java/com/volmit/iris/gen/layer/GenLayerUpdate.java @@ -45,7 +45,18 @@ public class GenLayerUpdate extends BlockPopulator @Override public void populate(World w, Random r, Chunk c) { - AtomicSliverMap map = gen.getParallaxChunk(c.getX(), c.getZ()); + AtomicSliverMap map = null; + + try + { + map = gen.getParallaxChunk(c.getX(), c.getZ()); + } + + catch(Throwable e) + { + map = new AtomicSliverMap(); + } + RNG rx = rng.nextParallelRNG(c.getX() + r.nextInt()).nextParallelRNG(c.getZ() + r.nextInt()); if(gen.getDimension().isVanillaCaves()) diff --git a/src/main/java/com/volmit/iris/object/IrisObjectRotation.java b/src/main/java/com/volmit/iris/object/IrisObjectRotation.java index 2b5cf2ec7..0a32d7675 100644 --- a/src/main/java/com/volmit/iris/object/IrisObjectRotation.java +++ b/src/main/java/com/volmit/iris/object/IrisObjectRotation.java @@ -2,11 +2,11 @@ package com.volmit.iris.object; import java.util.List; +import com.volmit.iris.util.M; +import org.bukkit.Axis; +import org.bukkit.Material; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Directional; -import org.bukkit.block.data.MultipleFacing; -import org.bukkit.block.data.Rotatable; +import org.bukkit.block.data.*; import org.bukkit.util.BlockVector; import com.volmit.iris.util.Desc; @@ -111,6 +111,56 @@ public class IrisObjectRotation return BlockFace.SOUTH; } + public BlockFace faceForAxis(Axis axis) + { + switch(axis) + { + case X: + return BlockFace.EAST; + case Y: + return BlockFace.UP; + case Z: + return BlockFace.NORTH; + } + + return BlockFace.NORTH; + } + + public Axis axisFor(BlockFace f) + { + switch(f) + { + case NORTH: + case SOUTH: + return Axis.Z; + case EAST: + case WEST: + return Axis.X; + case UP: + case DOWN: + return Axis.Y; + } + + return Axis.X; + } + + public Axis axisFor2D(BlockFace f) + { + switch(f) + { + case NORTH: + case SOUTH: + return Axis.Z; + case EAST: + case WEST: + case UP: + case DOWN: + return Axis.X; + } + + return Axis.X; + } + public BlockData rotate(BlockData dd, int spinxx, int spinyy, int spinzz) { BlockData d = dd; @@ -142,6 +192,17 @@ public class IrisObjectRotation } } + else if(d instanceof Orientable) + { + Orientable g = ((Orientable) d); + BlockFace f = faceForAxis(g.getAxis()); + BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ()); + bv = rotate(bv.clone(), spinx, spiny, spinz); + BlockFace t = getFace(bv); + Axis a = !((Orientable) d).getAxes().contains(Axis.Y) ? axisFor(t) : axisFor2D(t); + ((Orientable) d).setAxis(a); + } + else if(d instanceof Rotatable) { Rotatable g = ((Rotatable) d);