mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
Implement not-stupid cave liquid updating
This commit is contained in:
parent
2b460f8617
commit
d4e6f03aeb
@ -40,6 +40,7 @@ public class CarverConfig extends TerraConfig {
|
|||||||
private final boolean replaceIsBlacklistOuter;
|
private final boolean replaceIsBlacklistOuter;
|
||||||
private final boolean replaceIsBlacklistTop;
|
private final boolean replaceIsBlacklistTop;
|
||||||
private final boolean replaceIsBlacklistBottom;
|
private final boolean replaceIsBlacklistBottom;
|
||||||
|
private final boolean updateOcean;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
@ -66,6 +67,8 @@ public class CarverConfig extends TerraConfig {
|
|||||||
|
|
||||||
update = ConfigUtil.toBlockData(getStringList("update"), "update", getID());
|
update = ConfigUtil.toBlockData(getStringList("update"), "update", getID());
|
||||||
|
|
||||||
|
updateOcean = getBoolean("update-liquids", false);
|
||||||
|
|
||||||
shift = new HashMap<>();
|
shift = new HashMap<>();
|
||||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("shift")).getValues(false).entrySet()) {
|
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("shift")).getValues(false).entrySet()) {
|
||||||
Set<Material> l = new HashSet<>();
|
Set<Material> l = new HashSet<>();
|
||||||
@ -184,6 +187,10 @@ public class CarverConfig extends TerraConfig {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldUpdateOcean() {
|
||||||
|
return updateOcean;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Carver with ID " + getID();
|
return "Carver with ID " + getID();
|
||||||
|
@ -6,11 +6,13 @@ import com.dfsek.terra.carving.SimplexCarver;
|
|||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||||
|
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -46,19 +48,19 @@ public class CavePopulator extends BlockPopulator {
|
|||||||
if(e.getValue().equals(CarvingData.CarvingType.CENTER) && c.isReplaceableInner(m)) {
|
if(e.getValue().equals(CarvingData.CarvingType.CENTER) && c.isReplaceableInner(m)) {
|
||||||
if(c.getShiftedBlocks().containsKey(b.getType()))
|
if(c.getShiftedBlocks().containsKey(b.getType()))
|
||||||
shiftCandidate.put(b.getLocation(), b.getType());
|
shiftCandidate.put(b.getLocation(), b.getType());
|
||||||
b.setBlockData(c.getPaletteInner(v.getBlockY()).get(random), c.getUpdateBlocks().contains(m));
|
b.setBlockData(c.getPaletteInner(v.getBlockY()).get(random), c.shouldUpdateOcean() && borderingOcean(b));
|
||||||
} else if(e.getValue().equals(CarvingData.CarvingType.WALL) && c.isReplaceableOuter(m)) {
|
} else if(e.getValue().equals(CarvingData.CarvingType.WALL) && c.isReplaceableOuter(m)) {
|
||||||
if(c.getShiftedBlocks().containsKey(b.getType()))
|
if(c.getShiftedBlocks().containsKey(b.getType()))
|
||||||
shiftCandidate.put(b.getLocation(), b.getType());
|
shiftCandidate.put(b.getLocation(), b.getType());
|
||||||
b.setBlockData(c.getPaletteOuter(v.getBlockY()).get(random), c.getUpdateBlocks().contains(m));
|
b.setBlockData(c.getPaletteOuter(v.getBlockY()).get(random), c.shouldUpdateOcean() && borderingOcean(b));
|
||||||
} else if(e.getValue().equals(CarvingData.CarvingType.TOP) && c.isReplaceableTop(m)) {
|
} else if(e.getValue().equals(CarvingData.CarvingType.TOP) && c.isReplaceableTop(m)) {
|
||||||
if(c.getShiftedBlocks().containsKey(b.getType()))
|
if(c.getShiftedBlocks().containsKey(b.getType()))
|
||||||
shiftCandidate.put(b.getLocation(), b.getType());
|
shiftCandidate.put(b.getLocation(), b.getType());
|
||||||
b.setBlockData(c.getPaletteTop(v.getBlockY()).get(random), c.getUpdateBlocks().contains(m));
|
b.setBlockData(c.getPaletteTop(v.getBlockY()).get(random), c.shouldUpdateOcean() && borderingOcean(b));
|
||||||
} else if(e.getValue().equals(CarvingData.CarvingType.BOTTOM) && c.isReplaceableBottom(m)) {
|
} else if(e.getValue().equals(CarvingData.CarvingType.BOTTOM) && c.isReplaceableBottom(m)) {
|
||||||
if(c.getShiftedBlocks().containsKey(b.getType()))
|
if(c.getShiftedBlocks().containsKey(b.getType()))
|
||||||
shiftCandidate.put(b.getLocation(), b.getType());
|
shiftCandidate.put(b.getLocation(), b.getType());
|
||||||
b.setBlockData(c.getPaletteBottom(v.getBlockY()).get(random), c.getUpdateBlocks().contains(m));
|
b.setBlockData(c.getPaletteBottom(v.getBlockY()).get(random), c.shouldUpdateOcean() && borderingOcean(b));
|
||||||
}
|
}
|
||||||
if(c.getUpdateBlocks().contains(m)) {
|
if(c.getUpdateBlocks().contains(m)) {
|
||||||
updateNeeded.add(b);
|
updateNeeded.add(b);
|
||||||
@ -98,4 +100,7 @@ public class CavePopulator extends BlockPopulator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private boolean borderingOcean(Block b) {
|
||||||
|
return b.getRelative(BlockFace.UP).getType().equals(Material.WATER) || b.getType().equals(Material.LAVA);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user