From 8cd69933c97c841f91f04e8b56d1ab5eb4392f1b Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 16 Mar 2016 19:08:24 -0400 Subject: [PATCH] Implement Boat#getWoodType and Boat#setWoodType(TreeSpecies) --- .../bukkit/craftbukkit/entity/CraftBoat.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index 103b9d4597..af66b90a01 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityBoat; +import org.bukkit.TreeSpecies; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Boat; import org.bukkit.entity.EntityType; @@ -11,6 +12,16 @@ public class CraftBoat extends CraftVehicle implements Boat { super(server, entity); } + @Override + public TreeSpecies getWoodType() { + return getTreeSpecies(getHandle().r()); // PAIL: Rename getType + } + + @Override + public void setWoodType(TreeSpecies species) { + getHandle().a(getBoatType(species)); // PAIL: Rename setType + } + public double getMaxSpeed() { return getHandle().maxSpeed; } @@ -60,4 +71,40 @@ public class CraftBoat extends CraftVehicle implements Boat { public EntityType getType() { return EntityType.BOAT; } + + public static TreeSpecies getTreeSpecies(EntityBoat.EnumBoatType boatType) { + switch (boatType) { + case SPRUCE: + return TreeSpecies.REDWOOD; + case BIRCH: + return TreeSpecies.BIRCH; + case JUNGLE: + return TreeSpecies.JUNGLE; + case ACACIA: + return TreeSpecies.ACACIA; + case DARK_OAK: + return TreeSpecies.DARK_OAK; + case OAK: + default: + return TreeSpecies.GENERIC; + } + } + + public static EntityBoat.EnumBoatType getBoatType(TreeSpecies species) { + switch (species) { + case REDWOOD: + return EntityBoat.EnumBoatType.SPRUCE; + case BIRCH: + return EntityBoat.EnumBoatType.BIRCH; + case JUNGLE: + return EntityBoat.EnumBoatType.JUNGLE; + case ACACIA: + return EntityBoat.EnumBoatType.ACACIA; + case DARK_OAK: + return EntityBoat.EnumBoatType.DARK_OAK; + case GENERIC: + default: + return EntityBoat.EnumBoatType.OAK; + } + } }