forked from TAIGA/TAIGA
Merge pull request #16 from StevenTheEVILZ
Add documentation and fix book icons
This commit is contained in:
@@ -8,6 +8,9 @@ import static com.sosnitzka.taiga.util.Utils.registerTinkerAlloys;
|
||||
|
||||
public class Alloys {
|
||||
|
||||
/**
|
||||
* Registers alloying in the smeltery
|
||||
*/
|
||||
static void register() {
|
||||
registerTinkerAlloys(nitroniteFluid, 2, tiberiumFluid, 4, vibraniumFluid, 3, nitroFluid, 3);
|
||||
registerTinkerAlloys(bysmuidFluid, 1, rubiumFluid, 3, bismuthFluid, 2, anthraciteFluid, 3);
|
||||
|
@@ -91,18 +91,23 @@ public class Blocks {
|
||||
public static Block proxideumBlock = new BasicBlock("proxideum_block", Material.ROCK, 25.0f, 25.0f, 4, PREFIX_BLOCK);
|
||||
public static Block astriumBlock = new BasicBlock("astrium_block", Material.ROCK, 55.0f, 400.0f, 7, PREFIX_BLOCK);
|
||||
|
||||
|
||||
/**
|
||||
* Registers all materials' ingots and nuggets <br>
|
||||
* Detailed summary: <br>
|
||||
* Gets the ingots declared in the class (fields and reflection) and iterates through them: <br>
|
||||
* Checks that the field is static, registers the field (item), and adds an oreDict entry if needed
|
||||
*/
|
||||
public static void register() {
|
||||
Field[] declaredFields = Blocks.class.getDeclaredFields();
|
||||
for (Field field : declaredFields) {
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
|
||||
Field[] declaredFields = Blocks.class.getDeclaredFields(); // Gets the fields (ingots) declared above
|
||||
for (Field field : declaredFields) { // Iterates through the fields declared above
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { // Checks that the fields are static
|
||||
Class<?> targetType = field.getType();
|
||||
try {
|
||||
Block block = (Block) field.get(targetType);
|
||||
Utils.registerBlockWithItem(block);
|
||||
Block block = (Block) field.get(targetType); // Gets the field as a BasicBlock which is then casted to an Block
|
||||
Utils.registerBlockWithItem(block); // Registers block and its item
|
||||
|
||||
if (block instanceof BasicBlock) {
|
||||
if (((BasicBlock) block).isOreDict()) {
|
||||
if (block instanceof BasicBlock) { // Checks that the block is a BasicBlock
|
||||
if (((BasicBlock) block).isOreDict()) { // Checks that the block has an oreDict entry
|
||||
String oreDictName;
|
||||
String[] nameParts = block.getUnlocalizedName().replace("tile.", "").split("_");
|
||||
|
||||
@@ -111,7 +116,7 @@ public class Blocks {
|
||||
} else {
|
||||
oreDictName = nameParts[0];
|
||||
}
|
||||
OreDictionary.registerOre(((BasicBlock) block).getOreDictPrefix() + StringUtils.capitalize(oreDictName), block);
|
||||
OreDictionary.registerOre(((BasicBlock) block).getOreDictPrefix() + StringUtils.capitalize(oreDictName), block); // Registers the block's oreDict
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@@ -61,21 +61,28 @@ public class Fluids {
|
||||
public static BasicTinkerFluid anthraciteFluid = new BasicTinkerFluid("anthracite_fluid", 0xFF111111, false, 500, 0, 632);
|
||||
public static BasicTinkerFluid spectrumFluid = new BasicTinkerFluid("spectrum_fluid", 0xFF64748f, false, 600, 0, 512);
|
||||
|
||||
|
||||
/**
|
||||
* Registers all materials' fluids <br>
|
||||
* Detailed summary: <br>
|
||||
* Gets the fluids declared in the class (fields and reflection) and iterates through them: <br>
|
||||
* Checks that the field is static, registers the field (fluids), and registers the models on the client
|
||||
*/
|
||||
static void register() {
|
||||
Field[] declaredFields = Fluids.class.getDeclaredFields();
|
||||
for (Field field : declaredFields) {
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
|
||||
Field[] declaredFields = Fluids.class.getDeclaredFields(); // Gets the blocks and ores declared above
|
||||
for (Field field : declaredFields) { // Iterates through the fields declared above
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { // Checks that the fields are static
|
||||
Class<?> targetType = field.getType();
|
||||
try {
|
||||
BasicTinkerFluid fluid = (BasicTinkerFluid) field.get(targetType);
|
||||
registerFluid(fluid);
|
||||
BasicTinkerFluid fluid = (BasicTinkerFluid) field.get(targetType); // Gets the field as a BasicTinkerFluid
|
||||
registerFluid(fluid); // Registers the fluid into the game along wit its bucket
|
||||
|
||||
BlockMolten block = new BlockMolten(fluid);
|
||||
// Sets names
|
||||
block.setUnlocalizedName("molten_" + fluid.getName());
|
||||
block.setRegistryName(TAIGA.MODID, "molten_" + fluid.getName());
|
||||
// Registers the fluid in its block form and its corresponding item (block/fluid as item in inventory)
|
||||
Utils.registerBlockWithItem(block);
|
||||
|
||||
// Registers the fluid's model but only on the client side
|
||||
TAIGA.proxy.registerFluidModels(fluid);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
@@ -84,7 +91,9 @@ public class Fluids {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers special smeltery recipes (not alloying)
|
||||
*/
|
||||
static void registerfromItem() {
|
||||
registerMelting(radiant_pearl, radiant_enderium, 72);
|
||||
registerMelting(glimmer_pearl, glimming_enderium, 72);
|
||||
|
@@ -104,17 +104,22 @@ public class Items {
|
||||
|
||||
public static Item tiberiumShardInstable = new BasicItem("tiberium_shard_instable");
|
||||
|
||||
|
||||
/**
|
||||
* Registers all materials' ingots and nuggets <br>
|
||||
* Detailed summary: <br>
|
||||
* Gets the ingots declared in the class (fields and reflection) and iterates through them: <br>
|
||||
* Checks that the field is static, registers the field (item), and adds an oreDict entry if needed
|
||||
*/
|
||||
public static void register() {
|
||||
Field[] declaredFields = Items.class.getDeclaredFields();
|
||||
for (Field field : declaredFields) {
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
|
||||
Field[] declaredFields = Items.class.getDeclaredFields(); // Gets the fields (ingots) declared above
|
||||
for (Field field : declaredFields) { // Iterates through the fields declared above
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { // Checks that the fields are static
|
||||
Class<?> targetType = field.getType();
|
||||
try {
|
||||
Item item = (Item) field.get(targetType);
|
||||
GameRegistry.register(item);
|
||||
if (item instanceof BasicItem) {
|
||||
if (((BasicItem) item).isOreDict()) {
|
||||
Item item = (Item) field.get(targetType); // Gets the field as a BasicItem which is then casted to an Item
|
||||
GameRegistry.register(item); // Registers the item into the game
|
||||
if (item instanceof BasicItem) { // Checks that the item is a BasicItem
|
||||
if (((BasicItem) item).isOreDict()) { // Checks if this item should be registered into the oreDict and registers it
|
||||
String oreDictName;
|
||||
String[] nameParts = item.getUnlocalizedName().replace("item.", "").split("_");
|
||||
|
||||
@@ -124,7 +129,7 @@ public class Items {
|
||||
oreDictName = nameParts[0];
|
||||
}
|
||||
|
||||
OreDictionary.registerOre(((BasicItem) item).getOreDictPrefix() + StringUtils.capitalize(oreDictName), item);
|
||||
OreDictionary.registerOre(((BasicItem) item).getOreDictPrefix() + StringUtils.capitalize(oreDictName), item); // Registers into oreDict
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@@ -65,14 +65,12 @@ public class MaterialTraits {
|
||||
public static Material palladium = new Material("palladium", TextFormatting.DARK_GRAY).addTrait(dark);
|
||||
public static Material eternite = new Material("eternite", TextFormatting.AQUA).addTrait(writable2); //.addTrait(traditional)
|
||||
public static Material mythril = new Material("mythril", TextFormatting.GRAY).addTrait(holy, HeadMaterialStats.TYPE).addTrait(hellish, HandleMaterialStats.TYPE);
|
||||
|
||||
public static Material imperomite = new Material("imperomite", TextFormatting.DARK_RED).addTrait(cascade);
|
||||
public static Material fractoryte = new Material("fractoryte", TextFormatting.DARK_RED).addTrait(fracture);
|
||||
public static Material noctunyx = new Material("noctunyx", TextFormatting.LIGHT_PURPLE).addTrait(hollow, HeadMaterialStats.TYPE).addTrait(reviving, HandleMaterialStats.TYPE);
|
||||
public static Material nitronite = new Material("nitronite", TextFormatting.YELLOW).addTrait(uncertain);
|
||||
public static Material cryptogen = new Material("cryptogen", TextFormatting.DARK_GREEN).addTrait(randomize);
|
||||
public static Material seismodium = new Material("seismodium", TextFormatting.WHITE).addTrait(heroic).addTrait(fragile);
|
||||
;
|
||||
public static Material aegisalt = new Material("aegisalt", TextFormatting.AQUA).addTrait(analysing);
|
||||
public static Material ultranite = new Material("ultranite", TextFormatting.AQUA).addTrait(pulverizing);
|
||||
public static Material bysmuid = new Material("bysmuid", TextFormatting.AQUA).addTrait(organizing, HandleMaterialStats.TYPE).addTrait(melting, HeadMaterialStats.TYPE);
|
||||
|
@@ -6,6 +6,7 @@ import com.sosnitzka.taiga.recipes.Crafting;
|
||||
import com.sosnitzka.taiga.recipes.Smelting;
|
||||
import com.sosnitzka.taiga.util.FuelHandler;
|
||||
import com.sosnitzka.taiga.world.ZWorldGen;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
@@ -14,13 +15,16 @@ 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.registry.GameRegistry;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import slimeknights.tconstruct.library.MaterialIntegration;
|
||||
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||
import slimeknights.tconstruct.library.materials.ExtraMaterialStats;
|
||||
import slimeknights.tconstruct.library.materials.HandleMaterialStats;
|
||||
import slimeknights.tconstruct.library.materials.HeadMaterialStats;
|
||||
import slimeknights.tconstruct.library.materials.Material;
|
||||
import slimeknights.tconstruct.tools.TinkerMaterials;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import static com.sosnitzka.taiga.Fluids.*;
|
||||
@@ -35,19 +39,99 @@ public class TAIGA {
|
||||
|
||||
@SidedProxy(clientSide = "com.sosnitzka.taiga.proxy.ClientProxy", serverSide = "com.sosnitzka.taiga.proxy.ServerProxy")
|
||||
public static ServerProxy proxy;
|
||||
private List<MaterialIntegration> integrateList = Lists.newArrayList();
|
||||
|
||||
private List<MaterialIntegration> integrateList = Lists.newArrayList(); // List of materials needed to be integrated
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
Items.register();
|
||||
Blocks.register();
|
||||
Fluids.register();
|
||||
Fluids.registerfromItem();
|
||||
Alloys.register();
|
||||
Items.register(); // Registers items and its oreDict
|
||||
Blocks.register(); // Registers blocks and its items form a long with its oreDict
|
||||
Fluids.register(); // Registers all fluids and its buckets
|
||||
Fluids.registerfromItem(); // Registers some special smeltery recipes (not alloying)
|
||||
Alloys.register(); // Registers alloying recipes
|
||||
|
||||
registerTinkerMaterials(); // Registers materials and associated fluids and stats into tconstruct
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
proxy.registerModels(); // Registers models on the client side
|
||||
GameRegistry.registerWorldGenerator(new ZWorldGen(), 100); // Generates ores
|
||||
GameRegistry.registerFuelHandler(new FuelHandler()); // Registeres fuels' burn times
|
||||
Smelting.register(); // Registers smelting recipes
|
||||
Crafting.register(); // Registers crafting recipes
|
||||
|
||||
// Adds new harvest levels' names
|
||||
harvestLevelNames.put(METEORITE, TinkerMaterials.bone.getTextColor() + "Meteorite");
|
||||
harvestLevelNames.put(VIBRANIUM, TinkerMaterials.blueslime.getTextColor() + "Vibranium");
|
||||
harvestLevelNames.put(ADAMANTITE, TinkerMaterials.ardite.getTextColor() + "Adamantite");
|
||||
harvestLevelNames.put(TITANITE, TinkerMaterials.silver.getTextColor() + "Titanite");
|
||||
|
||||
for (MaterialIntegration m : integrateList) {
|
||||
m.integrateRecipes();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param oreSuffix Suffix in the oreDict, also the name. ex) the "Iron" in "ingotIron"
|
||||
* @param material TConstruct material
|
||||
* @param fluid material's fluid
|
||||
* @param headDura Durability (head)
|
||||
* @param headSpeed Mining speed (head)
|
||||
* @param headAttack Attack speed (head)
|
||||
* @param handleMod Durability multiplier (handle)
|
||||
* @param handleDura Extra durability (handle)
|
||||
* @param extra Extra durability (binding and more)
|
||||
* @param headLevel Mining level (head)
|
||||
* @param craft Can craft parts in part builder
|
||||
* @param cast Can craft parts by casting with fluid (smeltery)
|
||||
*/
|
||||
private void registerTinkerMaterial(String oreSuffix, Material material, Fluid fluid, int headDura, float headSpeed, float headAttack, float handleMod, int handleDura, int extra, int headLevel, boolean craft, boolean cast) {
|
||||
TinkerRegistry.addMaterialStats(material, new HeadMaterialStats(headDura, headSpeed, headAttack, headLevel));
|
||||
TinkerRegistry.addMaterialStats(material, new HandleMaterialStats(handleMod, handleDura));
|
||||
TinkerRegistry.addMaterialStats(material, new ExtraMaterialStats(extra));
|
||||
|
||||
System.out.println(material.getRepresentativeItem());
|
||||
Item item = null;
|
||||
Field[] items = Items.class.getDeclaredFields();
|
||||
for (Field i : items) {
|
||||
if (i.getName().equals(StringUtils.uncapitalize(oreSuffix) + "Ingot")) {
|
||||
Item r = null;
|
||||
try {
|
||||
r = (Item) i.get(i.getType());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
item = r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
material.setFluid(fluid).setCraftable(craft).setCastable(cast).addItem(item, 1, Material.VALUE_Ingot);
|
||||
material.setRepresentativeItem(item);
|
||||
|
||||
System.out.println(material.getRepresentativeItem());
|
||||
|
||||
proxy.setRenderInfo(material);
|
||||
MaterialIntegration integration = new MaterialIntegration(material, fluid, oreSuffix);
|
||||
integration.integrate();
|
||||
integrateList.add(integration);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers materials and associated fluids and stats into tconstruct
|
||||
*/
|
||||
private void registerTinkerMaterials() {
|
||||
// ARCANE ORES
|
||||
registerTinkerMaterial("Tiberium", tiberium, tiberiumFluid, 223, 6.2f, 8.35f, 0.63f, 50, 50, OBSIDIAN, false, true);
|
||||
|
||||
registerTinkerMaterial("Rubium", rubium, rubiumFluid, 351, 5.15f, 7.00f, 1.05f, -100, 250, COBALT, false, true);
|
||||
registerTinkerMaterial("Prometheum", prometheum, prometheumFluid, 539, 3.6f, 6.60f, 0.90f, 0, 150, TITANITE, false, true);
|
||||
registerTinkerMaterial("Arcanite", arcanite, arcaniteFluid, 698, 4.3f, 7.88f, 0.85f, -50, 150, METEORITE, false, true);
|
||||
@@ -85,40 +169,4 @@ public class TAIGA {
|
||||
registerTinkerMaterial("Cryptogen", cryptogen, cryptogenFluid, 538, 5.71f, 6.93f, 0.88f, 58, 117, METEORITE, false, true);
|
||||
registerTinkerMaterial("Proxideum", proxideum, proxideumFluid, 597, 10.55f, 4.21f, 0.99f, -60, 200, METEORITE, false, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
proxy.registerStuff();
|
||||
GameRegistry.registerWorldGenerator(new ZWorldGen(), 100);
|
||||
GameRegistry.registerFuelHandler(new FuelHandler());
|
||||
Smelting.register();
|
||||
Crafting.register();
|
||||
|
||||
harvestLevelNames.put(METEORITE, TinkerMaterials.bone.getTextColor() + "Meteorite");
|
||||
harvestLevelNames.put(VIBRANIUM, TinkerMaterials.blueslime.getTextColor() + "Vibranium");
|
||||
harvestLevelNames.put(ADAMANTITE, TinkerMaterials.ardite.getTextColor() + "Adamantite");
|
||||
harvestLevelNames.put(TITANITE, TinkerMaterials.silver.getTextColor() + "Titanite");
|
||||
|
||||
for (MaterialIntegration m : integrateList) {
|
||||
m.integrateRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
|
||||
}
|
||||
|
||||
private void registerTinkerMaterial(String oreSuffix, slimeknights.tconstruct.library.materials.Material material, Fluid fluid, int headDura, float headSpeed, float headAttack, float handleMod, int handleDura, int extra, int headLevel, boolean craft, boolean cast) {
|
||||
TinkerRegistry.addMaterialStats(material, new HeadMaterialStats(headDura, headSpeed, headAttack, headLevel));
|
||||
TinkerRegistry.addMaterialStats(material, new HandleMaterialStats(handleMod, handleDura));
|
||||
TinkerRegistry.addMaterialStats(material, new ExtraMaterialStats(extra));
|
||||
|
||||
material.setFluid(fluid).setCraftable(craft).setCastable(cast);
|
||||
|
||||
proxy.setRenderInfo(material);
|
||||
MaterialIntegration integration = new MaterialIntegration(material, fluid, oreSuffix);
|
||||
integration.integrate();
|
||||
integrateList.add(integration);
|
||||
}
|
||||
}
|
@@ -2,6 +2,9 @@ package com.sosnitzka.taiga.generic;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
/**
|
||||
* A "wrapper" for Item that makes construction and manipulation easier
|
||||
*/
|
||||
public class BasicItem extends Item {
|
||||
private String oreDictPrefix;
|
||||
|
||||
|
@@ -4,12 +4,17 @@ import net.minecraft.util.ResourceLocation;
|
||||
import slimeknights.tconstruct.library.Util;
|
||||
import slimeknights.tconstruct.library.fluid.FluidMolten;
|
||||
|
||||
/**
|
||||
* A "wrapper" for FluidMolten that makes construction and manipulation easier
|
||||
*/
|
||||
public class BasicTinkerFluid extends FluidMolten {
|
||||
|
||||
private boolean toolForge;
|
||||
|
||||
public BasicTinkerFluid(String fluidName, int color, boolean toolForge, int temp, int lumen, int visk) {
|
||||
// Constructs the FluidMolten with textures and color
|
||||
super(fluidName, color, new ResourceLocation("tconstruct:blocks/fluids/molten_metal"), new ResourceLocation("tconstruct:blocks/fluids/molten_metal_flow"));
|
||||
//Settings
|
||||
this.setUnlocalizedName(Util.prefix(fluidName));
|
||||
this.setTemperature(temp);
|
||||
this.setLuminosity(lumen);
|
||||
|
@@ -35,14 +35,13 @@ public class ClientProxy extends ServerProxy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStuff() {
|
||||
public void registerModels() {
|
||||
Field[] itemFields = Items.class.getDeclaredFields();
|
||||
for (Field field : itemFields) {
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
|
||||
Class<?> targetType = field.getType();
|
||||
try {
|
||||
Item item = (Item) field.get(targetType);
|
||||
|
||||
registerItemModel(item);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
@@ -56,7 +55,6 @@ public class ClientProxy extends ServerProxy {
|
||||
Class<?> targetType = field.getType();
|
||||
try {
|
||||
Block block = (Block) field.get(targetType);
|
||||
|
||||
registerBlockModel(block);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
|
@@ -5,7 +5,7 @@ import slimeknights.tconstruct.library.materials.Material;
|
||||
|
||||
public class ServerProxy {
|
||||
|
||||
public void registerStuff() {
|
||||
public void registerModels() {
|
||||
|
||||
}
|
||||
|
||||
|
@@ -16,12 +16,20 @@ public class Utils {
|
||||
public static String PREFIX_ORE = "ore";
|
||||
public static String PREFIX_BLOCK = "block";
|
||||
|
||||
|
||||
/**
|
||||
* Registers the block and its corresponding item (block as item in inventory)
|
||||
*
|
||||
* @param block the associated block
|
||||
*/
|
||||
public static void registerBlockWithItem(Block block) {
|
||||
GameRegistry.register(block);
|
||||
GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the fluid and its bucket item
|
||||
* @param fluid the fluid
|
||||
*/
|
||||
public static void registerFluid(Fluid fluid) {
|
||||
FluidRegistry.registerFluid(fluid);
|
||||
FluidRegistry.addBucketForFluid(fluid);
|
||||
|
Reference in New Issue
Block a user