port to MC 1.11

This commit is contained in:
octarine-noise
2016-12-10 21:30:55 +01:00
parent 1a1aa81c0f
commit ceb3e5b116
28 changed files with 77 additions and 74 deletions

View File

@@ -3,7 +3,7 @@ apply plugin: 'kotlin'
group = 'com.github.octarine-noise' group = 'com.github.octarine-noise'
version = "2.1.2" version = "2.1.2"
archivesBaseName = rootProject.name + '-MC1.10.2' archivesBaseName = rootProject.name + '-MC1.11'
buildscript { buildscript {
ext.kotlin_version = '1.0.3' ext.kotlin_version = '1.0.3'
@@ -32,11 +32,10 @@ dependencies {
shade "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" shade "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
} }
minecraft { minecraft {
version = '1.10.2-12.18.1.2075' version = '1.11-13.19.1.2188'
mappings = 'snapshot_20160905' mappings = 'snapshot_20161210'
runDir = 'run' runDir = 'run'
} }
processResources { processResources {
inputs.property "version", project.version inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version inputs.property "mcversion", project.minecraft.version

View File

@@ -30,7 +30,7 @@ object BetterFoliageMod {
const val MOD_NAME = "Better Foliage" const val MOD_NAME = "Better Foliage"
const val DOMAIN = "betterfoliage" const val DOMAIN = "betterfoliage"
const val LEGACY_DOMAIN = "bettergrassandleaves" const val LEGACY_DOMAIN = "bettergrassandleaves"
const val MC_VERSIONS = "[1.10.2]" const val MC_VERSIONS = "[1.11]"
const val GUI_FACTORY = "mods.betterfoliage.client.gui.ConfigGuiFactory" const val GUI_FACTORY = "mods.betterfoliage.client.gui.ConfigGuiFactory"
lateinit var log: Logger lateinit var log: Logger

View File

@@ -15,7 +15,6 @@ import net.minecraft.block.Block
import net.minecraft.block.state.IBlockState import net.minecraft.block.state.IBlockState
import net.minecraft.client.renderer.BlockRendererDispatcher import net.minecraft.client.renderer.BlockRendererDispatcher
import net.minecraft.client.renderer.VertexBuffer import net.minecraft.client.renderer.VertexBuffer
import net.minecraft.client.renderer.block.model.IBakedModel
import net.minecraft.init.Blocks import net.minecraft.init.Blocks
import net.minecraft.util.BlockRenderLayer import net.minecraft.util.BlockRenderLayer
import net.minecraft.util.BlockRenderLayer.CUTOUT import net.minecraft.util.BlockRenderLayer.CUTOUT
@@ -24,7 +23,6 @@ import net.minecraft.util.EnumFacing
import net.minecraft.util.math.BlockPos import net.minecraft.util.math.BlockPos
import net.minecraft.world.IBlockAccess import net.minecraft.world.IBlockAccess
import net.minecraft.world.World import net.minecraft.world.World
import net.minecraftforge.client.model.IModel
import net.minecraftforge.client.model.ModelLoader import net.minecraftforge.client.model.ModelLoader
import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.relauncher.Side import net.minecraftforge.fml.relauncher.Side

View File

@@ -32,17 +32,17 @@ object Config : DelegatingConfig(BetterFoliageMod.MOD_ID, BetterFoliageMod.DOMAI
var enabled by boolean(true) var enabled by boolean(true)
object blocks { object blocks {
val leavesClasses = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "LeavesBlocksDefault.cfg") val leavesClasses = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "leaves_blocks_default.cfg")
val leavesModels = ModelTextureListConfigOption(BetterFoliageMod.DOMAIN, "LeavesModelsDefault.cfg", 1) val leavesModels = ModelTextureListConfigOption(BetterFoliageMod.DOMAIN, "leaves_models_default.cfg", 1)
val grassClasses = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "GrassBlocksDefault.cfg") val grassClasses = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "grass_blocks_default.cfg")
val grassModels = ModelTextureListConfigOption(BetterFoliageMod.DOMAIN, "GrassModelsDefault.cfg", 1) val grassModels = ModelTextureListConfigOption(BetterFoliageMod.DOMAIN, "grass_models_default.cfg", 1)
val dirt = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "DirtDefault.cfg") val dirt = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "dirt_default.cfg")
val crops = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "CropDefault.cfg") val crops = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "crop_default.cfg")
val logClasses = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "LogBlocksDefault.cfg") val logClasses = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "log_blocks_default.cfg")
val logModels = ModelTextureListConfigOption(BetterFoliageMod.DOMAIN, "LogModelsDefault.cfg", 3) val logModels = ModelTextureListConfigOption(BetterFoliageMod.DOMAIN, "log_models_default.cfg", 3)
val sand = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "SandDefault.cfg") val sand = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "sand_default.cfg")
val lilypad = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "LilypadDefault.cfg") val lilypad = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "lilypad_default.cfg")
val cactus = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "CactusDefault.cfg") val cactus = ConfigurableBlockMatcher(BetterFoliageMod.DOMAIN, "cactus_default.cfg")
val leavesWhitelist = OBSOLETE val leavesWhitelist = OBSOLETE
val leavesBlacklist = OBSOLETE val leavesBlacklist = OBSOLETE

