mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-14 01:14:19 +00:00
Forward material to shader (#27)
This commit is contained in:
1 parent
11b6142320
commit
05eb683a33
6 files changed
+59
-8
No files matched your search
+2
-1
@@ -1,6 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Angelica:1.0.0-beta43:dev")
|
||||
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.7.18-GTNH:dev")
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package codechicken.microblock
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator
|
||||
import net.coderbot.iris.Iris
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.client.renderer.Tessellator
|
||||
|
||||
class AngelicaCompat {
|
||||
def setShaderMaterialOverride(block: Block, meta: Int) = {
|
||||
try {
|
||||
if (Tessellator.instance.isInstanceOf[CapturingTessellator])
|
||||
Iris.setShaderMaterialOverride(block, meta)
|
||||
} catch {
|
||||
case ex: ClassCastException => Unit
|
||||
}
|
||||
}
|
||||
|
||||
def resetShaderMaterialOverride() = {
|
||||
try {
|
||||
if (Tessellator.instance.isInstanceOf[CapturingTessellator])
|
||||
Iris.resetShaderMaterialOverride()
|
||||
} catch {
|
||||
case ex: ClassCastException => Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ import codechicken.lib.render.{
|
||||
CCRenderState,
|
||||
ColourMultiplier
|
||||
}
|
||||
import codechicken.microblock.handler.MicroblockProxy
|
||||
import codechicken.microblock.handler.{MicroblockMod, MicroblockProxy}
|
||||
import net.minecraft.entity.Entity
|
||||
import codechicken.lib.render.uv.{UVTransformation, MultiIconTransformation}
|
||||
import cpw.mods.fml.common.registry.{GameRegistry, GameData}
|
||||
import codechicken.lib.render.uv.{MultiIconTransformation, UVTransformation}
|
||||
import cpw.mods.fml.common.registry.{GameData, GameRegistry}
|
||||
|
||||
import java.util.function.Supplier
|
||||
|
||||
@@ -54,7 +54,17 @@ object MaterialRenderHelper {
|
||||
this
|
||||
}
|
||||
|
||||
def render() = builder.render()
|
||||
def blockAndMeta(b: Block, meta: Int) = {
|
||||
if (MicroblockMod.angelicaCompat != null)
|
||||
MicroblockMod.angelicaCompat.setShaderMaterialOverride(b, meta)
|
||||
this
|
||||
}
|
||||
|
||||
def render() = {
|
||||
builder.render()
|
||||
if (MicroblockMod.angelicaCompat != null)
|
||||
MicroblockMod.angelicaCompat.resetShaderMaterialOverride()
|
||||
}
|
||||
}
|
||||
|
||||
/** Standard micro material class suitable for most blocks.
|
||||
@@ -92,6 +102,7 @@ class BlockMicroMaterial(val block: Block, val meta: Int = 0)
|
||||
.start(pos, pass, icont)
|
||||
.blockColour(getColour(pass))
|
||||
.lighting()
|
||||
.blockAndMeta(block, meta)
|
||||
.render()
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class GrassMicroMaterial extends BlockMicroMaterial(Blocks.grass, 0) {
|
||||
.start(pos, pass, icont)
|
||||
.blockColour(getColour(pass))
|
||||
.lighting()
|
||||
.blockAndMeta(block, meta)
|
||||
.render()
|
||||
else
|
||||
MaterialRenderHelper.start(pos, pass, icont).lighting().render()
|
||||
@@ -35,6 +36,7 @@ class GrassMicroMaterial extends BlockMicroMaterial(Blocks.grass, 0) {
|
||||
.start(pos, pass, new UVTranslation(0, bounds.max.y - 1) ++ sideIconT)
|
||||
.blockColour(getColour(pass))
|
||||
.lighting()
|
||||
.blockAndMeta(block, meta)
|
||||
.render()
|
||||
}
|
||||
}
|
||||
@@ -48,12 +50,14 @@ class TopMicroMaterial($block: Block, $meta: Int = 0)
|
||||
.start(pos, pass, icont)
|
||||
.blockColour(getColour(pass))
|
||||
.lighting()
|
||||
.blockAndMeta(block, meta)
|
||||
.render()
|
||||
else
|
||||
MaterialRenderHelper
|
||||
.start(pos, pass, new UVTranslation(0, bounds.max.y - 1) ++ icont)
|
||||
.blockColour(getColour(pass))
|
||||
.lighting()
|
||||
.blockAndMeta(block, meta)
|
||||
.render()
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,16 @@ import cpw.mods.fml.common.event.FMLInitializationEvent
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent
|
||||
import cpw.mods.fml.common.Mod.EventHandler
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent
|
||||
import codechicken.microblock.MicroMaterialRegistry
|
||||
import codechicken.microblock.DefaultContent
|
||||
import codechicken.microblock.{
|
||||
AngelicaCompat,
|
||||
ConfigContent,
|
||||
DefaultContent,
|
||||
MicroMaterialRegistry
|
||||
}
|
||||
import codechicken.multipart.Tags
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent
|
||||
import codechicken.microblock.ConfigContent
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
@Mod(
|
||||
@@ -50,4 +54,6 @@ object MicroblockMod {
|
||||
def handleIMC(event: IMCEvent) {
|
||||
ConfigContent.handleIMC(event.getMessages)
|
||||
}
|
||||
|
||||
var angelicaCompat: AngelicaCompat = null
|
||||
}
|
||||
@@ -123,6 +123,9 @@ class MicroblockProxy_clientImpl extends MicroblockProxy_serverImpl {
|
||||
MicroMaterialRegistry.loadIcons()
|
||||
MinecraftForgeClient.registerItemRenderer(itemMicro, ItemMicroPartRenderer)
|
||||
PacketCustom.assignHandler(MicroblockCPH.registryChannel, MicroblockCPH)
|
||||
|
||||
if (Loader.isModLoaded("angelica"))
|
||||
MicroblockMod.angelicaCompat = new AngelicaCompat
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
Reference in new issue
Block a user