Skip to content

Commit

Permalink
v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
LasmGratel committed Feb 3, 2021
1 parent 2f46786 commit 27443f5
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 39 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### [Downloads and Docs](http://bdew.net/pressure)
### [Forum thread](http://www.minecraftforum.net/topic/2727722-)
### [Jenkins](http://jenkins.bdew.net/)

### Modifications

Now requires [CoFH Core](https://www.curseforge.com/minecraft/mc-mods/cofh-core/files/2920433) to be installed!

Fixed https://github.com/bdew/pressure/issues/115 https://github.com/bdew/pressure/issues/111 https://github.com/bdew/pressure/issues/117

Added wrench support, tested on Crescent Hammer
16 changes: 9 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ if (project.hasProperty('forgeOverride')) {
config.forge.version = forgeOverride
}

if (project.hasProperty('buildnum')) {
ext.simpleVersion = "${config.pressure.version}.${project.buildnum}"
} else {
ext.simpleVersion = "${config.pressure.version}-DEV"
}
ext.simpleVersion = config.pressure.version

version = simpleVersion + '-mc' + config.minecraft.version

Expand Down Expand Up @@ -71,7 +67,7 @@ repositories {
}
maven {
name "HWYLA"
url "http://tehnut.info/maven"
url "https://maven.tehnut.info/"
}
maven {
name "OpenComputers"
Expand All @@ -81,19 +77,25 @@ repositories {
name "MCMultipart"
url "http://maven.amadornes.com/"
}
maven {
name = "CoFH Maven"
url "http://maven.covers1624.net"
}
}

dependencies {
compile "net.bdew:bdlib:${config.bdlib.version}-mc${config.minecraft.version}:dev"

deobfCompile "mezz.jei:jei_${config.minecraft.version}:${config.jei.version}"
deobfCompile "mcp.mobius.waila:Hwyla:${config.hwyla.version}"
compile "mcp.mobius.waila:Hwyla:${config.hwyla.version}:api"
// deobfCompile "MCMultiPart:MCMultiPart:${config.mcmultipart.version}:universal"

compile "net.bdew.thirdparty:mekanism:${config.mekanism.version}:api"

// compile "net.bdew.thirdparty:computercraft:${config.computercraft.version}-mc${config.minecraft.version}:api"
compile "li.cil.oc:OpenComputers:${config.opencomputers.version}:api"
deobfCompile "cofh:CoFHCore:1.12.2-4.6.3.27:universal"

}

import org.apache.tools.ant.filters.ReplaceTokens
Expand Down
6 changes: 3 additions & 3 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pressure.version=1.3.1
pressure.version=1.3.2
curseforge.id=221214
bdlib.version=1.14.3.9
minecraft.version=1.12.2
minecraft.mappings=snapshot_20171003
forge.version=14.23.0.2512
minecraft.mappings=stable_39
forge.version=14.23.5.2838
#mcmultipart.version=1.3.0
jei.version=4.8.0.105
hwyla.version=1.8.20-B35_1.12
Expand Down
4 changes: 2 additions & 2 deletions src/net/bdew/pressure/Pressure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import net.minecraftforge.fml.common.network.NetworkRegistry
import net.minecraftforge.fml.relauncher.Side
import org.apache.logging.log4j.Logger

@Mod(modid = Pressure.modId, version = "PRESSURE_VER", name = "Pressure Pipes", dependencies = "required-after:bdlib", modLanguage = "scala", acceptedMinecraftVersions = "[1.12,1.12.2]")
@Mod(modid = Pressure.modId, version = "PRESSURE_VER", name = "Pressure Pipes", dependencies = "required-after:bdlib; required-after:cofhcore", modLanguage = "scala", acceptedMinecraftVersions = "[1.12,1.12.2]")
object Pressure {
var log: Logger = null
var instance = this
Expand Down Expand Up @@ -71,4 +71,4 @@ object Pressure {
if (Misc.haveModVersion("EnderIO"))
EnderIOProxy.init()
}
}
}
2 changes: 1 addition & 1 deletion src/net/bdew/pressure/blocks/BasePoweredBlock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BasePoweredBlock[T <: TileFilterable](name: String, teClass: Class[T]) ext
}

override def neighborChanged(state: IBlockState, world: World, pos: BlockPos, block: Block, fromPos: BlockPos): Unit = {
val powered = world.isBlockIndirectlyGettingPowered(pos) > 0
val powered = world.getRedstonePowerFromNeighbors(pos) > 0
if (powered != getSignal(state))
setSignal(world, pos, powered)
}
Expand Down
29 changes: 28 additions & 1 deletion src/net/bdew/pressure/blocks/BlockFilterableRotatable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,36 @@

package net.bdew.pressure.blocks

