Skip to content

Commit

Permalink
Fix #139, Cows will now follow the milking time set in the configurat…
Browse files Browse the repository at this point in the history
…ion. Disable a print that spams the console when the mod first loads.
  • Loading branch information
alexbegt committed Apr 16, 2017
1 parent 6016b67 commit f58dcb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -46,6 +46,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.MutableBlockPos;
Expand Down Expand Up @@ -121,6 +122,7 @@ else if (growingAge < 0 && rndChild >= 1)
{
float rnd = RandomHelper.nextFloat(rand, Config.eggTimeoutMultiplier);
EntityChicken chicken = (EntityChicken) event.getEntityLiving();

if (chicken.timeUntilNextEgg > 0 && rnd >= 1)
{
chicken.timeUntilNextEgg += 1;
Expand All @@ -131,6 +133,7 @@ else if (growingAge < 0 && rndChild >= 1)
if (Config.milkedTimeout > 0 && event.getEntityLiving() instanceof EntityCow && event.getEntityLiving().world.getTotalWorldTime() % 20 == 0)
{
NBTTagCompound tags = event.getEntityLiving().getEntityData();

if (tags.hasKey("Milked"))
{
int milked = tags.getInteger("Milked");
Expand All @@ -155,6 +158,7 @@ else if (growingAge < 0 && rndChild >= 1)
if (tags.hasKey("HungerOverhaulCheck"))
{
int lastCheck = tags.getInteger("HungerOverhaulCheck");

if (--lastCheck <= 0)
{
tags.removeTag("HungerOverhaulCheck");
Expand All @@ -170,6 +174,7 @@ else if (growingAge < 0 && rndChild >= 1)
int foodLevel = 20;
boolean creative = false;
boolean isPlayer = false;

if (event.getEntityLiving() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
Expand All @@ -185,6 +190,7 @@ else if (growingAge < 0 && rndChild >= 1)
if (event.getEntityLiving() instanceof EntityPlayer && Config.constantHungerLoss)
{
EntityPlayer player = (EntityPlayer) event.getEntityLiving();

if (!player.capabilities.isCreativeMode && !player.isDead)
{
player.addExhaustion(0.01F);
Expand All @@ -194,6 +200,7 @@ else if (growingAge < 0 && rndChild >= 1)
if (Config.addLowStatEffects)
{
int difficultyModifierEffects = 2;

if (Config.difficultyScalingEffects && event.getEntityLiving().world.getDifficulty() != null)
{
difficultyModifierEffects = event.getEntityLiving().world.getDifficulty().getDifficultyId();
Expand All @@ -207,7 +214,6 @@ else if (growingAge < 0 && rndChild >= 1)
// low stat effects
if (!creative && isPlayer && !event.getEntityLiving().isDead && healthPercent > 0f)
{

if (Config.addLowHealthSlowness || Config.addLowHungerSlowness)
{
if ((Config.addLowHungerSlowness && foodLevel <= 1) || (Config.addLowHealthSlowness && healthPercent <= 0.05F))
Expand Down Expand Up @@ -401,7 +407,8 @@ public void onEntityInteractEvent(EntityInteract event)
{
EntityCow cow = (EntityCow) event.getTarget();
EntityPlayer player = event.getEntityPlayer();
ItemStack equipped = player.getActiveItemStack();
EnumHand hand = event.getHand();
ItemStack equipped = player.getHeldItem(hand);

if (equipped != null && equipped.getItem() != null)
{
Expand All @@ -414,6 +421,7 @@ public void onEntityInteractEvent(EntityInteract event)
if (tags.hasKey("Milked"))
{
event.setCanceled(true);

if (!player.world.isRemote)
{
cow.playSound(SoundEvents.ENTITY_COW_HURT, 0.4F, (event.getEntity().world.rand.nextFloat() - event.getEntity().world.rand.nextFloat()) * 0.2F + 1.0F);
Expand All @@ -434,6 +442,7 @@ public void onLivingHurtEvent(LivingHurtEvent event)
if (event.getEntityLiving() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.getEntityLiving();

AppleCoreAPI.mutator.setHealthRegenTickCounter(player, 0);
}
}
Expand Down
Expand Up @@ -78,8 +78,6 @@ public void onLootTableLoad(LootTableLoadEvent event)

public static void addChestLoot(Item item, ItemStack stack, FoodValues values)
{
System.out.println("unlocalized Name: " + stack.getUnlocalizedName());

int maxStackSize = Math.min(Config.chestLootMaxStackSize, item.getItemStackLimit(stack));

LootCondition[] lootConditions = new LootCondition[0];
Expand Down

0 comments on commit f58dcb5

Please sign in to comment.