Compare commits

...
4 Commits
Author SHA1 Message Date
Ryan Nasers f10595d062 Isbrh interface fmp (#53) 2026-08-13 12:14:59 +02:00
Jason Mitchell 7221176efd Maybe more thread safe renderpass (#50) 2026-07-22 15:30:42 -07:00
DarkShadow44andRecursivePineapple aa7d02cfb0 Don't use rock material (#45)
Co-authored-by: RecursivePineapple <[email protected]>
2026-07-05 00:05:47 +00:00
FourIsTheNumber d2ce5b7362 Add postea transformer for microblock items (#48) 2026-07-04 20:02:17 -04:00
8 changed files with 109 additions and 17 deletions

No files matched your search

+1
View File
@@ -3,6 +3,7 @@
dependencies { dependencies {
implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.12:dev") implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.12:dev")
compileOnly("com.github.GTNewHorizons:Angelica:2.1.19:dev") compileOnly("com.github.GTNewHorizons:Angelica:2.1.19:dev")
compileOnly("com.github.GTNewHorizons:Postea:1.2.5:dev") {transitive = false}
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.93-GTNH:dev") { devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.93-GTNH:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'CodeChickenCore' exclude group: 'com.github.GTNewHorizons', module: 'CodeChickenCore'
} }
@@ -0,0 +1,29 @@
package codechicken.microblock.compat;
import net.minecraft.nbt.NBTTagCompound;
import com.gtnewhorizons.postea.api.IItemStackTransformationHandler;
import codechicken.microblock.MicroMaterialRegistry;
public class ItemMicroPartTransformer implements IItemStackTransformationHandler {
@Override
public boolean apply(String originalItemId, NBTTagCompound stackTag) {
if (!stackTag.hasKey("tag")) return false;
NBTTagCompound tag = stackTag.getCompoundTag("tag");
if (!tag.hasKey("mat")) return false;
String matName = tag.getString("mat");
// Goes through the remap layer, which is private
int remappedId = MicroMaterialRegistry.materialID(matName);
String remappedName = MicroMaterialRegistry.materialName(remappedId);
if (remappedName.equals(matName)) return false;
tag.setString("mat", remappedName);
stackTag.setTag("tag", tag);
return true;
}
}
@@ -0,0 +1,11 @@
package codechicken.microblock.compat;
import com.gtnewhorizons.postea.api.ItemStackReplacementManager;
public class PosteaCompat {
public static void registerTransformers() {
ItemStackReplacementManager
.addTransformationHandler("ForgeMicroblock:microblock", new ItemMicroPartTransformer());
}
}
@@ -16,6 +16,7 @@ import net.minecraftforge.oredict.OreDictionary
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraftforge.oredict.ShapedOreRecipe import net.minecraftforge.oredict.ShapedOreRecipe
import codechicken.lib.packet.PacketCustom import codechicken.lib.packet.PacketCustom
import codechicken.microblock.compat.PosteaCompat
import cpw.mods.fml.common.Loader import cpw.mods.fml.common.Loader
import cpw.mods.fml.common.registry.GameRegistry import cpw.mods.fml.common.registry.GameRegistry
import net.minecraft.client.renderer.RenderBlocks import net.minecraft.client.renderer.RenderBlocks
@@ -110,6 +111,9 @@ class MicroblockProxy_serverImpl {
MicroblockSPH.registryChannel, MicroblockSPH.registryChannel,
MicroblockSPH MicroblockSPH
) )
if (Loader.isModLoaded("postea")) {
PosteaCompat.registerTransformers()
}
} }
} }
@@ -3,7 +3,7 @@ package codechicken.multipart
import java.util.List import java.util.List
import java.lang.Iterable import java.lang.Iterable
import net.minecraft.block.Block import net.minecraft.block.Block
import net.minecraft.block.material.Material import net.minecraft.block.material.{MapColor, Material}
import net.minecraft.entity.Entity import net.minecraft.entity.Entity
import net.minecraft.util.AxisAlignedBB import net.minecraft.util.AxisAlignedBB
import net.minecraft.world.World import net.minecraft.world.World
@@ -12,6 +12,7 @@ import net.minecraft.util.Vec3
import net.minecraft.util.MovingObjectPosition import net.minecraft.util.MovingObjectPosition
import codechicken.lib.raytracer.RayTracer import codechicken.lib.raytracer.RayTracer
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import java.util.Random import java.util.Random
import java.util.ArrayList import java.util.ArrayList
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
@@ -68,7 +69,7 @@ object BlockMultipart {
/** Block class for all multiparts, should be internal use only. /** Block class for all multiparts, should be internal use only.
*/ */
class BlockMultipart extends Block(Material.rock) { class BlockMultipart extends Block(new Material(MapColor.stoneColor)) {
import BlockMultipart._ import BlockMultipart._
override def hasTileEntity(meta: Int = 0) = true override def hasTileEntity(meta: Int = 0) = true
@@ -256,10 +257,7 @@ class BlockMultipart extends Block(Material.rock) {
override def getRenderBlockPass = 1 override def getRenderBlockPass = 1
override def canRenderInPass(pass: Int): Boolean = { override def canRenderInPass(pass: Int): Boolean = true
MultipartRenderer.pass = pass
return true
}
override def getPickBlock( override def getPickBlock(
hit: MovingObjectPosition, hit: MovingObjectPosition,
@@ -0,0 +1,9 @@
package codechicken.multipart;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
public interface ISBRHPart {
boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, RenderBlocks renderer);
}
@@ -10,10 +10,13 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity import net.minecraft.tileentity.TileEntity
import net.minecraft.world.IBlockAccess import net.minecraft.world.IBlockAccess
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
import net.minecraftforge.client.ForgeHooksClient
import net.minecraftforge.client.MinecraftForgeClient
import cpw.mods.fml.relauncher.SideOnly import cpw.mods.fml.relauncher.SideOnly
import cpw.mods.fml.relauncher.Side import cpw.mods.fml.relauncher.Side
import codechicken.lib.raytracer.ExtendedMOP import codechicken.lib.raytracer.ExtendedMOP
import codechicken.lib.lighting.LightMatrix import codechicken.lib.lighting.LightMatrix
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH
/** Internal class for rendering callbacks. Should be moved to the handler /** Internal class for rendering callbacks. Should be moved to the handler
* package * package
@@ -23,7 +26,6 @@ object MultipartRenderer
extends TileEntitySpecialRenderer extends TileEntitySpecialRenderer
with ISimpleBlockRenderingHandler { with ISimpleBlockRenderingHandler {
TileMultipart.renderID = RenderingRegistry.getNextAvailableRenderId TileMultipart.renderID = RenderingRegistry.getNextAvailableRenderId
var pass: Int = 0
override def renderTileEntityAt( override def renderTileEntityAt(
t: TileEntity, t: TileEntity,
@@ -42,7 +44,7 @@ object MultipartRenderer
state.useNormals = true state.useNormals = true
val pos = new Vector3(x, y, z) val pos = new Vector3(x, y, z)
tmpart.renderDynamic(pos, f, pass) tmpart.renderDynamic(pos, f, MinecraftForgeClient.getRenderPass)
} }
override def getRenderId = TileMultipart.renderID override def getRenderId = TileMultipart.renderID
@@ -85,7 +87,7 @@ object MultipartRenderer
val state = CCRenderState.instance val state = CCRenderState.instance
state.resetInstance() state.resetInstance()
state.lightMatrix.locate(world, x, y, z) state.lightMatrix.locate(world, x, y, z)
val b = tmpart.renderStatic(new Vector3(x, y, z), pass) val b = tmpart.renderStatic(world, new Vector3(x, y, z), renderer)
state.lightMatrix.access = null state.lightMatrix.access = null
b b
} }
@@ -5,7 +5,7 @@ import net.minecraft.tileentity.TileEntity
import scala.collection.mutable.ListBuffer import scala.collection.mutable.ListBuffer
import codechicken.lib.packet.PacketCustom import codechicken.lib.packet.PacketCustom
import codechicken.lib.vec.{BlockCoord, Cuboid6, Vector3} import codechicken.lib.vec.{BlockCoord, Cuboid6, Vector3}
import net.minecraft.world.World import net.minecraft.world.{IBlockAccess, World}
import java.util.List import java.util.List
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
@@ -31,6 +31,8 @@ import net.minecraft.util.{AxisAlignedBB, Vec3}
import java.lang.Iterable import java.lang.Iterable
import codechicken.lib.world.IChunkLoadTile import codechicken.lib.world.IChunkLoadTile
import net.minecraft.block.Block import net.minecraft.block.Block
import net.minecraft.client.renderer.RenderBlocks
import net.minecraftforge.client.ForgeHooksClient
class TileMultipart extends TileEntity with IChunkLoadTile { class TileMultipart extends TileEntity with IChunkLoadTile {
@@ -517,17 +519,53 @@ trait TileMultipartClient extends TileMultipart {
} }
} }
def renderStatic(pos: Vector3, pass: Int) = { def renderStatic(
if (staticCache == null) updateRenderCache() world: IBlockAccess,
vec: Vector3,
renderer: RenderBlocks
) = {
if (staticCache == null)
updateRenderCache()
var rendered = false var rendered = false
def renderPart(part: TMultiPart): Unit = {
if (part == null)
return
part match {
case isbrh: ISBRHPart =>
if (
isbrh.renderWorldBlock(
world,
vec.x.toInt,
vec.y.toInt,
vec.z.toInt,
renderer
)
) {
rendered = true
}
case _ =>
if (
part.renderStatic(
vec,
ForgeHooksClient.getWorldRenderPass
)
) {
rendered = true
}
}
}
val statics = staticCache val statics = staticCache
if (statics != null) { if (statics != null) {
var i = 0 var i = 0
val len = statics.length val len = statics.length
while (i < len) { while (i < len) {
if (statics(i) != null && statics(i).renderStatic(pos, pass)) renderPart(statics(i))
rendered = true
i += 1 i += 1
} }
} }
@@ -536,12 +574,13 @@ trait TileMultipartClient extends TileMultipart {
if (dynamics != null) { if (dynamics != null) {
var i = 0 var i = 0
val len = dynamics.length val len = dynamics.length
while (i < len) { while (i < len) {
if (dynamics(i) != null && dynamics(i).renderStatic(pos, pass)) renderPart(dynamics(i))
rendered = true
i += 1 i += 1
} }
} }
rendered rendered
} }
@@ -562,7 +601,6 @@ trait TileMultipartClient extends TileMultipart {
def randomDisplayTick(random: Random) {} def randomDisplayTick(random: Random) {}
override def shouldRenderInPass(pass: Int) = { override def shouldRenderInPass(pass: Int) = {
MultipartRenderer.pass = pass
if (staticCache == null) updateRenderCache() if (staticCache == null) updateRenderCache()
hasDynamicParts hasDynamicParts
} }