本文整理汇总了Java中org.spongepowered.api.effect.particle.ParticleTypes类的典型用法代码示例。如果您正苦于以下问题:Java ParticleTypes类的具体用法?Java ParticleTypes怎么用?Java ParticleTypes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParticleTypes类属于org.spongepowered.api.effect.particle包,在下文中一共展示了ParticleTypes类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spiral
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
public void spiral(IActiveCharacter character) {
ParticleEffect build = ParticleEffect.builder().type(ParticleTypes.SMOKE)
.quantity(1).build();
double rot = 0.125;
Vector3d position = character.getLocation().getPosition();
World w = character.getLocation().getExtent();
while (rot < 1) {
new ParticleDecorator()
.spiral(
4,
32,
7,
rot,
vector3d -> {
Vector3d vector3d1 = VectorUtils.rotateAroundAxisY(character.getLocation().add(vector3d).getPosition(), 30);
w.spawnParticles(build, vector3d1);
});
rot += 0.125;
}
}
示例2: onApply
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
@Override
public void onApply() {
super.onApply();
character.setProperty(DefaultProperties.walk_speed, getGlobalScope().characterService.getCharacterProperty(character, DefaultProperties.walk_speed) + speedbonus);
getGlobalScope().characterService.updateWalkSpeed(character);
Location<World> location = getConsumer().getLocation();
ParticleEffect build = ParticleEffect.builder()
.type(ParticleTypes.CLOUD)
.velocity(new Vector3d(0, 0.8, 0))
.quantity(2).build();
Vector3d[] smallCircle = ParticleDecorator.smallCircle;
for (Vector3d vector3d : smallCircle) {
location.getExtent().spawnParticles(build, location.getPosition().add(vector3d));
}
getConsumer().sendMessage(Localization.SPEED_BOOST_APPLY);
}
示例3: generateDefaultList
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
private List<Trail> generateDefaultList() {
final ArrayList<Trail> trails = new ArrayList<>();
trails.add(new Trail(HappyTrails.PLUGIN_ID + ":hearts", "Hearts", 10, 30, ParticleEffect.builder()
.type(ParticleTypes.HEART)
.quantity(7)
.option(ParticleOptions.VELOCITY, Trail.DEFAULT_VELOCITY)
.build()));
this.defaultTrail = "happytrails:hearts";
trails.add(new Trail(HappyTrails.PLUGIN_ID + ":villager_happy", "Happy Villager", 10, 30, ParticleEffect.builder()
.type(ParticleTypes.HAPPY_VILLAGER)
.quantity(13)
.option(ParticleOptions.VELOCITY, Trail.DEFAULT_VELOCITY)
.option(ParticleOptions.OFFSET, Trail.DEFAULT_VELOCITY)
.build()));
trails.add(new Trail(HappyTrails.PLUGIN_ID + ":villager_storm", "Stormy Villager", 10, 30, ParticleEffect.builder()
.type(ParticleTypes.ANGRY_VILLAGER)
.quantity(5)
.option(ParticleOptions.VELOCITY, new Vector3d(0, 0.1, 0))
.option(ParticleOptions.OFFSET, new Vector3d(0, 3, 0))
.build()
));
trails.add(new Trail(HappyTrails.PLUGIN_ID + ":crit_strike", "Critical Strike", 5, 20, ParticleEffect.builder()
.type(ParticleTypes.CRITICAL_HIT)
.quantity(10)
.option(ParticleOptions.OFFSET, new Vector3d(10, 3, 10))
.option(ParticleOptions.COLOR, Color.DARK_CYAN)
.build()
));
trails.add(new Trail(HappyTrails.PLUGIN_ID + ":cloud", "Clouds", 2, 10, ParticleEffect.builder()
.type(ParticleTypes.CLOUD)
.quantity(2)
.option(ParticleOptions.OFFSET, new Vector3d(0, 3, 0))
.option(ParticleOptions.VELOCITY, new Vector3d(0.01, 0.01, 0.01))
.build()
));
return trails;
}
示例4: VanishEntitySpawnEffects
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
VanishEntitySpawnEffects(Vanish plugin) {
this.plugin = plugin;
this.effect = ParticleEffect.builder().type(ParticleTypes.LARGE_SMOKE).quantity(1).build();
// Set up permissions/entities map.
this.permEntityMap.put(Vanish.PERMISSION_EFFECTS_BATS, EntityTypes.BAT);
this.permEntityMap.put(Vanish.PERMISSION_EFFECTS_CATS, EntityTypes.OCELOT);
// Register to listen to events.
Sponge.getEventManager().registerListeners(this.plugin, this);
}
示例5: execute
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
Player targetPlayer = args.<Player>getOne(Text.of("player")).get();
IntegratedRunnable runnable = new IntegratedRunnable() {
@Override
public boolean run(int times) {
for (int i = 0; i < 75; ++i) {
ParticleEffect effect = ParticleEffect.builder().type(ParticleTypes.HEART).quantity(1).build();
targetPlayer.getWorld().spawnParticles(effect, targetPlayer.getLocation().getPosition().add(
getRangedRandom(-5.0, 5.0),
getRangedRandom(-2, 5.0),
getRangedRandom(-5.0, 5.0)
));
}
return true;
}
@Override
public void end() {
}
};
TimedRunnable timedRunnable = new TimedRunnable<>(runnable, 20);
timedRunnable.setTask(Task.builder().execute(
timedRunnable
).intervalTicks(5).submit(SkreePlugin.inst()));
return CommandResult.success();
}
示例6: playCreateEffect
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
private static void playCreateEffect(Location<World> loc)
{
ParticleEffect effect = ParticleEffect.builder().type(ParticleTypes.CLOUD).build();
Vector3d center = loc.getPosition().add(0.5, 0.5, 0.5);
for (Direction effectDir : Direction.values())
{
if (effectDir.isCardinal() || effectDir.isUpright())
{
loc.getExtent().spawnParticles(effect, center.add(effectDir.asOffset().div(1.9)));
}
}
loc.getExtent().playSound(SoundTypes.BLOCK_ANVIL_USE, loc.getPosition(), 1);
}
示例7: toParticle
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
public static ParticleType toParticle(Effect effect) {
if (effect.getType() == Effect.Type.VISUAL) {
switch (effect) {
case SMOKE:
return ParticleTypes.SMOKE_NORMAL;
default:
return null;
}
}
return null;
}
示例8: toggleMarkJob
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
public static void toggleMarkJob(Player player)
{
if (markJobs.containsKey(player.getUniqueId()))
{
Sponge.getScheduler().getTaskById(markJobs.get(player.getUniqueId())).ifPresent(task -> {task.cancel();});
markJobs.remove(player.getUniqueId());
return;
}
ParticleEffect nationParticule = ParticleEffect.builder().type(ParticleTypes.DRAGON_BREATH).quantity(1).build();
ParticleEffect zoneParticule = ParticleEffect.builder().type(ParticleTypes.HAPPY_VILLAGER).quantity(1).build();
Task t = Sponge.getScheduler()
.createTaskBuilder()
.execute(task -> {
if (!player.isOnline())
{
task.cancel();
markJobs.remove(player.getUniqueId());
return;
}
Location<World> loc = player.getLocation().add(0, 2, 0);
loc = loc.sub(8, 0, 8);
for (int x = 0; x < 16; ++x)
{
for (int y = 0; y < 16; ++y)
{
Nation nation = DataHandler.getNation(loc);
if (nation != null)
{
BlockRay<World> blockRay = BlockRay.from(loc).direction(new Vector3d(0, -1, 0)).distanceLimit(50).stopFilter(BlockRay.blockTypeFilter(BlockTypes.AIR)).build();
Optional<BlockRayHit<World>> block = blockRay.end();
if (block.isPresent())
{
if (nation.getZone(loc) != null)
{
player.spawnParticles(zoneParticule, block.get().getPosition(), 60);
}
else
{
player.spawnParticles(nationParticule, block.get().getPosition(), 60);
}
}
}
loc = loc.add(0,0,1);
}
loc = loc.add(1,0,0);
loc = loc.sub(0,0,16);
}
})
.delay(1, TimeUnit.SECONDS)
.interval(1, TimeUnit.SECONDS)
.async()
.submit(NationsPlugin.getInstance());
markJobs.put(player.getUniqueId(), t.getUniqueId());
}
示例9: onMiningProgress
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
@Listener(order = Order.BEFORE_POST)
public void onMiningProgress(MiningProgressEvent event) {
Player player = event.getPlayer();
BlockSnapshot snapshot = event.getSnapshot();
Location<World> location = snapshot.getLocation()
.orElseThrow(() -> new IllegalStateException("Could not access the location of the block that is being mined."));
CustomItemLibrary.getInstance().getService().getBlock(location)
.filter(SimpleCustomBlock.class::isInstance)
.map(SimpleCustomBlock.class::cast)
.ifPresent(customBlock -> {
SimpleCustomBlockDefinition definition = customBlock.getDefinition();
double hardness = definition.getHardness();
Optional<ItemStack> itemInHand = player.getItemInHand(HandTypes.MAIN_HAND);
boolean correctToolUsed = definition.getCorrectToolPredicate().isCorrectTool(itemInHand.orElse(null));
double requiredDuration = MiningManager.computeDuration(player, itemInHand.orElse(null),
correctToolUsed, hardness);
if (event.getDuration() >= requiredDuration) {
Cause cause = event.getCause();
CustomBlockBreakEvent customEvent = CustomBlockBreakEvent.of(customBlock, cause);
Sponge.getEventManager().post(customEvent);
if(customEvent.isCancelled())
return;
if(correctToolUsed) {
spawnDrops(snapshot, customBlock, player, cause);
}
World world = location.getExtent();
ParticleEffect particleEffect = ParticleEffect.builder()
.type(ParticleTypes.BREAK_BLOCK)
.option(ParticleOptions.BLOCK_STATE, definition.getEffectState())
.build();
Vector3d particlePosition = location.getBlockPosition().toDouble();
world.spawnParticles(particleEffect, particlePosition);
event.setCancelled(true);
customBlock.remove(cause);
} else {
ArmorStand damageIndicatorArmorStand = getOrSpawnDamageIndicatorArmorStand(customBlock);
String currentModel = definition.isGenerateDamageIndicatorModels() ? customBlock.getModel() : null;
double progress = event.getDuration() / requiredDuration;
String damageIndicatorModel = getDamageIndicatorModel(currentModel, progress);
ItemStack damageIndicatorItemStack = DurabilityRegistry.getInstance()
.createItemUnsafe(DAMAGE_INDICATOR_ITEM_TYPE, definition.getPluginContainer(), damageIndicatorModel);
damageIndicatorArmorStand.setHelmet(damageIndicatorItemStack);
}
});
}
示例10: ParticleTypeRegistryModule
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
public ParticleTypeRegistryModule() {
super(ParticleTypes.class);
}
示例11: cast
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
@Override
public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo info, SkillModifier modifier) {
Player p = character.getPlayer();
World world = p.getWorld();
Entity optional = world.createEntity(EntityTypes.TIPPED_ARROW, p.getLocation().getPosition().add(cos((p.getRotation().getX() - 90) % 360) * 0.2, 1.8, sin((p.getRotation().getX() - 90) % 360) * 0.2));
Vector3d rotation = p.getRotation();
Vector3d direction = Quaterniond.fromAxesAnglesDeg(rotation.getX(), -rotation.getY(), rotation.getZ()).getDirection();
TippedArrow sb = (TippedArrow) optional;
sb.setShooter(p);
Vector3d arrowVec = direction.normalize().mul(2);
sb.setVelocity(arrowVec);
double range = getDoubleNodeValue(info, SkillNodes.RANGE);
//final double rangeSquared = Math.pow(range, 2);
world.spawnEntity(sb);
cache.put(sb.getUniqueId(), System.currentTimeMillis());
ParticleEffect eff = ParticleEffect.builder()
.quantity(1)
.type(ParticleTypes.CRITICAL_HIT)
.build();
Sponge.getScheduler().createTaskBuilder().execute(new Consumer<Task>() {
double distTraveledSquared = 0;
Location<World> prev;
@Override
public void accept(Task task) {
if (sb.isRemoved()) {
task.cancel();
return;
}
if (prev != null) {
distTraveledSquared += sb.getLocation().getPosition().distance(prev.getPosition());
}
if (distTraveledSquared >= range) {
cache.remove(sb.getUniqueId());
sb.remove();
task.cancel();
return;
}
prev = sb.getLocation();
sb.setVelocity(arrowVec);
double dist = p.getLocation().getPosition().distance(sb.getLocation().getPosition());
Location<World> to = p.getLocation().copy();
double printer = 0.0D;
while (printer < dist) {
to.getExtent().spawnParticles(eff, to.getPosition());
to = to.add(sb.getLocation().getPosition().sub(p.getLocation().getPosition()).normalize());
printer = to.getPosition().distance(p.getLocation().getPosition());
}
}
}).delay(0, TimeUnit.MILLISECONDS)
.interval(50, TimeUnit.MILLISECONDS)
.submit(plugin);
return SkillResult.OK;
}
示例12: process
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
@Override
public STAGE process(IEffectConsumer consumer) {
ParticleUtils.drawSquare(consumer.getEntity().getLocation(), 2, ParticleEffect.builder().type(ParticleTypes.SMOKE).build());
return B;
}
示例13: getEffect
import org.spongepowered.api.effect.particle.ParticleTypes; //导入依赖的package包/类
public ParticleEffect getEffect() {
ParticleEffect particle = ParticleEffect.builder().type(ParticleTypes.BLOCK_CRACK).option(ParticleOptions.BLOCK_STATE, state).option(ParticleOptions.QUANTITY, count).offset(p_offset).build();
return particle;
}