New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start interacting with animals #900

Merged
merged 10 commits into from Apr 19, 2018

Conversation

Projects
None yet
3 participants
@FlorentClarret
Member

FlorentClarret commented Apr 17, 2018

Hi,

This PR adds the possibility to feed animals (give them breeding foods). I got all the data from here : https://minecraft.gamepedia.com/Breeding#Breeding_foods.

I did not implement the love mode, healing and so on yet. The only thing done is that the item is removed from the player inventory. Also, wolves or ocelots can not be tamed yet. I'm planning to do this on other PRs if this one is OK for you.

Don't hesitate to comment the code or ask if you have any question/remark. Thanks

* @return a set containing Material
*/
public Set<Material> getBreedingFoods() {
return EnumSet.noneOf(Material.class);

This comment has been minimized.

@momothereal

momothereal Apr 17, 2018

Member

Perhaps cache that set in a static field?

This comment has been minimized.

@FlorentClarret

FlorentClarret Apr 18, 2018

Member

This default is almost never used, because most of all the subclasses override this method. That's why i didn't cache this one. Fixed now ;)

/**
* Returns a set containing the breeding foods for the current animal.
* @return a set containing Material

This comment has been minimized.

@Pr0methean

Pr0methean Apr 19, 2018

Contributor

Mention that the returned set is immutable.

This comment has been minimized.

@FlorentClarret

FlorentClarret Apr 19, 2018

Member

Done, and I also added a test case to prevent subclasses to return mutable sets

import org.bukkit.Sound;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Ocelot;
public class GlowOcelot extends GlowTameable implements Ocelot {
private static final Set<Material> BREEDING_FOODS = Sets.immutableEnumSet(Material.RAW_FISH);

This comment has been minimized.

@Pr0methean

Pr0methean Apr 19, 2018

Contributor

Doesn't raw salmon also work?

This comment has been minimized.

@FlorentClarret

FlorentClarret Apr 19, 2018

Member

Before 1.13, raw salmon is not a specific value of Material, it just has the data byte set to 1 so this is going to work on 1.12.*. However, it will need to be updated for 1.13.

@@ -198,7 +198,7 @@ public boolean itemShiftClickAllowed(int slot, ItemStack stack) {
* @param clickedItem The item at which was clicked
*/
public void handleShiftClick(GlowPlayer player, InventoryView view, int clickedSlot,
ItemStack clickedItem) {
ItemStack clickedItem) {
clickedItem = player.getInventory().tryToFillSlots(clickedItem, 8, -1, 35, 8);

This comment has been minimized.

@Pr0methean

Pr0methean Apr 19, 2018

Contributor

Revert this to the old indentation.

This comment has been minimized.

@FlorentClarret

@momothereal momothereal merged commit c84935e into GlowstoneMC:dev Apr 19, 2018

2 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
license/cla Contributor License Agreement is signed.
Details
@momothereal

This comment has been minimized.

Member

momothereal commented Apr 19, 2018

Thank you!

@FlorentClarret FlorentClarret deleted the FlorentClarret:breeding_foods branch Apr 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment