port to MC 1.11
This commit is contained in:
@@ -48,9 +48,9 @@ abstract class AbstractBlockRenderingHandler(modId: String) : ResourceHandler(mo
|
||||
* Render the block in the current [BlockContext]
|
||||
*/
|
||||
fun renderWorldBlockBase(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer?): Boolean {
|
||||
ctx.blockState(Int3.zero).let {
|
||||
if (layer == null || it.block.canRenderInLayer(layer))
|
||||
return dispatcher.renderBlock(it, ctx.pos, ctx.world, renderer)
|
||||
ctx.blockState(Int3.zero).let { state ->
|
||||
if (layer == null || state.block.canRenderInLayer(state, layer))
|
||||
return dispatcher.renderBlock(state, ctx.pos, ctx.world, renderer)
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -111,8 +111,8 @@ class BlockContext() {
|
||||
/** Get the distance of the block from the camera (player). */
|
||||
val cameraDistance: Int get() {
|
||||
val camera = Minecraft.getMinecraft().renderViewEntity ?: return 0
|
||||
return Math.abs(pos.x - MathHelper.floor_double(camera.posX)) +
|
||||
Math.abs(pos.y - MathHelper.floor_double(camera.posY)) +
|
||||
Math.abs(pos.z - MathHelper.floor_double(camera.posZ))
|
||||
return Math.abs(pos.x - MathHelper.floor(camera.posX)) +
|
||||
Math.abs(pos.y - MathHelper.floor(camera.posY)) +
|
||||
Math.abs(pos.z - MathHelper.floor(camera.posZ))
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ class SimplexNoise() : IWorldLoadListener {
|
||||
var noise = NoiseGeneratorSimplex()
|
||||
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: BlockPos) = get(pos.x, pos.z)
|
||||
}
|
||||
@@ -37,8 +37,10 @@ operator fun IResourceManager.get(location: ResourceLocation): IResource? = tryD
|
||||
/** Index operator to get a texture sprite. */
|
||||
operator fun TextureMap.get(name: String): TextureAtlasSprite? = getTextureExtry(ResourceLocation(name).toString())
|
||||
|
||||
fun TextureMap.registerSprite(name: String): TextureAtlasSprite = registerSprite(ResourceLocation(name))!!
|
||||
|
||||
/** 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. */
|
||||
fun IResource.getLines(): List<String> {
|
||||
|
||||
Reference in New Issue
Block a user