Skocz do zawartości
  • 0

Wybuchanie wody poprzez TNT


Pytanie

Mam oto taki kod: 

 

	@Override
	public void onEnable(){
		Bukkit.getServer().getPluginManager().registerEvents(this , this);
	}
	
	@EventHandler
	public void onExplode(EntityExplodeEvent e){
		Settings ss = Settings.getInstance();
		Region region = RegionUtils.getAt(e.getLocation());
		if (region == null){
			return;
		}
		Guild g = region.getGuild();
		if (g == null || g.getName() == null){
			return;
		}
		if (g != null) {
			List<Location> s = sphere(e.getLocation(), 5, 5, false, true, 0);
			Map ExplodeMaterials = ss.explodeMaterials;
			for (final Location loc : s) {
				Material mat = loc.getBlock().getType();
				if (ExplodeMaterials.containsKey(mat)) {
					if(mat.equals(Material.WATER)){
						loc.getBlock().setType(Material.AIR);
					}
					else{ loc.getBlock().breakNaturally();
					}
				}
				if (mat.equals(Material.JUKEBOX)) {
					Bukkit.getScheduler().runTaskLater(new Main(), new Runnable(){
						public void run(){
							loc.getBlock().setType(Material.JUKEBOX);
						}
					}, 1L);
				}
			}
			g.setBuild(System.currentTimeMillis() + Settings.getInstance().regionExplode * 1000L);
		    for (User user : g.getMembers()){
		      Player player = Bukkit.getPlayer(user.getName());
		      if (player != null) {
		        player.sendMessage(Messages.getInstance().getMessage("regionExplode")
		          .replace("{TIME}", Integer.toString(Settings.getInstance().regionExplode)));
		      }
		    }
		}
	}
	
	public static List<Location> sphere(Location loc, int radius, int height, boolean hollow, boolean sphere, int plusY){
		List circleblocks = new ArrayList();
		int cx = loc.getBlockX();
		int cy = loc.getBlockY();
		int cz = loc.getBlockZ();
		for (int x = cx - radius; x <= cx + radius; x++) {
			for (int z = cz - radius; z <= cz + radius; z++) {
				for (int y = sphere ? cy - radius : cy; y < (sphere ? cy + radius : cy + height); y++) {
					double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
					if ((dist < radius * radius) && ((!hollow) || (dist >= (radius - 1) * (radius - 1)))) {
						Location l = new Location(loc.getWorld(), x, y + plusY, z);
						circleblocks.add(l);
					}
				}
			}
		}
		return circleblocks;
		}

 

 

ale oczywiście nie działa tylko to co chcę :(

Material mat = loc.getBlock().getType();
				if (ExplodeMaterials.containsKey(mat)) {
					if(mat.equals(Material.WATER)){
						loc.getBlock().setType(Material.AIR);
					}
					else{ loc.getBlock().breakNaturally();
					}
				}
				if (mat.equals(Material.JUKEBOX)) {
					Bukkit.getScheduler().runTaskLater(new Main(), new Runnable(){
						public void run(){
							loc.getBlock().setType(Material.JUKEBOX);
						}
					}, 1L);
				}

 

Pomoże ktoś to naprawić?

Odnośnik do komentarza
https://skript.pl/temat/20421-wybuchanie-wody-poprzez-tnt/
Udostępnij na innych stronach

2 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0

Jesteś pewny, że jest to Material.WATER? Sprawdź przy użyciu czegoś takiego:

if(mat.equals(Material.WATER) || mat.equals(Material.STATIONARY_WATER)){
    loc.getBlock().setType(Material.AIR);
}

Jeśli nadal nie działa to sobie zdebuguj i pokaż rezultaty.

Edytowane przez Nieaktywny
Odnośnik do komentarza
https://skript.pl/temat/20421-wybuchanie-wody-poprzez-tnt/#findComment-138535
Udostępnij na innych stronach

  • 0

zamiast anulować event i ręcznie ustawiać bloki na powietrze czy .break, to użyj z eventu tej listy bloków: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityExplodeEvent.html#blockList--

i dodawaj/usuwaj bloki, tam są wszystkie co mają być zniszczone.

Odnośnik do komentarza
https://skript.pl/temat/20421-wybuchanie-wody-poprzez-tnt/#findComment-138551
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...