mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-28 16:06:17 +00:00
Added compatibility for MCPC placement protection overrides
This commit is contained in:
1 parent
ee24d3362c
commit
31f1ee1197
3 files changed
+43
-10
No files matched your search
@@ -8,13 +8,12 @@ import net.minecraft.world.World
|
||||
import java.util.List
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import codechicken.lib.data.MCDataOutput
|
||||
import codechicken.multipart.handler.MultipartProxy
|
||||
import codechicken.multipart.handler.{MultipartCompatiblity, MultipartProxy, MultipartSPH}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.item.ItemStack
|
||||
import codechicken.lib.vec.Vector3
|
||||
import net.minecraft.nbt.NBTTagList
|
||||
import java.util.Random
|
||||
import codechicken.multipart.handler.MultipartSPH
|
||||
import codechicken.lib.lighting.LazyLightMatrix
|
||||
import net.minecraft.entity.item.EntityItem
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
@@ -225,14 +224,11 @@ class TileMultipart extends TileEntity
|
||||
/**
|
||||
* Returns true if part can be added to this space
|
||||
*/
|
||||
def canAddPart(part:TMultiPart):Boolean =
|
||||
{
|
||||
if(partList.contains(part))
|
||||
return false
|
||||
|
||||
return occlusionTest(partList, part)
|
||||
}
|
||||
|
||||
def canAddPart(part:TMultiPart) =
|
||||
MultipartCompatiblity.canAddPart(worldObj, xCoord, yCoord, zCoord) &&
|
||||
!partList.contains(part) &&
|
||||
occlusionTest(partList, part)
|
||||
|
||||
/**
|
||||
* Returns true if opart can be replaced with npart (note opart and npart may be the exact same object)
|
||||
*
|
||||
@@ -583,6 +579,8 @@ object TileMultipart
|
||||
val t = getOrConvertTile(world, pos)
|
||||
if(t != null)
|
||||
return t.canAddPart(part)
|
||||
else if(!MultipartCompatiblity.canAddPart(world, pos.x, pos.y, pos.z))
|
||||
return false
|
||||
|
||||
if(!replaceable(world, pos))
|
||||
return false
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package codechicken.multipart.handler
|
||||
|
||||
import net.minecraft.world.World
|
||||
import cpw.mods.fml.common.FMLCommonHandler
|
||||
import net.minecraft.block.Block
|
||||
|
||||
object MultipartCompatiblity
|
||||
{
|
||||
var canAddPart = (world:World, x:Int, y:Int, z:Int) => true
|
||||
|
||||
def load() {
|
||||
if(FMLCommonHandler.instance().getModName.contains("mcpc"))
|
||||
MCPCCompatModule.load()
|
||||
}
|
||||
}
|
||||
|
||||
object MCPCCompatModule
|
||||
{
|
||||
def load() {
|
||||
try {
|
||||
val m_canPlacePart = classOf[World].getDeclaredMethod("canPlaceMultipart", classOf[World], classOf[Block], classOf[Int], classOf[Int], classOf[Int])
|
||||
MultipartCompatiblity.canAddPart = (world:World, x:Int, y:Int, z:Int) => {
|
||||
m_canPlacePart.invoke(world, MultipartProxy.block, x:Integer, y:Integer, z:Integer).asInstanceOf[Boolean].booleanValue()
|
||||
}
|
||||
} catch {
|
||||
case e:Exception =>
|
||||
System.err.println("Failed to integrate MCPC placement hooks")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ class MultipartProxy_serverImpl
|
||||
TickRegistry.registerTickHandler(MultipartEventHandler, Side.SERVER)
|
||||
|
||||
WorldExtensionManager.registerWorldExtension(TickScheduler)
|
||||
|
||||
MultipartCompatiblity.load()
|
||||
}
|
||||
|
||||
def getFreeBlockID(preferred:Int):Int =
|
||||
|
||||
Reference in new issue
Block a user