SPIGOT-6373: Add getAttachedFace and setAttachedFace to the Shulker API

This commit is contained in:
Julian van den Berkmortel 2021-04-28 11:52:30 +10:00 committed by md_5
parent 0d86921e12
commit 69c8e78509
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 21 additions and 1 deletions

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityShulker.java --- a/net/minecraft/world/entity/monster/EntityShulker.java
+++ b/net/minecraft/world/entity/monster/EntityShulker.java +++ b/net/minecraft/world/entity/monster/EntityShulker.java
@@ -47,6 +47,12 @@ @@ -47,11 +47,17 @@
import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
@ -13,6 +13,12 @@
public class EntityShulker extends EntityGolem implements IMonster { public class EntityShulker extends EntityGolem implements IMonster {
private static final UUID bp = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F"); private static final UUID bp = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F");
private static final AttributeModifier bq = new AttributeModifier(EntityShulker.bp, "Covered armor bonus", 20.0D, AttributeModifier.Operation.ADDITION);
- protected static final DataWatcherObject<EnumDirection> b = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.n);
+ public static final DataWatcherObject<EnumDirection> b = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.n); // PAIL protected -> public, rename ATTACH_FACE
protected static final DataWatcherObject<Optional<BlockPosition>> c = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.m);
protected static final DataWatcherObject<Byte> d = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a);
public static final DataWatcherObject<Byte> COLOR = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a);
@@ -71,7 +77,7 @@ @@ -71,7 +77,7 @@
this.goalSelector.a(4, new EntityShulker.a()); this.goalSelector.a(4, new EntityShulker.a());
this.goalSelector.a(7, new EntityShulker.e()); this.goalSelector.a(7, new EntityShulker.e());

View File

@ -3,7 +3,9 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.world.entity.monster.EntityShulker; import net.minecraft.world.entity.monster.EntityShulker;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Shulker; import org.bukkit.entity.Shulker;
@ -48,4 +50,16 @@ public class CraftShulker extends CraftGolem implements Shulker {
Preconditions.checkArgument(value >= 0 && value <= 1, "value needs to be in between or equal to 0 and 1"); Preconditions.checkArgument(value >= 0 && value <= 1, "value needs to be in between or equal to 0 and 1");
getHandle().a((int) (value * 100)); // PAIL rename setPeek getHandle().a((int) (value * 100)); // PAIL rename setPeek
} }
@Override
public BlockFace getAttachedFace() {
return CraftBlock.notchToBlockFace(getHandle().eL()); // PAIL rename getAttachedFace
}
@Override
public void setAttachedFace(BlockFace face) {
Preconditions.checkNotNull(face, "face cannot be null");
Preconditions.checkArgument(face.isCartesian(), "%s is not a valid block face to attach a shulker to, a cartesian block face is expected", face);
getHandle().getDataWatcher().set(EntityShulker.b, CraftBlock.blockFaceToNotch(face));
}
} }