import cofh.core.util.RayTracer
import cofh.core.util.helpers.{ServerHelper, WrenchHelper}
import net.bdew.lib.block.HasTE
import net.bdew.lib.rotate.BaseRotatableBlock
import net.bdew.lib.rotate.{BaseRotatableBlock, Properties}
import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.util.math.BlockPos
import net.minecraft.util.{EnumFacing, EnumHand}
import net.minecraft.world.World

trait BlockFilterableRotatable extends BlockFilterable with BaseRotatableBlock {
this: HasTE[_ <: TileFilterable] =>
override def onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean ={
val traceResult = RayTracer.retrace(player)
if (traceResult == null) return false

val tile = world.getTileEntity(pos)
if (tile == null || tile.isInvalid) return false

if (WrenchHelper.isHoldingUsableWrench(player, traceResult)) {
if (ServerHelper.isServerWorld(world)) rotateBlock(world, pos, state, side)
WrenchHelper.usedWrench(player, traceResult)
return true
}

super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ)
}

def rotateBlock(world: World, pos: BlockPos, state: IBlockState, side: EnumFacing): Unit = {
val facing = state.getValue(Properties.FACING)
setFacing(world, pos, facing.rotateAround(side.getAxis))
}
}
12 changes: 11 additions & 1 deletion src/net/bdew/pressure/blocks/output/BlockOutput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@

package net.bdew.pressure.blocks.output

import net.bdew.lib.rotate.RotatedHelper
import net.bdew.pressure.api.IPressureConnectableBlock
import net.bdew.pressure.blocks.{BaseIOBlock, BlockNotifyUpdates}
import net.minecraft.block.state.IBlockState
import net.minecraft.entity.EntityLivingBase
import net.minecraft.item.ItemStack
import net.minecraft.util.EnumFacing
import net.minecraft.util.math.BlockPos
import net.minecraft.world.IBlockAccess
import net.minecraft.world.{IBlockAccess, World}

object BlockOutput extends BaseIOBlock("output", classOf[TileOutput]) with BlockNotifyUpdates with IPressureConnectableBlock {
override def canConnectTo(world: IBlockAccess, pos: BlockPos, side: EnumFacing) =
getFacing(world, pos) == side.getOpposite
override def isTraversable(world: IBlockAccess, pos: BlockPos) = false

override def onBlockPlacedBy(world: World, pos: BlockPos, state: IBlockState, placer: EntityLivingBase, stack: ItemStack) = {
val dir = RotatedHelper.getFacingFromEntity(placer, getValidFacings, getDefaultFacing)
setFacing(world, pos, dir.getOpposite)
super.onBlockPlacedBy(world, pos, state, placer, stack)
}
}
7 changes: 4 additions & 3 deletions src/net/bdew/pressure/blocks/output/TileOutput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

package net.bdew.pressure.blocks.output

import net.bdew.lib.PimpVanilla._
import net.bdew.lib.capabilities.helpers.{FluidHandlerNull, FluidHelper}
import net.bdew.lib.capabilities.{Capabilities, CapabilityProvider}
import net.bdew.lib.data.base.TileDataSlots
import net.bdew.pressure.api.IPressureEject
import net.bdew.pressure.blocks.TileFilterable
import net.minecraft.util.EnumFacing
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
import net.minecraftforge.fluids.FluidStack

class TileOutput extends TileDataSlots with CapabilityProvider with IPressureEject with TileFilterable {
Expand All @@ -32,7 +33,7 @@ class TileOutput extends TileDataSlots with CapabilityProvider with IPressureEje

addCapabilityOption(Capabilities.CAP_FLUID_HANDLER) { side => if (side == getFacing) Some(FluidHandlerNull) else None }

override def pressureNodePos = getPos
override def pressureNodeWorld = getWorld
override def pressureNodePos: BlockPos = getPos
override def pressureNodeWorld: World = getWorld
}

2 changes: 1 addition & 1 deletion src/net/bdew/pressure/blocks/router/TileRouter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TileRouter extends TileDataSlotsTicking with IPressureInject with IPressur
def canWorkWithRsMode(rsMode: RSMode.Value) = rsMode match {
case RSMode.ALWAYS => true
case RSMode.NEVER => false
case _ => (getWorld.isBlockIndirectlyGettingPowered(pos) > 0) ^ (rsMode == RSMode.RS_OFF)
case _ => (getWorld.getRedstonePowerFromNeighbors(pos) > 0) ^ (rsMode == RSMode.RS_OFF)
}

def isSideValidIO(side: EnumFacing, fluid: Fluid, modes: Set[RouterSideMode.Value]): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ContainerRouter(val te: TileRouter, player: EntityPlayer) extends NoInvCon
addSlotToContainer(new SlotMode(this, i, 27 + 21 * i, 19))

