Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
cleaned the code a bit, re-added thaumcraft & railcraft fuels support
Browse files Browse the repository at this point in the history
  • Loading branch information
ephys committed Aug 23, 2014
1 parent 16c1bd3 commit 3834bb6
Show file tree
Hide file tree
Showing 9 changed files with 278 additions and 200 deletions.
11 changes: 2 additions & 9 deletions src/main/java/tsteelworks/TSteelworks.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tsteelworks;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
Expand Down Expand Up @@ -60,6 +59,7 @@ public void preInit(FMLPreInitializationEvent event) {
proxy.preInit();

content = new TSContent();
content.preInit();

events = new TSEventHandler();
MinecraftForge.EVENT_BUS.register(events);
Expand All @@ -81,14 +81,7 @@ public void init(FMLInitializationEvent event) {

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
thermalExpansionAvailable = Loader.isModLoaded("ThermalExpansion");
railcraftAvailable = Loader.isModLoaded("Railcraft");

content.createEntities();
content.addCraftingRecipes();
content.modIntegration();
content.registerMixerMaterials();

content.postInit();
pluginController.postInit();

proxy.postInit();
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/tsteelworks/client/core/TSClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import mantle.books.BookData;
import mantle.client.MProxyClient;
import mantle.lib.client.MantleClientRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityBreakingFX;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
Expand All @@ -26,13 +23,14 @@
import tsteelworks.client.pages.TSHighOvenPage;
import tsteelworks.client.pages.TSPicturePage;
import tsteelworks.client.particle.TSParticle;
import tsteelworks.common.core.ModsData;
import tsteelworks.common.core.TSCommonProxy;
import tsteelworks.common.core.TSContent;
import tsteelworks.lib.TSRepo;
import tsteelworks.common.entity.HighGolem;
import tsteelworks.common.entity.SteelGolem;
import tsteelworks.common.entity.projectile.EntityLimestoneBrick;
import tsteelworks.common.entity.projectile.EntityScorchedBrick;
import tsteelworks.lib.TSRepo;
import tsteelworks.lib.client.TSClientRegistry;

public class TSClientProxy extends TSCommonProxy {
Expand Down Expand Up @@ -87,7 +85,7 @@ private void initManualIcons() {
MantleClientRegistry.registerManualIcon("scorchedbrickblock", new ItemStack(TSContent.highoven, 1, 2));

// Misc Blocks
MantleClientRegistry.registerManualIcon("charcoalblock", TSContent.charcoalBlock);
MantleClientRegistry.registerManualIcon("charcoalblock", ModsData.Shared.charcoalBlock);
MantleClientRegistry.registerManualIcon("gunpowderblock", new ItemStack(TSContent.dustStorageBlock, 1, 0));
MantleClientRegistry.registerManualIcon("sugarblock", new ItemStack(TSContent.dustStorageBlock, 1, 1));
MantleClientRegistry.registerManualIcon("spongeblock", new ItemStack(Blocks.sponge));
Expand Down Expand Up @@ -152,7 +150,7 @@ private void initManualRecipes() {

final ItemStack lapis = new ItemStack(Items.dye, 1, 4);

final ItemStack charcoalBlock = TSContent.charcoalBlock;
final ItemStack charcoalBlock = ModsData.Shared.charcoalBlock;
final ItemStack gunpowderBlock = new ItemStack(TSContent.dustStorageBlock, 1, 0);
final ItemStack sugarBlock = new ItemStack(TSContent.dustStorageBlock, 1, 1);

Expand Down
15 changes: 8 additions & 7 deletions src/main/java/tsteelworks/client/core/TSEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import tsteelworks.common.core.ModsData;
import tsteelworks.common.core.TSContent;

public class TSEventHandler {
@SubscribeEvent
public void reloadTextures(TextureStitchEvent.Post event) {
if (TSContent.steamIsOurs)
TSContent.steamFluid.setIcons(TSContent.steamBlock.getIcon(0,0), TSContent.steamBlock.getIcon(2, 0));
if (TSContent.steamFluid != null)
TSContent.steamFluid.setIcons(ModsData.Fluids.steamBlock.getIcon(0,0), ModsData.Fluids.steamBlock.getIcon(2, 0));

if (TSContent.limestoneIsOurs)
TSContent.moltenLimestoneFluid.setIcons(TSContent.moltenLimestone.getIcon(0,0), TSContent.moltenLimestone.getIcon(2, 0));
if (TSContent.moltenLimestoneFluid != null)
TSContent.moltenLimestoneFluid.setIcons(ModsData.Fluids.moltenLimestone.getIcon(0,0), ModsData.Fluids.moltenLimestone.getIcon(2, 0));

if (TSContent.cementIsOurs)
TSContent.liquidCementFluid.setIcons(TSContent.liquidCement.getIcon(0,0), TSContent.liquidCement.getIcon(2, 0));
if (TSContent.liquidCementFluid != null)
TSContent.liquidCementFluid.setIcons(ModsData.Fluids.liquidCement.getIcon(0,0), ModsData.Fluids.liquidCement.getIcon(2, 0));
}
}
}
216 changes: 216 additions & 0 deletions src/main/java/tsteelworks/common/core/ModsData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
package tsteelworks.common.core;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import nf.fr.ephys.cookiecore.helpers.RegistryHelper;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.LiquidCasting;
import tconstruct.tools.TinkerTools;
import tsteelworks.common.blocks.CementFluidBlock;
import tsteelworks.common.blocks.TSBaseBlock;
import tsteelworks.common.blocks.TSFluidBlock;

import java.util.List;

public class ModsData {
/**
* Anything fluid
*/
public static class Fluids {
public static Fluid steamFluid;
public static ItemStack bucketSteam;
public static Block steamBlock;

public static Fluid moltenLimestoneFluid;
public static ItemStack bucketLimestone;
public static Block moltenLimestone;

public static Fluid liquidCementFluid;
public static ItemStack bucketCement;
public static Block liquidCement;
}

/**
* Anything that can also be added by other mods, includes oredict things
*/
public static class Shared {
public static ItemStack charcoalBlock;
}

/**
* Anything added by thaumcraft
*/
public static class Thaumcraft {
public static ItemStack alumentum;
}

/**
* Anything added by TE
*/
public static class ThermalExpansion {
public static boolean isLoaded;

public static ItemStack slag;
}

/**
* Anything added by Railcraft
*/
public static class Railcraft {
public static boolean isLoaded;

public static ItemStack coalCoke;
public static ItemStack coalCokeBlock;
}

public static void loadModsData() {
if (TinkerTools.thaumcraftAvailable) {
TSLogger.info("Thaumcraft detected. Registering fuels.");

Thaumcraft.alumentum = RegistryHelper.getItemStack("Thaumcraft:ItemResource@0");
}

ThermalExpansion.isLoaded = Loader.isModLoaded("ThermalExpansion");
if (ThermalExpansion.isLoaded) {
TSLogger.info("TE detected. Getting slagged.");

ThermalExpansion.slag = RegistryHelper.getItemStack("ThermalExpansion:material@514");
}

Railcraft.isLoaded = Loader.isModLoaded("Railcraft");
if (Railcraft.isLoaded) {
TSLogger.info("Railcraft detected. Coke production in progress.");

Railcraft.coalCoke = RegistryHelper.getItemStack("Railcraft:fuel.coke@0");
Railcraft.coalCokeBlock = RegistryHelper.getItemStack("Railcraft:tile.railcraft.cube@0");
}
}

public static void loadSharedData() {
registerFluids();

/* Raw Vanilla Materials */
List<ItemStack> charcoalBlocks = OreDictionary.getOres("blockCharcoal");

if (charcoalBlocks.isEmpty()) {
TSContent.tsCharcoalBlock = new TSBaseBlock(Material.rock, 5.0f, new String[] {"charcoal_block"}).setBlockName("tsteelworks.blocks.charcoal");
GameRegistry.registerBlock(TSContent.tsCharcoalBlock, "blockCharcoal");

Blocks.fire.setFireInfo(TSContent.tsCharcoalBlock, 15, 30);
OreDictionary.registerOre("blockCharcoal", TSContent.tsCharcoalBlock);

Shared.charcoalBlock = new ItemStack(TSContent.tsCharcoalBlock);
GameRegistry.registerFuelHandler(new FuelHandler(Shared.charcoalBlock, 15000));
} else {
Shared.charcoalBlock = charcoalBlocks.get(0);
}
}

private static void registerFluids() {
LiquidCasting tableCasting = TConstructRegistry.getTableCasting();
ItemStack bucket = new ItemStack(Items.bucket);

/* Steam */
Fluids.steamFluid = FluidRegistry.getFluid("steam");
if (Fluids.steamFluid == null) {
Fluids.steamFluid = new Fluid("steam");
Fluids.steamFluid.setDensity(-1).setViscosity(5).setTemperature(1300).setGaseous(true);

FluidRegistry.registerFluid(Fluids.steamFluid);

TSContent.steamFluid = Fluids.steamFluid;
}

if (!Fluids.steamFluid.canBePlacedInWorld()) {
Fluids.steamBlock = new TSFluidBlock(Fluids.steamFluid, Material.air, "liquid_steam").setBlockName("steam").setLightOpacity(0);
GameRegistry.registerBlock(Fluids.steamBlock, "steam");
} else {
Fluids.steamBlock = Fluids.steamFluid.getBlock();
}

ItemStack filledBucket = FluidContainerRegistry.fillFluidContainer(new FluidStack(Fluids.steamFluid, 1000), bucket);
if (filledBucket == null) {
Item bucketSteam = new ItemBucket(Fluids.steamBlock).setTextureName("TSteelworks:materials/bucket_steam").setUnlocalizedName("tsteelworks.bucket.Steam").setCreativeTab(TSContent.creativeTab);
GameRegistry.registerItem(bucketSteam, "steamBucket");

filledBucket = new ItemStack(bucketSteam, 1, 0);
FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(new FluidStack(Fluids.steamFluid, 1000), filledBucket, bucket));
}

Fluids.bucketSteam = filledBucket;

tableCasting.addCastingRecipe(filledBucket, new FluidStack(Fluids.steamFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10);

/* Limestone */
Fluids.moltenLimestoneFluid = FluidRegistry.getFluid("limestone.molten");
if (Fluids.moltenLimestoneFluid == null) {
Fluids.moltenLimestoneFluid = new Fluid("limestone.molten").setLuminosity(12).setDensity(3000).setViscosity(6000).setTemperature(1300);

FluidRegistry.registerFluid(Fluids.moltenLimestoneFluid);

TSContent.moltenLimestoneFluid = Fluids.moltenLimestoneFluid;
}

if (!Fluids.moltenLimestoneFluid.canBePlacedInWorld()) {
Fluids.moltenLimestone = new TSFluidBlock(Fluids.moltenLimestoneFluid, Material.lava, "liquid_limestone").setBlockName("molten.limestone");
GameRegistry.registerBlock(Fluids.moltenLimestone, "molten.limestone");
} else {
Fluids.moltenLimestone = Fluids.moltenLimestoneFluid.getBlock();
}

filledBucket = FluidContainerRegistry.fillFluidContainer(new FluidStack(Fluids.moltenLimestoneFluid, 1000), bucket);
if (filledBucket == null) {
Item bucketLimestone = new ItemBucket(Fluids.moltenLimestone).setTextureName("TSteelworks:materials/bucket_limestone").setUnlocalizedName("tsteelworks.bucket.Limestone").setCreativeTab(TSContent.creativeTab);
GameRegistry.registerItem(bucketLimestone, "limestoneBucket");

filledBucket = new ItemStack(bucketLimestone, 1, 1);
FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(new FluidStack(Fluids.moltenLimestoneFluid, 1000), filledBucket, bucket));
}

Fluids.bucketLimestone = filledBucket;

tableCasting.addCastingRecipe(filledBucket, new FluidStack(Fluids.moltenLimestoneFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10);

/* Cement */
Fluids.liquidCementFluid = FluidRegistry.getFluid("cement.liquid");
if (Fluids.liquidCementFluid == null) {
Fluids.liquidCementFluid = new Fluid("cement.liquid").setLuminosity(0).setDensity(6000).setViscosity(6000).setTemperature(20);

FluidRegistry.registerFluid(Fluids.liquidCementFluid);

TSContent.liquidCementFluid = Fluids.liquidCementFluid;
}

if (!Fluids.liquidCementFluid.canBePlacedInWorld()) {
Fluids.liquidCement = new CementFluidBlock(Fluids.liquidCementFluid, Material.water, "liquid_cement").setBlockName("liquid.cement");
GameRegistry.registerBlock(Fluids.liquidCement, "liquid.cement");
} else {
Fluids.liquidCement = Fluids.liquidCementFluid.getBlock();
}

filledBucket = FluidContainerRegistry.fillFluidContainer(new FluidStack(Fluids.liquidCementFluid, 1000), bucket);
if (filledBucket == null) {
Item bucketCement = new ItemBucket(Fluids.liquidCement).setTextureName("TSteelworks:materials/bucket_cement").setUnlocalizedName("tsteelworks.bucket.Cement").setCreativeTab(TSContent.creativeTab);
GameRegistry.registerItem(bucketCement, "cementBucket");

filledBucket = new ItemStack(bucketCement, 1, 2);
FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(new FluidStack(Fluids.liquidCementFluid, 1000), filledBucket, bucket));
}

Fluids.bucketCement = filledBucket;

tableCasting.addCastingRecipe(filledBucket, new FluidStack(Fluids.liquidCementFluid, FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10);
}
}
Loading

0 comments on commit 3834bb6

Please sign in to comment.