本文整理汇总了Java中org.bukkit.entity.TNTPrimed.setFuseTicks方法的典型用法代码示例。如果您正苦于以下问题:Java TNTPrimed.setFuseTicks方法的具体用法?Java TNTPrimed.setFuseTicks怎么用?Java TNTPrimed.setFuseTicks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.TNTPrimed
的用法示例。
在下文中一共展示了TNTPrimed.setFuseTicks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockBreak
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
/**
* Spawns a creeper or primed TNT when a player breaks an ore block, by chance.
*
* @param event The event
*/
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (ORES.contains(block.getType())) {
double chance = Math.random();
Location location = block.getLocation().add(0.5, 0.5, 0.5);
if (0.05 > chance) {
TNTPrimed tnt = location.getWorld().spawn(location, TNTPrimed.class);
tnt.setFuseTicks(80);
} else if (0.1 > chance) {
Creeper creeper = location.getWorld().spawn(location, Creeper.class);
creeper.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 2));
}
}
}
示例2: remoteDetonation
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
/**
* Detonate TNT for Blast Mining
*/
public void remoteDetonation() {
Player player = getPlayer();
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) {
return;
}
TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class);
SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
tnt.setMetadata(mcMMO.tntMetadataKey, mcMMOPlayer.getPlayerMetadata());
tnt.setFuseTicks(0);
targetBlock.setType(Material.AIR);
mcMMOPlayer.setAbilityDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
}
示例3: doOnLeftClick
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@Override
public void doOnLeftClick(Racer racer, Action action)
{
// This will be performed in the event that you left-click with the item.
if(EquestrianDash.plugin.getConfig().getBoolean("Powerups.TNT.ThrowDirections.ThrowAheadEnabled"))
{
Player p = racer.getPlayer();
p.playSound(p.getLocation(), Sound.FUSE, 7, 1);
TNTPrimed tnt = p.getWorld().spawn(p.getLocation(), TNTPrimed.class);
tnt.setVelocity(p.getLocation().getDirection().normalize().multiply(EquestrianDash.plugin.getConfig().getDouble("Powerups.TNT.ThrowDirections.ThrowAheadMultiplier")));
tnt.setFuseTicks(EquestrianDash.plugin.getConfig().getInt("Powerups.TNT.ThrowDirections.ThrowAheadTicks"));
racer.getPlayer().getInventory().clear();
}
}
示例4: run
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@Override
public boolean run(Player player, ConfigurationSection config) {
Location loc = player.getTargetBlock(null, config.getInt("max_distence")).getLocation();
final TNTPrimed tnt = player.getWorld().spawn(loc.add(0, 1, 0), TNTPrimed.class);
tnt.setYield((float) config.getDouble("power"));
tnt.setIsIncendiary(config.getBoolean("enable_fire"));
tnt.setFuseTicks(0);
bombSites.put(tnt, player.getName());
Bukkit.getScheduler().scheduleSyncDelayedTask(RodsTwo.getInstance(), new Runnable(){
@Override
public void run() {
bombSites.remove(tnt);
}}, 10L);
//player.getWorld().createExplosion(loc, (float) config.getDouble("power"), config.getBoolean("enable_fire"));
return true;
}
示例5: handleInstantActivation
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleInstantActivation(BlockPlaceEvent event) {
if(this.properties.instantIgnite && event.getBlock().getType() == Material.TNT) {
World world = event.getBlock().getWorld();
TNTPrimed tnt = world.spawn(BlockUtils.base(event.getBlock()), TNTPrimed.class);
if(this.properties.fuse != null) {
tnt.setFuseTicks(this.getFuseTicks());
}
if(this.properties.power != null) {
tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield
}
if(callPrimeEvent(tnt, event.getPlayer(), true)) {
// Only cancel the block placement if the prime event is NOT cancelled.
// If priming is cancelled, the block is allowed to stay (unless some
// other handler has already cancelled the place event).
event.setCancelled(true);
world.playSound(tnt.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
ItemStack inHand = event.getItemInHand();
if(inHand.getAmount() == 1) {
inHand = null;
} else {
inHand.setAmount(inHand.getAmount() - 1);
}
event.getPlayer().getInventory().setItem(event.getHand(), inHand);
}
}
}
示例6: setCustomProperties
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void setCustomProperties(ExplosionPrimeEvent event) {
if(event.getEntity() instanceof TNTPrimed) {
TNTPrimed tnt = (TNTPrimed) event.getEntity();
if(this.properties.fuse != null) {
tnt.setFuseTicks(this.getFuseTicks());
}
if(this.properties.power != null) {
tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield
}
}
}
示例7: dispenserNukes
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void dispenserNukes(BlockTransformEvent event) {
BlockState oldState = event.getOldState();
if(oldState instanceof Dispenser &&
this.properties.dispenserNukeLimit > 0 &&
this.properties.dispenserNukeMultiplier > 0 &&
event.getCause() instanceof EntityExplodeEvent) {
EntityExplodeEvent explodeEvent = (EntityExplodeEvent) event.getCause();
Dispenser dispenser = (Dispenser) oldState;
int tntLimit = Math.round(this.properties.dispenserNukeLimit / this.properties.dispenserNukeMultiplier);
int tntCount = 0;
for(ItemStack stack : dispenser.getInventory().contents()) {
if(stack != null && stack.getType() == Material.TNT) {
int transfer = Math.min(stack.getAmount(), tntLimit - tntCount);
if(transfer > 0) {
stack.setAmount(stack.getAmount() - transfer);
tntCount += transfer;
}
}
}
tntCount = (int) Math.ceil(tntCount * this.properties.dispenserNukeMultiplier);
for(int i = 0; i < tntCount; i++) {
TNTPrimed tnt = this.getMatch().getWorld().spawn(BlockUtils.base(dispenser), TNTPrimed.class);
tnt.setFuseTicks(10 + this.getMatch().getRandom().nextInt(10)); // between 0.5 and 1.0 seconds, same as vanilla TNT chaining
Random random = this.getMatch().getRandom();
Vector velocity = new Vector(random.nextGaussian(), random.nextGaussian(), random.nextGaussian()); // uniform random direction
velocity.normalize().multiply(0.5 + 0.5 * random.nextDouble());
tnt.setVelocity(velocity);
callPrimeEvent(tnt, explodeEvent.getEntity(), false);
}
}
}
示例8: onThrowTNT
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@EventHandler
public void onThrowTNT(PlayerInteractEvent event) {
Player p = event.getPlayer();
Gamer g = Gamer.get(p.getName());
if (g.getVariable("spectator") != null)
return;
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (p.getItemInHand().getType() == Material.TNT) {
// Frag Grenades
TNTPrimed e = (TNTPrimed) event.getPlayer().getWorld().spawnEntity(p.getEyeLocation(), EntityType.PRIMED_TNT);
e.setFuseTicks(38);
e.setYield(2.5F);
e.setVelocity(event.getPlayer().getEyeLocation().getDirection());
e.setMetadata("Player", new FixedMetadataValue(Nexus.getPlugin(), g.getPlayer().getName()));
e.setMetadata("Cause", new FixedMetadataValue(Nexus.getPlugin(), CustomDamageCause.TNT_GRENADE.name()));
event.setUseItemInHand(Event.Result.DENY);
ItemStack stack = null;
if (event.getItem().getAmount() > 1) {
ItemStack s = event.getItem();
s.setAmount(event.getItem().getAmount() - 1);
stack = s;
}
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), stack);
event.setCancelled(true);
}
}
}
示例9: onPlayerInteract
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Gamer g = Gamer.get(event.getPlayer());
if (event.getAction() != Action.PHYSICAL)
return;
Block b = event.getClickedBlock();
if (!b.hasMetadata("Mine"))
return;
Mine mine = Mine.getList().get(b.getMetadata("Mine").get(0).asInt());
Team playerTeam = Nexus.getRotary().getCurrentMap().getTeam(g);
Team targetTeam = Nexus.getRotary().getCurrentMap().getTeam(mine.getGamer());
if (playerTeam == targetTeam)
return;
mine.setIgnited(true);
TNTPrimed e = (TNTPrimed) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getEyeLocation(), EntityType.PRIMED_TNT);
e.setFuseTicks(10);
e.setYield(2.7F);
e.setMetadata("Player", new FixedMetadataValue(Nexus.getPlugin(), mine.getGamer().getName()));
e.setMetadata("Cause", new FixedMetadataValue(Nexus.getPlugin(), CustomDamageCause.TNT_MINE.name()));
event.getClickedBlock().setType(Material.AIR);
}
示例10: onBlockPlace
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
/**
* Fire the TNT's automatically
*
* @param event Event
*/
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
if (this.game != null && this.game.isPvPActivated() && event.getBlock().getType() == Material.TNT)
{
event.getBlock().setType(Material.AIR);
TNTPrimed tnt = event.getBlock().getWorld().spawn(event.getBlock().getLocation(), TNTPrimed.class);
tnt.setFuseTicks(tnt.getFuseTicks() / 2);
}
}
示例11: onBlockPlace
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockPlace(BlockPlaceEvent ev) {
Player p = ev.getPlayer();
// BlockData block = plugin.getArenaManager().getBlock(location);
Material type = ev.getBlock().getType();
GameManager gameMan = plugin.getGameManager();
ArenaManager arenaMan = plugin.getArenaManager();
ArenaData aData = arenaMan.getCurrentArena();
if(!arenaMan.isEditing(p.getName(), p.getWorld().getName())) {
if(gameMan.isSpectator(p)) {
ev.setCancelled(true);
} else if(gameMan.getState() != SGGameState.GAME
&& gameMan.getState() != SGGameState.DEATHMATCH) {
ev.setCancelled(true);
} else if(aData != null && !aData.placeWhitelist.contains(type)) {
ev.setCancelled(true);
}
}
if(!ev.isCancelled()) {
// Allowed
if(ev.getBlock().getType() == Material.TNT) {
ev.getBlock().setType(Material.AIR);
TNTPrimed tnt = (TNTPrimed) p.getWorld().spawnEntity(ev.getBlock().getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(plugin.getSettings().tntTicks);
tnt.setMetadata("explode", new FixedMetadataValue(plugin, false));
}
// else if (block == null
// && !arenaMan.isEditing(p.getName(), p.getWorld().getName())) {
// block = new BlockData();
// block.location = location;
// block.type = Material.AIR;
// block.data = 0;
// plugin.getDebug().normal("OnBlockPlace");
// plugin.getArenaManager().setBlock(p.getName(), p.getWorld(), block);
// }
}
}
示例12: handleTraps
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
private void handleTraps() {
Player player = getPlayer();
if (Permissions.trapsBypass(player)) {
return;
}
if (Misc.getRandom().nextBoolean()) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.Boom"));
TNTPrimed tnt = (TNTPrimed) player.getWorld().spawnEntity(fishingCatch.getLocation(), EntityType.PRIMED_TNT);
fishingCatch.setPassenger(tnt);
Vector velocity = fishingCatch.getVelocity();
double magnitude = velocity.length();
fishingCatch.setVelocity(velocity.multiply((magnitude + 1) / magnitude));
tnt.setMetadata(mcMMO.tntsafeMetadataKey, mcMMO.metadataValue);
tnt.setFuseTicks(3 * Misc.TICK_CONVERSION_FACTOR);
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.Poison"));
ThrownPotion thrownPotion = player.getWorld().spawn(fishingCatch.getLocation(), ThrownPotion.class);
thrownPotion.setItem(new Potion(PotionType.POISON).splash().toItemStack(1));
fishingCatch.setPassenger(thrownPotion);
}
}
示例13: effect
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@Override
public void effect(Event e, ItemStack item, int level) {
PlayerDeathEvent event = (PlayerDeathEvent) e;
for(int i = level; i >= 0; i--) {
TNTPrimed tnt = (TNTPrimed) event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(delay);
tnt.setVelocity(new Vector(Tools.random.nextDouble()*1.5 - 1, Tools.random.nextDouble() * 1.5, Tools.random.nextDouble()*1.5 - 1));
if(!Main.createExplosions)
tnt.setMetadata("ce.explosive", new FixedMetadataValue(getPlugin(), null));
}
}
示例14: doOnRightClick
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@Override
public void doOnRightClick(Racer racer, Action action)
{
racer.getPlayer().sendMessage(getMessage());
// This will be performed in the event that you right-click with the item.
if (EquestrianDash.plugin.getConfig().getBoolean("Powerups.TNT.ThrowDirections.ThrowBehindEnabled"))
{
Player p = racer.getPlayer();
p.playSound(p.getLocation(), Sound.FUSE, 7, 1);
TNTPrimed tnt = p.getWorld().spawn(p.getLocation(), TNTPrimed.class);
tnt.setFuseTicks(EquestrianDash.plugin.getConfig().getInt("Powerups.TNT.ThrowDirections.ThrowBehindTicks"));
racer.getPlayer().getInventory().clear();
}
}
示例15: onExplosionPrime
import org.bukkit.entity.TNTPrimed; //导入方法依赖的package包/类
@EventHandler
public void onExplosionPrime(ExplosionPrimeEvent event) {
if (event.getEntity() instanceof TNTPrimed) {
TNTPrimed tnt = (TNTPrimed) event.getEntity();
if (fuse != 4) {
tnt.setFuseTicks(fuse);
}
if (power != 4.0) {
tnt.setYield((float) power);
}
}
}