mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-10-26 14:33:50 +00:00
IMC to allow adding a material + liquid to all the standard metal tool part casting stuff.
This commit is contained in:
1 parent
ff79f7d2da
commit
e7a2fb54e2
2 files changed
+68
-1
No files matched your search
@@ -16,7 +16,7 @@ public class PatternBuilder
|
||||
public static PatternBuilder instance = new PatternBuilder();
|
||||
// Map items to their parts with a hashmap
|
||||
public List<ItemKey> materials = new ArrayList<ItemKey>();
|
||||
public HashMap materialSets = new HashMap<String, MaterialSet>();
|
||||
public HashMap<String, MaterialSet> materialSets = new HashMap<String, MaterialSet>();
|
||||
|
||||
// We could use IRecipe if it wasn't tied to InventoryCrafting
|
||||
public List<IPattern> toolPatterns = new ArrayList<IPattern>();
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.tools.DynamicToolPart;
|
||||
import tconstruct.library.tools.ToolMaterial;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.smeltery.TinkerSmeltery;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public final class IMCHandler {
|
||||
@@ -35,6 +44,64 @@ public final class IMCHandler {
|
||||
TConstruct.logger.info("IMC: Added material " + mat.materialName);
|
||||
}
|
||||
}
|
||||
else if(type.equals("addPartBuilderMaterial"))
|
||||
{
|
||||
if(!message.isNBTMessage())
|
||||
{
|
||||
logInvalidMessage(message);
|
||||
continue;
|
||||
}
|
||||
// PatternBuilder.instance.registerMaterial();
|
||||
}
|
||||
else if(type.equals("addPartCastingMaterial"))
|
||||
{
|
||||
if(!message.isNBTMessage())
|
||||
{
|
||||
logInvalidMessage(message);
|
||||
continue;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = message.getNBTValue();
|
||||
|
||||
if(!tag.hasKey("MaterialId"))
|
||||
{
|
||||
TConstruct.logger.error("Casting IMC: Not material ID for the result present");
|
||||
continue;
|
||||
}
|
||||
|
||||
int matID = tag.getInteger("MaterialId");
|
||||
FluidStack liquid = FluidStack.loadFluidStackFromNBT(tag);
|
||||
if(liquid == null) {
|
||||
TConstruct.logger.error("Casting IMC: No fluid found");
|
||||
continue;
|
||||
}
|
||||
|
||||
// we add the toolpart to all smeltery recipies that use iron and create a toolpart
|
||||
List<CastingRecipe> newRecipies = new LinkedList<CastingRecipe>();
|
||||
for(CastingRecipe recipe : TConstructRegistry.getTableCasting().getCastingRecipes())
|
||||
{
|
||||
if(recipe.castingMetal.getFluid() != TinkerSmeltery.moltenIronFluid)
|
||||
continue;
|
||||
if(recipe.cast == null || !(recipe.cast.getItem() instanceof IPattern))
|
||||
continue;
|
||||
if(!(recipe.getResult().getItem() instanceof DynamicToolPart)) // has to be dynamic toolpart to support automatic addition
|
||||
continue;
|
||||
|
||||
newRecipies.add(recipe);
|
||||
}
|
||||
|
||||
// has to be done separately so we have all checks and no concurrent modification exception
|
||||
for(CastingRecipe recipe : newRecipies)
|
||||
{
|
||||
ItemStack output = recipe.getResult().copy();
|
||||
output.setItemDamage(matID);
|
||||
|
||||
FluidStack liquid2 = new FluidStack(liquid, recipe.castingMetal.amount);
|
||||
|
||||
// ok, this recipe creates a toolpart and uses iron for it. add a new one for the IMC stuff!
|
||||
TConstructRegistry.getTableCasting().addCastingRecipe(output, liquid2, recipe.cast, recipe.consumeCast, recipe.coolTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user