This doesn't seem to be working with TNT? Is this intended? Even if I setYield with getYield there is no explosion damage. I'm trying to have a multiplier on a TNTPrimed entity. In my head it all seemed easy enough Code (Java): public TNTPrimed createPrimedTNT(String type, Location location, Float multiplier, int ticks, Sound sound, float pitch, JavaPlugin plugin) { TNTPrimed tnt = location.getWorld().spawn(location, TNTPrimed.class); location.getWorld().playSound(location, sound, 1, pitch); tnt.setYield(tnt.getYield() * multiplier); tnt.setMetadata("tntType", new FixedMetadataValue(plugin, type)); tnt.setFuseTicks(ticks); return tnt; } Update: Figured it out. My float was default to zero as there was a typo in the config path key.
What multiplier are you trying? Maybe add some debug prints- setYield definitely works, though I've never used getYield.
Just figured it out. Hard to get yield-multiplier from yeld-multipler lol, which had a default value of 0 (being no yeield as a multiplier)
Should work on spawn, too. I'm doing something very similar and it works (can make very large or very small explosions) Code (Text): TNTPrimed grenade = (TNTPrimed)context.getWorld().spawnEntity(targetLoc, EntityType.PRIMED_TNT); if (grenade == null) { return SpellResult.FAIL; } if (living != null) { CompatibilityUtils.setTNTSource(grenade, living); } Vector aim = context.getDirection(); grenade.setVelocity(aim); grenade.setYield(size); grenade.setFuseTicks(fuse); grenade.setIsIncendiary(useFire);
I use the setYield in the event so i can change also creepers explosions range, that's why i suggested that.
Thanks I figured it out. It was a typo. Oi. But I am curious. Because you use spawnEntity, does your primed TNT pass through the entity-based event listeners? Default bukkit uses spawn like I am using in my method which I wonder if that is why the TNTPrimed circumvents those events? Or are the events literally just ignoring TNTPrimed
I think it might throw you an error. I think spawnEntity() can be used only with LivingEntity. Not 100% sure though