mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 21:20:06 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -8,8 +8,7 @@ import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
/** Melting and hacking, churn and burn */
|
||||
public class Smeltery
|
||||
{
|
||||
public class Smeltery {
|
||||
public static Smeltery instance = new Smeltery();
|
||||
|
||||
private final Map<ItemMetaWrapper, FluidStack> smeltingList = new HashMap<ItemMetaWrapper, FluidStack>();
|
||||
@@ -24,24 +23,21 @@ public class Smeltery
|
||||
* @param power The temperature of the fluid. This also influences the melting speed. Lava is 1000.
|
||||
* @param duration How long one "portion" of liquid fuels the smeltery. Lava is 10.
|
||||
*/
|
||||
public static void addSmelteryFuel (Fluid fluid, int power, int duration)
|
||||
{
|
||||
instance.smelteryFuels.put(fluid, new Integer[] { power, duration });
|
||||
public static void addSmelteryFuel(Fluid fluid, int power, int duration) {
|
||||
instance.smelteryFuels.put(fluid, new Integer[] {power, duration});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the liquid is a valid smeltery fuel.
|
||||
*/
|
||||
public static boolean isSmelteryFuel (Fluid fluid)
|
||||
{
|
||||
public static boolean isSmelteryFuel(Fluid fluid) {
|
||||
return instance.smelteryFuels.containsKey(fluid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the power of a smeltery fuel or 0 if it's not a fuel.
|
||||
*/
|
||||
public static int getFuelPower (Fluid fluid)
|
||||
{
|
||||
public static int getFuelPower(Fluid fluid) {
|
||||
Integer[] power = instance.smelteryFuels.get(fluid);
|
||||
return power == null ? 0 : power[0];
|
||||
}
|
||||
@@ -49,8 +45,7 @@ public class Smeltery
|
||||
/**
|
||||
* Returns the duration of a smeltery fuel or 0 if it's not a fuel.
|
||||
*/
|
||||
public static int getFuelDuration (Fluid fluid)
|
||||
{
|
||||
public static int getFuelDuration(Fluid fluid) {
|
||||
Integer[] power = instance.smelteryFuels.get(fluid);
|
||||
return power == null ? 0 : power[1];
|
||||
}
|
||||
@@ -59,31 +54,28 @@ public class Smeltery
|
||||
* Adds mappings between an itemstack and an output liquid Example:
|
||||
* Smeltery.addMelting(Block.oreIron, 0, 600, new
|
||||
* FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
|
||||
*
|
||||
*
|
||||
* @param stack The itemstack to liquify. Must hold a block.
|
||||
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary
|
||||
* @param output The result of the process in liquid form
|
||||
*/
|
||||
public static void addMelting (ItemStack stack, int temperature, FluidStack output)
|
||||
{
|
||||
public static void addMelting(ItemStack stack, int temperature, FluidStack output) {
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
addMelting(stack, ((ItemBlock) stack.getItem()).field_150939_a, stack.getItemDamage(), temperature, output);
|
||||
else
|
||||
throw new IllegalArgumentException("ItemStack must house a block.");
|
||||
else throw new IllegalArgumentException("ItemStack must house a block.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mappings between a block and its liquid Example:
|
||||
* Smeltery.addMelting(Block.oreIron, 0, 600, new
|
||||
* FluidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue * 2, 0));
|
||||
*
|
||||
*
|
||||
* @param block The block to liquify and render
|
||||
* @param metadata The metadata of the block to liquify and render
|
||||
* @param temperature How hot the block should be before liquifying. Max temp in the Smeltery is 800, other structures may vary
|
||||
* @param output The result of the process in liquid form
|
||||
*/
|
||||
public static void addMelting (Block block, int metadata, int temperature, FluidStack output)
|
||||
{
|
||||
public static void addMelting(Block block, int metadata, int temperature, FluidStack output) {
|
||||
addMelting(new ItemStack(block, 1, metadata), block, metadata, temperature, output);
|
||||
}
|
||||
|
||||
@@ -92,15 +84,14 @@ public class Smeltery
|
||||
* input's block ID and metadata Example: Smeltery.addMelting(Block.oreIron,
|
||||
* 0, 600, new FluidStack(liquidMetalStill.blockID,
|
||||
* TConstruct.ingotLiquidValue * 2, 0));
|
||||
*
|
||||
*
|
||||
* @param input The item to liquify
|
||||
* @param block The block to render
|
||||
* @param metadata The metadata of the block to render
|
||||
* @param temperature How hot the block should be before liquifying
|
||||
* @param liquid The result of the process
|
||||
*/
|
||||
public static void addMelting (ItemStack input, Block block, int metadata, int temperature, FluidStack liquid)
|
||||
{
|
||||
public static void addMelting(ItemStack input, Block block, int metadata, int temperature, FluidStack liquid) {
|
||||
ItemMetaWrapper in = new ItemMetaWrapper(input);
|
||||
instance.smeltingList.put(in, liquid);
|
||||
instance.temperatureList.put(in, temperature);
|
||||
@@ -112,148 +103,136 @@ public class Smeltery
|
||||
* FluidStack(bronzeID, 2, 0), new FluidStack(copperID, 3, 0), new
|
||||
* FluidStack(tinID, 1, 0)); The example mixes 3 copper with 1 tin to make 2
|
||||
* bronze
|
||||
*
|
||||
*
|
||||
* @param result The output of the combination of mixers. The quantity is used for amount of a successful mix
|
||||
* @param mixers the liquids to be mixed. Quantities are used as ratios
|
||||
*/
|
||||
public static void addAlloyMixing (FluidStack result, FluidStack... mixers)
|
||||
{
|
||||
public static void addAlloyMixing(FluidStack result, FluidStack... mixers) {
|
||||
ArrayList inputs = new ArrayList();
|
||||
for (FluidStack liquid : mixers)
|
||||
inputs.add(liquid);
|
||||
for (FluidStack liquid : mixers) inputs.add(liquid);
|
||||
|
||||
instance.alloys.add(new AlloyMix(result, inputs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the resulting temperature from a source ItemStack
|
||||
*
|
||||
*
|
||||
* @param item The Source ItemStack
|
||||
* @return The result temperature
|
||||
*/
|
||||
public static Integer getLiquifyTemperature (ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
return 20;
|
||||
public static Integer getLiquifyTemperature(ItemStack item) {
|
||||
if (item == null) return 20;
|
||||
|
||||
Integer temp = instance.temperatureList.get(new ItemMetaWrapper(item));
|
||||
if (temp == null)
|
||||
return 20;
|
||||
else
|
||||
return temp;
|
||||
if (temp == null) return 20;
|
||||
else return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the resulting temperature from a source Block
|
||||
*
|
||||
*
|
||||
* @param block The Source Block
|
||||
* @return The result ItemStack
|
||||
*/
|
||||
public static Integer getLiquifyTemperature (Block block, int metadata)
|
||||
{
|
||||
public static Integer getLiquifyTemperature(Block block, int metadata) {
|
||||
return instance.getLiquifyTemperature(new ItemStack(block, 1, metadata));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the resulting ItemStack from a source ItemStack
|
||||
*
|
||||
*
|
||||
* @param item The Source ItemStack
|
||||
* @return The result ItemStack
|
||||
*/
|
||||
public static FluidStack getSmelteryResult (ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
public static FluidStack getSmelteryResult(ItemStack item) {
|
||||
if (item == null) return null;
|
||||
|
||||
FluidStack stack = instance.smeltingList.get(new ItemMetaWrapper(item));
|
||||
if (stack == null)
|
||||
return null;
|
||||
if (stack == null) return null;
|
||||
return stack.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the resulting ItemStack from a source Block
|
||||
*
|
||||
*
|
||||
* @param block The Source Block
|
||||
* @return The result ItemStack
|
||||
*/
|
||||
public static FluidStack getSmelteryResult (Block block, int metadata)
|
||||
{
|
||||
public static FluidStack getSmelteryResult(Block block, int metadata) {
|
||||
return instance.getSmelteryResult(new ItemStack(block, 1, metadata));
|
||||
}
|
||||
|
||||
public static ItemStack getRenderIndex (ItemStack input)
|
||||
{
|
||||
public static ItemStack getRenderIndex(ItemStack input) {
|
||||
return instance.renderIndex.get(new ItemMetaWrapper(input));
|
||||
}
|
||||
|
||||
public static ArrayList mixMetals (ArrayList<FluidStack> moltenMetal)
|
||||
{
|
||||
public static ArrayList mixMetals(ArrayList<FluidStack> moltenMetal) {
|
||||
ArrayList liquids = new ArrayList();
|
||||
for (AlloyMix alloy : instance.alloys)
|
||||
{
|
||||
for (AlloyMix alloy : instance.alloys) {
|
||||
FluidStack liquid = alloy.mix(moltenMetal);
|
||||
if (liquid != null)
|
||||
liquids.add(liquid);
|
||||
if (liquid != null) liquids.add(liquid);
|
||||
}
|
||||
return liquids;
|
||||
}
|
||||
|
||||
public static Map<ItemMetaWrapper, FluidStack> getSmeltingList ()
|
||||
{
|
||||
public static Map<ItemMetaWrapper, FluidStack> getSmeltingList() {
|
||||
return instance.smeltingList;
|
||||
}
|
||||
|
||||
public static Map<ItemMetaWrapper, Integer> getTemperatureList ()
|
||||
{
|
||||
public static Map<ItemMetaWrapper, Integer> getTemperatureList() {
|
||||
return instance.temperatureList;
|
||||
}
|
||||
|
||||
public static Map<ItemMetaWrapper, ItemStack> getRenderIndex ()
|
||||
{
|
||||
public static Map<ItemMetaWrapper, ItemStack> getRenderIndex() {
|
||||
return instance.renderIndex;
|
||||
}
|
||||
|
||||
public static List<AlloyMix> getAlloyList ()
|
||||
{
|
||||
public static List<AlloyMix> getAlloyList() {
|
||||
return instance.alloys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mapping between FluidType and ItemStack
|
||||
*
|
||||
*
|
||||
* @author samtrion
|
||||
*
|
||||
*
|
||||
* @param type Type of Fluid
|
||||
* @param input The item to liquify
|
||||
* @param temperatureDifference Difference between FluidType BaseTemperature
|
||||
* @param fluidAmount Amount of Fluid
|
||||
*/
|
||||
public static void addMelting (FluidType type, ItemStack input, int temperatureDifference, int fluidAmount)
|
||||
{
|
||||
public static void addMelting(FluidType type, ItemStack input, int temperatureDifference, int fluidAmount) {
|
||||
int temp = type.baseTemperature + temperatureDifference;
|
||||
if (temp <= 20)
|
||||
temp = type.baseTemperature;
|
||||
if (temp <= 20) temp = type.baseTemperature;
|
||||
|
||||
if (input.getItem() instanceof ItemBlock)
|
||||
addMelting(input, ((ItemBlock) input.getItem()).field_150939_a, input.getItemDamage(), type.baseTemperature + temperatureDifference, new FluidStack(type.fluid, fluidAmount));
|
||||
addMelting(
|
||||
input,
|
||||
((ItemBlock) input.getItem()).field_150939_a,
|
||||
input.getItemDamage(),
|
||||
type.baseTemperature + temperatureDifference,
|
||||
new FluidStack(type.fluid, fluidAmount));
|
||||
else
|
||||
addMelting(input, type.renderBlock, type.renderMeta, type.baseTemperature + temperatureDifference, new FluidStack(type.fluid, fluidAmount));
|
||||
addMelting(
|
||||
input,
|
||||
type.renderBlock,
|
||||
type.renderMeta,
|
||||
type.baseTemperature + temperatureDifference,
|
||||
new FluidStack(type.fluid, fluidAmount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all Items to the Smeltery based on the oreDictionary Name
|
||||
*
|
||||
*
|
||||
* @author samtrion
|
||||
*
|
||||
*
|
||||
* @param oreName oreDictionary name e.g. oreIron
|
||||
* @param type Type of Fluid
|
||||
* @param temperatureDifference Difference between FluidType BaseTemperature
|
||||
* @param fluidAmount Amount of Fluid
|
||||
*/
|
||||
public static void addDictionaryMelting (String oreName, FluidType type, int temperatureDifference, int fluidAmount)
|
||||
{
|
||||
for (ItemStack is : OreDictionary.getOres(oreName))
|
||||
addMelting(type, is, temperatureDifference, fluidAmount);
|
||||
public static void addDictionaryMelting(
|
||||
String oreName, FluidType type, int temperatureDifference, int fluidAmount) {
|
||||
for (ItemStack is : OreDictionary.getOres(oreName)) addMelting(type, is, temperatureDifference, fluidAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user