for (i <- 0 until 6)
addSlotToContainer(new SlotFilter(inventory, te.getCapability(PressureAPI.FILTERABLE, EnumFacing.getFront(i)), i, 27 + 21 * i, 39))
addSlotToContainer(new SlotFilter(inventory, te.getCapability(PressureAPI.FILTERABLE, EnumFacing.byIndex(i)), i, 27 + 21 * i, 39))

bindPlayerInventory(player.inventory, 8, 84, 142)

Expand Down
2 changes: 1 addition & 1 deletion src/net/bdew/pressure/blocks/router/gui/SlotMode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.util.EnumFacing

class SlotMode(container: ContainerRouter, index: Int, x: Int, y: Int) extends Slot(container.inventory, index, x, y) with SlotClickable {
val dir = EnumFacing.getFront(index)
val dir = EnumFacing.byIndex(index)

override def onClick(clickType: ClickType, button: Int, player: EntityPlayer): ItemStack = {
val stack = player.inventory.getItemStack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import net.bdew.lib.block.{BaseBlock, HasTE}
import net.bdew.pressure.blocks.BlockFilterable
import net.minecraft.block.material.Material

object BlockCreativeSource extends BaseBlock("creative_source", Material.IRON) with HasTE[TileCreativeSource] with BlockFilterable {
object BlockCreativeSource extends BaseBlock("creative_source", Material.IRON) with HasTE[TileCreativeSource] with BlockFilterable with InteractiveTank {
override val TEClass = classOf[TileCreativeSource]
setHardness(1)
}
2 changes: 1 addition & 1 deletion src/net/bdew/pressure/blocks/source/BlockWaterSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package net.bdew.pressure.blocks.source
import net.bdew.lib.block.{BaseBlock, HasTE}
import net.minecraft.block.material.Material

object BlockWaterSource extends BaseBlock("water_source", Material.IRON) with HasTE[TileWaterSource] {
object BlockWaterSource extends BaseBlock("water_source", Material.IRON) with HasTE[TileWaterSource] with InteractiveTank {
override val TEClass = classOf[TileWaterSource]
setHardness(1)
}
25 changes: 25 additions & 0 deletions src/net/bdew/pressure/blocks/source/InteractiveTank.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.bdew.pressure.blocks.source

import cofh.core.util.helpers.FluidHelper
import net.bdew.lib.block.BaseBlock
import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.util.math.BlockPos
import net.minecraft.util.{EnumFacing, EnumHand}
import net.minecraft.world.World
import net.minecraftforge.fluids.capability.CapabilityFluidHandler

trait InteractiveTank extends BaseBlock {
override def onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ)
val tile = world.getTileEntity(pos)
if (tile == null) return false
val heldItem = player.getHeldItem(hand)
val handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)
if (FluidHelper.isFluidHandler(heldItem)) {
FluidHelper.interactWithHandler(heldItem, handler, player, hand)
return true
}
false
}
}
3 changes: 2 additions & 1 deletion src/net/bdew/pressure/blocks/tank/BaseController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

package net.bdew.pressure.blocks.tank

import net.bdew.lib.multiblock.ResourceProvider
import net.bdew.lib.multiblock.block.BlockController
import net.bdew.lib.multiblock.tile.TileController
import net.bdew.pressure.PressureResourceProvider
import net.minecraft.block.material.Material

class BaseController[T <: TileController](name: String, TEClass: Class[T])
extends BlockController(name, Material.IRON, TEClass) {
override def resources = PressureResourceProvider
override def resources: ResourceProvider = PressureResourceProvider

setHardness(1)
}
10 changes: 4 additions & 6 deletions src/net/bdew/pressure/blocks/tank/TileFluidOutputBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

package net.bdew.pressure.blocks.tank

import net.bdew.lib.PimpVanilla._
import net.bdew.lib.capabilities.helpers.{FluidDrainMonitor, FluidHelper, FluidMultiHandler}
import net.bdew.lib.capabilities.helpers.{FluidHelper, FluidMultiHandler}
import net.bdew.lib.capabilities.{Capabilities, CapabilityProvider}
import net.bdew.lib.multiblock.data.OutputConfigFluid
import net.bdew.lib.multiblock.interact.CIFluidOutput
Expand All @@ -24,10 +23,9 @@ abstract class TileFluidOutputBase extends TileOutput[OutputConfigFluid] with RS
override def getCore = getCoreAs[CIFluidOutput]
override val outputConfigType = classOf[OutputConfigFluid]

addCapabilityOption(Capabilities.CAP_FLUID_HANDLER) { side =>
if (getCfg(side).exists(checkCanOutput))
getCore map (core => new FluidDrainMonitor(FluidMultiHandler.wrap(core.getOutputTanks), stack => addOutput(side, stack)))
else None
// bdew/pressure#111
addCapabilityOption(Capabilities.CAP_FLUID_HANDLER) { _ =>
getCore.map(core => FluidMultiHandler.wrap(core.getOutputTanks))
}

def addOutput(side: EnumFacing, res: FluidStack) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object BlockCheckValve extends BlockValve("check_valve") with HasTE[TileCheckVal
setHardness(2)

override def neighborChanged(state: IBlockState, world: World, pos: BlockPos, block: Block, fromPos: BlockPos): Unit = {
val powered = world.isBlockIndirectlyGettingPowered(pos) > 0
val powered = world.getRedstonePowerFromNeighbors(pos) > 0
if (powered != getSignal(world, pos))
setSignal(world, pos, powered)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object BlockPipeSensor extends BlockValve("pipe_sensor") with HasTE[TilePipeSens
for ((fluid, amount) <- flow) {
player.sendMessage(
L(" * %s - %s mB/t",
L(FluidNameHelper.sanitizeUnlocalizedName(fluid)).setColor(Color.YELLOW),
L(FluidNameHelper.sanitizeTranslationKey(fluid)).setColor(Color.YELLOW),
DecFormat.short(amount).setColor(Color.YELLOW)
)
)
Expand Down
3 changes: 1 addition & 2 deletions src/net/bdew/pressure/items/ItemDebugger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package net.bdew.pressure.items

import net.bdew.lib.PimpVanilla._
import net.bdew.lib.items.BaseItem
import net.bdew.pressure.pressurenet.{Helper, ScanResult}
import net.minecraft.entity.player.EntityPlayer
Expand All @@ -32,7 +31,7 @@ object ItemDebugger extends BaseItem("debugger") {
player.sendMessage("Outs: " + (outs map (_.blockRefFace) mkString ", "))
player.sendMessage("Seen:")
for (x <- seen)
player.sendMessage(" * %s: %s".format(x, world.getBlockState(x).getBlock.getUnlocalizedName))
player.sendMessage(" * %s: %s".format(x, world.getBlockState(x).getBlock.getTranslationKey))
player.sendMessage("PConn: " + Helper.getPipeConnections(world, br).mkString(","))
player.sendMessage("Scanned %d blocks, took %d μs".format(seen.size, scanTime / 1000))
}
Expand Down
4 changes: 2 additions & 2 deletions src/net/bdew/pressure/misc/FluidNameHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ package net.bdew.pressure.misc
import net.minecraftforge.fluids.{Fluid, FluidRegistry}

object FluidNameHelper {
// because their getUnlocalizedName returns bullshit
def sanitizeUnlocalizedName(f: Fluid) = f match {
// because their getTranslationKey returns bullshit
def sanitizeTranslationKey(f: Fluid) = f match {
case FluidRegistry.WATER => "tile.water.name"
case FluidRegistry.LAVA => "tile.lava.name"
case _ => f.getUnlocalizedName
Expand Down
2 changes: 1 addition & 1 deletion src/net/bdew/pressure/misc/SlotFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.util.EnumFacing

class SlotFilter(container: IInventory, filterable: IFilterable, index: Int, x: Int, y: Int) extends Slot(container, index, x, y) with SlotClickable {
val dir = EnumFacing.getFront(index)
val dir = EnumFacing.byIndex(index)

override def onClick(clickType: ClickType, button: Int, player: EntityPlayer): ItemStack = {
val stack = player.inventory.getItemStack
Expand Down
4 changes: 2 additions & 2 deletions src/net/bdew/pressure/model/ExtendedModelLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import net.minecraftforge.client.model.{ICustomModelLoader, ModelLoaderRegistry}

object ExtendedModelLoader extends ICustomModelLoader {
override def accepts(modelLocation: ResourceLocation) =
modelLocation.getResourceDomain.equals("pressure") && modelLocation.getResourcePath.endsWith(".extended")
modelLocation.getNamespace.equals("pressure") && modelLocation.getPath.endsWith(".extended")

def wrap(model: String, enhancer: ModelEnhancer) =
enhancer.wrap(ModelLoaderRegistry.getModel(new ResourceLocation(model)))

override def loadModel(modelLocation: ResourceLocation) =
modelLocation.getResourcePath match {
modelLocation.getPath match {
case "models/block/filtered_rotated.extended" => wrap("pressure:block/rotated", FluidFilterRotatedModelEnhancer)
case "models/block/filtered_cube_all.extended" => wrap("minecraft:block/cube_all", FluidFilterModelEnhancer)
case "models/block/router.extended" => wrap("minecraft:block/cube_all", RouterOverlayModelEnhancer)
Expand Down

0 comments on commit 27443f5

Please sign in to comment.