Skip to content

Commit

Permalink
Fix a couple of edges in milk bottle creation
Browse files Browse the repository at this point in the history
Prevent making it from non-cow cows
Prevent it bypassing milk cooldown
  • Loading branch information
KnightMiner committed Nov 7, 2022
1 parent 55fe782 commit 8d6e17d
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.animal.Cow;
import net.minecraft.world.entity.animal.Pig;
Expand Down Expand Up @@ -354,6 +355,7 @@ static void milkCow(EntityInteract event) {
if (tags.getShort(TAG_MILKCOOLDOWN) > 0) {
event.setCancellationResult(InteractionResult.PASS);
event.setCanceled(true);
return;
} else {
// no tag means we add it as part of milking
tags.putShort(TAG_MILKCOOLDOWN, Config.milkCooldownTime.get().shortValue());
Expand All @@ -364,7 +366,7 @@ static void milkCow(EntityInteract event) {
}

// milk the cow with the bottle
if (stack.is(Items.GLASS_BOTTLE) && Config.enableMilkBottles.getAsBoolean()) {
if (stack.is(Items.GLASS_BOTTLE) && Config.enableMilkBottles.getAsBoolean() && cow.getType() == EntityType.COW) {
player.setItemInHand(hand, ItemUtils.createFilledResult(stack, player, new ItemStack(InspirationsCaudrons.milkBottle)));
event.setCancellationResult(InteractionResult.SUCCESS);
event.setCanceled(true);
Expand Down

0 comments on commit 8d6e17d

Please sign in to comment.