mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
Better model handling!
This commit is contained in:
parent
2f83eebbab
commit
5b9e03084d
@ -3,6 +3,7 @@ package li.cil.oc.integration.mcmp
|
||||
import li.cil.oc.Constants
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.client.renderer.block.ModelInitialization
|
||||
import mcmultipart.item.PartPlacementWrapper
|
||||
import mcmultipart.multipart.MultipartRegistry
|
||||
import net.minecraft.client.resources.model.IBakedModel
|
||||
@ -11,10 +12,10 @@ import net.minecraft.util.RegistrySimple
|
||||
import net.minecraftforge.client.event.ModelBakeEvent
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority
|
||||
|
||||
object MCMultiPart {
|
||||
final val CableMultipartLocation = Settings.resourceDomain + ":" + "multipart_" + Constants.BlockName.Cable
|
||||
final val CableMultipartVariantLocation = new ModelResourceLocation(CableMultipartLocation, "multipart")
|
||||
final val CableMultipartLocation = new ModelResourceLocation(Settings.resourceDomain + ":" + Constants.BlockName.Cable, "multipart")
|
||||
|
||||
def init(): Unit = {
|
||||
MultipartRegistry.registerPart(classOf[PartCable], PartProvider.PartTypeCable)
|
||||
@ -28,10 +29,13 @@ object MCMultiPart {
|
||||
MinecraftForge.EVENT_BUS.register(this)
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
def onModelBake(e: ModelBakeEvent): Unit = {
|
||||
val registry = e.modelRegistry.asInstanceOf[RegistrySimple[ModelResourceLocation, IBakedModel]]
|
||||
|
||||
registry.putObject(CableMultipartVariantLocation, PartCableModel)
|
||||
// Replace default cable model with part model to properly handle connection
|
||||
// rendering to multipart cables.
|
||||
registry.putObject(ModelInitialization.CableBlockLocation, PartCableModel)
|
||||
registry.putObject(CableMultipartLocation, PartCableModel)
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class PartCable extends Multipart with ISlottedPart with IOccludingPart with ISl
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def getModelPath = MCMultiPart.CableMultipartLocation
|
||||
override def getModelPath = MCMultiPart.CableMultipartLocation.getResourceDomain + ":" + MCMultiPart.CableMultipartLocation.getResourcePath
|
||||
|
||||
override def createBlockState(): BlockState = new ExtendedBlockState(CableBlock, Array.empty, Array(property.PropertyTile.Tile))
|
||||
|
||||
|
@ -8,6 +8,7 @@ import mcmultipart.multipart.MultipartHelper
|
||||
import mcmultipart.multipart.PartSlot
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.client.resources.model.IBakedModel
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.common.property.IExtendedBlockState
|
||||
|
||||
object PartCableModel extends SmartBlockModelBase with ISmartMultipartModel {
|
||||
@ -16,6 +17,13 @@ object PartCableModel extends SmartBlockModelBase with ISmartMultipartModel {
|
||||
case _ => missingModel
|
||||
}
|
||||
|
||||
override def handleBlockState(state: IBlockState) = state match {
|
||||
case extended: IExtendedBlockState => new BlockModel(extended)
|
||||
case _ => missingModel
|
||||
}
|
||||
|
||||
override def handleItemState(stack: ItemStack) = CableModel.ItemModel
|
||||
|
||||
class BlockModel(state: IExtendedBlockState) extends CableModel.BlockModel(state) {
|
||||
override protected def isCable(pos: BlockPosition): Boolean = super.isCable(pos) || (pos.world match {
|
||||
case Some(world) =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user