mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
优化
This commit is contained in:
@@ -5,12 +5,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.momirealms.craftengine.bukkit.api.BukkitAdaptors;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MRegistryOps;
|
||||
import net.momirealms.craftengine.bukkit.util.ParticleUtils;
|
||||
import net.momirealms.craftengine.bukkit.world.particle.BukkitParticleType;
|
||||
import net.momirealms.craftengine.core.plugin.Platform;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
import net.momirealms.craftengine.core.world.particle.ParticleType;
|
||||
import net.momirealms.sparrow.nbt.CompoundTag;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -62,4 +67,13 @@ public class BukkitPlatform implements Platform {
|
||||
}
|
||||
return BukkitAdaptors.adapt(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleType getParticleType(Key name) {
|
||||
Particle particle = ParticleUtils.getParticle(name);
|
||||
if (particle == null) {
|
||||
throw new IllegalArgumentException("Invalid particle: " + name);
|
||||
}
|
||||
return new BukkitParticleType(particle, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.*;
|
||||
import net.momirealms.craftengine.core.world.particle.ParticleData;
|
||||
import net.momirealms.craftengine.core.world.particle.ParticleType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.SoundCategory;
|
||||
@@ -106,8 +107,8 @@ public class BukkitWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Position location, Key particle, int count, double xOffset, double yOffset, double zOffset, double speed, @Nullable ParticleData extraData, @NotNull Context context) {
|
||||
Particle particleType = ParticleUtils.getParticle(particle);
|
||||
public void spawnParticle(Position location, ParticleType particle, int count, double xOffset, double yOffset, double zOffset, double speed, @Nullable ParticleData extraData, @NotNull Context context) {
|
||||
Particle particleType = (Particle) particle.platformParticle();
|
||||
if (particleType == null) return;
|
||||
org.bukkit.World platformWorld = platformWorld();
|
||||
platformWorld.spawnParticle(particleType, location.x(), location.y(), location.z(), count, xOffset, yOffset, zOffset, speed, extraData == null ? null : ParticleUtils.toBukkitParticleData(extraData, context, platformWorld, location.x(), location.y(), location.z()));
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.momirealms.craftengine.bukkit.world.particle;
|
||||
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.world.particle.ParticleType;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public class BukkitParticleType implements ParticleType {
|
||||
private final Particle particle;
|
||||
private final Key type;
|
||||
|
||||
public BukkitParticleType(Particle particle, Key type) {
|
||||
this.particle = particle;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle platformParticle() {
|
||||
return particle;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user