From 8d2f4e00397b1b51128ae2112130e34503be38a4 Mon Sep 17 00:00:00 2001 From: 08draven Date: Fri, 17 Jan 2025 22:29:04 -0500 Subject: [PATCH] change around some things --- app/build.gradle.kts | 2 +- .../main/java/net/xuyezo/main/Generator.java | 20 ++++-- .../main/java/net/xuyezo/main/Handler.java | 31 +++++---- app/src/main/java/net/xuyezo/main/Main.java | 67 +++---------------- app/src/main/resources/plugin.yml | 10 +-- 5 files changed, 47 insertions(+), 83 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2264a19..cffda5b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -28,7 +28,7 @@ dependencies { // This dependency is used by the application. implementation(libs.guava) - compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT") } // Apply a specific Java toolchain to ease working on different environments. diff --git a/app/src/main/java/net/xuyezo/main/Generator.java b/app/src/main/java/net/xuyezo/main/Generator.java index a0e7bb0..5f2c179 100644 --- a/app/src/main/java/net/xuyezo/main/Generator.java +++ b/app/src/main/java/net/xuyezo/main/Generator.java @@ -8,10 +8,17 @@ import org.bukkit.World; import org.bukkit.block.data.BlockData; import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.WorldInfo; +import org.bukkit.util.noise.PerlinNoiseGenerator; import org.jetbrains.annotations.NotNull; public class Generator extends ChunkGenerator { + public PerlinNoiseGenerator gen; + + public Generator() { + this.gen = new PerlinNoiseGenerator(69420); + } + public static int getHash(int x,int z) { return (((x * 223) ^ (z * 82395) ^ (x * 9634) ^ (z * 23958)) & 0x2FF3); } @@ -34,13 +41,12 @@ public class Generator extends ChunkGenerator { int x2 = chunkX * 16 + x; int z2 = chunkZ * 16 + z; - if (Generator.getHash(x2,z2) == (y & (y * 7))) { - for (int a = 0; a < 8; a++) { - for (int b = 0; b < 8; b++) { - chunkData.setBlock((x+a)%16, y, (z+b)%16, Material.STONE); - } - } - } + double fac = (y - chunkData.getMinHeight()) / (1.0 * chunkData.getMaxHeight()); + fac = 1.0 - fac; + + if (this.gen.noise(x2 * 0.01,y* 0.01,z2* 0.01, 5, 1.5, 0.5) * fac < 0.4) continue; + + chunkData.setBlock(x, y, z, Material.STONE); } } } diff --git a/app/src/main/java/net/xuyezo/main/Handler.java b/app/src/main/java/net/xuyezo/main/Handler.java index e6dc984..9f622a9 100644 --- a/app/src/main/java/net/xuyezo/main/Handler.java +++ b/app/src/main/java/net/xuyezo/main/Handler.java @@ -29,7 +29,7 @@ public class Handler implements Listener { } @EventHandler - private void onBlockExplode(EntityExplodeEvent e) { + private void onBlockExplode(BlockExplodeEvent e) { e.setCancelled(true); for (Block b : e.blockList()) { Location loc = b.getLocation(); @@ -38,27 +38,30 @@ public class Handler implements Listener { b.setType(Material.LAVA); } else if (b.getType() == Material.COBBLESTONE || b.getType() == Material.GRAVEL) { Material[] items = { + Material.ICE, + Material.ICE, + Material.ICE, + Material.ICE, + Material.ICE, + Material.ICE, Material.ICE, Material.ICE, Material.COAL_ORE, - Material.ICE, - Material.ICE, + Material.COAL_ORE, + Material.COAL_ORE, + Material.COAL_ORE, + Material.COAL_ORE, + Material.COAL_ORE, + Material.COAL_ORE, Material.COAL_ORE, Material.COPPER_ORE, - Material.ICE, - Material.ICE, - Material.COAL_ORE, - Material.ICE, - Material.ICE, - Material.COAL_ORE, + Material.COPPER_ORE, + Material.COPPER_ORE, Material.COPPER_ORE, Material.IRON_ORE, + Material.IRON_ORE, + Material.GOLD_ORE, Material.GOLD_ORE, - Material.EMERALD_ORE, - Material.LAPIS_ORE, - Material.REDSTONE_ORE, - Material.ANCIENT_DEBRIS, - Material.NETHER_QUARTZ_ORE, Material.DIAMOND_ORE }; diff --git a/app/src/main/java/net/xuyezo/main/Main.java b/app/src/main/java/net/xuyezo/main/Main.java index b855718..1c24cea 100644 --- a/app/src/main/java/net/xuyezo/main/Main.java +++ b/app/src/main/java/net/xuyezo/main/Main.java @@ -4,6 +4,7 @@ import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.Server; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; @@ -21,125 +22,79 @@ public class Main extends JavaPlugin { public void onEnable() { Bukkit.getPluginManager().registerEvents(new Handler(), this); + Server server = getServer(); + NamespacedKey key = new NamespacedKey(this, "FlintAxe"); ItemStack item = new ItemStack(Material.STONE_AXE); Damageable meta = (Damageable) item.getItemMeta(); meta.setMaxDamage(80); meta.displayName(Component.text("Flint Axe")); item.setItemMeta(meta); - ShapedRecipe recipe = new ShapedRecipe(key, item); recipe.shape("A ", "B ", " "); recipe.setIngredient('A', Material.FLINT); recipe.setIngredient('B', Material.STICK); + server.addRecipe(recipe); - key = new NamespacedKey(this, "FlintPickaxe"); item = new ItemStack(Material.STONE_PICKAXE); meta = (Damageable) item.getItemMeta(); meta.setMaxDamage(100); meta.displayName(Component.text("Flint Pickaxe")); item.setItemMeta(meta); - recipe = new ShapedRecipe(key, item); recipe.shape("AA ", "B ", " "); recipe.setIngredient('A', Material.FLINT); recipe.setIngredient('B', Material.STICK); - - getServer().addRecipe(recipe); + server.addRecipe(recipe); key = new NamespacedKey(this, "BoneDirt"); item = new ItemStack(Material.GRASS_BLOCK,1); - recipe = new ShapedRecipe(key, item); recipe.shape("AAA", "ABA", "ACA"); recipe.setIngredient('A', Material.GRAVEL); recipe.setIngredient('B', Material.BONE_MEAL); recipe.setIngredient('C', new RecipeChoice.MaterialChoice(Material.COAL,Material.CHARCOAL)); - - getServer().addRecipe(recipe); - - key = new NamespacedKey(this, "SandCane"); - item = new ItemStack(Material.SUGAR_CANE,1); - - recipe = new ShapedRecipe(key, item); - recipe.shape("AAA", "ABA", "ACA"); - recipe.setIngredient('A', Material.SAND); - recipe.setIngredient('B', Material.BONE_MEAL); - recipe.setIngredient('C', new RecipeChoice.MaterialChoice(Material.COAL,Material.CHARCOAL)); - - getServer().addRecipe(recipe); + server.addRecipe(recipe); key = new NamespacedKey(this, "StoneStick"); item = new ItemStack(Material.STICK,4); - recipe = new ShapedRecipe(key, item); recipe.shape("A ", "A ", " "); recipe.setIngredient('A', Material.COBBLESTONE); - - getServer().addRecipe(recipe); + server.addRecipe(recipe); key = new NamespacedKey(this, "GrassSapling"); item = new ItemStack(Material.OAK_SAPLING); - recipe = new ShapedRecipe(key, item); recipe.shape("AAA", "ABA", "AAA"); recipe.setIngredient('A', Material.BONE_MEAL); recipe.setIngredient('B', Material.DIRT); - - getServer().addRecipe(recipe); - - key = new NamespacedKey(this, "SandCactus"); - item = new ItemStack(Material.CACTUS); - - recipe = new ShapedRecipe(key, item); - recipe.shape("AAA", "ABA", "AAA"); - recipe.setIngredient('A', Material.BONE_MEAL); - recipe.setIngredient('B', Material.SAND); - - getServer().addRecipe(recipe); + server.addRecipe(recipe); key = new NamespacedKey(this, "CoarseishDirt"); item = new ItemStack(Material.COARSE_DIRT,2); - recipe = new ShapedRecipe(key, item); recipe.shape("AB ", " ", " "); recipe.setIngredient('A', Material.GRAVEL); recipe.setIngredient('B', Material.DIRT); - - getServer().addRecipe(recipe); + server.addRecipe(recipe); key = new NamespacedKey(this, "StoneTable"); item = new ItemStack(Material.CRAFTING_TABLE); - recipe = new ShapedRecipe(key, item); recipe.shape("AA ", "AA ", " "); recipe.setIngredient('A', Material.COBBLESTONE); - - getServer().addRecipe(recipe); + server.addRecipe(recipe); key = new NamespacedKey(this, "CobbledStone"); item = new ItemStack(Material.COBBLESTONE); - recipe = new ShapedRecipe(key, item); recipe.shape("AA ", "AA ", " "); recipe.setIngredient('A', Material.GRAVEL); - - getServer().addRecipe(recipe); - - - key = new NamespacedKey(this, "AltUpgrade"); - item = new ItemStack(Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE); - - recipe = new ShapedRecipe(key, item); - recipe.shape("ABA", "ACA", "AAA"); - recipe.setIngredient('A', Material.DIAMOND); - recipe.setIngredient('B', Material.NETHERITE_INGOT); - recipe.setIngredient('C', Material.NETHERRACK); - - getServer().addRecipe(recipe); + server.addRecipe(recipe); } @Override diff --git a/app/src/main/resources/plugin.yml b/app/src/main/resources/plugin.yml index 88fae95..fc409e1 100644 --- a/app/src/main/resources/plugin.yml +++ b/app/src/main/resources/plugin.yml @@ -1,8 +1,8 @@ -name: MinzeoPlugin -version: 1.0.0 +name: DerverCore +version: 2.0.0 main: net.xuyezo.main.Main description: A test plugin -author: 08draven -website: https://xuyezo.net/ -api-version: '1.21.1' +author: BiglyDerv +website: https://dervland.net/ +api-version: '1.21.4' load: STARTUP \ No newline at end of file