SPIGOT-6273: Expose ItemFrame ItemDropChance through API

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2020-12-28 08:58:39 +11:00
parent 2eda6f0b01
commit 3e80d2e4ec
2 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,14 @@
--- a/net/minecraft/server/EntityItemFrame.java
+++ b/net/minecraft/server/EntityItemFrame.java
@@ -10,7 +10,7 @@
private static final Logger LOGGER = LogManager.getLogger();
private static final DataWatcherObject<ItemStack> ITEM = DataWatcher.a(EntityItemFrame.class, DataWatcherRegistry.g);
private static final DataWatcherObject<Integer> g = DataWatcher.a(EntityItemFrame.class, DataWatcherRegistry.b);
- private float ag = 1.0F;
+ public float ag = 1.0F; // PAIL itemDropChance
public boolean fixed;
public EntityItemFrame(EntityTypes<? extends EntityItemFrame> entitytypes, World world) {
@@ -53,16 +53,27 @@
@Override
protected void updateBoundingBox() {

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.EntityHanging;
import net.minecraft.server.EntityItemFrame;
@ -69,6 +70,17 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
return CraftItemStack.asBukkitCopy(getHandle().getItem());
}
@Override
public float getItemDropChance() {
return getHandle().ag;
}
@Override
public void setItemDropChance(float chance) {
Preconditions.checkArgument(0.0 <= chance && chance <= 1.0, "Chance outside range [0, 1]");
getHandle().ag = chance;
}
@Override
public Rotation getRotation() {
return toBukkitRotation(getHandle().getRotation());