Added mixture and molten buckets
This commit is contained in:
parent
0a9d565cf2
commit
d50d2412e1
5 changed files with 146 additions and 4 deletions
|
@ -232,6 +232,7 @@ tooltip.ingot=Ingot
|
||||||
tooltip.rubble=Rubble
|
tooltip.rubble=Rubble
|
||||||
tooltip.dust=Dust
|
tooltip.dust=Dust
|
||||||
tooltip.refinedDust=Refined Dust
|
tooltip.refinedDust=Refined Dust
|
||||||
|
tooltip.bucket=Bucket
|
||||||
|
|
||||||
tooltip.pipe.rate=Flow Rate: %v
|
tooltip.pipe.rate=Flow Rate: %v
|
||||||
tooltip.pipe.pressure=Max Pressure: %v
|
tooltip.pipe.pressure=Max Pressure: %v
|
||||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraftforge.fluids.{FluidContainerRegistry, FluidRegistry, FluidSt
|
||||||
import net.minecraftforge.oredict.OreDictionary
|
import net.minecraftforge.oredict.OreDictionary
|
||||||
import resonant.api.recipe.MachineRecipes
|
import resonant.api.recipe.MachineRecipes
|
||||||
import resonant.lib.factory.resources.RecipeType
|
import resonant.lib.factory.resources.RecipeType
|
||||||
import resonant.lib.prefab.item.ItemFluidBucket
|
|
||||||
import resonant.lib.utility.LanguageUtility
|
import resonant.lib.utility.LanguageUtility
|
||||||
import resonant.lib.wrapper.StringWrapper._
|
import resonant.lib.wrapper.StringWrapper._
|
||||||
import resonantinduction.core.resource.content._
|
import resonantinduction.core.resource.content._
|
||||||
|
@ -72,7 +71,7 @@ object ResourceFactory
|
||||||
if (LanguageUtility.getLocal(localizedName) != null && LanguageUtility.getLocal(localizedName) != "")
|
if (LanguageUtility.getLocal(localizedName) != null && LanguageUtility.getLocal(localizedName) != "")
|
||||||
localizedName = LanguageUtility.getLocal(localizedName)
|
localizedName = LanguageUtility.getLocal(localizedName)
|
||||||
|
|
||||||
localizedName.replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" $", "")
|
localizedName.replace("misc.resonantinduction.ingot".getLocal, "").replaceAll("^ ", "").replaceAll(" $", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate molten fluid
|
//Generate molten fluid
|
||||||
|
@ -84,7 +83,8 @@ object ResourceFactory
|
||||||
moltenFluidMap += (materialName -> blockFluidMaterial)
|
moltenFluidMap += (materialName -> blockFluidMaterial)
|
||||||
|
|
||||||
//Generate molten bucket
|
//Generate molten bucket
|
||||||
val moltenBucket = new ItemFluidBucket
|
val moltenBucket = CoreContent.manager.newItem("bucketMolten" + materialName.capitalizeFirst, new ItemMoltenBucket(materialName))
|
||||||
|
LanguageRegistry.instance.addStringLocalization(moltenBucket.getUnlocalizedName + ".name", "tooltip.molten".getLocal + " " + localizedName + " " + "tooltip.bucket".getLocal)
|
||||||
FluidContainerRegistry.registerFluidContainer(fluidMolten, new ItemStack(moltenBucket))
|
FluidContainerRegistry.registerFluidContainer(fluidMolten, new ItemStack(moltenBucket))
|
||||||
moltenBucketMap += materialName -> moltenBucket
|
moltenBucketMap += materialName -> moltenBucket
|
||||||
|
|
||||||
|
@ -97,7 +97,8 @@ object ResourceFactory
|
||||||
mixtureFluidMap += materialName -> blockFluidMixture
|
mixtureFluidMap += materialName -> blockFluidMixture
|
||||||
|
|
||||||
//Generate mixture bucket
|
//Generate mixture bucket
|
||||||
val mixtureBucket = new ItemFluidBucket
|
val mixtureBucket = CoreContent.manager.newItem("bucketMixture" + materialName.capitalizeFirst, new ItemMixtureBucket(materialName))
|
||||||
|
LanguageRegistry.instance.addStringLocalization(mixtureBucket.getUnlocalizedName + ".name", "tooltip.mixture".getLocal + " " + localizedName + " " + "tooltip.bucket".getLocal)
|
||||||
FluidContainerRegistry.registerFluidContainer(fluidMixture, new ItemStack(mixtureBucket))
|
FluidContainerRegistry.registerFluidContainer(fluidMixture, new ItemStack(mixtureBucket))
|
||||||
mixtureBucketMap += materialName -> mixtureBucket
|
mixtureBucketMap += materialName -> mixtureBucket
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package resonantinduction.core.resource.content
|
||||||
|
|
||||||
|
import resonantinduction.core.Reference
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Calclavia
|
||||||
|
*/
|
||||||
|
class ItemMixtureBucket(material: String) extends ItemResource(material) with TBucket
|
||||||
|
{
|
||||||
|
setTextureName(Reference.prefix + "bucketMixture")
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package resonantinduction.core.resource.content
|
||||||
|
|
||||||
|
import resonantinduction.core.Reference
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Calclavia
|
||||||
|
*/
|
||||||
|
class ItemMoltenBucket(material: String) extends ItemResource(material) with TBucket
|
||||||
|
{
|
||||||
|
setTextureName(Reference.prefix + "bucketMolten")
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
package resonantinduction.core.resource.content
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
import net.minecraftforge.fluids.{FluidContainerRegistry, FluidStack, IFluidContainerItem}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A trait implemented by buckets
|
||||||
|
* @author Calclavia
|
||||||
|
*/
|
||||||
|
trait TBucket extends IFluidContainerItem
|
||||||
|
{
|
||||||
|
protected var capacity = FluidContainerRegistry.BUCKET_VOLUME
|
||||||
|
|
||||||
|
def getFluid(container: ItemStack): FluidStack =
|
||||||
|
{
|
||||||
|
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid"))
|
||||||
|
{
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid"))
|
||||||
|
}
|
||||||
|
|
||||||
|
def getCapacity(container: ItemStack): Int =
|
||||||
|
{
|
||||||
|
return capacity
|
||||||
|
}
|
||||||
|
|
||||||
|
override def fill(container: ItemStack, resource: FluidStack, doFill: Boolean): Int =
|
||||||
|
{
|
||||||
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if (!doFill)
|
||||||
|
{
|
||||||
|
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid"))
|
||||||
|
{
|
||||||
|
return Math.min(capacity, resource.amount)
|
||||||
|
}
|
||||||
|
val stack: FluidStack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid"))
|
||||||
|
if (stack == null)
|
||||||
|
{
|
||||||
|
return Math.min(capacity, resource.amount)
|
||||||
|
}
|
||||||
|
if (!stack.isFluidEqual(resource))
|
||||||
|
{
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return Math.min(capacity - stack.amount, resource.amount)
|
||||||
|
}
|
||||||
|
if (container.stackTagCompound == null)
|
||||||
|
{
|
||||||
|
container.stackTagCompound = new NBTTagCompound
|
||||||
|
}
|
||||||
|
if (!container.stackTagCompound.hasKey("Fluid"))
|
||||||
|
{
|
||||||
|
val fluidTag: NBTTagCompound = resource.writeToNBT(new NBTTagCompound)
|
||||||
|
if (capacity < resource.amount)
|
||||||
|
{
|
||||||
|
fluidTag.setInteger("Amount", capacity)
|
||||||
|
container.stackTagCompound.setTag("Fluid", fluidTag)
|
||||||
|
return capacity
|
||||||
|
}
|
||||||
|
container.stackTagCompound.setTag("Fluid", fluidTag)
|
||||||
|
return resource.amount
|
||||||
|
}
|
||||||
|
val fluidTag: NBTTagCompound = container.stackTagCompound.getCompoundTag("Fluid")
|
||||||
|
val stack: FluidStack = FluidStack.loadFluidStackFromNBT(fluidTag)
|
||||||
|
if (!stack.isFluidEqual(resource))
|
||||||
|
{
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var filled: Int = capacity - stack.amount
|
||||||
|
if (resource.amount < filled)
|
||||||
|
{
|
||||||
|
stack.amount += resource.amount
|
||||||
|
filled = resource.amount
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack.amount = capacity
|
||||||
|
}
|
||||||
|
container.stackTagCompound.setTag("Fluid", stack.writeToNBT(fluidTag))
|
||||||
|
return filled
|
||||||
|
}
|
||||||
|
|
||||||
|
override def drain(container: ItemStack, maxDrain: Int, doDrain: Boolean): FluidStack =
|
||||||
|
{
|
||||||
|
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid"))
|
||||||
|
{
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val stack: FluidStack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid"))
|
||||||
|
if (stack == null)
|
||||||
|
{
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val currentAmount: Int = stack.amount
|
||||||
|
stack.amount = Math.min(stack.amount, maxDrain)
|
||||||
|
if (doDrain)
|
||||||
|
{
|
||||||
|
if (currentAmount == stack.amount)
|
||||||
|
{
|
||||||
|
container.stackTagCompound.removeTag("Fluid")
|
||||||
|
if (container.stackTagCompound.hasNoTags)
|
||||||
|
{
|
||||||
|
container.stackTagCompound = null
|
||||||
|
}
|
||||||
|
return stack
|
||||||
|
}
|
||||||
|
val fluidTag: NBTTagCompound = container.stackTagCompound.getCompoundTag("Fluid")
|
||||||
|
fluidTag.setInteger("Amount", currentAmount - stack.amount)
|
||||||
|
container.stackTagCompound.setTag("Fluid", fluidTag)
|
||||||
|
}
|
||||||
|
return stack
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue