From 3075579f612de06d61506d32e11ca82147467466 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 1 Apr 2020 09:14:29 +1100 Subject: [PATCH] Add FaceAttachable interface to handle Grindstone facing in common with Switches --- .../block/data/CraftFaceAttachable.java | 18 ++++++++++++++++++ .../block/impl/CraftGrindstone.java | 16 +++++++++++++++- .../craftbukkit/block/impl/CraftLever.java | 16 +++++++++++++++- .../block/impl/CraftStoneButton.java | 16 +++++++++++++++- .../block/impl/CraftWoodButton.java | 16 +++++++++++++++- 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/CraftFaceAttachable.java diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftFaceAttachable.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftFaceAttachable.java new file mode 100644 index 0000000000..a2c0ed7a4b --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftFaceAttachable.java @@ -0,0 +1,18 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.FaceAttachable; + +public abstract class CraftFaceAttachable extends CraftBlockData implements FaceAttachable { + + private static final net.minecraft.server.BlockStateEnum ATTACH_FACE = getEnum("face"); + + @Override + public AttachedFace getAttachedFace() { + return get(ATTACH_FACE, AttachedFace.class); + } + + @Override + public void setAttachedFace(AttachedFace face) { + set(ATTACH_FACE, face); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java index f4c08558e9..151d301ae2 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftGrindstone extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { +public final class CraftGrindstone extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Grindstone, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable { public CraftGrindstone() { super(); @@ -31,4 +31,18 @@ public final class CraftGrindstone extends org.bukkit.craftbukkit.block.data.Cra public java.util.Set getFaces() { return getValues(FACING, org.bukkit.block.BlockFace.class); } + + // org.bukkit.craftbukkit.block.data.CraftFaceAttachable + + private static final net.minecraft.server.BlockStateEnum ATTACH_FACE = getEnum(net.minecraft.server.BlockGrindstone.class, "face"); + + @Override + public AttachedFace getAttachedFace() { + return get(ATTACH_FACE, AttachedFace.class); + } + + @Override + public void setAttachedFace(AttachedFace face) { + set(ATTACH_FACE, face); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java index a8b030f2fd..c3713d1dcf 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftLever extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { +public final class CraftLever extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable { public CraftLever() { super(); @@ -46,6 +46,20 @@ public final class CraftLever extends org.bukkit.craftbukkit.block.data.CraftBlo return getValues(FACING, org.bukkit.block.BlockFace.class); } + // org.bukkit.craftbukkit.block.data.CraftFaceAttachable + + private static final net.minecraft.server.BlockStateEnum ATTACH_FACE = getEnum(net.minecraft.server.BlockLever.class, "face"); + + @Override + public AttachedFace getAttachedFace() { + return get(ATTACH_FACE, AttachedFace.class); + } + + @Override + public void setAttachedFace(AttachedFace face) { + set(ATTACH_FACE, face); + } + // org.bukkit.craftbukkit.block.data.CraftPowerable private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockLever.class, "powered"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java index 84097d5efe..ee3bef1364 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { +public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable { public CraftStoneButton() { super(); @@ -46,6 +46,20 @@ public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.Cr return getValues(FACING, org.bukkit.block.BlockFace.class); } + // org.bukkit.craftbukkit.block.data.CraftFaceAttachable + + private static final net.minecraft.server.BlockStateEnum ATTACH_FACE = getEnum(net.minecraft.server.BlockStoneButton.class, "face"); + + @Override + public AttachedFace getAttachedFace() { + return get(ATTACH_FACE, AttachedFace.class); + } + + @Override + public void setAttachedFace(AttachedFace face) { + set(ATTACH_FACE, face); + } + // org.bukkit.craftbukkit.block.data.CraftPowerable private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockStoneButton.class, "powered"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java index 799714178f..bbe76e7ddd 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftWoodButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { +public final class CraftWoodButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable { public CraftWoodButton() { super(); @@ -46,6 +46,20 @@ public final class CraftWoodButton extends org.bukkit.craftbukkit.block.data.Cra return getValues(FACING, org.bukkit.block.BlockFace.class); } + // org.bukkit.craftbukkit.block.data.CraftFaceAttachable + + private static final net.minecraft.server.BlockStateEnum ATTACH_FACE = getEnum(net.minecraft.server.BlockWoodButton.class, "face"); + + @Override + public AttachedFace getAttachedFace() { + return get(ATTACH_FACE, AttachedFace.class); + } + + @Override + public void setAttachedFace(AttachedFace face) { + set(ATTACH_FACE, face); + } + // org.bukkit.craftbukkit.block.data.CraftPowerable private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockWoodButton.class, "powered");