Skip to content

Commit

Permalink
Add more vanilla potions for brewing
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Feb 9, 2018
1 parent b2d8b3a commit 6d979eb
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/main/java/knightminer/inspirations/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public class Config {
public static boolean betterFlowerPot = true;
public static boolean flowerPotComparator = true;
public static boolean coloredEnchantedRibbons = true;
public static boolean brewMissingPotions = true;
// heartbeet
public static boolean enableHeartbeet = true;
public static boolean brewHeartbeet = true;
Expand Down Expand Up @@ -287,7 +288,11 @@ public static void preInit(FMLPreInitializationEvent event) {
betterFlowerPot = configFile.getBoolean("betterFlowerPot", "tweaks", betterFlowerPot, "Flower pots can hold modded flowers");
flowerPotComparator = configFile.getBoolean("comparator", "tweaks.betterFlowerPot", flowerPotComparator, "Flower pots will emit a comparator signal if they have a flower");

// colored enchanted book ribbons
coloredEnchantedRibbons = configFile.getBoolean("coloredEnchantedRibbons", "tweaks", coloredEnchantedRibbons, "The ribbon on enchanted books colors based on the enchantment rarity");

// more potions
brewMissingPotions = configFile.getBoolean("brewMissingPotions", "tweaks", brewMissingPotions, "Adds brewing recipes for vanilla potions which are missing a recipe");
}

// compatibility
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/knightminer/inspirations/common/PulseBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootEntry;
import net.minecraft.world.storage.loot.LootEntryTable;
import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.RandomValueRange;
import net.minecraft.world.storage.loot.conditions.LootCondition;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
Expand Down Expand Up @@ -163,4 +169,20 @@ protected static void registerDispenserBehavior(Item item, IBehaviorDispenseItem
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(item, behavior);
}
}

