Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Implement API to get and set FireworkMeta on Firework entities
Dieser Commit ist enthalten in:
Ursprung
fdb4b2d911
Commit
2ee62eb580
@ -1,15 +1,37 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityFireworks;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.ItemStack;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
|
||||
public class CraftFirework extends CraftEntity implements Firework {
|
||||
private static final int FIREWORK_ITEM_INDEX = 8;
|
||||
|
||||
private final CraftItemStack item;
|
||||
|
||||
public CraftFirework(CraftServer server, EntityFireworks entity) {
|
||||
super(server, entity);
|
||||
|
||||
ItemStack item = getHandle().getDataWatcher().f(FIREWORK_ITEM_INDEX);
|
||||
|
||||
if (item == null) {
|
||||
item = new ItemStack(Item.FIREWORKS);
|
||||
getHandle().getDataWatcher().watch(FIREWORK_ITEM_INDEX, item);
|
||||
}
|
||||
|
||||
this.item = CraftItemStack.asCraftMirror(item);
|
||||
|
||||
// Ensure the item is a firework...
|
||||
if (this.item.getType() != Material.FIREWORK) {
|
||||
this.item.setType(Material.FIREWORK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -25,4 +47,12 @@ public class CraftFirework extends CraftEntity implements Firework {
|
||||
public EntityType getType() {
|
||||
return EntityType.FIREWORK;
|
||||
}
|
||||
|
||||
public FireworkMeta getFireworkMeta() {
|
||||
return (FireworkMeta) item.getItemMeta();
|
||||
}
|
||||
|
||||
public void setFireworkMeta(FireworkMeta meta) {
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren