mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
#1357: Remove legacy Particle values
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
parent
65bc2541a3
commit
1b0447274f
7 changed files with 19 additions and 19 deletions
|
@ -78,15 +78,6 @@ public abstract class CraftParticle<D> implements Keyed {
|
|||
return object;
|
||||
}
|
||||
|
||||
public static Particle convertLegacy(Particle particle) {
|
||||
return switch (particle) {
|
||||
case LEGACY_BLOCK_DUST -> Particle.BLOCK_DUST;
|
||||
case LEGACY_FALLING_DUST -> Particle.FALLING_DUST;
|
||||
case LEGACY_BLOCK_CRACK -> Particle.BLOCK_CRACK;
|
||||
default -> particle;
|
||||
};
|
||||
}
|
||||
|
||||
private final NamespacedKey key;
|
||||
private final net.minecraft.core.particles.Particle<?> particle;
|
||||
private final Class<D> clazz;
|
||||
|
|
|
@ -1869,7 +1869,6 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
|
||||
particle = CraftParticle.convertLegacy(particle);
|
||||
data = CraftParticle.convertLegacy(data);
|
||||
if (data != null) {
|
||||
Preconditions.checkArgument(particle.getDataType().isInstance(data), "data (%s) should be %s", data.getClass(), particle.getDataType());
|
||||
|
|
|
@ -122,7 +122,6 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
|
|||
|
||||
@Override
|
||||
public <T> void setParticle(Particle particle, T data) {
|
||||
particle = CraftParticle.convertLegacy(particle);
|
||||
data = CraftParticle.convertLegacy(data);
|
||||
if (data != null) {
|
||||
Preconditions.checkArgument(particle.getDataType().isInstance(data), "data (%s) should be %s", data.getClass(), particle.getDataType());
|
||||
|
|
|
@ -2240,7 +2240,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
|
||||
particle = CraftParticle.convertLegacy(particle);
|
||||
data = CraftParticle.convertLegacy(data);
|
||||
if (data != null) {
|
||||
Preconditions.checkArgument(particle.getDataType().isInstance(data), "data (%s) should be %s", data.getClass(), particle.getDataType());
|
||||
|
|
|
@ -5,12 +5,15 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
|||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
/**
|
||||
* @deprecated do not use for any reason
|
||||
|
@ -103,4 +106,14 @@ public final class CraftEvil {
|
|||
public static int getId(Material material) {
|
||||
return CraftLegacy.toLegacy(material).getId();
|
||||
}
|
||||
|
||||
public static Class<?> getDataType(Particle particle) {
|
||||
Class<?> clazz = particle.getDataType();
|
||||
|
||||
if (clazz == BlockData.class) {
|
||||
return MaterialData.class;
|
||||
}
|
||||
|
||||
return clazz;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,11 +261,6 @@ public class Commodore {
|
|||
case "SPELL_MOB_AMBIENT":
|
||||
super.visitFieldInsn(opcode, owner, "SPELL_MOB", desc);
|
||||
return;
|
||||
case "BLOCK_CRACK":
|
||||
case "BLOCK_DUST":
|
||||
case "FALLING_DUST":
|
||||
super.visitFieldInsn(opcode, owner, "LEGACY_" + name, desc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,6 +302,12 @@ public class Commodore {
|
|||
return;
|
||||
}
|
||||
|
||||
// Change Particle#getDataType() from BlockData to MaterialData for legacy plugins and particle
|
||||
if (owner.equals("org/bukkit/Particle") && name.equals("getDataType") && desc.equals("()Ljava/lang/Class;")) {
|
||||
visitor.visit(Opcodes.INVOKESTATIC, "org/bukkit/craftbukkit/legacy/CraftEvil", name, "(Lorg/bukkit/Particle;)Ljava/lang/Class;", false, samMethodType, instantiatedMethodType);
|
||||
return;
|
||||
}
|
||||
|
||||
if (owner.equals("org/bukkit/ChunkSnapshot") && name.equals("getBlockData") && desc.equals("(III)I")) {
|
||||
visitor.visit(opcode, owner, "getData", desc, itf, samMethodType, instantiatedMethodType);
|
||||
return;
|
||||
|
|
|
@ -54,7 +54,6 @@ public class ParticleTest extends AbstractTestingBase {
|
|||
@EnumSource(Particle.class)
|
||||
public void testMinecraftValuesPresent(Particle bukkit) {
|
||||
// TODO: 10/19/23 Remove with enum PR, it is then no longer needed, since the enum PR has a extra test for this
|
||||
bukkit = CraftParticle.convertLegacy(bukkit);
|
||||
Particle finalBukkit = bukkit;
|
||||
assertDoesNotThrow(() -> CraftParticle.bukkitToMinecraft(finalBukkit), String.format("""
|
||||
No minecraft particle found for bukkit particle %s.
|
||||
|
@ -65,7 +64,6 @@ public class ParticleTest extends AbstractTestingBase {
|
|||
@ParameterizedTest
|
||||
@EnumSource(Particle.class)
|
||||
public void testRightParticleParamCreation(Particle bukkit) {
|
||||
bukkit = CraftParticle.convertLegacy(bukkit);
|
||||
net.minecraft.core.particles.Particle<?> minecraft = CraftParticle.bukkitToMinecraft(bukkit);
|
||||
|
||||
if (bukkit.getDataType().equals(Void.class)) {
|
||||
|
|
Loading…
Reference in a new issue