Gutter now accepts water blocks from above
This commit is contained in:
parent
f19f7ab1ff
commit
c0ff13b673
|
@ -3,6 +3,7 @@ package resonantinduction.archaic.fluid.gutter
|
||||||
import java.util.{ArrayList, List}
|
import java.util.{ArrayList, List}
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||||
|
import net.minecraft.block.Block
|
||||||
import net.minecraft.block.material.Material
|
import net.minecraft.block.material.Material
|
||||||
import net.minecraft.entity.Entity
|
import net.minecraft.entity.Entity
|
||||||
import net.minecraft.entity.item.EntityItem
|
import net.minecraft.entity.item.EntityItem
|
||||||
|
@ -12,7 +13,7 @@ import net.minecraft.tileentity.TileEntity
|
||||||
import net.minecraft.util.ResourceLocation
|
import net.minecraft.util.ResourceLocation
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader
|
import net.minecraftforge.client.model.AdvancedModelLoader
|
||||||
import net.minecraftforge.common.util.ForgeDirection
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
import net.minecraftforge.fluids.{Fluid, FluidRegistry, FluidStack, IFluidTank}
|
import net.minecraftforge.fluids._
|
||||||
import org.lwjgl.opengl.GL11
|
import org.lwjgl.opengl.GL11
|
||||||
import resonant.api.recipe.{MachineRecipes, RecipeResource}
|
import resonant.api.recipe.{MachineRecipes, RecipeResource}
|
||||||
import resonant.content.factory.resources.RecipeType
|
import resonant.content.factory.resources.RecipeType
|
||||||
|
@ -111,6 +112,31 @@ class TileGutter extends TileFluidProvider(Material.rock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override def onNeighborChanged(block: Block)
|
||||||
|
{
|
||||||
|
super.onNeighborChanged(block)
|
||||||
|
|
||||||
|
if (!world.isRemote)
|
||||||
|
{
|
||||||
|
val posAbove = toVectorWorld + new Vector3(0, 1, 0)
|
||||||
|
val blockAbove = posAbove.getBlock
|
||||||
|
val tanks = findAllTanks
|
||||||
|
|
||||||
|
def drainAbove(doDrain: Boolean) =
|
||||||
|
{
|
||||||
|
val stack = FluidUtility.drainBlock(posAbove.world, posAbove, doDrain)
|
||||||
|
|
||||||
|
if (stack != null)
|
||||||
|
FluidUtility.fillAllTanks(tanks, stack, doDrain)
|
||||||
|
else
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drainAbove(false) == FluidContainerRegistry.BUCKET_VOLUME)
|
||||||
|
drainAbove(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override def activate(player: EntityPlayer, side: Int, vector3: Vector3): Boolean =
|
override def activate(player: EntityPlayer, side: Int, vector3: Vector3): Boolean =
|
||||||
{
|
{
|
||||||
if (player.getCurrentEquippedItem != null)
|
if (player.getCurrentEquippedItem != null)
|
||||||
|
@ -147,8 +173,7 @@ class TileGutter extends TileFluidProvider(Material.rock)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
FluidUtility.playerActivatedFluidItem(findGutters().map(_.getPrimaryTank).toList, player, side)
|
return FluidUtility.playerActivatedFluidItem(findAllTanks, player, side)
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -167,6 +192,8 @@ class TileGutter extends TileFluidProvider(Material.rock)
|
||||||
return foundGutters
|
return foundGutters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def findAllTanks = findGutters().map(_.getPrimaryTank).toList
|
||||||
|
|
||||||
override def onFillRain()
|
override def onFillRain()
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
|
|
|
@ -3,7 +3,7 @@ package resonantinduction.mechanical.mech.turbine
|
||||||
import java.util.List
|
import java.util.List
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.ReflectionHelper
|
import cpw.mods.fml.relauncher.ReflectionHelper
|
||||||
import net.minecraft.block.{Block, BlockDynamicLiquid}
|
import net.minecraft.block.{BlockLiquid, Block, BlockDynamicLiquid}
|
||||||
import net.minecraft.creativetab.CreativeTabs
|
import net.minecraft.creativetab.CreativeTabs
|
||||||
import net.minecraft.init.Blocks
|
import net.minecraft.init.Blocks
|
||||||
import net.minecraft.item.{Item, ItemStack}
|
import net.minecraft.item.{Item, ItemStack}
|
||||||
|
@ -89,7 +89,7 @@ class TileWaterTurbine extends TileTurbine
|
||||||
if (blockID == Blocks.water || blockID == Blocks.flowing_water)
|
if (blockID == Blocks.water || blockID == Blocks.flowing_water)
|
||||||
{
|
{
|
||||||
|
|
||||||
val m = ReflectionHelper.findMethod(classOf[BlockDynamicLiquid], null, Array[String]("getFlowVector", "func_72202_i"), classOf[IBlockAccess], Integer.TYPE, Integer.TYPE, Integer.TYPE)
|
val m = ReflectionHelper.findMethod(classOf[BlockLiquid], null, Array[String]("getFlowVector", "func_72202_i"), classOf[IBlockAccess], Integer.TYPE, Integer.TYPE, Integer.TYPE)
|
||||||
val vector = new Vector3(m.invoke(Blocks.water, Array(worldObj, check.xi, check.yi, check.zi)).asInstanceOf[Vec3])
|
val vector = new Vector3(m.invoke(Blocks.water, Array(worldObj, check.xi, check.yi, check.zi)).asInstanceOf[Vec3])
|
||||||
val invert = (currentDir.offsetZ > 0 && vector.x < 0) || (currentDir.offsetZ < 0 && vector.x > 0) || (currentDir.offsetX > 0 && vector.z > 0) || (currentDir.offsetX < 0 && vector.z < 0)
|
val invert = (currentDir.offsetZ > 0 && vector.x < 0) || (currentDir.offsetZ < 0 && vector.x > 0) || (currentDir.offsetX > 0 && vector.z > 0) || (currentDir.offsetX < 0 && vector.z < 0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue