#1523: Add Creaking methods

This commit is contained in:
Doc 2024-12-18 07:30:01 +11:00 committed by md_5
parent 57f48e54c2
commit c818af1fe7
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -1,7 +1,11 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.world.entity.monster.creaking.Creaking;
import org.bukkit.Location;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.util.CraftLocation;
import org.bukkit.entity.Player;
public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Creaking {
@ -14,6 +18,34 @@ public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Cre
return (Creaking) entity;
}
@Override
public Location getHome() {
return CraftLocation.toBukkit(this.getHandle().getHomePos(), this.getHandle().level());
}
@Override
public void setHome(Location location) {
Preconditions.checkArgument(location != null, "location cannot be null");
Preconditions.checkArgument(this.getWorld().equals(location.getWorld()), "Home must be in the same world as the creaking");
this.getHandle().setHomePos(CraftLocation.toBlockPosition(location));
}
@Override
public void activate(Player player) {
Preconditions.checkArgument(player != null, "player cannot be null");
this.getHandle().activate(((CraftPlayer) player).getHandle());
}
@Override
public void deactivate() {
this.getHandle().deactivate();
}
@Override
public boolean isActive() {
return this.getHandle().isActive();
}
@Override
public String toString() {
return "CraftCreaking";