Skip to content

Commit

Permalink
Abstract saddleable to a separate interface (#2534)
Browse files Browse the repository at this point in the history
update strider interface
  • Loading branch information
ImMorpheus authored Jun 29, 2024
1 parent 98f409f commit c24fd3a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 23 deletions.
43 changes: 43 additions & 0 deletions src/main/java/org/spongepowered/api/entity/Saddleable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.entity;

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;

/**
* Represents an {@link Entity} which can be saddled.
*/
public interface Saddleable extends Entity {

/**
* {@link Keys#IS_SADDLED}
*
* @return Whether the entity is saddled
*/
default Value.Mutable<Boolean> saddled() {
return this.requireValue(Keys.IS_SADDLED).asMutable();
}
}
14 changes: 2 additions & 12 deletions src/main/java/org/spongepowered/api/entity/living/animal/Pig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,11 @@
*/
package org.spongepowered.api.entity.living.animal;

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.Saddleable;

/**
* Represents a Pig.
*/
public interface Pig extends Animal {

/**
* {@link Keys#IS_SADDLED}
*
* @return Whether this pig has a saddle, and ready to be ridden
*/
default Value.Mutable<Boolean> saddled() {
return this.requireValue(Keys.IS_SADDLED).asMutable();
}
public interface Pig extends Animal, Saddleable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.Ownable;
import org.spongepowered.api.entity.Saddleable;
import org.spongepowered.api.entity.living.animal.Animal;
import org.spongepowered.api.item.inventory.Carrier;


/**
* An abstract representation of a Horse.
*/
public interface HorseLike extends Animal, Ownable, Carrier {
public interface HorseLike extends Animal, Ownable, Saddleable, Carrier {

/**
* {@link Keys#IS_TAMED}
Expand All @@ -45,13 +46,4 @@ default Value.Mutable<Boolean> tamed() {
return this.requireValue(Keys.IS_TAMED).asMutable();
}

/**
* {@link Keys#IS_SADDLED}
*
* @return Whether the horse is saddled
*/
default Value.Mutable<Boolean> saddled() {
return this.requireValue(Keys.IS_SADDLED).asMutable();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
*/
package org.spongepowered.api.entity.living.monster;

import org.spongepowered.api.entity.Saddleable;
import org.spongepowered.api.entity.living.Monster;

/**
* Represents a Strider.
*/
public interface Strider extends Monster {
public interface Strider extends Monster, Saddleable {
}

0 comments on commit c24fd3a

Please sign in to comment.