Skip to content

Instantly share code, notes, and snippets.

@defeatedcrow
Created October 16, 2018 13:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defeatedcrow/b587e212fdd188aa68c4d912162f6c9d to your computer and use it in GitHub Desktop.
Save defeatedcrow/b587e212fdd188aa68c4d912162f6c9d to your computer and use it in GitHub Desktop.
HaC add-on sample code
import defeatedcrow.hac.api.climate.ClimateAPI;
import defeatedcrow.hac.api.climate.DCAirflow;
import defeatedcrow.hac.api.climate.DCHeatTier;
import defeatedcrow.hac.api.climate.DCHumidity;
import defeatedcrow.hac.api.damage.DamageAPI;
import defeatedcrow.hac.api.recipe.IMillRecipe;
import defeatedcrow.hac.api.recipe.RecipeAPI;
import net.minecraft.init.Biomes;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
@Mod(modid = ExampleAddon.MODID, name = ExampleAddon.NAME, version = ExampleAddon.VERSION)
public class ExampleAddon
{
public static final String MODID = "example_addon";
public static final String NAME = "Example HaC Addon";
public static final String VERSION = "1.0";
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
// some example code of modifying HaC recipes.
// I recommend writing these in postInit.
// 1. recipe API
// climate change recipe
// If you use Block object as input, it is called on random tick update of Block.
// "addRecipe(output ItemStack, HeatTier, input ItemStack)"
RecipeAPI.registerSmelting.addRecipe(new ItemStack(Blocks.PACKED_ICE), DCHeatTier.CRYOGENIC, new ItemStack(Blocks.SNOW));
// mill recipe
// "addRecipe(output ItemStack, secondary output ItemStack, secondary chance, input ItemStack)"
RecipeAPI.registerMills.addRecipe(new ItemStack(Items.IRON_INGOT, 2), new ItemStack(Items.STICK), 0.5F, new ItemStack(Items.IRON_SWORD));
// You can use String (ore dictionary name) instead of input ItemStack.
RecipeAPI.registerMills.addRecipe(new ItemStack(Items.PUMPKIN_SEEDS), new ItemStack(Items.PUMPKIN_PIE), 0.05F, "cropPumpkin");
// fluid recipe (It is used by pots.)
// "addRecipe(output ItemStack, secondary output ItemStack, secondary chance, output FluidStack,
// heattier(nullable), humidity(nullable), airflow(nullable), bool(unimplemented),
// input FluidStack, input ItemStack(multiple possible))"
RecipeAPI.registerFluidRecipes.addRecipe(new ItemStack(Items.MUSHROOM_STEW), ItemStack.EMPTY, 0F, null,
DCHeatTier.BOIL, null, null, false, new FluidStack(FluidRegistry.WATER, 200),
new ItemStack(Blocks.BROWN_MUSHROOM), new ItemStack(Blocks.RED_MUSHROOM), new ItemStack(Items.BOWL));
// How to get items of HaCMod using FML method
ResourceLocation res = new ResourceLocation("dcs_climate", "dcs_creative_drill");
if(Item.REGISTRY.containsKey(res)){
Item drill = Item.REGISTRY.getObject(res);
RecipeAPI.registerMills.addRecipe(new ItemStack(Items.IRON_INGOT, 2), new ItemStack(Items.CHICKEN), 1.0F, new ItemStack(drill));
}
// How to find and remove a recipe
IMillRecipe target = RecipeAPI.registerMills.getRecipe(new ItemStack(Blocks.IRON_ORE));
if(target != null){
RecipeAPI.registerMills.getRecipeList().remove(target);
}
// 2. climate API
// Setting of biome climate
ClimateAPI.register.addBiomeClimate(Biomes.BEACH, DCHeatTier.WARM, DCHumidity.WET, DCAirflow.NORMAL);
// block climate parameter
ClimateAPI.registerBlock.registerHeatBlock(Blocks.LIT_REDSTONE_ORE, 0, DCHeatTier.HOT);
// calculation climate (It can be called at any time if there is World and BlockPos.)
// "IClimate" including heattier, humidity, and airflow.
// sample -> IClimate climate = ClimateAPI.calculator.getClimate(world, pos);
// 3. damage API
// Heat Resistant ofArmor
DamageAPI.itemRegister.registerMaterial(new ItemStack(Items.GOLDEN_HELMET), 2.0F, 2.0F);
// Heat Resistant of Armor Material
DamageAPI.armorRegister.registerMaterial(ArmorMaterial.CHAIN, 1.0F, 1.0F);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment