mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
SPIGOT-5311: Add API to get/set item associated with throwable projectiles
This commit is contained in:
parent
689f429c50
commit
f7cdb53c0e
10 changed files with 97 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
--- a/net/minecraft/server/EntityFireballFireball.java
|
--- a/net/minecraft/server/EntityFireballFireball.java
|
||||||
+++ b/net/minecraft/server/EntityFireballFireball.java
|
+++ b/net/minecraft/server/EntityFireballFireball.java
|
||||||
@@ -18,7 +18,7 @@
|
@@ -18,14 +18,14 @@
|
||||||
|
|
||||||
public void b(ItemStack itemstack) {
|
public void b(ItemStack itemstack) {
|
||||||
if (itemstack.getItem() != Items.FIRE_CHARGE || itemstack.hasTag()) {
|
if (itemstack.getItem() != Items.FIRE_CHARGE || itemstack.hasTag()) {
|
||||||
|
@ -9,6 +9,14 @@
|
||||||
itemstack1.setCount(1);
|
itemstack1.setCount(1);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- protected ItemStack l() {
|
||||||
|
+ public ItemStack l() { // PAIL protected -> public
|
||||||
|
return (ItemStack) this.getDataWatcher().get(EntityFireballFireball.f);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -50,6 +50,6 @@
|
@@ -50,6 +50,6 @@
|
||||||
super.a(nbttagcompound);
|
super.a(nbttagcompound);
|
||||||
ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("Item"));
|
ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("Item"));
|
||||||
|
|
|
@ -11,3 +11,18 @@
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,7 +27,13 @@
|
||||||
|
|
||||||
|
protected abstract Item i();
|
||||||
|
|
||||||
|
- protected ItemStack getItem() {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ public Item getDefaultItem() {
|
||||||
|
+ return i();
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
|
+ public ItemStack getItem() { // PAIL protected -> public
|
||||||
|
return (ItemStack) this.getDataWatcher().get(EntityProjectileThrowable.e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.entity.Egg;
|
import org.bukkit.entity.Egg;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
public class CraftEgg extends CraftProjectile implements Egg {
|
public class CraftEgg extends CraftThrowableProjectile implements Egg {
|
||||||
public CraftEgg(CraftServer server, EntityEgg entity) {
|
public CraftEgg(CraftServer server, EntityEgg entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.entity.EnderPearl;
|
import org.bukkit.entity.EnderPearl;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
public class CraftEnderPearl extends CraftProjectile implements EnderPearl {
|
public class CraftEnderPearl extends CraftThrowableProjectile implements EnderPearl {
|
||||||
public CraftEnderPearl(CraftServer server, EntityEnderPearl entity) {
|
public CraftEnderPearl(CraftServer server, EntityEnderPearl entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LargeFireball;
|
import org.bukkit.entity.LargeFireball;
|
||||||
|
|
||||||
public class CraftLargeFireball extends CraftFireball implements LargeFireball {
|
public class CraftLargeFireball extends CraftSizedFireball implements LargeFireball {
|
||||||
public CraftLargeFireball(CraftServer server, EntityLargeFireball entity) {
|
public CraftLargeFireball(CraftServer server, EntityLargeFireball entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.bukkit.craftbukkit.entity;
|
||||||
|
|
||||||
|
import net.minecraft.server.EntityFireballFireball;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.SizedFireball;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class CraftSizedFireball extends CraftFireball implements SizedFireball {
|
||||||
|
|
||||||
|
public CraftSizedFireball(CraftServer server, EntityFireballFireball entity) {
|
||||||
|
super(server, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getDisplayItem() {
|
||||||
|
if (getHandle().l().isEmpty()) { // PAIL rename getItem
|
||||||
|
return new ItemStack(Material.FIRE_CHARGE);
|
||||||
|
} else {
|
||||||
|
return CraftItemStack.asBukkitCopy(getHandle().l()); // PAIL rename getItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDisplayItem(ItemStack item) {
|
||||||
|
getHandle().b(CraftItemStack.asNMSCopy(item)); // PAIL rename setItem
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityFireballFireball getHandle() {
|
||||||
|
return (EntityFireballFireball) entity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.SmallFireball;
|
import org.bukkit.entity.SmallFireball;
|
||||||
|
|
||||||
public class CraftSmallFireball extends CraftFireball implements SmallFireball {
|
public class CraftSmallFireball extends CraftSizedFireball implements SmallFireball {
|
||||||
public CraftSmallFireball(CraftServer server, EntitySmallFireball entity) {
|
public CraftSmallFireball(CraftServer server, EntitySmallFireball entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Snowball;
|
import org.bukkit.entity.Snowball;
|
||||||
|
|
||||||
public class CraftSnowball extends CraftProjectile implements Snowball {
|
public class CraftSnowball extends CraftThrowableProjectile implements Snowball {
|
||||||
public CraftSnowball(CraftServer server, EntitySnowball entity) {
|
public CraftSnowball(CraftServer server, EntitySnowball entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package org.bukkit.craftbukkit.entity;
|
||||||
|
|
||||||
|
import net.minecraft.server.EntityProjectileThrowable;
|
||||||
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.ThrowableProjectile;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public abstract class CraftThrowableProjectile extends CraftProjectile implements ThrowableProjectile {
|
||||||
|
|
||||||
|
public CraftThrowableProjectile(CraftServer server, EntityProjectileThrowable entity) {
|
||||||
|
super(server, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem() {
|
||||||
|
if (getHandle().getItem().isEmpty()) {
|
||||||
|
return CraftItemStack.asBukkitCopy(new net.minecraft.server.ItemStack(getHandle().getDefaultItem()));
|
||||||
|
} else {
|
||||||
|
return CraftItemStack.asBukkitCopy(getHandle().getItem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem(ItemStack item) {
|
||||||
|
getHandle().setItem(CraftItemStack.asNMSCopy(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityProjectileThrowable getHandle() {
|
||||||
|
return (EntityProjectileThrowable) entity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.ThrownExpBottle;
|
import org.bukkit.entity.ThrownExpBottle;
|
||||||
|
|
||||||
public class CraftThrownExpBottle extends CraftProjectile implements ThrownExpBottle {
|
public class CraftThrownExpBottle extends CraftThrowableProjectile implements ThrownExpBottle {
|
||||||
public CraftThrownExpBottle(CraftServer server, EntityThrownExpBottle entity) {
|
public CraftThrownExpBottle(CraftServer server, EntityThrownExpBottle entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue