Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
Seasonings affect drink
Browse files Browse the repository at this point in the history
  • Loading branch information
Snownee committed Oct 27, 2018
1 parent e195a07 commit ddaddd8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/main/java/snownee/cuisine/api/CulinaryHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public static final class CommonSpices
public static final Spice CRUDE_SALT = find("crude_salt");
public static final Spice SALT = find("salt");
public static final Spice SUGAR = find("sugar");
public static final Spice UNREFINED_SUGAR = find("unrefined_sugar");

private static Spice find(final String uniqueName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
public class DefaultConsumedCollector implements EffectCollector
{
private final Map<Potion, PotionEffectInfo> mapPotions = new HashMap<>();
private final float durationModifier;

public DefaultConsumedCollector()
{
this(1);
}

public DefaultConsumedCollector(float durationModifier)
{
this.durationModifier = Math.max(durationModifier, 0);
}

@Override
public void apply(CompositeFood food, EntityPlayer player)
Expand All @@ -35,7 +46,7 @@ public void apply(CompositeFood food, EntityPlayer player)
continue;
}
PotionEffectInfo info = entry.getValue();
player.addPotionEffect(new PotionEffect(entry.getKey(), info.duration, info.amplifier, false, info.showParticles));
player.addPotionEffect(new PotionEffect(entry.getKey(), (int) (info.duration * durationModifier), info.amplifier, false, info.showParticles));
if (info.duration > maxDuration)
{
maxDuration = info.duration;
Expand All @@ -44,7 +55,7 @@ public void apply(CompositeFood food, EntityPlayer player)
}
if (maxDuration > 0)
{
player.addPotionEffect(new PotionEffect(CuisineRegistry.EFFECT_RESISTANCE, maxDuration * 2, 0, true, false));
player.addPotionEffect(new PotionEffect(CuisineRegistry.EFFECT_RESISTANCE, (int) (maxDuration * durationModifier * 2), 0, true, false));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,9 @@ public boolean hasGlowingOverlay(Ingredient ingredient)
api.register(new SpiceChiliPowder("chili_powder", 11546150));
api.register(new SimpleSpiceImpl("sichuan_pepper_powder", 8606770));
api.register(new SimpleSpiceImpl("crude_salt", 4673362));
api.register(new SimpleSpiceImpl("salt", 16383998));
api.register(new SimpleSpiceImpl("salt", 0xE3E3E3));
api.register(new SimpleSpiceImpl("sugar", 16383998));
api.register(new SimpleSpiceImpl("unrefined_sugar", 0xB35400));

CulinaryHub.CommonSkills.init();
}
Expand Down Expand Up @@ -619,9 +620,10 @@ public static void deferredInit()
api.fluidToSpiceMapping.put(CuisineFluids.FRUIT_VINEGAR.getName(), CulinaryHub.CommonSpices.FRUIT_VINEGAR);
api.fluidToSpiceMapping.put(FluidRegistry.WATER.getName(), CulinaryHub.CommonSpices.WATER);

api.itemToSpiceMapping.put(ItemDefinition.of(CuisineRegistry.MATERIAL.getItemStack(Cuisine.Materials.CHILI_POWDER)), CulinaryHub.CommonSpices.CHILI_POWDER);
api.itemToSpiceMapping.put(ItemDefinition.of(CuisineRegistry.MATERIAL.getItemStack(Cuisine.Materials.SICHUAN_PEPPER_POWDER)), CulinaryHub.CommonSpices.SICHUAN_PEPPER_POWDER);
api.itemToSpiceMapping.put(ItemDefinition.of(CuisineRegistry.MATERIAL, Cuisine.Materials.CHILI_POWDER.getMeta()), CulinaryHub.CommonSpices.CHILI_POWDER);
api.itemToSpiceMapping.put(ItemDefinition.of(CuisineRegistry.MATERIAL, Cuisine.Materials.SICHUAN_PEPPER_POWDER.getMeta()), CulinaryHub.CommonSpices.SICHUAN_PEPPER_POWDER);
api.itemToSpiceMapping.put(ItemDefinition.of(Items.SUGAR), CulinaryHub.CommonSpices.SUGAR);
api.itemToSpiceMapping.put(ItemDefinition.of(CuisineRegistry.MATERIAL, Cuisine.Materials.UNREFINED_SUGAR.getMeta()), CulinaryHub.CommonSpices.UNREFINED_SUGAR);

api.oreDictToSpiceMapping.put("dustSalt", CulinaryHub.CommonSpices.SALT);
api.oreDictToSpiceMapping.put("dustCrudesalt", CulinaryHub.CommonSpices.CRUDE_SALT);
Expand Down
36 changes: 34 additions & 2 deletions src/main/java/snownee/cuisine/internal/food/Drink.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,32 @@ public Collection<String> getKeywords()
public void onEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
Collection<IngredientBinding> bindings = getEffectBindings();
EffectCollector collector = new DefaultConsumedCollector();
float modifier = 1;
for (Seasoning seasoning : seasonings)
{
if (seasoning.getSpice() == CulinaryHub.CommonSpices.UNREFINED_SUGAR)
{
modifier += seasoning.getSize() * 0.1;
}
else if (seasoning.getSpice() == CulinaryHub.CommonSpices.SUGAR)
{
modifier += seasoning.getSize() * 0.2;
}
else if (seasoning.getSpice() == CulinaryHub.CommonSpices.SALT)
{
modifier -= seasoning.getSize() * 0.1;
}
else if (seasoning.getSpice() == CulinaryHub.CommonSpices.CRUDE_SALT)
{
modifier -= seasoning.getSize() * 0.2;
}
else if (seasoning.getSpice() == CulinaryHub.CommonSpices.SOY_SAUCE || seasoning.getSpice() == CulinaryHub.CommonSpices.CHILI_POWDER || seasoning.getSpice() == CulinaryHub.CommonSpices.SICHUAN_PEPPER_POWDER)
{
modifier = 0;
break;
}
}
EffectCollector collector = new DefaultConsumedCollector(modifier);

// And then apply them
for (IngredientBinding binding : bindings)
Expand Down Expand Up @@ -441,7 +466,14 @@ else if (drinkType == DrinkType.SMOOTHIE)
}
collector.addEffect(DefaultTypes.POTION, new PotionEffect(potion, duration, 0, true, true));
}
collector.apply(this, player);
if (modifier <= 0.1F)
{
player.addPotionEffect(new PotionEffect(worldIn.rand.nextBoolean() ? MobEffects.SLOWNESS : MobEffects.MINING_FATIGUE, 1200));
}
else if (modifier > 0.25F)
{
collector.apply(this, player);
}
if (drinkType == DrinkType.SMOOTHIE)
{
player.extinguish();
Expand Down

0 comments on commit ddaddd8

Please sign in to comment.