Compare commits

..
13 Commits
Author SHA1 Message Date
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
Caedis 09e2b847fc fix(microblock): prevent microblocks becoming blood rune slabs (#47) 2026-06-21 09:20:32 +02:00
Dan faa052f70c fix npe on chunk unload when tile is null (#46) 2026-06-05 20:58:04 +02:00
Alexdoruandboubou19 15298cb677 [Memory-opti:fix leak] fix world client leak in renderer (#44)
Co-authored-by: boubou19 <[email protected]>
2026-04-30 11:18:51 +02:00
Alexdoru d3054211db [Memory-opti:fix leak] fix world client from keybind handler (#43) 2026-04-30 11:13:22 +02:00
Martin Robertz 732f64a1b4 update+gradle+deps+bs 2026-04-27 13:42:24 +02:00
UltraProdigy 2a5e2a150f Optimize Images & Workflow (#42) 2026-04-26 08:39:13 +02:00
Alexdoru 1a4edfbc89 fix world server leak (#41) 2026-04-14 14:48:23 +00:00
Worive 525fcc56ad Update buildscript to v2 (#40) 2026-03-08 19:23:42 +01:00
Woriveandgithub-actions[bot] a36120fc91 Add dynamic render option without relying on doesTick (#38)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-08 10:50:16 +01:00
Worive 238b041f12 Revert light value caching, applying better iteration to avoid null exceptions (#37) 2025-12-08 10:04:49 +01:00
28 changed files with 252 additions and 99 deletions

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
name: Optimize images
on:
pull_request:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
push:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
jobs:
optimize-images:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
secrets: inherit
+4 -3
View File
@@ -1,9 +1,10 @@
// Add your dependencies here
dependencies {
implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev")
compileOnly("com.github.GTNewHorizons:Angelica:1.0.0-beta62:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.20-GTNH:dev") {
implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.12: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") {
exclude group: 'com.github.GTNewHorizons', module: 'CodeChickenCore'
}
}
+32 -2
View File
@@ -39,10 +39,34 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
# Enables modern Java syntax support. Valid values:
# - false: No modern syntax, Java 8 only
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
# - modern: Native modern Java bytecode, no downgrading
enableModernJavaSyntax = false
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
# and should *not* be used in most situations. -1 disables this.
# forceToolchainVersion = -1
# Target JVM version for JVM Downgrader bytecode downgrading.
# Only used when enableModernJavaSyntax = jvmDowngrader
# downgradeTargetVersion = 8
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
# Classes will be available in META-INF/versions/N/ for each version N in this list.
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
# jvmDowngraderMultiReleaseVersions = 21,25
# Specifies how JVM Downgrader API stubs are provided. Options:
# - shade: Shade minimized stubs into the jar
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
# - external: Another dependency provides stubs (no constraint, no warning)
# - (empty): Warning reminding you to configure stubs
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
# jvmDowngraderStubsProvider =
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
@@ -174,6 +198,12 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
+12
View File
@@ -0,0 +1,12 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
toolchainVersion=25
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+3 -6
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -114,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -172,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -212,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+1 -2
View File
@@ -70,11 +70,10 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1 -3
View File
@@ -17,7 +17,5 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.46'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

After

Width:  |  Height:  |  Size: 500 B

@@ -54,5 +54,7 @@ object DefaultContent {
registerMaterial(new GrassMicroMaterial, materialKey(grass))
MicroMaterialRegistry.remapName(oldKey(mycelium), materialKey(mycelium))
registerMaterial(new TopMicroMaterial(mycelium), materialKey(mycelium))
registerMaterial(MissingMicroMaterial, MissingMicroMaterial.key)
}
}
@@ -133,15 +133,18 @@ object ItemMicroPart {
if (!stack.getTagCompound.hasKey("mat"))
return null
return MicroMaterialRegistry.getMaterial(
MicroMaterialRegistry.getMaterial(
stack.getTagCompound.getString("mat")
)
) match {
case null => MissingMicroMaterial
case mat => mat
}
}
def getMaterialID(stack: ItemStack): Int = {
checkTagCompound(stack)
if (!stack.getTagCompound.hasKey("mat"))
return 0
return MicroMaterialRegistry.getMissingId
return MicroMaterialRegistry.materialID(
stack.getTagCompound.getString("mat")
@@ -114,6 +114,7 @@ object MicroMaterialRegistry {
private var maxCuttingStrength: Int = _
private val remap = HashMap[String, String]()
private var missingId: Int = 0
/** Register a micro material with unique identifier name
*/
@@ -162,8 +163,17 @@ object MicroMaterialRegistry {
nameMap.clear()
for (i <- 0 until idMap.length)
nameMap.put(idMap(i)._1, i)
missingId = nameMap.getOrElse(
MissingMicroMaterial.key,
throw new IllegalStateException(
"MissingMicroMaterial is not registered; the placeholder must never " +
"fall back to id 0."
)
)
}
def getMissingId = missingId
private[microblock] def calcMaxCuttingStrength() {
val it = Item.itemRegistry.iterator.asInstanceOf[JIterator[Item]]
maxCuttingStrength = it.flatMap {
@@ -216,7 +226,7 @@ object MicroMaterialRegistry {
case Some(v) => v
case None =>
logger.error("Missing mapping for part with ID: " + name)
0
missingId
}
def getMaterial(name: String) =
@@ -0,0 +1,55 @@
package codechicken.microblock
import codechicken.lib.render.uv.IconTransformation
import codechicken.lib.vec.{Cuboid6, Vector3}
import codechicken.microblock.MicroMaterialRegistry.IMicroMaterial
import codechicken.microblock.handler.MicroblockProxy
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.block.Block
import net.minecraft.block.Block.SoundType
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack
import net.minecraft.util.IIcon
/** Stand-in for a material whose name could not be resolved at load time.
* Renders the vanilla missing texture (magenta/black checkerboard) and behaves
* inertly. Resolving an unknown name to this placeholder keeps microblocks
* from silently becoming material id 0 (Blood Rune in GTNH).
*/
object MissingMicroMaterial extends IMicroMaterial {
val key = "forgemicroblock:missing"
@SideOnly(Side.CLIENT)
private var icon: IIcon = _
@SideOnly(Side.CLIENT)
override def loadIcons(): Unit = {
icon = MicroblockProxy.renderBlocks.getIconSafe(null)
}
@SideOnly(Side.CLIENT)
override def getBreakingIcon(side: Int): IIcon = icon
@SideOnly(Side.CLIENT)
override def renderMicroFace(
pos: Vector3,
pass: Int,
bounds: Cuboid6
): Unit = {
MaterialRenderHelper
.start(pos, pass, new IconTransformation(icon))
.lighting()
.render()
}
override def isTransparent: Boolean = false
override def getLightValue: Int = 0
override def getStrength(player: EntityPlayer): Float = 1f
override def getLocalizedName: String = "Missing Material"
override def getItem: ItemStack = new ItemStack(Blocks.stone)
override def getCutterStrength: Int = 0
override def getSound: SoundType = Block.soundTypeStone
override def explosionResistance(entity: Entity): Float = 6f
}
@@ -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());
}
}
@@ -26,7 +26,14 @@ object MicroblockCPH extends MicroblockPH with IClientPacketHandler {
netHandler: INetHandlerPlayClient
) {
packet.getType match {
case 1 => handleMaterialRegistration(packet, netHandler)
// In singleplayer the integrated server and this client share the one
// static registry, so the id-map packet is redundant. Skipping it avoids
// rebuilding (clearing) the shared maps on the netty thread while the
// server thread reads them - the race that turned microblocks into Blood
// Rune slabs.
case 1 =>
if (!mc.isSingleplayer)
handleMaterialRegistration(packet, netHandler)
}
}
@@ -16,6 +16,7 @@ import net.minecraftforge.oredict.OreDictionary
import net.minecraft.item.ItemStack
import net.minecraftforge.oredict.ShapedOreRecipe
import codechicken.lib.packet.PacketCustom
import codechicken.microblock.compat.PosteaCompat
import cpw.mods.fml.common.Loader
import cpw.mods.fml.common.registry.GameRegistry
import net.minecraft.client.renderer.RenderBlocks
@@ -110,6 +111,9 @@ class MicroblockProxy_serverImpl {
MicroblockSPH.registryChannel,
MicroblockSPH
)
if (Loader.isModLoaded("postea")) {
PosteaCompat.registerTransformers()
}
}
}
@@ -3,7 +3,7 @@ package codechicken.multipart
import java.util.List
import java.lang.Iterable
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.util.AxisAlignedBB
import net.minecraft.world.World
@@ -12,6 +12,7 @@ import net.minecraft.util.Vec3
import net.minecraft.util.MovingObjectPosition
import codechicken.lib.raytracer.RayTracer
import net.minecraft.entity.player.EntityPlayer
import java.util.Random
import java.util.ArrayList
import net.minecraft.item.ItemStack
@@ -68,7 +69,7 @@ object BlockMultipart {
/** 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._
override def hasTileEntity(meta: Int = 0) = true
@@ -256,10 +257,7 @@ class BlockMultipart extends Block(Material.rock) {
override def getRenderBlockPass = 1
override def canRenderInPass(pass: Int): Boolean = {
MultipartRenderer.pass = pass
return true
}
override def canRenderInPass(pass: Int): Boolean = true
override def getPickBlock(
hit: MovingObjectPosition,
@@ -305,7 +303,10 @@ class BlockMultipart extends Block(Material.rock) {
}
override def getLightValue(world: IBlockAccess, x: Int, y: Int, z: Int): Int =
world.getBlockMetadata(x, y, z)
getTile(world, x, y, z) match {
case null => 0
case tile => tile.getLightValue
}
override def randomDisplayTick(
world: World,
@@ -18,10 +18,17 @@ object ControlKeyModifer {
implicit def playerControlValue(p: EntityPlayer) = new ControlKeyValue(p)
class ControlKeyValue(p: EntityPlayer) {
def isControlDown = map(p)
def isControlDown = {
if (p.worldObj.isRemote) {
isClientPressing
} else {
map(p)
}
}
}
val map = HashMap[EntityPlayer, Boolean]().withDefaultValue(false)
var isClientPressing = false;
/** Implicit static for Java users.
*/
@@ -38,7 +45,6 @@ object ControlKeyHandler
) {
import ControlKeyModifer._
var wasPressed = false
var oldPlayer: EntityPlayer = null
@SubscribeEvent
@SideOnly(Side.CLIENT)
@@ -47,19 +53,11 @@ object ControlKeyHandler
if (pressed != wasPressed) {
wasPressed = pressed
if (Minecraft.getMinecraft.getNetHandler != null) {
map.put(Minecraft.getMinecraft.thePlayer, pressed)
isClientPressing = pressed
val packet = new PacketCustom(MultipartCPH.channel, 1)
packet.writeBoolean(pressed)
packet.sendToServer()
}
}
if (oldPlayer != null) {
if (oldPlayer != Minecraft.getMinecraft.thePlayer) {
map.remove(oldPlayer)
oldPlayer = Minecraft.getMinecraft.thePlayer
}
} else {
oldPlayer = Minecraft.getMinecraft.thePlayer
}
}
}
@@ -10,6 +10,8 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.IBlockAccess
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.Side
import codechicken.lib.raytracer.ExtendedMOP
@@ -23,7 +25,6 @@ object MultipartRenderer
extends TileEntitySpecialRenderer
with ISimpleBlockRenderingHandler {
TileMultipart.renderID = RenderingRegistry.getNextAvailableRenderId
var pass: Int = 0
override def renderTileEntityAt(
t: TileEntity,
@@ -42,7 +43,7 @@ object MultipartRenderer
state.useNormals = true
val pos = new Vector3(x, y, z)
tmpart.renderDynamic(pos, f, pass)
tmpart.renderDynamic(pos, f, MinecraftForgeClient.getRenderPass)
}
override def getRenderId = TileMultipart.renderID
@@ -85,7 +86,12 @@ object MultipartRenderer
val state = CCRenderState.instance
state.resetInstance()
state.lightMatrix.locate(world, x, y, z)
return tmpart.renderStatic(new Vector3(x, y, z), pass)
val b = tmpart.renderStatic(
new Vector3(x, y, z),
ForgeHooksClient.getWorldRenderPass
)
state.lightMatrix.access = null
b
}
override def renderInventoryBlock(
@@ -252,7 +252,9 @@ abstract class TMultiPart {
* Incremental changes should be sent rather than the whole description
* packet if possible.
*/
def sendDescUpdate() = writeDesc(getWriteStream)
def sendDescUpdate() {
if (tile != null) writeDesc(getWriteStream)
}
/** Called when a part is added or removed from this block space. The part
* parameter may be null if several things have changed.
@@ -316,6 +318,12 @@ abstract class TMultiPart {
*/
def doesTick = true
/** Return whether this part needs to be included in the dynamic render loop
* (renderDynamic). Default is false. Override this to true for parts like
* lights that need per-frame rendering but no logic updates.
*/
def shouldRenderDynamic = false
/** Called once per world tick. This will be called even if doesTick returns
* false if another part in the space needs ticks.
*/
@@ -40,8 +40,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
private var doesTick = false
private var cachedLightValue: Int = 0
private[multipart] def from(that: TileMultipart) {
copyFrom(that)
loadFrom(that)
@@ -118,6 +116,7 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
override def validate() {
super.validate()
if (worldObj != null && worldObj.isRemote)
TileCache.add(this)
}
@@ -170,25 +169,9 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
*/
def getWeakChanges = false
def getLightValue: Int = cachedLightValue
override def shouldRefresh(
oldBlock: Block,
newBlock: Block,
oldMeta: Int,
newMeta: Int,
world: World,
x: Int,
y: Int,
z: Int
): Boolean = {
oldBlock != newBlock
}
private def updateLight(): Unit = {
def getLightValue: Int = {
if (partList.isEmpty) {
cachedLightValue = 0
return
return 0
}
var max = 0
@@ -197,23 +180,8 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
val l = it.next().getLightValue
if (l > max) max = l
}
cachedLightValue = max
if (
worldObj != null && worldObj.getBlockMetadata(
xCoord,
yCoord,
zCoord
) != cachedLightValue
) {
worldObj.setBlockMetadataWithNotify(
xCoord,
yCoord,
zCoord,
cachedLightValue,
3
)
}
max
}
def getExplosionResistance(entity: Entity) =
@@ -336,10 +304,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
bindPart(part)
part.bind(this)
if (part.getLightValue > cachedLightValue) {
cachedLightValue = part.getLightValue
}
if (!doesTick && part.doesTick)
setTicking(true)
}
@@ -394,10 +358,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
part.onRemoved()
part.tile = null
if (removedLightValue == cachedLightValue && removedLightValue > 0) {
updateLight()
}
if (partList.isEmpty) {
worldObj.setBlockToAir(xCoord, yCoord, zCoord)
} else {
@@ -420,8 +380,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
clearParts()
parts.foreach(p => addPart_do(p))
updateLight()
if (worldObj != null) {
if (worldObj.isRemote)
operate(_.onWorldJoin())
@@ -434,7 +392,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
*/
def clearParts() {
partList = Seq()
cachedLightValue = 0
}
/** Writes the description of this tile, and all parts composing it, to packet
@@ -523,7 +480,8 @@ trait TileMultipartClient extends TileMultipart {
def updateRenderCache() {
if (partList != null) {
val (dynamic, static) = partList.partition(_.doesTick)
val (dynamic, static) =
partList.partition(p => p.doesTick || p.shouldRenderDynamic)
val sArr = static.toArray
val dArr = dynamic.toArray
@@ -604,7 +562,6 @@ trait TileMultipartClient extends TileMultipart {
def randomDisplayTick(random: Random) {}
override def shouldRenderInPass(pass: Int) = {
MultipartRenderer.pass = pass
if (staticCache == null) updateRenderCache()
hasDynamicParts
}
@@ -1,13 +1,15 @@
package codechicken.multipart.handler
import cpw.mods.fml.common.Mod
import cpw.mods.fml.common.event.FMLPostInitializationEvent
import cpw.mods.fml.common.event.FMLPreInitializationEvent
import cpw.mods.fml.common.event.FMLInitializationEvent
import cpw.mods.fml.common.event.{
FMLInitializationEvent,
FMLPostInitializationEvent,
FMLPreInitializationEvent,
FMLServerAboutToStartEvent,
FMLServerStoppedEvent
}
import cpw.mods.fml.common.Mod.EventHandler
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent
import codechicken.multipart.MultiPartRegistry
import codechicken.multipart.Tags
import codechicken.multipart.{ControlKeyModifer, MultiPartRegistry, Tags}
@Mod(
modid = "ForgeMultipart",
@@ -39,4 +41,10 @@ object MultipartMod {
def beforeServerStart(event: FMLServerAboutToStartEvent) {
MultiPartRegistry.beforeServerStart()
}
@EventHandler
def serverStopped(event: FMLServerStoppedEvent) {
MultipartSaveLoad.loadingWorld = null;
ControlKeyModifer.map.clear();
}
}