From 4e6c8a8362543696756372b66a8e6a07e66e32d4 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 23 Jul 2016 10:55:43 +1000 Subject: [PATCH] Enhance Beacon Block API By: md_5 --- paper-server/nms-patches/TileEntityBeacon.patch | 17 ++++++++--------- .../bukkit/craftbukkit/block/CraftBeacon.java | 13 +++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/paper-server/nms-patches/TileEntityBeacon.patch b/paper-server/nms-patches/TileEntityBeacon.patch index 7440468b08..7444710428 100644 --- a/paper-server/nms-patches/TileEntityBeacon.patch +++ b/paper-server/nms-patches/TileEntityBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntityBeacon.java +++ b/net/minecraft/server/TileEntityBeacon.java -@@ -9,19 +9,61 @@ +@@ -9,19 +9,58 @@ import java.util.Set; import javax.annotation.Nullable; @@ -20,9 +20,11 @@ - private int k = -1; + public int k = -1; // PAIL: private -> public @Nullable - private MobEffectList l; +- private MobEffectList l; ++ public MobEffectList l; // PAIL: private -> public @Nullable - private MobEffectList m; +- private MobEffectList m; ++ public MobEffectList m; // PAIL: private -> public private ItemStack inventorySlot; private String o; + // CraftBukkit start - add fields and methods @@ -50,20 +52,17 @@ + } + + public PotionEffect getPrimaryEffect() { -+ return CraftPotionUtil.toBukkit(new MobEffect(this.l, getLevel(), getAmplification(), true, true)); ++ return (this.l != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.l, getLevel(), getAmplification(), true, true)) : null; + } + + public PotionEffect getSecondaryEffect() { -+ if (hasSecondaryEffect()) { -+ return CraftPotionUtil.toBukkit(new MobEffect(this.m, getLevel(), getAmplification(), true, true)); -+ } -+ return null; ++ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.m, getLevel(), getAmplification(), true, true)) : null; + } + // CraftBukkit end public TileEntityBeacon() {} -@@ -40,41 +82,79 @@ +@@ -40,41 +79,79 @@ } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index 486bc3ec93..1cb5e589a3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -3,15 +3,18 @@ package org.bukkit.craftbukkit.block; import java.util.ArrayList; import java.util.Collection; import net.minecraft.server.EntityHuman; +import net.minecraft.server.MobEffectList; import net.minecraft.server.TileEntityBeacon; import org.bukkit.Material; import org.bukkit.block.Beacon; import org.bukkit.block.Block; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.inventory.CraftInventoryBeacon; +import org.bukkit.craftbukkit.potion.CraftPotionUtil; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.Inventory; import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class CraftBeacon extends CraftBlockState implements Beacon { private final CraftWorld world; @@ -72,8 +75,18 @@ public class CraftBeacon extends CraftBlockState implements Beacon { return beacon.getPrimaryEffect(); } + @Override + public void setPrimaryEffect(PotionEffectType effect) { + beacon.l = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + } + @Override public PotionEffect getSecondaryEffect() { return beacon.getSecondaryEffect(); } + + @Override + public void setSecondaryEffect(PotionEffectType effect) { + beacon.m = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + } }