diff --git a/build.gradle b/build.gradle index 8dc4bd2..c6a046d 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'kotlin' group = 'com.github.octarine-noise' version = "2.0" -archivesBaseName = rootProject.name + '-MC1.8' +archivesBaseName = rootProject.name + '-MC1.8.8' buildscript { ext.kotlin_version = '1.0.0-beta-4584' @@ -19,7 +19,7 @@ buildscript { } } dependencies { - classpath "net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT" + classpath "net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -32,8 +32,8 @@ dependencies { } minecraft { - version = '1.8-11.14.4.1563' - mappings = 'stable_18' + version = '1.8.8-11.15.0.1655' + mappings = 'stable_20' } processResources { diff --git a/src/main/kotlin/mods/betterfoliage/BetterFoliageMod.kt b/src/main/kotlin/mods/betterfoliage/BetterFoliageMod.kt index 1595fa6..fc46b7d 100644 --- a/src/main/kotlin/mods/betterfoliage/BetterFoliageMod.kt +++ b/src/main/kotlin/mods/betterfoliage/BetterFoliageMod.kt @@ -24,11 +24,11 @@ object BetterFoliageMod { const val MOD_NAME = "Better Foliage" const val DOMAIN = "betterfoliage" const val LEGACY_DOMAIN = "bettergrassandleaves" - const val MC_VERSIONS = "[1.8]" + const val MC_VERSIONS = "[1.8.8]" const val GUI_FACTORY = "mods.betterfoliage.client.gui.ConfigGuiFactory" - var log: Logger? = null - var config: Configuration? = null + lateinit var log: Logger + lateinit var config: Configuration @JvmStatic @Mod.InstanceFactory @@ -45,7 +45,7 @@ object BetterFoliageMod { @Mod.EventHandler fun postInit(event: FMLPostInitializationEvent) { if (FMLCommonHandler.instance().effectiveSide == Side.CLIENT) { - Config.attach(config!!) + Config.attach(config) Client.log(INFO, "BetterFoliage initialized") } } diff --git a/src/main/kotlin/mods/betterfoliage/client/render/EntityFallingLeavesFX.kt b/src/main/kotlin/mods/betterfoliage/client/render/EntityFallingLeavesFX.kt index aa9ceda..1dae140 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/EntityFallingLeavesFX.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/EntityFallingLeavesFX.kt @@ -99,7 +99,6 @@ object LeafWindTracker { init { MinecraftForge.EVENT_BUS.register(this) - FMLCommonHandler.instance().bus().register(this) } fun changeWind(world: World) { diff --git a/src/main/kotlin/mods/betterfoliage/loader/BetterFoliageCore.kt b/src/main/kotlin/mods/betterfoliage/loader/BetterFoliageCore.kt index a4c14f7..1a38293 100644 --- a/src/main/kotlin/mods/betterfoliage/loader/BetterFoliageCore.kt +++ b/src/main/kotlin/mods/betterfoliage/loader/BetterFoliageCore.kt @@ -28,11 +28,11 @@ class BetterFoliageTransformer : Transformer() { // what: invoke BF code for every random display tick // why: allows us to catch random display ticks, without touching block code transformMethod(Refs.doVoidFogParticles) { - find(IINC)?.insertBefore { + find(invokeRef(Refs.randomDisplayTick))?.insertAfter { log.info("Applying random display tick call hook") varinsn(ALOAD, 0) varinsn(ALOAD, 13) - varinsn(ALOAD, if (isOptifinePresent) 8 else 12) + varinsn(ALOAD, 8) invokeStatic(Refs.onRandomDisplayTick) } ?: log.warn("Failed to apply random display tick call hook!") } @@ -93,7 +93,7 @@ class BetterFoliageTransformer : Transformer() { transformMethod(Refs.rebuildChunk) { find(invokeRef(Refs.renderBlock))?.replace { log.info("Applying RenderChunk block render override") - varinsn(ALOAD, if (isOptifinePresent) 21 else 18) + varinsn(ALOAD, 21) invokeStatic(Refs.renderWorldBlock) } if (isOptifinePresent) { diff --git a/src/main/kotlin/mods/betterfoliage/loader/Refs.kt b/src/main/kotlin/mods/betterfoliage/loader/Refs.kt index 4a9e138..351f0f6 100644 --- a/src/main/kotlin/mods/betterfoliage/loader/Refs.kt +++ b/src/main/kotlin/mods/betterfoliage/loader/Refs.kt @@ -12,50 +12,52 @@ object Refs { // Java val Map = ClassRef("java.util.Map") val List = ClassRef("java.util.List") + val Random = ClassRef("java.util.Random") // Minecraft - val IBlockAccess = ClassRef("net.minecraft.world.IBlockAccess", "ard") - val IBlockState = ClassRef("net.minecraft.block.state.IBlockState", "bec") - val BlockPos = ClassRef("net.minecraft.util.BlockPos", "dt") - val EnumWorldBlockLayer = ClassRef("net.minecraft.util.EnumWorldBlockLayer", "aql") - val EnumFacing = ClassRef("net.minecraft.util.EnumFacing", "ej") + val IBlockAccess = ClassRef("net.minecraft.world.IBlockAccess", "adq") + val IBlockState = ClassRef("net.minecraft.block.state.IBlockState", "alz") + val BlockPos = ClassRef("net.minecraft.util.BlockPos", "cj") + val EnumWorldBlockLayer = ClassRef("net.minecraft.util.EnumWorldBlockLayer", "adf") + val EnumFacing = ClassRef("net.minecraft.util.EnumFacing", "cq") - val Block = ClassRef("net.minecraft.block.Block", "atr") + val World = ClassRef("net.minecraft.world.World", "adm") + val WorldClient = ClassRef("net.minecraft.client.multiplayer.WorldClient", "bdb") + val doVoidFogParticles = MethodRef(WorldClient, "doVoidFogParticles", "func_73029_E", "b", ClassRef.void, ClassRef.int, ClassRef.int, ClassRef.int) + + val Block = ClassRef("net.minecraft.block.Block", "afh") val canRenderInLayer = MethodRef(Block, "canRenderInLayer", ClassRef.boolean, EnumWorldBlockLayer) val getAmbientOcclusionLightValue = MethodRef(Block, "getAmbientOcclusionLightValue", "func_149685_I", "f", ClassRef.float) val getUseNeighborBrightness = MethodRef(Block, "getUseNeighborBrightness", "func_149710_n", "q", ClassRef.boolean) val shouldSideBeRendered = MethodRef(Block, "shouldSideBeRendered", "func_149646_a", "a", ClassRef.boolean, IBlockAccess, BlockPos, EnumFacing) + val randomDisplayTick = MethodRef(Block, "randomDisplayTick", "func_180655_c", "c", ClassRef.void, World, BlockPos, IBlockState, Random) - val BlockModelRenderer = ClassRef("net.minecraft.client.renderer.BlockModelRenderer", "cln") - val AmbientOcclusionFace = ClassRef("net.minecraft.client.renderer.BlockModelRenderer\$AmbientOcclusionFace", "clq") - val ChunkCompileTaskGenerator = ClassRef("net.minecraft.client.renderer.chunk.ChunkCompileTaskGenerator", "coa") - val WorldRenderer = ClassRef("net.minecraft.client.renderer.WorldRenderer", "civ") + val BlockModelRenderer = ClassRef("net.minecraft.client.renderer.BlockModelRenderer", "bgf") + val AmbientOcclusionFace = ClassRef("net.minecraft.client.renderer.BlockModelRenderer\$AmbientOcclusionFace", "bgf\$b") + val ChunkCompileTaskGenerator = ClassRef("net.minecraft.client.renderer.chunk.ChunkCompileTaskGenerator", "bhn") + val WorldRenderer = ClassRef("net.minecraft.client.renderer.WorldRenderer", "bfd") val AOF_constructor = MethodRef(AmbientOcclusionFace, "", ClassRef.void, BlockModelRenderer) - val RenderChunk = ClassRef("net.minecraft.client.renderer.chunk.RenderChunk", "cop") + val RenderChunk = ClassRef("net.minecraft.client.renderer.chunk.RenderChunk", "bht") val rebuildChunk = MethodRef(RenderChunk, "rebuildChunk", "func_178581_b", "b", ClassRef.void, ClassRef.float, ClassRef.float, ClassRef.float, ChunkCompileTaskGenerator) - val BlockRendererDispatcher = ClassRef("net.minecraft.client.renderer.BlockRendererDispatcher", "cll") + val BlockRendererDispatcher = ClassRef("net.minecraft.client.renderer.BlockRendererDispatcher", "bgd") val renderBlock = MethodRef(BlockRendererDispatcher, "renderBlock", "func_175018_a", "a", ClassRef.boolean, IBlockState, BlockPos, IBlockAccess, WorldRenderer) - val World = ClassRef("net.minecraft.world.World", "aqu") - val WorldClient = ClassRef("net.minecraft.client.multiplayer.WorldClient", "cen") - val doVoidFogParticles = MethodRef(WorldClient, "doVoidFogParticles", "func_73029_E", "b", ClassRef.void, ClassRef.int, ClassRef.int, ClassRef.int) - // val IMetadataSerializer = ClassRef("net.minecraft.client.resources.data.IMetadataSerializer", "brw") // val SimpleReloadableResourceManager = ClassRef("net.minecraft.client.resources.SimpleReloadableResourceManager", "brg") // val metadataSerializer = FieldRef(SimpleReloadableResourceManager, "rmMetadataSerializer", "field_110547_c", "f", IMetadataSerializer) - val TextureAtlasSprite = ClassRef("net.minecraft.client.renderer.texture.TextureAtlasSprite", "bqd") + val TextureAtlasSprite = ClassRef("net.minecraft.client.renderer.texture.TextureAtlasSprite", "bmi") - val IRegistry = ClassRef("net.minecraft.util.IRegistry", "ez") + val IRegistry = ClassRef("net.minecraft.util.IRegistry", "db") val ModelLoader = ClassRef("net.minecraftforge.client.model.ModelLoader") val stateModels = FieldRef(ModelLoader, "stateModels", Map) val setupModelRegistry = MethodRef(ModelLoader, "setupModelRegistry", "func_177570_a", "a", IRegistry) val IModel = ClassRef("net.minecraftforge.client.model.IModel", "") - val ModelBlock = ClassRef("net.minecraft.client.renderer.block.model.ModelBlock", "cmc") - val ModelResourceLocation = ClassRef("net.minecraft.client.renderer.block.model.ModelResourceLocation", "cmc") + val ModelBlock = ClassRef("net.minecraft.client.renderer.block.model.ModelBlock", "bgl") + val ModelResourceLocation = ClassRef("net.minecraft.client.renderer.block.model.ModelResourceLocation", "bov") val VanillaModelWrapper = ClassRef("net.minecraftforge.client.model.ModelLoader\$VanillaModelWrapper") val model_VMW = FieldRef(VanillaModelWrapper, "model", ModelBlock) val location_VMW = FieldRef(VanillaModelWrapper, "location", ModelBlock) diff --git a/src/main/kotlin/mods/octarinecore/client/render/AbstractEntityFX.kt b/src/main/kotlin/mods/octarinecore/client/render/AbstractEntityFX.kt index d054dd5..a8f0a8f 100644 --- a/src/main/kotlin/mods/octarinecore/client/render/AbstractEntityFX.kt +++ b/src/main/kotlin/mods/octarinecore/client/render/AbstractEntityFX.kt @@ -82,11 +82,42 @@ abstract class AbstractEntityFX(world: World, x: Double, y: Double, z: Double) : val v2 = if (rotation == 0) billboardRot.second * size else Double3.weight(billboardRot.first, -sin[rotation and 63] * size, billboardRot.second, cos[rotation and 63] * size) - worldRenderer.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, alpha) - worldRenderer.addVertexWithUV(center.x - v1.x, center.y - v1.y, center.z - v1.z, maxU, maxV) - worldRenderer.addVertexWithUV(center.x - v2.x, center.y - v2.y, center.z - v2.z, maxU, minV) - worldRenderer.addVertexWithUV(center.x + v1.x, center.y + v1.y, center.z + v1.z, minU, minV) - worldRenderer.addVertexWithUV(center.x + v2.x, center.y + v2.y, center.z + v2.z, minU, maxV) + val renderBrightness = this.getBrightnessForRender(partialTickTime) + val brLow = renderBrightness shr 16 and 65535 + val brHigh = renderBrightness and 65535 + + worldRenderer + .pos(center.x - v1.x, center.y - v1.y, center.z - v1.z) + .tex(maxU, maxV) + .color(particleRed, particleGreen, particleBlue, alpha) + .lightmap(brLow, brHigh) + .endVertex() + + worldRenderer + .pos(center.x - v2.x, center.y - v2.y, center.z - v2.z) + .tex(maxU, minV) + .color(particleRed, particleGreen, particleBlue, alpha) + .lightmap(brLow, brHigh) + .endVertex() + + worldRenderer + .pos(center.x + v1.x, center.y + v1.y, center.z + v1.z) + .tex(minU, minV) + .color(particleRed, particleGreen, particleBlue, alpha) + .lightmap(brLow, brHigh) + .endVertex() + + worldRenderer + .pos(center.x + v2.x, center.y + v2.y, center.z + v2.z) + .tex(minU, maxV) + .color(particleRed, particleGreen, particleBlue, alpha) + .lightmap(brLow, brHigh) + .endVertex() + +// worldRenderer.addVertexWithUV(center.x - v1.x, center.y - v1.y, center.z - v1.z, maxU, maxV) +// worldRenderer.addVertexWithUV(center.x - v2.x, center.y - v2.y, center.z - v2.z, maxU, minV) +// worldRenderer.addVertexWithUV(center.x + v1.x, center.y + v1.y, center.z + v1.z, minU, minV) +// worldRenderer.addVertexWithUV(center.x + v2.x, center.y + v2.y, center.z + v2.z, minU, maxV) } override fun getFXLayer() = 1 diff --git a/src/main/kotlin/mods/octarinecore/client/render/ModelRenderer.kt b/src/main/kotlin/mods/octarinecore/client/render/ModelRenderer.kt index ec30e54..8848a2b 100644 --- a/src/main/kotlin/mods/octarinecore/client/render/ModelRenderer.kt +++ b/src/main/kotlin/mods/octarinecore/client/render/ModelRenderer.kt @@ -5,6 +5,7 @@ import mods.octarinecore.common.* import net.minecraft.client.Minecraft import net.minecraft.client.renderer.WorldRenderer import net.minecraft.client.renderer.texture.TextureAtlasSprite +import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.util.EnumFacing import net.minecraft.util.EnumFacing.* @@ -39,6 +40,12 @@ class ModelRenderer() : ShadingContext() { rotation = rot aoEnabled = Minecraft.isAmbientOcclusionEnabled() + // make sure we have space in the buffer for our quads plus one + worldRenderer.apply { + rawIntBuffer.position(bufferSize) + growBuffer((model.quads.size * 4 + 1) * vertexFormat.func_181719_f()) + } + model.quads.forEachIndexed { quadIdx, quad -> val drawIcon = icon(this, quadIdx, quad) if (drawIcon != null) { @@ -49,11 +56,13 @@ class ModelRenderer() : ShadingContext() { val shader = if (aoEnabled && !forceFlat) vert.aoShader else vert.flatShader shader.shade(this, temp) temp.postProcess(this, quadIdx, quad, vertIdx, vert) - worldRenderer.setTextureUV(temp.u, temp.v) - worldRenderer.setBrightness(temp.brightness) - worldRenderer.setColorOpaque_F(temp.red, temp.green, temp.blue) - worldRenderer.addVertex(temp.x, temp.y, temp.z) + worldRenderer + .pos(temp.x, temp.y, temp.z) + .color(temp.red, temp.green, temp.blue, 1.0f) + .tex(temp.u, temp.v) + .lightmap(temp.brightness shr 16 and 65535, temp.brightness and 65535) + .endVertex() } } } @@ -93,6 +102,8 @@ class RenderVertex() { var green: Float = 0.0f var blue: Float = 0.0f + val rawData = IntArray(7) + fun init(vertex: Vertex, rot: Rotation, trans: Double3): RenderVertex { val result = vertex.xyz.rotate(rot) + trans x = result.x; y = result.y; z = result.z @@ -140,6 +151,7 @@ class RenderVertex() { green = (color shr 8 and 255) / 256.0f blue = (color and 255) / 256.0f } + } val allFaces: (EnumFacing) -> Boolean = { true } diff --git a/src/main/kotlin/mods/octarinecore/client/resource/ResourceGeneration.kt b/src/main/kotlin/mods/octarinecore/client/resource/ResourceGeneration.kt index 10b2596..dec3aa8 100644 --- a/src/main/kotlin/mods/octarinecore/client/resource/ResourceGeneration.kt +++ b/src/main/kotlin/mods/octarinecore/client/resource/ResourceGeneration.kt @@ -2,6 +2,7 @@ package mods.octarinecore.client.resource import mods.octarinecore.metaprog.reflectField import net.minecraft.client.resources.IResourcePack +import net.minecraft.client.resources.data.IMetadataSection import net.minecraft.client.resources.data.IMetadataSerializer import net.minecraft.client.resources.data.PackMetadataSection import net.minecraft.util.ChatComponentText @@ -26,8 +27,8 @@ class GeneratorPack(val name: String, vararg val generators: GeneratorBase) : IR override fun getPackName() = name override fun getPackImage() = null override fun getResourceDomains() = HashSet(generators.map { it.domain }) - override fun getPackMetadata(serializer: IMetadataSerializer?, type: String?) = - if (type == "pack") PackMetadataSection(ChatComponentText("Generated resources"), 1) else null + override fun getPackMetadata(serializer: IMetadataSerializer?, type: String?) = + if (type == "pack") PackMetadataSection(ChatComponentText("Generated resources"), 1) as? T else null override fun resourceExists(location: ResourceLocation?): Boolean = if (location == null) false @@ -42,7 +43,9 @@ class GeneratorPack(val name: String, vararg val generators: GeneratorBase) : IR }.map { it.getInputStream(location) } .filterNotNull().first() - operator fun get(location: ResourceLocation?) = getInputStream(location) +// override fun getPackMetadata(p_135058_1_: IMetadataSerializer?, p_135058_2_: String?): T { +// return if (type == "pack") PackMetadataSection(ChatComponentText("Generated resources"), 1) else null +// } } /** diff --git a/src/main/kotlin/mods/octarinecore/client/resource/ResourceHandler.kt b/src/main/kotlin/mods/octarinecore/client/resource/ResourceHandler.kt index 27b51ff..bbe6891 100644 --- a/src/main/kotlin/mods/octarinecore/client/resource/ResourceHandler.kt +++ b/src/main/kotlin/mods/octarinecore/client/resource/ResourceHandler.kt @@ -40,10 +40,7 @@ open class ResourceHandler(val modId: String) { // ============================ // Self-registration // ============================ - init { - MinecraftForge.EVENT_BUS.register(this) - FMLCommonHandler.instance().bus().register(this) - } + init { MinecraftForge.EVENT_BUS.register(this) } // ============================ // Resource declarations diff --git a/src/main/kotlin/mods/octarinecore/common/config/DelegatingConfig.kt b/src/main/kotlin/mods/octarinecore/common/config/DelegatingConfig.kt index 9987197..3da3991 100644 --- a/src/main/kotlin/mods/octarinecore/common/config/DelegatingConfig.kt +++ b/src/main/kotlin/mods/octarinecore/common/config/DelegatingConfig.kt @@ -4,6 +4,7 @@ import com.google.common.collect.LinkedListMultimap import mods.octarinecore.metaprog.reflectField import mods.octarinecore.metaprog.reflectFieldsOfType import mods.octarinecore.metaprog.reflectNestedObjects +import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.config.ConfigElement import net.minecraftforge.common.config.Configuration import net.minecraftforge.common.config.Property @@ -33,7 +34,7 @@ import kotlin.reflect.KProperty */ abstract class DelegatingConfig(val modId: String, val langPrefix: String) { - init { FMLCommonHandler.instance().bus().register(this) } + init { MinecraftForge.EVENT_BUS.register(this) } /** The [Configuration] backing this config object. */ var config: Configuration? = null diff --git a/src/main/resources/META-INF/BetterFoliage_at.cfg b/src/main/resources/META-INF/BetterFoliage_at.cfg index 521cdff..270d96f 100644 --- a/src/main/resources/META-INF/BetterFoliage_at.cfg +++ b/src/main/resources/META-INF/BetterFoliage_at.cfg @@ -5,3 +5,7 @@ public net.minecraft.client.renderer.BlockModelRenderer$AmbientOcclusionFace fie public net.minecraft.client.resources.model.ModelBakery field_177610_k # blockModelShapes public net.minecraft.client.renderer.block.statemap.BlockStateMapper field_178450_a # blockStateMap + +public net.minecraft.client.renderer.WorldRenderer field_178999_b # rawIntBuffer +public net.minecraft.client.renderer.WorldRenderer func_181670_b(I)V # growBuffer +public net.minecraft.client.renderer.WorldRenderer func_181664_j()I # getBufferSize \ No newline at end of file