Skip to content

Commit

Permalink
Add support for Horse inventories (#2558)
Browse files Browse the repository at this point in the history
* Can now open horse inventory

Command still needs testing and needs to be updated to use `autoExecute`

* Update command to use `autoExecute`

* Move errors and fix slot default value

* Change order of types

`public static` sounds better than `static public` in my opinion

* Fix `expire:` argument throwing an error when it shouldn't

* Cast to `CraftAbstractHorse` and throw exception to prevent NPE

* Update error messages
  • Loading branch information
BreadcrumbIsTaken committed Nov 12, 2023
1 parent 25d6f31 commit 74f28ba
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 127 deletions.
Expand Up @@ -466,4 +466,6 @@ public void startUsingItem(LivingEntity entity, EquipmentSlot hand) {
public void stopUsingItem(LivingEntity entity) {
throw new UnsupportedOperationException();
}

public abstract void openHorseInventory(Player player, AbstractHorse horse);
}

Large diffs are not rendered by default.

Expand Up @@ -700,4 +700,10 @@ public boolean isAggressive(org.bukkit.entity.Mob mob) {
public void setAggressive(org.bukkit.entity.Mob mob, boolean aggressive) {
((CraftMob) mob).getHandle().setAggressive(aggressive);
}

@Override
public void openHorseInventory(Player player, AbstractHorse horse) {
net.minecraft.world.entity.animal.horse.AbstractHorse nmsHorse = ((CraftAbstractHorse) horse).getHandle();
((CraftPlayer) player).getHandle().openHorseInventory(nmsHorse, nmsHorse.inventory);
}
}
Expand Up @@ -777,4 +777,10 @@ public boolean isAggressive(org.bukkit.entity.Mob mob) {
public void setAggressive(org.bukkit.entity.Mob mob, boolean aggressive) {
((CraftMob) mob).getHandle().setAggressive(aggressive);
}

@Override
public void openHorseInventory(Player player, AbstractHorse horse) {
net.minecraft.world.entity.animal.horse.AbstractHorse nmsHorse = ((CraftAbstractHorse) horse).getHandle();
((CraftPlayer) player).getHandle().openHorseInventory(nmsHorse, nmsHorse.inventory);
}
}
Expand Up @@ -830,4 +830,10 @@ public float getStepHeight(Entity entity) {
public void setStepHeight(Entity entity, float stepHeight) {
((CraftEntity) entity).getHandle().setMaxUpStep(stepHeight);
}

@Override
public void openHorseInventory(Player player, AbstractHorse horse) {
net.minecraft.world.entity.animal.horse.AbstractHorse nmsHorse = ((CraftAbstractHorse) horse).getHandle();
((CraftPlayer) player).getHandle().openHorseInventory(nmsHorse, nmsHorse.inventory);
}
}
Expand Up @@ -856,4 +856,10 @@ public void startUsingItem(LivingEntity entity, EquipmentSlot hand) {
public void stopUsingItem(LivingEntity entity) {
((CraftLivingEntity) entity).getHandle().stopUsingItem();
}

@Override
public void openHorseInventory(Player player, AbstractHorse horse) {
net.minecraft.world.entity.animal.horse.AbstractHorse nmsHorse = ((CraftAbstractHorse) horse).getHandle();
((CraftPlayer) player).getHandle().openHorseInventory(nmsHorse, nmsHorse.inventory);
}
}

0 comments on commit 74f28ba

Please sign in to comment.