Fix some issues with ore generators
This commit is contained in:
parent
18cb07f34e
commit
92664eb636
|
|
@ -26,19 +26,14 @@ public class GeneratorHandler {
|
||||||
return generatorLevels.getInt(tier);
|
return generatorLevels.getInt(tier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material generateOre(Island island, boolean cobblestone, int depth) {
|
|
||||||
boolean deepslate = depth <= 16 && cobblestone;
|
|
||||||
Material ore = rollGenerator(island, cobblestone);
|
|
||||||
return deepslate ? deepslateVariant(ore) : ore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material generateOre(Island island, Material material) {
|
public Material generateOre(Island island, Material material) {
|
||||||
boolean deepslate = material == Material.DEEPSLATE;
|
boolean deepslate = material == Material.DEEPSLATE;
|
||||||
Material ore = rollGenerator(island, material == Material.STONE || material == Material.COBBLESTONE || deepslate);
|
Material ore = rollGenerator(island, material);
|
||||||
return deepslate ? deepslateVariant(ore) : ore;
|
return deepslate ? deepslateVariant(ore) : ore;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Material rollGenerator(Island island, boolean cobblestone) {
|
private Material rollGenerator(Island island, Material material) {
|
||||||
|
boolean cobblestone = material == Material.STONE || material == Material.COBBLESTONE || material == Material.DEEPSLATE;
|
||||||
double random = Math.random() * 100;
|
double random = Math.random() * 100;
|
||||||
double checkedChance = 0;
|
double checkedChance = 0;
|
||||||
|
|
||||||
|
|
@ -58,12 +53,15 @@ public class GeneratorHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cobblestone ? Material.COBBLESTONE : Material.BASALT;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material deepslateVariant(Material material) {
|
public Material deepslateVariant(Material material) {
|
||||||
switch (material) {
|
switch (material) {
|
||||||
case COBBLESTONE -> {
|
case COBBLESTONE -> {
|
||||||
|
return Material.COBBLED_DEEPSLATE;
|
||||||
|
}
|
||||||
|
case STONE -> {
|
||||||
return Material.DEEPSLATE;
|
return Material.DEEPSLATE;
|
||||||
}
|
}
|
||||||
case COAL_ORE -> {
|
case COAL_ORE -> {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class cobblestoneGeneratorListener extends EventListener {
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onBockForm(BlockFormEvent blockFormEvent) {
|
public void onBockForm(BlockFormEvent blockFormEvent) {
|
||||||
Block block = blockFormEvent.getBlock();
|
Block block = blockFormEvent.getBlock();
|
||||||
if (block.getType() == Material.OBSIDIAN)
|
if (!isFromGenerator(blockFormEvent.getNewState().getType()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Island island = Island.getIsland(block.getWorld().getUID());
|
Island island = Island.getIsland(block.getWorld().getUID());
|
||||||
|
|
@ -46,7 +46,7 @@ public class cobblestoneGeneratorListener extends EventListener {
|
||||||
if(!block.hasMetadata(GENERATOR_METADATA_KEY))
|
if(!block.hasMetadata(GENERATOR_METADATA_KEY))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (block.getType() == Material.OBSIDIAN)
|
if (!isFromGenerator(block.getType()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Island island = Island.getIsland(block.getWorld().getUID());
|
Island island = Island.getIsland(block.getWorld().getUID());
|
||||||
|
|
@ -70,22 +70,29 @@ public class cobblestoneGeneratorListener extends EventListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
// @EventHandler(ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
// public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
cleanPistonBlocks(event.getBlocks());
|
// cleanPistonBlocks(event.getBlocks());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// @EventHandler(ignoreCancelled = true)
|
||||||
|
// public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
|
// cleanPistonBlocks(event.getBlocks());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void cleanPistonBlocks(List<Block> blocks) {
|
||||||
|
// for (Block block : blocks) {
|
||||||
|
// if(block.hasMetadata(GENERATOR_METADATA_KEY)) {
|
||||||
|
// block.removeMetadata(GENERATOR_METADATA_KEY, plugin);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
private boolean isFromGenerator(Material material) {
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
return switch (material) {
|
||||||
cleanPistonBlocks(event.getBlocks());
|
case STONE, COBBLESTONE, DEEPSLATE, BASALT -> true;
|
||||||
}
|
default -> false;
|
||||||
|
};
|
||||||
private void cleanPistonBlocks(List<Block> blocks) {
|
|
||||||
for (Block block : blocks) {
|
|
||||||
if(block.hasMetadata(GENERATOR_METADATA_KEY)) {
|
|
||||||
block.removeMetadata(GENERATOR_METADATA_KEY, plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CometMeta extends FixedMetadataValue {
|
public class CometMeta extends FixedMetadataValue {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user