ausgebildet
Redstoneengineer
Guten Tag, ich programmiere gerade einen CobbleGenerator für SkyBlock.
Es klappt auch alles super. Bis auf eines.
Sobald ich Wasser setze wird alles drum rum direkt replacet. Also das Wasser kommt garnicht erst zum fließen.
In etwas so :
--x
x x x -> Das hellblaue x steht hierbei für das Wasser.
--x
Ich nutze die Spigot 1.12.2 und folgenden Code.
Würde mich über jede Art von Hilfe freuen.
Grüße
Es klappt auch alles super. Bis auf eines.
Sobald ich Wasser setze wird alles drum rum direkt replacet. Also das Wasser kommt garnicht erst zum fließen.
In etwas so :
--x
x x x -> Das hellblaue x steht hierbei für das Wasser.
--x
Ich nutze die Spigot 1.12.2 und folgenden Code.
Code:
package com.ausgebildet.customcobblegenerator;
import java.io.File;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
public class CobbleEvents implements Listener {
public CobbleGenerator plugin;
public CobbleEvents(CobbleGenerator plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, this.plugin);
}
@SuppressWarnings({ "deprecation" })
@EventHandler
public void event(BlockFromToEvent event) {
File file = new File("plugins/CobbleGenerator", "chances.yml");
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
int i = event.getBlock().getTypeId();
if (i >= 8 && i <= 11) {
Block b = event.getToBlock();
int id = b.getTypeId();
if (id == 0 && generatesCobble(id, b)) {
if (b.getLocation().getWorld().getName().equalsIgnoreCase("world_nether")) {
Random r = new Random();
int c = 0;
for (int counter = 1; counter <= 1; counter++) {
c = 1 + r.nextInt(100);
}
double netherbrick = cfg.getDouble("Nether.Netherbrick");
double quartz = cfg.getDouble("Nether.Quartz");
double soulsand = cfg.getDouble("Nether.Soulsand");
double glowstone = cfg.getDouble("Nether.Glowstone");
if (c >= 0 && c <= netherbrick) {
b.setType(Material.NETHER_BRICK);
}
if (c >= netherbrick && c <= quartz) {
b.setType(Material.QUARTZ_ORE);
}
if (c >= quartz && c <= soulsand) {
b.setType(Material.SOUL_SAND);
}
if (c >= soulsand && c <= glowstone) {
b.setType(Material.GLOWSTONE);
}
if(c >= glowstone && c <= 100) {
b.setType(Material.NETHERRACK);
}
} else {
Random r = new Random();
int c = 0;
for (int counter = 1; counter <= 1; counter++) {
c = 1 + r.nextInt(100);
}
double andesit = cfg.getDouble("World.Andesite");
double diorite = cfg.getDouble("World.Diorite");
double granite = cfg.getDouble("World.Granite");
double coal = cfg.getDouble("World.Coal");
double iron = cfg.getDouble("World.Iron");
double gold = cfg.getDouble("World.Gold");
double redstone = cfg.getDouble("World.Redstone");
double lapis = cfg.getDouble("World.Lapis");
double emerald = cfg.getDouble("World.Emerald");
double diamond = cfg.getDouble("World.Diamond");
if (c >= 0 && c <= andesit) {
b.setTypeIdAndData(1, (byte) 1, true);
}
if (c >= andesit && c <= diorite) {
b.setTypeIdAndData(1, (byte) 3, true);
}
if (c >= diorite && c <= granite) {
b.setTypeIdAndData(1, (byte) 5, true);
}
if (c >= granite && c <= coal) {
b.setType(Material.COAL_ORE);
}
if (c >= coal && c <= iron) {
b.setType(Material.IRON_ORE);
}
if (c >= iron && c <= gold) {
b.setType(Material.GOLD_ORE);
}
if (c >= gold && c <= redstone) {
b.setType(Material.REDSTONE_ORE);
}
if (c >= redstone && c <= lapis) {
b.setType(Material.LAPIS_ORE);
}
if (c >= lapis && c <= emerald) {
b.setType(Material.EMERALD_ORE);
}
if (c >= emerald && c <= diamond) {
b.setType(Material.DIAMOND_ORE);
}
if (c >= diamond && c <= 100) {
b.setType(Material.COBBLESTONE);
}
}
}
}
}
private final BlockFace[] faces = { BlockFace.SELF, BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST,
BlockFace.SOUTH, BlockFace.WEST };
@SuppressWarnings("deprecation")
public boolean generatesCobble(int id, Block b) {
int mirrorID1 = (id == 8) || (id == 9) ? 10 : 8;
int mirrorID2 = (id == 8) || (id == 9) ? 11 : 9;
BlockFace[] arrayOfBlockFace;
int j = (arrayOfBlockFace = this.faces).length;
for (int i = 0; i < j; i++) {
BlockFace face = arrayOfBlockFace[i];
Block r = b.getRelative(face, 1);
if ((r.getTypeId() == mirrorID1) || (r.getTypeId() == mirrorID2)) {
return true;
}
}
return false;
}
}
Würde mich über jede Art von Hilfe freuen.
Grüße