Skip to content

Commit

Permalink
Improve Food and Alcohol (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
RusTit authored and mezz committed Mar 27, 2018
1 parent c051bf5 commit 61d2f3e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
4 changes: 3 additions & 1 deletion core/src/main/java/binnie/core/liquid/AlcoholEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static void makeDrunk(final EntityPlayer player, final float strength) {
slowIntense = 0.0f;
}

// TODO blindIntense
float blindIntense = (intensity - 25.0f) / 2.0f;
if (blindIntense < 0.0f) {
blindIntense = 0.0f;
Expand All @@ -28,5 +27,8 @@ public static void makeDrunk(final EntityPlayer player, final float strength) {
if (slowIntense > 0.0f) {
player.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, time, (int) slowIntense, false, true));
}
if (blindIntense > 0.0f) {
player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, time, (int) blindIntense, false, true));
}
}
}
4 changes: 0 additions & 4 deletions extratrees/src/main/java/binnie/extratrees/items/Food.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,6 @@ public static void registerOreDictionary() {

abstract void registerOreDictEntries();

public boolean isEdible() {
return this.hunger > 0;
}

public int getHealth() {
return this.hunger;
}
Expand Down
24 changes: 9 additions & 15 deletions extratrees/src/main/java/binnie/extratrees/items/ItemDrink.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,20 @@ public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
@Override
public String getItemStackDisplayName(final ItemStack stack) {
final FluidStack fluid = FluidUtil.getFluidContained(stack);
final IDrinkLiquid liquid;
if (fluid == null) {
liquid = null;
} else {
liquid = DrinkManager.getLiquid(fluid.getFluid());
}

final String liquidName;
if (liquid == null) {
liquidName = null;
} else {
liquidName = liquid.getName();
}
final IDrinkLiquid liquid = (fluid == null) ? null : DrinkManager.getLiquid(fluid.getFluid());
final String liquidName = (liquid == null) ? null : liquid.getName();
return this.getGlassware(stack).getName(liquidName);
}

@Override
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
super.onFoodEaten(stack, world, player);
AlcoholEffect.makeDrunk(player, 2.1f);
final FluidStack fluid = FluidUtil.getFluidContained(stack);
final IDrinkLiquid liquid = (fluid == null) ? null : DrinkManager.getLiquid(fluid.getFluid());
float strength = (liquid == null) ? 0.0f : liquid.getABV();
if (strength > 0.0f) {
AlcoholEffect.makeDrunk(player, strength);
}
}

@Override
Expand All @@ -153,7 +147,7 @@ public EnumAction getItemUseAction(final ItemStack itemStack) {
}

@Override
public int getMaxItemUseDuration(final ItemStack p_77626_1_) {
public int getMaxItemUseDuration(final ItemStack stack) {
return 16;
}

Expand Down
11 changes: 9 additions & 2 deletions extratrees/src/main/java/binnie/extratrees/items/ItemETFood.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
}
}

private IItemMiscProvider getItem(int damage) {
private IItemMiscProvider getItem(final int damage) {
return (damage >= ItemETFood.items.length) ? ItemETFood.items[0] : ItemETFood.items[damage];
}

Expand Down Expand Up @@ -75,13 +75,20 @@ private Food getFood(ItemStack itemStack) {
return Food.VALUES[itemStack.getItemDamage()];
}

private final int MINIMUM_USE_DURATION = 8;

@Override
public int getMaxItemUseDuration(ItemStack stack) {
return MINIMUM_USE_DURATION + getFood(stack).getHealth() * 2;
}

@Override
public int getHealAmount(ItemStack itemStack) {
return getFood(itemStack).getHealth();
}

@Override
public float getSaturationModifier(ItemStack itemStack) {
return 0.5f;
return getFood(itemStack).getHealth() / 10.0f;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ extratrees.item.glassware.beermug.usage=Mug of %1$s
extratrees.item.glassware.pint.usage=Glass of %1$s
extratrees.item.glassware.snifter.usage=Glass of %1$s
extratrees.item.glassware.cocktail.usage=Glass of %1$s
extratrees.item.glassware.flute.usage=Glass of %1$s
extratrees.item.glassware.cordial.usage=Glass of %1$s
extratrees.item.glassware.collins.usage=Glass of %1$s
extratrees.item.glassware.highball.usage=Glass of %1$s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ extratrees.item.glassware.beermug.usage=Кружка %1$s
extratrees.item.glassware.pint.usage=Стакан %1$s
extratrees.item.glassware.snifter.usage=Стакан %1$s
extratrees.item.glassware.cocktail.usage=Стакан %1$s
extratrees.item.glassware.flute.usage=Стакан %1$s
extratrees.item.glassware.cordial.usage=Стакан %1$s
extratrees.item.glassware.collins.usage=Стакан %1$s
extratrees.item.glassware.highball.usage=Стакан %1$s
Expand Down

0 comments on commit 61d2f3e

Please sign in to comment.