/**
* Adds entries from a loot table in the inspirations directory to a vanilla loot table
* @param event LootTableLoadEvent
* @param name Name of vanilla table and the inspirations table
*/
protected static void addToVanillaLoot(LootTableLoadEvent event, String name) {
ResourceLocation extra = Util.getResource(name);
event.getTable().addPool(new LootPool(
new LootEntry[]{new LootEntryTable(extra, 1, 0, new LootCondition[0], Inspirations.modID)},
new LootCondition[0],
new RandomValueRange(1.0f),
new RandomValueRange(0.0F),
Inspirations.modID
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ public void doTheOredict(FMLInitializationEvent event) {
ensureVanilla();
registerBuilding();
registerRecipes();
registerShared();
registerUtility();
}

private void ensureVanilla() {
oredict(Items.BOOK, "book");
}

private void registerShared() {
oredict(InspirationsShared.witherBone, "boneWithered");
}

private static void registerBuilding() {
oredict(InspirationsBuilding.books, "book");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class InspirationsShared extends PulseBase {
public static ItemStack lingeringBottle;
public static ItemStack mushrooms;
public static ItemStack rabbitStewMix;
public static ItemStack silverfishPowder;
public static ItemStack witherBone;

// edibles
public static ItemStack heartbeet;
Expand Down Expand Up @@ -78,8 +80,14 @@ public void registerItems(Register<Item> event) {
key = materials.addMeta(1, "key");
}

if(isTweaksLoaded() && Config.enableHeartbeet) {
heartbeet = edibles.addFood(0, 2, 2.4f, "heartbeet", new PotionEffect(MobEffects.REGENERATION, 100));
if(isTweaksLoaded()) {
if(Config.enableHeartbeet) {
heartbeet = edibles.addFood(0, 2, 2.4f, "heartbeet", new PotionEffect(MobEffects.REGENERATION, 100));
}
if(Config.brewMissingPotions) {
silverfishPowder = materials.addMeta(6, "silverfish_powder", CreativeTabs.BREWING);
witherBone = materials.addMeta(7, "wither_bone", CreativeTabs.BREWING);
}
}
if(isRecipesLoaded()) {
if(Config.enableCauldronPotions) {
Expand Down
133 changes: 133 additions & 0 deletions src/main/java/knightminer/inspirations/tweaks/InspirationsTweaks.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package knightminer.inspirations.tweaks;

import java.util.Iterator;

import com.google.common.eventbus.Subscribe;

import knightminer.inspirations.common.CommonProxy;
Expand All @@ -17,20 +19,30 @@
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionHelper;
import net.minecraft.potion.PotionHelper.MixPredicate;
import net.minecraft.potion.PotionType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.oredict.OreIngredient;
import net.minecraftforge.registries.IForgeRegistry;
import slimeknights.mantle.pulsar.pulse.Pulse;

Expand All @@ -45,6 +57,26 @@ public class InspirationsTweaks extends PulseBase {
public static Block carpet;
public static Block flowerPot;

// potions
public static PotionType haste;
public static PotionType strongHaste;
public static PotionType fatigue;
public static PotionType strongFatigue;

public static PotionType hunger;
public static PotionType strongHunger;

public static PotionType resistance;
public static PotionType longResistance;
public static PotionType levitation;
public static PotionType longLevitation;

public static PotionType blindness;
public static PotionType longBlindness;
public static PotionType decay;
public static PotionType strongDecay;
public static PotionType longHunger;

@Subscribe
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit();
Expand All @@ -62,6 +94,35 @@ public void registerBlocks(Register<Block> event) {
}
}

@SubscribeEvent
public void registerPotionTypes(Register<PotionType> event) {
IForgeRegistry<PotionType> r = event.getRegistry();

if(Config.brewMissingPotions) {
haste = register(r, new PotionType(new PotionEffect(MobEffects.HASTE, 3600)), "haste");
strongHaste = register(r, new PotionType("haste", new PotionEffect(MobEffects.HASTE, 1800, 1)), "strong_haste");
fatigue = register(r, new PotionType(new PotionEffect(MobEffects.MINING_FATIGUE, 1200)), "fatigue");
strongFatigue = register(r, new PotionType("fatigue", new PotionEffect(MobEffects.MINING_FATIGUE, 600, 1)), "strong_fatigue");

hunger = register(r, new PotionType(new PotionEffect(MobEffects.HUNGER, 900)), "hunger");
longHunger = register(r, new PotionType("hunger", new PotionEffect(MobEffects.HUNGER, 1800)), "long_hunger");
strongHunger = register(r, new PotionType("hunger", new PotionEffect(MobEffects.HUNGER, 450, 1)), "strong_hunger");

resistance = register(r, new PotionType(new PotionEffect(MobEffects.RESISTANCE, 2400)), "resistance");
longResistance = register(r, new PotionType("resistance", new PotionEffect(MobEffects.RESISTANCE, 6000)), "long_resistance");

levitation = register(r, new PotionType(new PotionEffect(MobEffects.LEVITATION, 160)), "levitation");
longLevitation = register(r, new PotionType("levitation", new PotionEffect(MobEffects.LEVITATION, 300)), "long_levitation");

blindness = register(r, new PotionType(new PotionEffect(MobEffects.BLINDNESS, 600)), "blindness");
longBlindness = register(r, new PotionType("blindness", new PotionEffect(MobEffects.BLINDNESS, 1200)), "long_blindness");

decay = register(r, new PotionType(new PotionEffect(MobEffects.WITHER, 600)), "decay");
strongDecay = register(r, new PotionType("decay", new PotionEffect(MobEffects.WITHER, 300, 1)), "long_decay");

}
}

@Subscribe
public void init(FMLInitializationEvent event) {
proxy.init();
Expand All @@ -77,6 +138,62 @@ public void init(FMLInitializationEvent event) {
InspirationsRegistry.registerFlower(Blocks.CACTUS, 0, true);
InspirationsRegistry.registerFlower(Blocks.TALLGRASS, BlockTallGrass.EnumType.FERN.getMeta(), true);
}
if(Config.brewMissingPotions) {
// we need to start by removing a couple vanilla ones which we override
Iterator<MixPredicate<PotionType>> iterator = PotionHelper.POTION_TYPE_CONVERSIONS.iterator();
while(iterator.hasNext()) {
MixPredicate<PotionType> mix = iterator.next();
if(mix.input == PotionTypes.LEAPING || mix.input == PotionTypes.LONG_LEAPING) {
iterator.remove();
}
}

// then add the new recipes
Ingredient redstone = Ingredient.fromItem(Items.REDSTONE);
Ingredient glowstone = Ingredient.fromItem(Items.GLOWSTONE_DUST);
Ingredient spiderEye = Ingredient.fromItem(Items.FERMENTED_SPIDER_EYE);

// haste
Ingredient silverfishPowder = Ingredient.fromStacks(InspirationsShared.silverfishPowder);
PotionHelper.addMix(PotionTypes.WATER, silverfishPowder, PotionTypes.MUNDANE);
PotionHelper.addMix(PotionTypes.AWKWARD, silverfishPowder, haste);
PotionHelper.addMix(haste, glowstone, strongHaste);

// fatigue
PotionHelper.addMix(haste, spiderEye, fatigue);
PotionHelper.addMix(strongHaste, spiderEye, strongFatigue);
PotionHelper.addMix(fatigue, glowstone, strongFatigue);

// hunger
PotionHelper.addMix(PotionTypes.REGENERATION, spiderEye, hunger);
PotionHelper.addMix(PotionTypes.LONG_REGENERATION, spiderEye, longHunger);
PotionHelper.addMix(PotionTypes.STRONG_REGENERATION, spiderEye, strongHunger);
PotionHelper.addMix(hunger, redstone, longHunger);
PotionHelper.addMix(hunger, glowstone, strongHunger);

// resistance
Ingredient skulkerShell = Ingredient.fromItem(Items.SHULKER_SHELL);
PotionHelper.addMix(PotionTypes.WATER, skulkerShell, PotionTypes.MUNDANE);
PotionHelper.addMix(PotionTypes.AWKWARD, skulkerShell, resistance);
PotionHelper.addMix(resistance, redstone, longResistance);

// levitation
PotionHelper.addMix(PotionTypes.LEAPING, spiderEye, levitation);
PotionHelper.addMix(PotionTypes.LONG_LEAPING, spiderEye, longLevitation);
PotionHelper.addMix(levitation, redstone, longLevitation);

// blindness
Ingredient inkSac = Ingredient.fromStacks(new ItemStack(Items.DYE, 1, EnumDyeColor.BLACK.getDyeDamage()));
PotionHelper.addMix(PotionTypes.WATER, inkSac, PotionTypes.MUNDANE);
PotionHelper.addMix(PotionTypes.AWKWARD, inkSac, blindness);
PotionHelper.addMix(blindness, redstone, longBlindness);

// decay
Ingredient witherBone = new OreIngredient("boneWithered");
PotionHelper.addMix(PotionTypes.WATER, witherBone, PotionTypes.MUNDANE);
PotionHelper.addMix(PotionTypes.AWKWARD, witherBone, decay);
PotionHelper.addMix(decay, glowstone, strongDecay);
}

registerDispenserBehavior();
}
Expand All @@ -87,6 +204,22 @@ public void postInit(FMLPostInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(TweaksEvents.class);
}

private static final ResourceLocation SILVERFISH_TABLE = new ResourceLocation("entities/silverfish");
private static final ResourceLocation WITHER_SKELETON_TABLE = new ResourceLocation("entities/wither_skeleton");
@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event) {
if(!Config.brewMissingPotions) {
return;
}

ResourceLocation name = event.getName();
if(SILVERFISH_TABLE.equals(name)) {
addToVanillaLoot(event, "entities/silverfish");
// skip wither skeleton drop if TConstruct is loaded
} else if(WITHER_SKELETON_TABLE.equals(name) && !Loader.isModLoaded("tconstruct")) {
addToVanillaLoot(event, "entities/wither_skeleton");
}
}

private static final IBehaviorDispenseItem DEFAULT = new BehaviorDefaultDispenseItem();
private void registerDispenserBehavior() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"lingering_bottle": [{ "textures": { "layer0": "items/potion_bottle_lingering" }}],

"mushrooms": [{ "textures": { "layer0": "inspirations:items/mushrooms" }}],
"rabbit_stew_mix": [{ "textures": { "layer0": "inspirations:items/rabbit_stew_mix" }}]
"rabbit_stew_mix": [{ "textures": { "layer0": "inspirations:items/rabbit_stew_mix" }}],

"silverfish_powder": [{ "textures": { "layer0": "inspirations:items/silverfish_powder" }}],
"wither_bone": [{ "textures": { "layer0": "inspirations:items/wither_bone" }}]
}
}
35 changes: 34 additions & 1 deletion src/main/resources/assets/inspirations/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,40 @@ gui.jei.cauldron.boiling=Cauldron must be placed above fire
############

item.inspirations.edibles.heartbeet.name=Heartbeet

item.inspirations.materials.silverfish_powder.name=Silverfish Powder
item.inspirations.materials.wither_bone.name=Withered Bone

potion.effect.haste=Potion of Haste
potion.effect.fatigue=Potion of Fatigue
potion.effect.hunger=Potion of Hunger
potion.effect.resistance=Potion of Resistance
potion.effect.levitation=Potion of Levitation
potion.effect.blindness=Potion of Blindness
potion.effect.decay=Potion of Decay

splash_potion.effect.haste=Splash Potion of Haste
splash_potion.effect.fatigue=Splash Potion of Fatigue
splash_potion.effect.hunger=Splash Potion of Hunger
splash_potion.effect.resistance=Splash Potion of Resistance
splash_potion.effect.levitation=Splash Potion of Levitation
splash_potion.effect.blindness=Splash Potion of Blindness
splash_potion.effect.decay=Splash Potion of Decay

lingering_potion.effect.haste=Lingering Potion of Haste
lingering_potion.effect.fatigue=Lingering Potion of Fatigue
lingering_potion.effect.hunger=Lingering Potion of Hunger
lingering_potion.effect.resistance=Lingering Potion of Resistance
lingering_potion.effect.levitation=Lingering Potion of Levitation
lingering_potion.effect.blindness=Lingering Potion of Blindness
lingering_potion.effect.decay=Lingering Potion of Decay

tipped_arrow.effect.haste=Arrow of Haste
tipped_arrow.effect.fatigue=Arrow of Fatigue
tipped_arrow.effect.hunger=Arrow of Hunger
tipped_arrow.effect.resistance=Arrow of Resistance
tipped_arrow.effect.levitation=Arrow of Levitation
tipped_arrow.effect.blindness=Arrow of Blindness
tipped_arrow.effect.decay=Arrow of Decay

#############
# TANPlugin #
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"pools": [
{
"name": "silverfish_powder",
"conditions": [
{
"condition": "killed_by_player"
},
{
"condition": "random_chance_with_looting",
"chance": 0.15,
"looting_multiplier": 0.05
}
],
"rolls": 1,
"entries": [
{
"type": "item",
"name": "inspirations:materials",
"weight": 1,
"functions": [
{
"function": "set_data",
"data": 6
}
]
}
]
}
]
}
Loading

0 comments on commit 6d979eb

Please sign in to comment.