Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ final class HusbandryEggs {

private HusbandryEggs() {}

// Cold and warm chicken variants lay blue and brown eggs.
static boolean isVanillaEgg(Material material) {
return material == Material.EGG || material == Material.BLUE_EGG || material == Material.BROWN_EGG;
}

static void tryLay(LivingEntity entity, HusbandryAnimal animal, long nowMillis) {
if (entity == null || animal == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void onDropEgg(EntityDropItemEvent event) {
return;
}
ItemStack stack = event.getItemDrop().getItemStack();
if (stack.getType() != Material.EGG) {
if (!HusbandryEggs.isVanillaEgg(stack.getType())) {
return;
}
HusbandryRepository repository = HusbandryEntities.repository();
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/conversions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ conversions:
- v.beetroot vegetable(type=vegetable_1;origin=Beetroot;tags=freshness.0)
- v.apple fruit(type=fruit_1;origin=Apple;tags=freshness.0)
- v.egg egg(type=egg;origin=Egg;tags=freshness.0:cooked.0)
- v.blue_egg egg(type=egg;origin=Egg;tags=freshness.0:cooked.0)
- v.brown_egg egg(type=egg;origin=Egg;tags=freshness.0:cooked.0)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
- v.melon fruit(type=fruit_1;origin=Melon;tags=freshness.0)
- v.melon_slice fruit(type=fruit_1;origin=Melon Slice;tags=freshness.0)
- v.pumpkin vegetable(type=vegetable_1;origin=Pumpkin;tags=freshness.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.tfminecraft.cooking.husbandry;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.bukkit.Material;
import org.junit.jupiter.api.Test;

class HusbandryEggsTest {

@Test
void everyChickenVariantEggIsSuppressed() {
assertTrue(HusbandryEggs.isVanillaEgg(Material.EGG));
assertTrue(HusbandryEggs.isVanillaEgg(Material.BLUE_EGG));
assertTrue(HusbandryEggs.isVanillaEgg(Material.BROWN_EGG));
assertFalse(HusbandryEggs.isVanillaEgg(Material.FEATHER));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void eggStatesAndHusbandryQualityAreConfigured() throws Exception {

assertTrue(types.contains("edible-when-cooked: true"));
assertTrue(conversions.contains("v.egg egg(type=egg;origin=Egg;tags=freshness.0:cooked.0)"));
assertTrue(conversions.contains("v.blue_egg egg(type=egg;origin=Egg;tags=freshness.0:cooked.0)"));
assertTrue(conversions.contains("v.brown_egg egg(type=egg;origin=Egg;tags=freshness.0:cooked.0)"));
assertTrue(husbandry.contains("food(type=egg;origin=Egg;tags=freshness.0:cooked.0)"));
assertTrue(husbandry.contains("egg-timer: 1h"));
assertFalse(husbandry.contains("egg-timer: 10m"));
Expand Down