View File

@@ -14,6 +14,7 @@ import mods.betterfoliage.client.texture.StandardLeafSupport
import mods.betterfoliage.loader.Refs import mods.betterfoliage.loader.Refs
import mods.octarinecore.client.resource.ModelProcessor import mods.octarinecore.client.resource.ModelProcessor
import mods.octarinecore.client.resource.get import mods.octarinecore.client.resource.get
import mods.octarinecore.client.resource.registerSprite
import mods.octarinecore.metaprog.ClassRef import mods.octarinecore.metaprog.ClassRef
import mods.octarinecore.metaprog.FieldRef import mods.octarinecore.metaprog.FieldRef
import mods.octarinecore.metaprog.MethodRef import mods.octarinecore.metaprog.MethodRef
@@ -95,8 +96,8 @@ object ForestryLeavesSupport : ILeafRegistry {
} }
fun registerLeaf(textureLocation: ResourceLocation, atlas: TextureMap) { fun registerLeaf(textureLocation: ResourceLocation, atlas: TextureMap) {
val texture = atlas[textureLocation.toString()] ?: return val texture = atlas.registerSprite(textureLocation)
var leafType = LeafRegistry.typeMappings.getType(texture) ?: "default" val leafType = LeafRegistry.typeMappings.getType(texture) ?: "default"
Client.logDetail("ForestryLeavesSupport: texture ${texture.iconName}") Client.logDetail("ForestryLeavesSupport: texture ${texture.iconName}")
Client.logDetail("ForestryLeavesSupport: particle $leafType") Client.logDetail("ForestryLeavesSupport: particle $leafType")
val generated = atlas.registerSprite( val generated = atlas.registerSprite(
@@ -156,8 +157,8 @@ object ForestryLogSupport : ModelProcessor<List<String>, IColumnTextureResolver>
} }
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? { override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? {
val heart = atlas[key[0]] ?: return null val heart = atlas.registerSprite(key[0])
val bark = atlas[key[1]] ?: return null val bark = atlas.registerSprite(key[1])
return StaticColumnInfo(heart, heart, bark) return StaticColumnInfo(heart, heart, bark)
} }

View File

@@ -38,7 +38,7 @@ AbstractEntityFX(world, pos.x.toDouble() + 0.5, pos.y.toDouble(), pos.z.toDouble
var wasCollided = false var wasCollided = false
init { init {
particleMaxAge = MathHelper.floor_double(random(0.6, 1.0) * Config.fallingLeaves.lifetime * 20.0) particleMaxAge = MathHelper.floor(random(0.6, 1.0) * Config.fallingLeaves.lifetime * 20.0)
motionY = -Config.fallingLeaves.speed motionY = -Config.fallingLeaves.speed
particleScale = Config.fallingLeaves.size.toFloat() * 0.1f particleScale = Config.fallingLeaves.size.toFloat() * 0.1f
@@ -60,7 +60,7 @@ AbstractEntityFX(world, pos.x.toDouble() + 0.5, pos.y.toDouble(), pos.z.toDouble
if (rand.nextFloat() > 0.95f) rotPositive = !rotPositive if (rand.nextFloat() > 0.95f) rotPositive = !rotPositive
if (particleAge > particleMaxAge - 20) particleAlpha = 0.05f * (particleMaxAge - particleAge) if (particleAge > particleMaxAge - 20) particleAlpha = 0.05f * (particleMaxAge - particleAge)
if (isCollided || wasCollided) { if (onGround || wasCollided) {
velocity.setTo(0.0, 0.0, 0.0) velocity.setTo(0.0, 0.0, 0.0)
if (!wasCollided) { if (!wasCollided) {
particleAge = Math.max(particleAge, particleMaxAge - 20) particleAge = Math.max(particleAge, particleMaxAge - 20)
@@ -117,7 +117,7 @@ object LeafWindTracker {
@SubscribeEvent @SubscribeEvent
fun handleWorldTick(event: TickEvent.ClientTickEvent) { fun handleWorldTick(event: TickEvent.ClientTickEvent) {
if (event.phase == TickEvent.Phase.START) Minecraft.getMinecraft().theWorld?.let { world -> if (event.phase == TickEvent.Phase.START) Minecraft.getMinecraft().world?.let { world ->
// change target wind speed // change target wind speed
if (world.worldInfo.worldTime >= nextChange) changeWind(world) if (world.worldInfo.worldTime >= nextChange) changeWind(world)

View File

@@ -26,7 +26,7 @@ AbstractEntityFX(world, pos.x.toDouble() + 0.5, pos.y.toDouble() + 1.0, pos.z.to
motionY = 0.1 motionY = 0.1
particleGravity = 0.0f particleGravity = 0.0f
particleTexture = RisingSoulTextures.headIcons[rand.nextInt(256)] particleTexture = RisingSoulTextures.headIcons[rand.nextInt(256)]
particleMaxAge = MathHelper.floor_double((0.6 + 0.4 * rand.nextDouble()) * Config.risingSoul.lifetime * 20.0) particleMaxAge = MathHelper.floor((0.6 + 0.4 * rand.nextDouble()) * Config.risingSoul.lifetime * 20.0)
} }
override val isValid: Boolean get() = true override val isValid: Boolean get() = true

View File

@@ -6,6 +6,7 @@ import mods.betterfoliage.client.config.Config
import mods.octarinecore.client.render.* import mods.octarinecore.client.render.*
import mods.octarinecore.client.resource.TextureListModelProcessor import mods.octarinecore.client.resource.TextureListModelProcessor
import mods.octarinecore.client.resource.get import mods.octarinecore.client.resource.get
import mods.octarinecore.client.resource.registerSprite
import mods.octarinecore.common.Int3 import mods.octarinecore.common.Int3
import mods.octarinecore.common.Rotation import mods.octarinecore.common.Rotation
import mods.octarinecore.common.config.ConfigurableBlockMatcher import mods.octarinecore.common.config.ConfigurableBlockMatcher
@@ -45,10 +46,10 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
) )
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? { override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? {
val topTex = atlas[key[0]] val topTex = atlas.registerSprite(key[0])
val bottomTex = atlas[key[1]] val bottomTex = atlas.registerSprite(key[1])
val sideTex = atlas[key[2]] val sideTex = atlas.registerSprite(key[2])
return if (topTex != null && bottomTex != null && sideTex != null) StaticColumnInfo(topTex, bottomTex, sideTex) else null return StaticColumnInfo(topTex, bottomTex, sideTex)
} }
override fun get(state: IBlockState) = stateToValue[state] override fun get(state: IBlockState) = stateToValue[state]

View File

@@ -8,6 +8,7 @@ import mods.betterfoliage.client.texture.StandardGrassSupport
import mods.octarinecore.client.render.BlockContext import mods.octarinecore.client.render.BlockContext
import mods.octarinecore.client.resource.TextureListModelProcessor import mods.octarinecore.client.resource.TextureListModelProcessor
import mods.octarinecore.client.resource.get import mods.octarinecore.client.resource.get
import mods.octarinecore.client.resource.registerSprite
import mods.octarinecore.common.Int3 import mods.octarinecore.common.Int3
import mods.octarinecore.common.config.ConfigurableBlockMatcher import mods.octarinecore.common.config.ConfigurableBlockMatcher
import mods.octarinecore.common.config.ModelTextureList import mods.octarinecore.common.config.ModelTextureList
@@ -72,10 +73,10 @@ object StandardLogSupport : TextureListModelProcessor<IColumnTextureResolver>, I
override val modelTextures: List<ModelTextureList> get() = Config.blocks.logModels.list override val modelTextures: List<ModelTextureList> get() = Config.blocks.logModels.list
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? { override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? {
val topTex = atlas[key[0]] val topTex = atlas.registerSprite(key[0])
val bottomTex = atlas[key[1]] val bottomTex = atlas.registerSprite(key[1])
val sideTex = atlas[key[2]] val sideTex = atlas.registerSprite(key[2])
return if (topTex != null && bottomTex != null && sideTex != null) StaticColumnInfo(topTex, bottomTex, sideTex) else null return StaticColumnInfo(topTex, bottomTex, sideTex)
} }
override fun get(state: IBlockState) = stateToValue[state] override fun get(state: IBlockState) = stateToValue[state]

View File

@@ -5,10 +5,7 @@ import mods.betterfoliage.client.config.Config
import mods.betterfoliage.client.integration.OptifineCTM import mods.betterfoliage.client.integration.OptifineCTM
import mods.octarinecore.client.render.BlockContext import mods.octarinecore.client.render.BlockContext
import mods.octarinecore.client.render.HSB import mods.octarinecore.client.render.HSB
import mods.octarinecore.client.resource.TextureListModelProcessor import mods.octarinecore.client.resource.*
import mods.octarinecore.client.resource.TextureMediatedRegistry
import mods.octarinecore.client.resource.averageColor
import mods.octarinecore.client.resource.get
import mods.octarinecore.common.Int3 import mods.octarinecore.common.Int3
import mods.octarinecore.common.config.ConfigurableBlockMatcher import mods.octarinecore.common.config.ConfigurableBlockMatcher
import mods.octarinecore.common.config.ModelTextureList import mods.octarinecore.common.config.ModelTextureList
@@ -83,7 +80,7 @@ object StandardGrassSupport :
if (it == null) null else textureToValue[it] if (it == null) null else textureToValue[it]
} }
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap) = atlas[key[0]] override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap) = atlas.registerSprite(key[0])
override fun processTexture(states: List<IBlockState>, texture: TextureAtlasSprite, atlas: TextureMap) { override fun processTexture(states: List<IBlockState>, texture: TextureAtlasSprite, atlas: TextureMap) {
registerGrass(texture, atlas) registerGrass(texture, atlas)

View File

@@ -59,7 +59,7 @@ object LeafRegistry : ILeafRegistry {
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)
fun handlePreStitch(event: TextureStitchEvent.Pre) { fun handlePreStitch(event: TextureStitchEvent.Pre) {
particles.clear() particles.clear()
typeMappings.loadMappings(ResourceLocation(BetterFoliageMod.DOMAIN, "leafTextureMappings.cfg")) typeMappings.loadMappings(ResourceLocation(BetterFoliageMod.DOMAIN, "leaf_texture_mappings.cfg"))
} }
override fun get(state: IBlockState, world: IBlockAccess, pos: BlockPos, face: EnumFacing) = override fun get(state: IBlockState, world: IBlockAccess, pos: BlockPos, face: EnumFacing) =
@@ -113,7 +113,7 @@ object StandardLeafSupport :
if (it == null) null else textureToValue[it] if (it == null) null else textureToValue[it]
} }
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap) = atlas[key[0]] override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap) = atlas.registerSprite(key[0])
override fun processTexture(states: List<IBlockState>, texture: TextureAtlasSprite, atlas: TextureMap) { override fun processTexture(states: List<IBlockState>, texture: TextureAtlasSprite, atlas: TextureMap) {
logger?.log(Level.DEBUG, "$logName: leaf texture ${texture.iconName}") logger?.log(Level.DEBUG, "$logName: leaf texture ${texture.iconName}")

View File

@@ -13,7 +13,7 @@ import org.objectweb.asm.Opcodes.*
"kotlin", "kotlin",
"mods.octarinecore.kotlin" "mods.octarinecore.kotlin"
) )
@IFMLLoadingPlugin.MCVersion("1.10.2") @IFMLLoadingPlugin.MCVersion("1.11")
class BetterFoliageLoader : ASMPlugin(BetterFoliageTransformer::class.java) class BetterFoliageLoader : ASMPlugin(BetterFoliageTransformer::class.java)
class BetterFoliageTransformer : Transformer() { class BetterFoliageTransformer : Transformer() {

View File

@@ -16,50 +16,53 @@ object Refs {
val Random = ClassRef("java.util.Random") val Random = ClassRef("java.util.Random")
// Minecraft // Minecraft
val IBlockAccess = ClassRef("net.minecraft.world.IBlockAccess", "aih") val IBlockAccess = ClassRef("net.minecraft.world.IBlockAccess", "aju")
val IBlockState = ClassRef("net.minecraft.block.state.IBlockState", "ars") val IBlockState = ClassRef("net.minecraft.block.state.IBlockState", "atj")
val BlockStateBase = ClassRef("net.minecraft.block.state.BlockStateBase", "arp") val BlockStateBase = ClassRef("net.minecraft.block.state.BlockStateBase", "agg")
val BlockPos = ClassRef("net.minecraft.util.math.BlockPos", "cm") val BlockPos = ClassRef("net.minecraft.util.math.BlockPos", "co")
val MutableBlockPos = ClassRef("net.minecraft.util.math.BlockPos\$MutableBlockPos", "cm\$a") val MutableBlockPos = ClassRef("net.minecraft.util.math.BlockPos\$MutableBlockPos", "co\$a")
val BlockRenderLayer = ClassRef("net.minecraft.util.BlockRenderLayer", "ahv") val BlockRenderLayer = ClassRef("net.minecraft.util.BlockRenderLayer", "aji")
val EnumFacing = ClassRef("net.minecraft.util.EnumFacing", "ct") val EnumFacing = ClassRef("net.minecraft.util.EnumFacing", "cv")
val World = ClassRef("net.minecraft.world.World", "aid") val World = ClassRef("net.minecraft.world.World", "ajq")
val WorldClient = ClassRef("net.minecraft.client.multiplayer.WorldClient", "bln") val WorldClient = ClassRef("net.minecraft.client.multiplayer.WorldClient", "bno")
val showBarrierParticles = MethodRef(WorldClient, "showBarrierParticles", "func_184153_a", "a", ClassRef.void, ClassRef.int, ClassRef.int, ClassRef.int, ClassRef.int, Random, ClassRef.boolean, MutableBlockPos) val showBarrierParticles = MethodRef(WorldClient, "showBarrierParticles", "func_184153_a", "a", ClassRef.void, ClassRef.int, ClassRef.int, ClassRef.int, ClassRef.int, Random, ClassRef.boolean, MutableBlockPos)
val Block = ClassRef("net.minecraft.block.Block", "akf") val Block = ClassRef("net.minecraft.block.Block", "als")
val StateImplementation = ClassRef("net.minecraft.block.state.BlockStateContainer\$StateImplementation", "art\$a") val StateImplementation = ClassRef("net.minecraft.block.state.BlockStateContainer\$StateImplementation", "atk\$a")
val canRenderInLayer = MethodRef(Block, "canRenderInLayer", ClassRef.boolean, IBlockState, BlockRenderLayer) val canRenderInLayer = MethodRef(Block, "canRenderInLayer", ClassRef.boolean, IBlockState, BlockRenderLayer)
val getAmbientOcclusionLightValue = MethodRef(StateImplementation, "getAmbientOcclusionLightValue", "func_185892_j", "j", ClassRef.float) val getAmbientOcclusionLightValue = MethodRef(StateImplementation, "getAmbientOcclusionLightValue", "func_185892_j", "k", ClassRef.float)
val useNeighborBrightness = MethodRef(StateImplementation, "useNeighborBrightness", "func_185916_f", "f", ClassRef.boolean) val useNeighborBrightness = MethodRef(StateImplementation, "useNeighborBrightness", "func_185916_f", "f", ClassRef.boolean)
val doesSideBlockRendering = MethodRef(StateImplementation, "doesSideBlockRendering", ClassRef.boolean, IBlockAccess, BlockPos, EnumFacing) val doesSideBlockRendering = MethodRef(StateImplementation, "doesSideBlockRendering", ClassRef.boolean, IBlockAccess, BlockPos, EnumFacing)
val isOpaqueCube = MethodRef(StateImplementation, "isOpaqueCube", "func_185914_p", "p", ClassRef.boolean) val isOpaqueCube = MethodRef(StateImplementation, "isOpaqueCube", "func_185914_p", "q", ClassRef.boolean)
val randomDisplayTick = MethodRef(Block, "randomDisplayTick", "func_180655_c", "a", ClassRef.void, IBlockState, World, BlockPos, Random) val randomDisplayTick = MethodRef(Block, "randomDisplayTick", "func_180655_c", "a", ClassRef.void, IBlockState, World, BlockPos, Random)
val BlockModelRenderer = ClassRef("net.minecraft.client.renderer.BlockModelRenderer", "box") val BlockModelRenderer = ClassRef("net.minecraft.client.renderer.BlockModelRenderer", "bra")
val AmbientOcclusionFace = ClassRef("net.minecraft.client.renderer.BlockModelRenderer\$AmbientOcclusionFace", "box\$b") val AmbientOcclusionFace = ClassRef("net.minecraft.client.renderer.BlockModelRenderer\$AmbientOcclusionFace", "bra\$b")
val ChunkCompileTaskGenerator = ClassRef("net.minecraft.client.renderer.chunk.ChunkCompileTaskGenerator", "bqs") val ChunkCompileTaskGenerator = ClassRef("net.minecraft.client.renderer.chunk.ChunkCompileTaskGenerator", "bsw")
val VertexBuffer = ClassRef("net.minecraft.client.renderer.VertexBuffer", "bnt") val VertexBuffer = ClassRef("net.minecraft.client.renderer.VertexBuffer", "bpw")
val AOF_constructor = MethodRef(AmbientOcclusionFace, "<init>", ClassRef.void, BlockModelRenderer) val AOF_constructor = MethodRef(AmbientOcclusionFace, "<init>", ClassRef.void, BlockModelRenderer)
val RenderChunk = ClassRef("net.minecraft.client.renderer.chunk.RenderChunk", "bqy") val RenderChunk = ClassRef("net.minecraft.client.renderer.chunk.RenderChunk", "btc")
val rebuildChunk = MethodRef(RenderChunk, "rebuildChunk", "func_178581_b", "b", ClassRef.void, ClassRef.float, ClassRef.float, ClassRef.float, ChunkCompileTaskGenerator) 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", "bov") val BlockRendererDispatcher = ClassRef("net.minecraft.client.renderer.BlockRendererDispatcher", "bqy")
val renderBlock = MethodRef(BlockRendererDispatcher, "renderBlock", "func_175018_a", "a", ClassRef.boolean, IBlockState, BlockPos, IBlockAccess, VertexBuffer) val renderBlock = MethodRef(BlockRendererDispatcher, "renderBlock", "func_175018_a", "a", ClassRef.boolean, IBlockState, BlockPos, IBlockAccess, VertexBuffer)
val TextureAtlasSprite = ClassRef("net.minecraft.client.renderer.texture.TextureAtlasSprite", "bwe") val TextureAtlasSprite = ClassRef("net.minecraft.client.renderer.texture.TextureAtlasSprite", "byw")
val TextureMap = ClassRef("net.minecraft.client.renderer.texture.TextureMap", "byv")
val IResourceManager = ClassRef("net.minecraft.client.resources.IResourceManager", "bzv")
val loadTextureAtlas = MethodRef(TextureMap, "loadTextureAtlas", "func_110571_b", "b", ClassRef.void, IResourceManager)
val IRegistry = ClassRef("net.minecraft.util.registry.IRegistry", "de") val IRegistry = ClassRef("net.minecraft.util.registry.IRegistry", "dh")
val ModelLoader = ClassRef("net.minecraftforge.client.model.ModelLoader") val ModelLoader = ClassRef("net.minecraftforge.client.model.ModelLoader")
val stateModels = FieldRef(ModelLoader, "stateModels", Map) val stateModels = FieldRef(ModelLoader, "stateModels", Map)
val setupModelRegistry = MethodRef(ModelLoader, "setupModelRegistry", "func_177570_a", "a", IRegistry) val setupModelRegistry = MethodRef(ModelLoader, "setupModelRegistry", "func_177570_a", "a", IRegistry)
val IModel = ClassRef("net.minecraftforge.client.model.IModel") val IModel = ClassRef("net.minecraftforge.client.model.IModel")
val ModelBlock = ClassRef("net.minecraft.client.renderer.block.model.ModelBlock", "bpd") val ModelBlock = ClassRef("net.minecraft.client.renderer.block.model.ModelBlock", "brg")
val ResourceLocation = ClassRef("net.minecraft.util.ResourceLocation", "kn") val ResourceLocation = ClassRef("net.minecraft.util.ResourceLocation", "kq")
val ModelResourceLocation = ClassRef("net.minecraft.client.renderer.block.model.ModelResourceLocation", "byq") val ModelResourceLocation = ClassRef("net.minecraft.client.renderer.block.model.ModelResourceLocation", "cbj")
val VanillaModelWrapper = ClassRef("net.minecraftforge.client.model.ModelLoader\$VanillaModelWrapper") val VanillaModelWrapper = ClassRef("net.minecraftforge.client.model.ModelLoader\$VanillaModelWrapper")
val model_VMW = FieldRef(VanillaModelWrapper, "model", ModelBlock) val model_VMW = FieldRef(VanillaModelWrapper, "model", ModelBlock)
val location_VMW = FieldRef(VanillaModelWrapper, "location", ModelBlock) val location_VMW = FieldRef(VanillaModelWrapper, "location", ModelBlock)
@@ -85,6 +88,7 @@ object Refs {
val onAfterBakeModels = MethodRef(BetterFoliageHooks, "onAfterBakeModels", ClassRef.void, Map) val onAfterBakeModels = MethodRef(BetterFoliageHooks, "onAfterBakeModels", ClassRef.void, Map)
val renderWorldBlock = MethodRef(BetterFoliageHooks, "renderWorldBlock", ClassRef.boolean, BlockRendererDispatcher, IBlockState, BlockPos, IBlockAccess, VertexBuffer, BlockRenderLayer) val renderWorldBlock = MethodRef(BetterFoliageHooks, "renderWorldBlock", ClassRef.boolean, BlockRendererDispatcher, IBlockState, BlockPos, IBlockAccess, VertexBuffer, BlockRenderLayer)
val canRenderBlockInLayer = MethodRef(BetterFoliageHooks, "canRenderBlockInLayer", ClassRef.boolean, Block, IBlockState, BlockRenderLayer) val canRenderBlockInLayer = MethodRef(BetterFoliageHooks, "canRenderBlockInLayer", ClassRef.boolean, Block, IBlockState, BlockRenderLayer)
val onLoadAtlasPre = MethodRef(BetterFoliageHooks, "onLoadAtlasPre", ClassRef.void, TextureMap)
// Optifine // Optifine
val OptifineClassTransformer = ClassRef("optifine.OptiFineClassTransformer") val OptifineClassTransformer = ClassRef("optifine.OptiFineClassTransformer")

View File

@@ -48,9 +48,9 @@ abstract class AbstractBlockRenderingHandler(modId: String) : ResourceHandler(mo
* Render the block in the current [BlockContext] * Render the block in the current [BlockContext]
*/ */
fun renderWorldBlockBase(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer?): Boolean { fun renderWorldBlockBase(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer?): Boolean {
ctx.blockState(Int3.zero).let { ctx.blockState(Int3.zero).let { state ->
if (layer == null || it.block.canRenderInLayer(layer)) if (layer == null || state.block.canRenderInLayer(state, layer))
return dispatcher.renderBlock(it, ctx.pos, ctx.world, renderer) return dispatcher.renderBlock(state, ctx.pos, ctx.world, renderer)
} }
return false return false
} }
@@ -111,8 +111,8 @@ class BlockContext() {
/** Get the distance of the block from the camera (player). */ /** Get the distance of the block from the camera (player). */
val cameraDistance: Int get() { val cameraDistance: Int get() {
val camera = Minecraft.getMinecraft().renderViewEntity ?: return 0 val camera = Minecraft.getMinecraft().renderViewEntity ?: return 0
return Math.abs(pos.x - MathHelper.floor_double(camera.posX)) + return Math.abs(pos.x - MathHelper.floor(camera.posX)) +
Math.abs(pos.y - MathHelper.floor_double(camera.posY)) + Math.abs(pos.y - MathHelper.floor(camera.posY)) +
Math.abs(pos.z - MathHelper.floor_double(camera.posZ)) Math.abs(pos.z - MathHelper.floor(camera.posZ))
} }
} }

View File

@@ -117,7 +117,7 @@ class SimplexNoise() : IWorldLoadListener {
var noise = NoiseGeneratorSimplex() var noise = NoiseGeneratorSimplex()
override fun onWorldLoad(world: World) { noise = NoiseGeneratorSimplex(Random(world.worldInfo.seed)) override fun onWorldLoad(world: World) { noise = NoiseGeneratorSimplex(Random(world.worldInfo.seed))
} }
operator fun get(x: Int, z: Int) = MathHelper.floor_double((noise.getValue(x.toDouble(), z.toDouble()) + 1.0) * 32.0) operator fun get(x: Int, z: Int) = MathHelper.floor((noise.getValue(x.toDouble(), z.toDouble()) + 1.0) * 32.0)
operator fun get(pos: Int3) = get(pos.x, pos.z) operator fun get(pos: Int3) = get(pos.x, pos.z)
operator fun get(pos: BlockPos) = get(pos.x, pos.z) operator fun get(pos: BlockPos) = get(pos.x, pos.z)
} }

View File

@@ -37,8 +37,10 @@ operator fun IResourceManager.get(location: ResourceLocation): IResource? = tryD
/** Index operator to get a texture sprite. */ /** Index operator to get a texture sprite. */
operator fun TextureMap.get(name: String): TextureAtlasSprite? = getTextureExtry(ResourceLocation(name).toString()) operator fun TextureMap.get(name: String): TextureAtlasSprite? = getTextureExtry(ResourceLocation(name).toString())
fun TextureMap.registerSprite(name: String): TextureAtlasSprite = registerSprite(ResourceLocation(name))!!
/** Load an image resource. */ /** Load an image resource. */
fun IResource.loadImage() = ImageIO.read(this.inputStream) fun IResource.loadImage(): BufferedImage? = ImageIO.read(this.inputStream)
/** Get the lines of a text resource. */ /** Get the lines of a text resource. */
fun IResource.getLines(): List<String> { fun IResource.getLines(): List<String> {