mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-04-11 03:15:44 +02:00
Update code and textures to Minecraft 1.15.2
This commit is contained in:
parent
25096c4d33
commit
8d4e1cda4f
src/main/java/chylex/hee
client
gui
model
render
OverlayRenderer.kt
block
RenderTileAbstractChest.ktRenderTileAbstractPortal.ktRenderTileDarkChest.ktRenderTileEndPortal.ktRenderTileExperienceGate.ktRenderTileIgneousPlate.ktRenderTileJarODust.ktRenderTileLootChest.ktRenderTileMinersBurialAltar.ktRenderTileSpawner.ktRenderTileTable.ktRenderTileTablePedestal.ktRenderTileVoidPortal.kt
entity
RenderEntityBossEnderEye.ktRenderEntityItem.ktRenderEntityItemNoBob.ktRenderEntityMobAbstractEnderman.ktRenderEntityMobSpiderling.ktRenderEntityMobUndread.ktRenderEntityMobVillagerDying.ktRenderEntityNothing.ktRenderEntityProjectileEyeOfEnder.ktRenderEntitySprite.ktRenderEntityTokenHolder.kt
layer
territory
util
game
block
BlockAbstractCauldron.ktBlockAbstractChest.ktBlockAbstractTable.ktBlockAncientCobweb.ktBlockBrewingStandCustom.ktBlockCorruptedEnergy.ktBlockDarkChest.ktBlockDeathFlowerDecaying.ktBlockDragonEggOverride.ktBlockDryVines.ktBlockDustyStoneUnstable.ktBlockEndPlant.ktBlockEndPortalOverride.ktBlockEternalFire.ktBlockExperienceGate.ktBlockFallingObsidian.ktBlockFlowerPotDeathFlowerDecaying.ktBlockGloomtorch.ktBlockGraveDirt.ktBlockHumus.ktBlockIgneousPlate.ktBlockInfusedGlass.ktBlockInfusedTNT.ktBlockJarODust.ktBlockPuzzleLogic.ktBlockScaffolding.ktBlockShulkerBoxOverride.ktBlockStardustOre.ktBlockTablePedestal.ktBlockVoidPortalStorage.ktBlockVoidPortalStorageCrafted.ktBlockWhitebarkLeaves.ktBlockWhitebarkSapling.ktIBlockDeathFlowerDecaying.kt
dispenser
entity
TileEntityBrewingStandCustom.ktTileEntityExperienceGate.ktTileEntityLootChest.ktTileEntitySpawnerObsidianTower.kt
fluid
info
container/slot
@ -7,7 +7,7 @@ import chylex.hee.system.migration.forge.Sided
|
||||
import net.minecraft.client.resources.I18n
|
||||
import net.minecraft.entity.player.PlayerInventory
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
import net.minecraftforge.fml.client.config.GuiButtonExt
|
||||
import net.minecraftforge.fml.client.gui.widget.ExtendedButton
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class GuiAmuletOfRecovery(container: ContainerAmuletOfRecovery, inventory: PlayerInventory, title: ITextComponent) : GuiBaseChestContainer<ContainerAmuletOfRecovery>(container, inventory, title){
|
||||
@ -17,7 +17,7 @@ class GuiAmuletOfRecovery(container: ContainerAmuletOfRecovery, inventory: Playe
|
||||
val moveAllTitle = I18n.format("gui.hee.amulet_of_recovery.move_all")
|
||||
val moveAllWidth = (font.getStringWidth(moveAllTitle) + 14).coerceAtMost(xSize / 2)
|
||||
|
||||
addButton(GuiButtonExt(guiLeft + xSize - moveAllWidth - 7, (height / 2) + 6, moveAllWidth, 11, moveAllTitle){
|
||||
addButton(ExtendedButton(guiLeft + xSize - moveAllWidth - 7, (height / 2) + 6, moveAllWidth, 11, moveAllTitle){
|
||||
PacketServerContainerEvent(0).sendToServer()
|
||||
})
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class GuiBrewingStandCustom(container: ContainerBrewingStand, inventory: PlayerI
|
||||
val y = (height - ySize) / 2
|
||||
|
||||
GL.color(1F, 1F, 1F, 1F)
|
||||
MC.textureManager.bindTexture(TEX_BACKGROUND)
|
||||
GL.bindTexture(TEX_BACKGROUND)
|
||||
blit(x, y, 0, 0, xSize, ySize)
|
||||
|
||||
val worldTime = MC.world!!.totalTime
|
||||
|
@ -1,6 +1,5 @@
|
||||
package chylex.hee.client.gui.base
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.ContainerChest
|
||||
@ -36,7 +35,7 @@ abstract class GuiBaseChestContainer<T : ContainerChest>(container: T, inventory
|
||||
val heightContainer = 17 + (containerRows * 18)
|
||||
|
||||
GL.color(1F, 1F, 1F, 1F)
|
||||
MC.textureManager.bindTexture(TEX_BACKGROUND)
|
||||
GL.bindTexture(TEX_BACKGROUND)
|
||||
blit(x, y, 0, 0, xSize, heightContainer)
|
||||
blit(x, y + heightContainer, 0, 126, xSize, 96)
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package chylex.hee.client.gui.base
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.container.base.ContainerBaseCustomInventory
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
@ -30,7 +29,7 @@ abstract class GuiBaseCustomInventory<T : ContainerBaseCustomInventory<*>>(conta
|
||||
val y = (height - ySize) / 2
|
||||
|
||||
GL.color(1F, 1F, 1F, 1F)
|
||||
MC.textureManager.bindTexture(texBackground)
|
||||
GL.bindTexture(texBackground)
|
||||
blit(x, y, 0, 0, xSize, ySize)
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@ import chylex.hee.system.migration.vanilla.EntityPlayer
|
||||
import chylex.hee.system.util.Vec3
|
||||
import chylex.hee.system.util.lookPosVec
|
||||
import chylex.hee.system.util.subtractY
|
||||
import net.minecraft.client.renderer.model.IBakedModel
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.HandSide.RIGHT
|
||||
import net.minecraft.util.math.MathHelper
|
||||
@ -15,6 +17,11 @@ import kotlin.math.abs
|
||||
import kotlin.math.pow
|
||||
|
||||
object ModelHelper{
|
||||
@Sided(Side.CLIENT)
|
||||
fun getItemModel(stack: ItemStack): IBakedModel{
|
||||
return MC.itemRenderer.getItemModelWithOverrides(stack, MC.world, null)
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
fun getHandPosition(player: EntityPlayer, hand: Hand): Vec3d{
|
||||
val yawOffsetMp = (if (player.primaryHand == RIGHT) 1 else -1) * (if (hand == MAIN_HAND) 1 else -1)
|
||||
|
@ -1,43 +1,49 @@
|
||||
package chylex.hee.client.model.block
|
||||
import chylex.hee.client.render.util.beginBox
|
||||
import chylex.hee.client.render.util.render
|
||||
import chylex.hee.client.render.util.translateZ
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import net.minecraft.client.renderer.entity.model.RendererModel
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.model.Model
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.sin
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object ModelBlockIgneousPlate : Model(){
|
||||
object ModelBlockIgneousPlate : Model(RenderType::getEntityCutout){
|
||||
const val ANIMATION_PERIOD = PI
|
||||
|
||||
private val outerBox: RendererModel
|
||||
private val innerBox: RendererModel
|
||||
private val outerBox: ModelRenderer
|
||||
private val innerBox: ModelRenderer
|
||||
|
||||
init{
|
||||
textureWidth = 32
|
||||
textureHeight = 16
|
||||
|
||||
outerBox = RendererModel(this).apply {
|
||||
outerBox = ModelRenderer(this).apply {
|
||||
beginBox.offset(12F, 4F, 0F).size( 2, 8, 2).tex(0, 6).add()
|
||||
beginBox.offset( 2F, 4F, 0F).size( 2, 8, 2).tex(8, 6).add()
|
||||
beginBox.offset( 2F, 2F, 0F).size(12, 2, 2).tex(0, 0).add()
|
||||
beginBox.offset( 2F, 12F, 0F).size(12, 2, 2).tex(0, 4).add()
|
||||
}
|
||||
|
||||
innerBox = RendererModel(this).apply {
|
||||
innerBox = ModelRenderer(this).apply {
|
||||
beginBox.offset(4F, 4F, 0.5F).size(8, 8, 1).tex(14, 7).add()
|
||||
}
|
||||
}
|
||||
|
||||
fun renderOuterBox(){
|
||||
outerBox.render()
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
outerBox.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
}
|
||||
|
||||
fun renderInnerBox(animation: Double){
|
||||
innerBox.offsetZ = -abs(sin(-animation)).toFloat() * 0.0925F
|
||||
innerBox.render()
|
||||
fun renderInnerBox(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, color: Vec3d, animation: Double){
|
||||
matrix.push()
|
||||
matrix.translateZ(-abs(sin(-animation)).toFloat() * 0.0925)
|
||||
innerBox.render(matrix, builder, combinedLight, combinedOverlay, color.x.toFloat(), color.y.toFloat(), color.z.toFloat(), 1F)
|
||||
matrix.pop()
|
||||
}
|
||||
}
|
||||
|
@ -6,35 +6,39 @@ import chylex.hee.game.entity.living.EntityBossEnderEye
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.toRadians
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel
|
||||
import net.minecraft.client.renderer.entity.model.RendererModel
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object ModelEntityBossEnderEye : EntityModel<EntityBossEnderEye>(){
|
||||
const val SCALE = 16F / 18F
|
||||
|
||||
private val head: RendererModel
|
||||
private val eyes: Array<RendererModel>
|
||||
private val arms: RendererModel
|
||||
private val head: ModelRenderer
|
||||
private val eyes: Array<ModelRenderer>
|
||||
private val arms: ModelRenderer
|
||||
|
||||
private var eyeState = 0
|
||||
|
||||
init{
|
||||
textureWidth = 128
|
||||
textureHeight = 64
|
||||
|
||||
head = RendererModel(this).apply {
|
||||
head = ModelRenderer(this).apply {
|
||||
setRotationPoint(0F, 15F, 0F)
|
||||
beginBox.offset(-9F, -9F, -9F).size(18, 18, 18).tex(0, 0).add()
|
||||
}
|
||||
|
||||
eyes = Array(8){
|
||||
RendererModel(this).apply {
|
||||
ModelRenderer(this).apply {
|
||||
setRotationPoint(0F, 15F, 0F)
|
||||
beginBox.offset(-8F, -8F, -9F).size(16, 16, 1).tex(-1 + (16 * it), 47).add()
|
||||
cubeList[0].retainFace(FACE_FRONT)
|
||||
}
|
||||
}
|
||||
|
||||
arms = RendererModel(this).apply {
|
||||
arms = ModelRenderer(this).apply {
|
||||
setRotationPoint(0F, 15.5F, -0.5F)
|
||||
beginBox.offset(-12F, -1.5F, -1.5F).size(3, 27, 3).tex(73, 0).add()
|
||||
beginBox.offset( 9F, -1.5F, -1.5F).size(3, 27, 3).tex(73, 0).mirror().add()
|
||||
@ -42,28 +46,17 @@ object ModelEntityBossEnderEye : EntityModel<EntityBossEnderEye>(){
|
||||
}
|
||||
|
||||
override fun setLivingAnimations(entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float){
|
||||
super.setLivingAnimations(entity, limbSwing, limbSwingAmount, partialTicks)
|
||||
arms.rotateAngleX = (entity as? EntityBossEnderEye)?.clientArmAngle?.get(partialTicks)?.toRadians() ?: 0F
|
||||
arms.rotateAngleX = entity.clientArmAngle.get(partialTicks).toRadians()
|
||||
eyeState = if (entity.isSleeping) 0 else entity.demonLevel + 1
|
||||
}
|
||||
|
||||
override fun setRotationAngles(entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, ageInTicks: Float, netHeadYaw: Float, headPitch: Float, scale: Float){
|
||||
super.setRotationAngles(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale)
|
||||
override fun setRotationAngles(entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, age: Float, headYaw: Float, headPitch: Float){
|
||||
head.rotateAngleX = headPitch.toRadians()
|
||||
}
|
||||
|
||||
override fun render(entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, ageInTicks: Float, netHeadYaw: Float, headPitch: Float, scale: Float){
|
||||
super.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale)
|
||||
|
||||
val boss = entity as? EntityBossEnderEye
|
||||
|
||||
val eyeState = when{
|
||||
boss == null -> 1
|
||||
boss.isSleeping -> 0
|
||||
else -> boss.demonLevel + 1
|
||||
}
|
||||
|
||||
head.render(scale)
|
||||
eyes[eyeState].also { it.rotateAngleX = head.rotateAngleX }.render(scale)
|
||||
arms.render(scale)
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
head.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
eyes[eyeState].also { it.rotateAngleX = head.rotateAngleX }.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
arms.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,29 @@
|
||||
package chylex.hee.client.model.entity
|
||||
import chylex.hee.client.render.util.beginBox
|
||||
import chylex.hee.client.render.util.render
|
||||
import chylex.hee.game.entity.item.EntityTokenHolder
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel
|
||||
import net.minecraft.client.renderer.entity.model.RendererModel
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object ModelEntityTokenHolder : EntityModel<EntityTokenHolder>(){
|
||||
private val box: RendererModel
|
||||
private val box: ModelRenderer
|
||||
|
||||
init{
|
||||
textureWidth = 64
|
||||
textureHeight = 32
|
||||
|
||||
box = RendererModel(this).apply {
|
||||
box = ModelRenderer(this).apply {
|
||||
beginBox.offset(-8F, -8F, -8F).size(16, 16, 16).add()
|
||||
}
|
||||
}
|
||||
|
||||
fun render(){
|
||||
box.render()
|
||||
override fun setRotationAngles(entity: EntityTokenHolder, limbSwing: Float, limbSwingAmount: Float, age: Float, headYaw: Float, headPitch: Float){}
|
||||
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
box.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ class ModelEntityUndread private constructor(modelSize: Float, textureWidth: Int
|
||||
constructor(modelSize: Float, tallTexture: Boolean) : this(modelSize, 64, if (tallTexture) 32 else 64)
|
||||
constructor() : this(0F, false)
|
||||
|
||||
override fun func_212850_a_(entity: EntityMobUndread): Boolean{
|
||||
override fun isAggressive(entity: EntityMobUndread): Boolean{
|
||||
return entity.isAggressive
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.forge.SubscribeAllEvents
|
||||
import chylex.hee.system.migration.forge.SubscribeEvent
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.model.IBakedModel
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND
|
||||
@ -19,8 +20,6 @@ import net.minecraftforge.client.event.ModelRegistryEvent
|
||||
import net.minecraftforge.client.model.BakedModelWrapper
|
||||
import net.minecraftforge.client.model.ModelLoader
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
|
||||
import org.apache.commons.lang3.tuple.Pair
|
||||
import javax.vecmath.Matrix4f
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class ModelItemAmuletOfRecovery private constructor(sourceModel: IBakedModel) : BakedModelWrapper<IBakedModel>(sourceModel){
|
||||
@ -43,14 +42,14 @@ class ModelItemAmuletOfRecovery private constructor(sourceModel: IBakedModel) :
|
||||
}
|
||||
}
|
||||
|
||||
override fun handlePerspective(transformType: TransformType): Pair<out IBakedModel, Matrix4f> = when(transformType){
|
||||
override fun handlePerspective(transformType: TransformType, matrix: MatrixStack): IBakedModel = when(transformType){
|
||||
FIRST_PERSON_LEFT_HAND,
|
||||
FIRST_PERSON_RIGHT_HAND,
|
||||
THIRD_PERSON_LEFT_HAND,
|
||||
THIRD_PERSON_RIGHT_HAND ->
|
||||
modelRegistry.getOrElse(RESOURCE_HELD){ MC.instance.modelManager.missingModel }.handlePerspective(transformType)
|
||||
modelRegistry.getOrElse(RESOURCE_HELD){ MC.instance.modelManager.missingModel }.handlePerspective(transformType, matrix)
|
||||
|
||||
else ->
|
||||
super.handlePerspective(transformType)
|
||||
super.handlePerspective(transformType, matrix)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import chylex.hee.HEE
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.GL.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.GL.DF_ZERO
|
||||
import chylex.hee.client.render.util.GL.FOG_EXP
|
||||
import chylex.hee.client.render.util.GL.SF_ONE
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.util.MC
|
||||
@ -27,7 +26,7 @@ import chylex.hee.system.util.getTile
|
||||
import net.minecraft.client.gui.AbstractGui
|
||||
import net.minecraft.client.resources.I18n
|
||||
import net.minecraft.util.text.TextFormatting
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent
|
||||
import net.minecraftforge.client.event.DrawHighlightEvent
|
||||
import net.minecraftforge.client.event.EntityViewRenderEvent.FogDensity
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.HELMET
|
||||
@ -49,7 +48,7 @@ object OverlayRenderer{
|
||||
val inside = e.info.blockAtCamera.material
|
||||
|
||||
if (inside === Materials.ENDER_GOO || inside === Materials.PURIFIED_ENDER_GOO){
|
||||
GL.setFogMode(FOG_EXP)
|
||||
GL.setFogMode(GL.FOG_EXP)
|
||||
e.density = if (inside === Materials.ENDER_GOO) 0.66F else 0.06F
|
||||
e.isCanceled = true // otherwise the event is ignored
|
||||
}
|
||||
@ -72,10 +71,10 @@ object OverlayRenderer{
|
||||
GL.blendFunc(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA, SF_ONE, DF_ZERO)
|
||||
|
||||
if (inside === Materials.ENDER_GOO){
|
||||
MC.textureManager.bindTexture(TEX_ENDER_GOO_OVERLAY)
|
||||
GL.bindTexture(TEX_ENDER_GOO_OVERLAY)
|
||||
}
|
||||
else{
|
||||
MC.textureManager.bindTexture(TEX_PURIFIED_ENDER_GOO_OVERLAY)
|
||||
GL.bindTexture(TEX_PURIFIED_ENDER_GOO_OVERLAY)
|
||||
}
|
||||
|
||||
MC.instance.ingameGUI.blit(0, 0, 0, 0, window.scaledWidth, window.scaledHeight)
|
||||
@ -135,7 +134,7 @@ object OverlayRenderer{
|
||||
// Block outlines
|
||||
|
||||
@SubscribeEvent
|
||||
fun onRenderBlockOutline(e: DrawBlockHighlightEvent.HighlightBlock){
|
||||
fun onRenderBlockOutline(e: DrawHighlightEvent.HighlightBlock){
|
||||
val world = MC.world ?: return
|
||||
|
||||
val pos = e.target.pos
|
||||
|
@ -1,44 +1,43 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.beginBox
|
||||
import chylex.hee.client.render.util.rotateY
|
||||
import chylex.hee.game.block.entity.base.TileEntityBaseChest
|
||||
import chylex.hee.system.migration.Facing.EAST
|
||||
import chylex.hee.system.migration.Facing.NORTH
|
||||
import chylex.hee.system.migration.Facing.WEST
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.Atlases
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.model.Material
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.model.ChestModel
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11.GL_MODELVIEW
|
||||
import org.lwjgl.opengl.GL11.GL_TEXTURE
|
||||
import java.util.function.Function
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.pow
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
abstract class RenderTileAbstractChest<T : TileEntityBaseChest> : TileEntityRenderer<T>(){
|
||||
protected abstract val texture: ResourceLocation
|
||||
abstract class RenderTileAbstractChest<T : TileEntityBaseChest>(dispatcher: TileEntityRendererDispatcher, private val texture: ResourceLocation) : TileEntityRenderer<T>(dispatcher){
|
||||
private val modelLid = ModelRenderer(64, 64, 0, 0).apply {
|
||||
setRotationPoint(0F, 9F, 1F)
|
||||
beginBox.offset(1F, 0F, 0F).size(14, 5, 14).add()
|
||||
}
|
||||
|
||||
private val modelChest = ChestModel()
|
||||
private val modelBottom = ModelRenderer(64, 64, 0, 19).apply {
|
||||
beginBox.offset(1F, 0F, 1F).size(14, 10, 14).add()
|
||||
}
|
||||
|
||||
override fun render(tile: T, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int){
|
||||
if (destroyStage >= 0){
|
||||
bindTexture(DESTROY_STAGES[destroyStage])
|
||||
GL.matrixMode(GL_TEXTURE)
|
||||
GL.pushMatrix()
|
||||
GL.scale(4F, 4F, 1F)
|
||||
GL.translate(0.0625F, 0.0625F, 0.0625F)
|
||||
GL.matrixMode(GL_MODELVIEW)
|
||||
}
|
||||
else{
|
||||
bindTexture(texture)
|
||||
}
|
||||
|
||||
GL.pushMatrix()
|
||||
GL.enableRescaleNormal()
|
||||
GL.color(1F, 1F, 1F)
|
||||
GL.translate(x, y + 1F, z + 1F)
|
||||
GL.scale(1F, -1F, -1F)
|
||||
GL.translate(0.5F, 0.5F, 0.5F)
|
||||
private val modelLatch = ModelRenderer(64, 64, 0, 0).apply {
|
||||
setRotationPoint(0F, 8F, 0F)
|
||||
beginBox.offset(7F, -1F, 15F).size(2, 4, 1).add()
|
||||
}
|
||||
|
||||
override fun render(tile: T, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
matrix.push()
|
||||
|
||||
val rotation = when(tile.facing){
|
||||
EAST -> 270F
|
||||
@ -47,20 +46,18 @@ abstract class RenderTileAbstractChest<T : TileEntityBaseChest> : TileEntityRend
|
||||
else -> 0F
|
||||
}
|
||||
|
||||
GL.rotate(rotation, 0F, 1F, 0F)
|
||||
GL.translate(-0.5F, -0.5F, -0.5F)
|
||||
matrix.translate(0.5, 0.5, 0.5)
|
||||
matrix.rotateY(rotation)
|
||||
matrix.translate(-0.5, -0.5, -0.5)
|
||||
|
||||
modelChest.lid.rotateAngleX = -(1F - (1F - tile.lidAngle.get(partialTicks)).pow(3)) * PI.toFloat() * 0.5F
|
||||
modelChest.renderAll()
|
||||
val builder = Material(Atlases.CHEST_ATLAS, texture).getBuffer(buffer, Function(RenderType::getEntityCutout))
|
||||
|
||||
GL.disableRescaleNormal()
|
||||
GL.popMatrix()
|
||||
GL.color(1F, 1F, 1F, 1F)
|
||||
modelLid.rotateAngleX = -(1F - (1F - tile.lidAngle.get(partialTicks)).pow(3)) * PI.toFloat() * 0.5F
|
||||
modelLatch.rotateAngleX = modelLid.rotateAngleX
|
||||
modelLid.render(matrix, builder, combinedLight, combinedOverlay)
|
||||
modelLatch.render(matrix, builder, combinedLight, combinedOverlay)
|
||||
modelBottom.render(matrix, builder, combinedLight, combinedOverlay)
|
||||
|
||||
if (destroyStage >= 0){
|
||||
GL.matrixMode(GL_TEXTURE)
|
||||
GL.popMatrix()
|
||||
GL.matrixMode(GL_MODELVIEW)
|
||||
}
|
||||
matrix.pop()
|
||||
}
|
||||
}
|
||||
|
@ -8,40 +8,143 @@ import chylex.hee.client.render.util.GL.TEX_Q
|
||||
import chylex.hee.client.render.util.GL.TEX_R
|
||||
import chylex.hee.client.render.util.GL.TEX_S
|
||||
import chylex.hee.client.render.util.GL.TEX_T
|
||||
import chylex.hee.client.render.util.TESSELLATOR
|
||||
import chylex.hee.client.render.util.draw
|
||||
import chylex.hee.client.render.util.RenderStateBuilder
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.FOG_ENABLED
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.block.BlockAbstractPortal
|
||||
import chylex.hee.game.block.BlockAbstractPortal.IPortalController
|
||||
import chylex.hee.game.block.entity.TileEntityPortalInner
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.center
|
||||
import chylex.hee.system.util.component1
|
||||
import chylex.hee.system.util.component2
|
||||
import chylex.hee.system.util.component3
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.square
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder
|
||||
import net.minecraft.client.renderer.GLAllocation
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.Matrix4f
|
||||
import net.minecraft.client.renderer.RenderState.TexturingState
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import net.minecraft.world.World
|
||||
import org.lwjgl.opengl.GL11
|
||||
import org.lwjgl.opengl.GL11.GL_EYE_LINEAR
|
||||
import org.lwjgl.opengl.GL11.GL_EYE_PLANE
|
||||
import org.lwjgl.opengl.GL11.GL_MODELVIEW
|
||||
import org.lwjgl.opengl.GL11.GL_OBJECT_LINEAR
|
||||
import org.lwjgl.opengl.GL11.GL_OBJECT_PLANE
|
||||
import org.lwjgl.opengl.GL11.GL_QUADS
|
||||
import org.lwjgl.opengl.GL11.GL_TEXTURE
|
||||
import java.util.Random
|
||||
import kotlin.math.pow
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalController> : TileEntityRenderer<T>(){
|
||||
abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalController>(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<T>(dispatcher){
|
||||
private companion object{
|
||||
private val TEX_BACKGROUND = Resource.Vanilla("textures/environment/end_sky.png")
|
||||
private val TEX_PARTICLE_LAYER = Resource.Vanilla("textures/entity/end_portal.png")
|
||||
|
||||
// UPDATE figure out how to rewrite in the new rendering system
|
||||
|
||||
private fun RENDER_TEXTURING_STATE(matrix: Matrix4f, layer: Int, globalTranslation: Double, y: Double): TexturingState{
|
||||
val cameraTarget = Vec3d.ZERO
|
||||
val layerRotation: Float
|
||||
val layerScale: Float
|
||||
|
||||
if (layer == 0){
|
||||
layerRotation = 0F
|
||||
layerScale = 0.125F
|
||||
}
|
||||
else{
|
||||
layerRotation = 2F * ((square(layer) * 4321) + (layer * 9))
|
||||
layerScale = 0.0625F
|
||||
}
|
||||
|
||||
return object : TexturingState("hee:portal_layer_$layer", {
|
||||
val offsetY = -y - 0.75
|
||||
val topY = offsetY + cameraTarget.y
|
||||
|
||||
val layerPosition: Double
|
||||
val cameraOffsetMp: Double
|
||||
|
||||
if (layer == 0){
|
||||
layerPosition = (topY / (topY + 65.0)) - offsetY
|
||||
cameraOffsetMp = 65.0 / topY
|
||||
}
|
||||
else{
|
||||
val layerIndexRev = 16 - layer
|
||||
layerPosition = (topY / (topY + layerIndexRev)) - offsetY
|
||||
cameraOffsetMp = layerIndexRev / topY
|
||||
}
|
||||
|
||||
val globalX = MC.player!!.posX % 69420.0 // TODO works around extreme coordinates, but causes a sudden jump at boundary
|
||||
val globalY = MC.player!!.posY
|
||||
val globalZ = MC.player!!.posZ % 69420.0
|
||||
|
||||
GL.matrixMode(GL_MODELVIEW)
|
||||
GL.pushMatrix()
|
||||
GL.translate(globalX, layerPosition, globalZ)
|
||||
|
||||
GL.enableTexGenCoord(TEX_S)
|
||||
GL.enableTexGenCoord(TEX_T)
|
||||
GL.enableTexGenCoord(TEX_R)
|
||||
GL.enableTexGenCoord(TEX_Q)
|
||||
|
||||
GL.texGenMode(TEX_S, GL_OBJECT_LINEAR)
|
||||
GL.texGenMode(TEX_T, GL_OBJECT_LINEAR)
|
||||
GL.texGenMode(TEX_R, GL_OBJECT_LINEAR)
|
||||
GL.texGenMode(TEX_Q, GL_EYE_LINEAR)
|
||||
|
||||
GL.texGenParam(TEX_S, GL_OBJECT_PLANE, updateBuffer(1F, 0F, 0F, 0F))
|
||||
GL.texGenParam(TEX_T, GL_OBJECT_PLANE, updateBuffer(0F, 0F, 1F, 0F))
|
||||
GL.texGenParam(TEX_R, GL_OBJECT_PLANE, updateBuffer(1F, 0F, 0F, 1F))
|
||||
GL.texGenParam(TEX_Q, GL_EYE_PLANE, updateBuffer(0F, 1F, 0F, 0F))
|
||||
|
||||
GL.popMatrix()
|
||||
|
||||
GL.matrixMode(GL_TEXTURE)
|
||||
GL.pushMatrix()
|
||||
GL.loadIdentity()
|
||||
|
||||
GL.translate(0.0, globalTranslation, 0.0)
|
||||
GL.scale(layerScale, layerScale, layerScale)
|
||||
GL.translate(0.5, 0.5, 0.5)
|
||||
GL.rotate(layerRotation, 0F, 0F, 1F)
|
||||
GL.translate((cameraTarget.x * cameraOffsetMp) - globalX - 0.5, (cameraTarget.z * cameraOffsetMp) - globalZ - 0.5, -globalY * 2)
|
||||
}, {
|
||||
GL.matrixMode(GL_TEXTURE)
|
||||
GL.popMatrix()
|
||||
GL.matrixMode(GL_MODELVIEW)
|
||||
|
||||
GL.disableTexGenCoord(TEX_S)
|
||||
GL.disableTexGenCoord(TEX_T)
|
||||
GL.disableTexGenCoord(TEX_R)
|
||||
GL.disableTexGenCoord(TEX_Q)
|
||||
}){}
|
||||
}
|
||||
|
||||
private fun RENDER_TYPE_BACKGROUND(mat: Matrix4f, globalTranslation: Double, y: Double) = with(RenderStateBuilder()){
|
||||
tex(TEX_BACKGROUND)
|
||||
fog(FOG_ENABLED)
|
||||
blend(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA)
|
||||
texturing(RENDER_TEXTURING_STATE(mat, 0, globalTranslation, y))
|
||||
buildType("hee:portal_background", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, bufferSize = 256)
|
||||
}
|
||||
|
||||
private fun RENDER_TYPE_LAYERS(mat: Matrix4f, layer: Int, globalTranslation: Double, y: Double) = with(RenderStateBuilder()){
|
||||
tex(TEX_PARTICLE_LAYER)
|
||||
fog(FOG_ENABLED)
|
||||
blend(SF_ONE, DF_ONE)
|
||||
texturing(RENDER_TEXTURING_STATE(mat, layer, globalTranslation, y))
|
||||
buildType("hee:portal_layer_$layer", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, bufferSize = 256)
|
||||
}
|
||||
|
||||
private val BUFFER = GLAllocation.createDirectFloatBuffer(16)
|
||||
|
||||
private fun updateBuffer(value1: Float, value2: Float, value3: Float, value4: Float) = BUFFER.apply {
|
||||
@ -89,7 +192,7 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
|
||||
// Rendering
|
||||
|
||||
override fun render(tile: T, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int){
|
||||
override fun render(tile: T, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
val controller = findController(tile.world ?: return, tile.pos)
|
||||
|
||||
rand.setSeed(controller?.let { generateSeed(it) } ?: 0L)
|
||||
@ -100,41 +203,18 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
cameraTarget = Vec3d.ZERO // UPDATE fix bobbing
|
||||
globalTranslation = ((MC.systemTime % BlockAbstractPortal.TRANSLATION_SPEED_LONG) * BlockAbstractPortal.TRANSLATION_SPEED_INV) - (controller?.clientPortalOffset?.get(partialTicks) ?: 0F)
|
||||
|
||||
val offsetY = -y - 0.75
|
||||
val topY = offsetY + cameraTarget.y
|
||||
|
||||
// setup
|
||||
|
||||
GL.disableLighting()
|
||||
GL.enableBlend()
|
||||
|
||||
GL.enableTexGenCoord(TEX_S)
|
||||
GL.enableTexGenCoord(TEX_T)
|
||||
GL.enableTexGenCoord(TEX_R)
|
||||
GL.enableTexGenCoord(TEX_Q)
|
||||
|
||||
MC.gameRenderer.setupFogColor(true)
|
||||
val (x, y, z) = renderDispatcher.renderInfo.projectedView.subtract(tile.pos.center)
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
// background
|
||||
|
||||
GL.blendFunc(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA)
|
||||
|
||||
controller?.let { generateNextColor(it, 0) }
|
||||
transformColor { 0.1F } // discards provided value
|
||||
|
||||
renderLayer(
|
||||
x, y, z,
|
||||
texture = TEX_BACKGROUND,
|
||||
layerPosition = (topY / (topY + 65.0)) - offsetY,
|
||||
layerRotation = 0F,
|
||||
layerScale = 0.125F,
|
||||
cameraOffsetMp = 65.0 / topY
|
||||
)
|
||||
renderLayer(mat, buffer.getBuffer(RENDER_TYPE_BACKGROUND(mat, globalTranslation, y)))
|
||||
|
||||
// inner layers
|
||||
|
||||
GL.blendFunc(SF_ONE, DF_ONE)
|
||||
|
||||
val layerCount = getLayerCount((x * x) + (y * y) + (z * z))
|
||||
|
||||
for(layer in 1..15){
|
||||
@ -145,28 +225,9 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
transformColor { it * colorMultiplier * calculateEasing(layer) }
|
||||
|
||||
if (layerIndexRev <= layerCount){
|
||||
renderLayer(
|
||||
x, y, z,
|
||||
texture = TEX_PARTICLE_LAYER,
|
||||
layerPosition = (topY / (topY + layerIndexRev)) - offsetY,
|
||||
layerRotation = 2F * ((square(layer) * 4321) + (layer * 9)),
|
||||
layerScale = 0.0625F,
|
||||
cameraOffsetMp = layerIndexRev / topY
|
||||
)
|
||||
renderLayer(mat, buffer.getBuffer(RENDER_TYPE_LAYERS(mat, layer, globalTranslation, y)))
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup
|
||||
|
||||
MC.gameRenderer.setupFogColor(false)
|
||||
|
||||
GL.disableTexGenCoord(TEX_S)
|
||||
GL.disableTexGenCoord(TEX_T)
|
||||
GL.disableTexGenCoord(TEX_R)
|
||||
GL.disableTexGenCoord(TEX_Q)
|
||||
|
||||
GL.disableBlend()
|
||||
GL.enableLighting()
|
||||
}
|
||||
|
||||
// Utilities
|
||||
@ -177,56 +238,10 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
color[2] = func(color[2])
|
||||
}
|
||||
|
||||
private fun renderLayer(renderX: Double, renderY: Double, renderZ: Double, texture: ResourceLocation, layerPosition: Double, layerRotation: Float, layerScale: Float, cameraOffsetMp: Double){
|
||||
val globalX = TileEntityRendererDispatcher.staticPlayerX % 69420.0 // TODO works around extreme coordinates, but causes a sudden jump at boundary
|
||||
val globalY = TileEntityRendererDispatcher.staticPlayerY
|
||||
val globalZ = TileEntityRendererDispatcher.staticPlayerZ % 69420.0
|
||||
|
||||
// texture
|
||||
|
||||
if (texture != TEX_BACKGROUND){
|
||||
bindTexture(TEX_BACKGROUND) // force re-bind to fix a bug in older AMD drivers
|
||||
}
|
||||
|
||||
bindTexture(texture)
|
||||
|
||||
GL.pushMatrix()
|
||||
GL.translate(globalX, layerPosition, globalZ)
|
||||
|
||||
GL.texGenMode(TEX_S, GL_OBJECT_LINEAR)
|
||||
GL.texGenMode(TEX_T, GL_OBJECT_LINEAR)
|
||||
GL.texGenMode(TEX_R, GL_OBJECT_LINEAR)
|
||||
GL.texGenMode(TEX_Q, GL_EYE_LINEAR)
|
||||
|
||||
GL.texGenParam(TEX_S, GL_OBJECT_PLANE, updateBuffer(1F, 0F, 0F, 0F))
|
||||
GL.texGenParam(TEX_T, GL_OBJECT_PLANE, updateBuffer(0F, 0F, 1F, 0F))
|
||||
GL.texGenParam(TEX_R, GL_OBJECT_PLANE, updateBuffer(1F, 0F, 0F, 1F))
|
||||
GL.texGenParam(TEX_Q, GL_EYE_PLANE, updateBuffer(0F, 1F, 0F, 0F))
|
||||
|
||||
GL.popMatrix()
|
||||
|
||||
// position
|
||||
|
||||
GL.matrixMode(GL_TEXTURE)
|
||||
GL.pushMatrix()
|
||||
GL.loadIdentity()
|
||||
|
||||
GL.translate(0.0, globalTranslation, 0.0)
|
||||
GL.scale(layerScale, layerScale, layerScale)
|
||||
GL.translate(0.5F, 0.5F, 0.5F)
|
||||
GL.rotate(layerRotation, 0F, 0F, 1F)
|
||||
GL.translate((cameraTarget.x * cameraOffsetMp) - globalX - 0.5, (cameraTarget.z * cameraOffsetMp) - globalZ - 0.5, -globalY * 2)
|
||||
|
||||
// rendering
|
||||
|
||||
TESSELLATOR.draw(GL_QUADS, DefaultVertexFormats.POSITION_COLOR){
|
||||
pos(renderX + 0.0, renderY + 0.75, renderZ + 0.0).color(color[0], color[1], color[2], 1F).endVertex()
|
||||
pos(renderX + 0.0, renderY + 0.75, renderZ + 1.0).color(color[0], color[1], color[2], 1F).endVertex()
|
||||
pos(renderX + 1.0, renderY + 0.75, renderZ + 1.0).color(color[0], color[1], color[2], 1F).endVertex()
|
||||
pos(renderX + 1.0, renderY + 0.75, renderZ + 0.0).color(color[0], color[1], color[2], 1F).endVertex()
|
||||
}
|
||||
|
||||
GL.popMatrix()
|
||||
GL.matrixMode(GL_MODELVIEW)
|
||||
private fun renderLayer(mat: Matrix4f, builder: IVertexBuilder){
|
||||
builder.pos(mat, 0F, 0.75F, 0F).color(color[0], color[1], color[2], 1F).endVertex()
|
||||
builder.pos(mat, 0F, 0.75F, 1F).color(color[0], color[1], color[2], 1F).endVertex()
|
||||
builder.pos(mat, 1F, 0.75F, 1F).color(color[0], color[1], color[2], 1F).endVertex()
|
||||
builder.pos(mat, 1F, 0.75F, 0F).color(color[0], color[1], color[2], 1F).endVertex()
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,47 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.game.block.entity.TileEntityDarkChest
|
||||
import chylex.hee.init.ModAtlases
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.model.Material
|
||||
import net.minecraft.client.renderer.tileentity.ChestTileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.state.properties.ChestType
|
||||
import net.minecraft.state.properties.ChestType.LEFT
|
||||
import net.minecraft.state.properties.ChestType.RIGHT
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileDarkChest : ChestTileEntityRenderer<TileEntityDarkChest>(){
|
||||
private val TEX_SINGLE = Resource.Custom("textures/entity/dark_chest_single.png")
|
||||
private val TEX_DOUBLE = Resource.Custom("textures/entity/dark_chest_double.png")
|
||||
class RenderTileDarkChest(dispatcher: TileEntityRendererDispatcher) : ChestTileEntityRenderer<TileEntityDarkChest>(dispatcher){
|
||||
companion object{
|
||||
val TEX_SINGLE = Resource.Custom("entity/dark_chest_single")
|
||||
val TEX_DOUBLE_LEFT = Resource.Custom("entity/dark_chest_left")
|
||||
val TEX_DOUBLE_RIGHT = Resource.Custom("entity/dark_chest_right")
|
||||
|
||||
private val MAT_SINGLE = Material(ModAtlases.ATLAS_TILES, TEX_SINGLE)
|
||||
private val MAT_DOUBLE_LEFT = Material(ModAtlases.ATLAS_TILES, TEX_DOUBLE_LEFT)
|
||||
private val MAT_DOUBLE_RIGHT = Material(ModAtlases.ATLAS_TILES, TEX_DOUBLE_RIGHT)
|
||||
}
|
||||
|
||||
init{
|
||||
isChristmas = false
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityDarkChest, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int){
|
||||
val prevTexSingle = TEXTURE_NORMAL
|
||||
val prevTexDouble = TEXTURE_NORMAL_DOUBLE
|
||||
|
||||
TEXTURE_NORMAL = TEX_SINGLE
|
||||
TEXTURE_NORMAL_DOUBLE = TEX_DOUBLE
|
||||
|
||||
super.render(tile, x, y, z, partialTicks, destroyStage)
|
||||
|
||||
TEXTURE_NORMAL = prevTexSingle
|
||||
TEXTURE_NORMAL_DOUBLE = prevTexDouble
|
||||
override fun getMaterial(tile: TileEntityDarkChest, type: ChestType) = when(type){
|
||||
LEFT -> MAT_DOUBLE_LEFT
|
||||
RIGHT -> MAT_DOUBLE_RIGHT
|
||||
else -> MAT_SINGLE
|
||||
}
|
||||
|
||||
object AsItem : ItemStackTileEntityRenderer(){
|
||||
private val tile = TileEntityDarkChest()
|
||||
|
||||
override fun renderByItem(stack: ItemStack){
|
||||
TileEntityRendererDispatcher.instance.renderAsItem(tile)
|
||||
override fun render(stack: ItemStack, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
TileEntityRendererDispatcher.instance.renderItem(tile, matrix, buffer, combinedLight, combinedOverlay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,12 @@ import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.closestTickingTile
|
||||
import chylex.hee.system.util.math.LerpedFloat
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileEndPortal : RenderTileAbstractPortal<TileEntityPortalInner.End, IPortalController>(){
|
||||
class RenderTileEndPortal(dispatcher: TileEntityRendererDispatcher) : RenderTileAbstractPortal<TileEntityPortalInner.End, IPortalController>(dispatcher){
|
||||
private object AlwaysOnController : IPortalController{
|
||||
override val clientAnimationProgress = LerpedFloat(1F)
|
||||
override val clientPortalOffset = LerpedFloat(0F)
|
||||
|
@ -1,5 +1,9 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.render.util.RenderStateBuilder
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.ALPHA_CUTOUT
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.LIGHTMAP_ENABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.SHADE_ENABLED
|
||||
import chylex.hee.game.block.entity.TileEntityExperienceGate
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
@ -7,110 +11,128 @@ import chylex.hee.system.migration.forge.SubscribeAllEvents
|
||||
import chylex.hee.system.migration.forge.SubscribeEvent
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.floorToInt
|
||||
import net.minecraft.client.renderer.BufferBuilder
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.Matrix4f
|
||||
import net.minecraft.client.renderer.WorldRenderer
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.inventory.container.PlayerContainer
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.client.event.TextureStitchEvent
|
||||
import net.minecraftforge.client.model.animation.TileEntityRendererFast
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
object RenderTileExperienceGate : TileEntityRendererFast<TileEntityExperienceGate>(){
|
||||
private const val SPRITE_COUNT = 40
|
||||
|
||||
private val TEX = Array(SPRITE_COUNT){ Resource.Custom("block/experience_gate_top_bar_$it") }
|
||||
private val SPRITES = mutableListOf<TextureAtlasSprite>()
|
||||
|
||||
private val FRAMES_CORNER = intArrayOf(9, 10, 11, 12, 13, 14, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39)
|
||||
private val FRAMES_STRAIGHT = intArrayOf(9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24)
|
||||
|
||||
private val FRAMES = arrayOf(
|
||||
intArrayOf(0, 1, 2),
|
||||
FRAMES_STRAIGHT,
|
||||
FRAMES_CORNER,
|
||||
FRAMES_STRAIGHT,
|
||||
intArrayOf(5, 6, 7, 8, 4),
|
||||
FRAMES_STRAIGHT,
|
||||
FRAMES_CORNER,
|
||||
FRAMES_STRAIGHT,
|
||||
intArrayOf(3, 4)
|
||||
)
|
||||
|
||||
private val FRAME_COUNT = 1 + FRAMES.sumBy { it.size }
|
||||
private val FRAME_OFFSETS = FRAMES.indices.map { index -> 1 + FRAMES.take(index).sumBy { it.size } }.toIntArray()
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPre(e: TextureStitchEvent.Pre){
|
||||
if (e.map.basePath != "textures"){
|
||||
return
|
||||
class RenderTileExperienceGate(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityExperienceGate>(dispatcher){
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
companion object{
|
||||
private const val SPRITE_COUNT = 40
|
||||
|
||||
private val TEX = Array(SPRITE_COUNT){ Resource.Custom("block/experience_gate_top_bar_$it") }
|
||||
private val SPRITES = mutableListOf<TextureAtlasSprite>()
|
||||
|
||||
private val RENDER_TYPE_BAR = with(RenderStateBuilder()){
|
||||
tex(PlayerContainer.LOCATION_BLOCKS_TEXTURE, mipmap = true)
|
||||
alpha(ALPHA_CUTOUT)
|
||||
shade(SHADE_ENABLED)
|
||||
lightmap(LIGHTMAP_ENABLED)
|
||||
buildType("hee:experience_gate_bar", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, drawMode = GL11.GL_QUADS, bufferSize = 256)
|
||||
}
|
||||
|
||||
with(e){
|
||||
TEX.forEach { addSprite(it) }
|
||||
private val FRAMES_CORNER = intArrayOf(9, 10, 11, 12, 13, 14, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39)
|
||||
private val FRAMES_STRAIGHT = intArrayOf(9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24)
|
||||
|
||||
private val FRAMES = arrayOf(
|
||||
intArrayOf(0, 1, 2),
|
||||
FRAMES_STRAIGHT,
|
||||
FRAMES_CORNER,
|
||||
FRAMES_STRAIGHT,
|
||||
intArrayOf(5, 6, 7, 8, 4),
|
||||
FRAMES_STRAIGHT,
|
||||
FRAMES_CORNER,
|
||||
FRAMES_STRAIGHT,
|
||||
intArrayOf(3, 4)
|
||||
)
|
||||
|
||||
private val FRAME_COUNT = 1 + FRAMES.sumBy { it.size }
|
||||
private val FRAME_OFFSETS = FRAMES.indices.map { index -> 1 + FRAMES.take(index).sumBy { it.size } }.toIntArray()
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPre(e: TextureStitchEvent.Pre){
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE){
|
||||
with(e){
|
||||
TEX.forEach { addSprite(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPost(e: TextureStitchEvent.Post){
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE){
|
||||
SPRITES.clear()
|
||||
|
||||
with(e.map){
|
||||
TEX.forEach { SPRITES.add(getSprite(it)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTexture(index: Int, frame: Int): TextureAtlasSprite?{
|
||||
return FRAMES[index].getOrNull((frame - FRAME_OFFSETS[index]).coerceAtMost(FRAMES[index].lastIndex))?.let(SPRITES::getOrNull)
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPost(e: TextureStitchEvent.Post){
|
||||
if (e.map.basePath != "textures"){
|
||||
return
|
||||
}
|
||||
|
||||
SPRITES.clear()
|
||||
|
||||
with(e.map){
|
||||
TEX.forEach { SPRITES.add(getAtlasSprite(it.toString())) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTexture(index: Int, frame: Int): TextureAtlasSprite?{
|
||||
return FRAMES[index].getOrNull((frame - FRAME_OFFSETS[index]).coerceAtMost(FRAMES[index].lastIndex))?.let(SPRITES::getOrNull)
|
||||
}
|
||||
|
||||
override fun renderTileEntityFast(tile: TileEntityExperienceGate, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int, buffer: BufferBuilder){
|
||||
override fun render(tile: TileEntityExperienceGate, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
val world = tile.world ?: return
|
||||
val pos = tile.pos
|
||||
|
||||
val builder = buffer.getBuffer(RENDER_TYPE_BAR)
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
val progress = tile.chargeProgress
|
||||
val frame = if (progress == 0F) 0 else 1 + (progress * (FRAME_COUNT - 2)).floorToInt()
|
||||
|
||||
val topLeftBlock = getTexture(8, frame) ?: getTexture(0, frame)
|
||||
|
||||
topLeftBlock?.let { buffer.renderTextureAt(x - 1.0, y, z - 1.0, world, pos.add(-1, 1, -1), it, 0b000) }
|
||||
getTexture(1, frame)?.let { buffer.renderTextureAt(x + 0.0, y, z - 1.0, world, pos.add( 0, 1, -1), it, 0b111) }
|
||||
getTexture(2, frame)?.let { buffer.renderTextureAt(x + 1.0, y, z - 1.0, world, pos.add( 1, 1, -1), it, 0b011) }
|
||||
getTexture(3, frame)?.let { buffer.renderTextureAt(x + 1.0, y, z + 0.0, world, pos.add( 1, 1, 0), it, 0b110) }
|
||||
getTexture(4, frame)?.let { buffer.renderTextureAt(x + 1.0, y, z + 1.0, world, pos.add( 1, 1, 1), it, 0b110) }
|
||||
getTexture(5, frame)?.let { buffer.renderTextureAt(x + 0.0, y, z + 1.0, world, pos.add( 0, 1, 1), it, 0b001) }
|
||||
getTexture(6, frame)?.let { buffer.renderTextureAt(x - 1.0, y, z + 1.0, world, pos.add(-1, 1, 1), it, 0b101) }
|
||||
getTexture(7, frame)?.let { buffer.renderTextureAt(x - 1.0, y, z + 0.0, world, pos.add(-1, 1, 0), it, 0b000) }
|
||||
topLeftBlock?.let { builder.renderTextureAt(mat, -1F, -1F, world, pos.add(-1, 1, -1), it, 0b0000, combinedOverlay) }
|
||||
getTexture(1, frame)?.let { builder.renderTextureAt(mat, 0F, -1F, world, pos.add( 0, 1, -1), it, 0b0111, combinedOverlay) }
|
||||
getTexture(2, frame)?.let { builder.renderTextureAt(mat, 1F, -1F, world, pos.add( 1, 1, -1), it, 0b1001, combinedOverlay) }
|
||||
getTexture(3, frame)?.let { builder.renderTextureAt(mat, 1F, 0F, world, pos.add( 1, 1, 0), it, 0b0110, combinedOverlay) }
|
||||
getTexture(4, frame)?.let { builder.renderTextureAt(mat, 1F, 1F, world, pos.add( 1, 1, 1), it, 0b0110, combinedOverlay) }
|
||||
getTexture(5, frame)?.let { builder.renderTextureAt(mat, 0F, 1F, world, pos.add( 0, 1, 1), it, 0b0001, combinedOverlay) }
|
||||
getTexture(6, frame)?.let { builder.renderTextureAt(mat, -1F, 1F, world, pos.add(-1, 1, 1), it, 0b1111, combinedOverlay) }
|
||||
getTexture(7, frame)?.let { builder.renderTextureAt(mat, -1F, 0F, world, pos.add(-1, 1, 0), it, 0b0000, combinedOverlay) }
|
||||
}
|
||||
|
||||
private fun BufferBuilder.renderTextureAt(x: Double, y: Double, z: Double, world: World, pos: BlockPos, tex: TextureAtlasSprite, rot: Int){
|
||||
val rotX = (((rot shr 1) and 1) - 0.5) * 1.002
|
||||
val rotZ = (((rot shr 2) and 1) - 0.5) * 1.002
|
||||
private fun IVertexBuilder.renderTextureAt(mat: Matrix4f, x: Float, z: Float, world: World, pos: BlockPos, tex: TextureAtlasSprite, rot: Int, overlay: Int){
|
||||
val rotX = (((rot shr 1) and 1) - 0.5F) * 1.002F
|
||||
val rotZ = (((rot shr 2) and 1) - 0.5F) * 1.002F
|
||||
|
||||
val u1 = tex.minU.toDouble()
|
||||
val u2 = tex.maxU.toDouble()
|
||||
val v1 = tex.minV.toDouble()
|
||||
val v2 = tex.maxV.toDouble()
|
||||
val u1 = tex.minU
|
||||
val u2 = tex.maxU
|
||||
val v1 = tex.minV
|
||||
val v2 = tex.maxV
|
||||
|
||||
val c = if (rot and 1 == 0){
|
||||
doubleArrayOf(u1, u2, u2, u1, v1, v1, v2, v2)
|
||||
val c = if (rot and 0b1000 != 0){
|
||||
floatArrayOf(u2, u1, u1, u2, v1, v1, v2, v2)
|
||||
}
|
||||
else if (rot and 0b0001 == 0){
|
||||
floatArrayOf(u2, u2, u1, u1, v2, v1, v1, v2)
|
||||
}
|
||||
else{
|
||||
doubleArrayOf(u1, u1, u2, u2, v1, v2, v2, v1)
|
||||
floatArrayOf(u2, u1, u1, u2, v2, v2, v1, v1)
|
||||
}
|
||||
|
||||
val light = world.getCombinedLight(pos, 0)
|
||||
val sky = (light shr 16) and 65535
|
||||
val block = light and 65535
|
||||
val light = WorldRenderer.getCombinedLight(world, pos)
|
||||
|
||||
this.pos(x + 0.5 + rotX, y + 1.001, z + 0.5 + rotZ).color(255, 255, 255, 255).tex(c[0], c[4]).lightmap(sky, block).endVertex()
|
||||
this.pos(x + 0.5 - rotX, y + 1.001, z + 0.5 + rotZ).color(255, 255, 255, 255).tex(c[1], c[5]).lightmap(sky, block).endVertex()
|
||||
this.pos(x + 0.5 - rotX, y + 1.001, z + 0.5 - rotZ).color(255, 255, 255, 255).tex(c[2], c[6]).lightmap(sky, block).endVertex()
|
||||
this.pos(x + 0.5 + rotX, y + 1.001, z + 0.5 - rotZ).color(255, 255, 255, 255).tex(c[3], c[7]).lightmap(sky, block).endVertex()
|
||||
this.pos(mat, x + 0.5F - rotX, 1.001F, z + 0.5F - rotZ).color(255, 255, 255, 255).tex(c[0], c[4]).lightmap(light).overlay(overlay).endVertex()
|
||||
this.pos(mat, x + 0.5F - rotX, 1.001F, z + 0.5F + rotZ).color(255, 255, 255, 255).tex(c[1], c[5]).lightmap(light).overlay(overlay).endVertex()
|
||||
this.pos(mat, x + 0.5F + rotX, 1.001F, z + 0.5F + rotZ).color(255, 255, 255, 255).tex(c[2], c[6]).lightmap(light).overlay(overlay).endVertex()
|
||||
this.pos(mat, x + 0.5F + rotX, 1.001F, z + 0.5F - rotZ).color(255, 255, 255, 255).tex(c[3], c[7]).lightmap(light).overlay(overlay).endVertex()
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,14 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.client.model.block.ModelBlockIgneousPlate
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.RenderStateBuilder
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.BLEND_NONE
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.LIGHTING_DISABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.LIGHTMAP_ENABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.OVERLAY_ENABLED
|
||||
import chylex.hee.client.render.util.rotateX
|
||||
import chylex.hee.client.render.util.rotateY
|
||||
import chylex.hee.client.render.util.translateX
|
||||
import chylex.hee.client.render.util.translateZ
|
||||
import chylex.hee.game.block.BlockIgneousPlate
|
||||
import chylex.hee.game.block.entity.TileEntityIgneousPlate
|
||||
import chylex.hee.init.ModBlocks
|
||||
@ -15,92 +23,80 @@ import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.floorToInt
|
||||
import chylex.hee.system.util.getState
|
||||
import chylex.hee.system.util.offsetTowards
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import org.lwjgl.opengl.GL11.GL_MODELVIEW
|
||||
import org.lwjgl.opengl.GL11.GL_TEXTURE
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileIgneousPlate : TileEntityRenderer<TileEntityIgneousPlate>(){
|
||||
private val TEX_PLATE = Resource.Custom("textures/entity/igneous_plate.png")
|
||||
|
||||
private val COLOR_TRANSITIONS = arrayOf(
|
||||
RGB(207, 187, 161).asVec,
|
||||
RGB(247, 205, 82).asVec,
|
||||
RGB(235, 23, 23).asVec
|
||||
)
|
||||
|
||||
private fun getInnerBoxColor(combinedHeat: Float): Vec3d{
|
||||
val index = combinedHeat.floorToInt().coerceIn(0, COLOR_TRANSITIONS.lastIndex - 1)
|
||||
val progress = combinedHeat.toDouble() - index
|
||||
class RenderTileIgneousPlate(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityIgneousPlate>(dispatcher){
|
||||
private companion object{
|
||||
private val TEX_PLATE = Resource.Custom("textures/entity/igneous_plate.png")
|
||||
|
||||
return COLOR_TRANSITIONS[index].offsetTowards(COLOR_TRANSITIONS[index + 1], progress)
|
||||
private val RENDER_TYPE_OUTER = RenderType.getEntitySolid(TEX_PLATE)
|
||||
private val RENDER_TYPE_INNER = with(RenderStateBuilder()){
|
||||
tex(TEX_PLATE)
|
||||
blend(BLEND_NONE)
|
||||
lighting(LIGHTING_DISABLED)
|
||||
lightmap(LIGHTMAP_ENABLED)
|
||||
overlay(OVERLAY_ENABLED)
|
||||
buildType("hee:igneous_plate_inner", DefaultVertexFormats.ENTITY, GL11.GL_QUADS, bufferSize = 256, useDelegate = true)
|
||||
}
|
||||
|
||||
private val COLOR_TRANSITIONS = arrayOf(
|
||||
RGB(207, 187, 161).asVec,
|
||||
RGB(247, 205, 82).asVec,
|
||||
RGB(235, 23, 23).asVec
|
||||
)
|
||||
|
||||
private fun getInnerBoxColor(combinedHeat: Float): Vec3d{
|
||||
val index = combinedHeat.floorToInt().coerceIn(0, COLOR_TRANSITIONS.lastIndex - 1)
|
||||
val progress = combinedHeat.toDouble() - index
|
||||
|
||||
return COLOR_TRANSITIONS[index].offsetTowards(COLOR_TRANSITIONS[index + 1], progress)
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityIgneousPlate, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int){
|
||||
if (destroyStage >= 0){
|
||||
bindTexture(DESTROY_STAGES[destroyStage])
|
||||
GL.matrixMode(GL_TEXTURE)
|
||||
GL.pushMatrix()
|
||||
GL.scale(4F, 2F, 1F)
|
||||
GL.matrixMode(GL_MODELVIEW)
|
||||
}
|
||||
else{
|
||||
bindTexture(TEX_PLATE)
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityIgneousPlate, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
val state = tile.world?.let { tile.pos.getState(it) }
|
||||
|
||||
if (state?.block !== ModBlocks.IGNEOUS_PLATE){
|
||||
return
|
||||
}
|
||||
|
||||
GL.pushMatrix()
|
||||
GL.translate(x, y, z)
|
||||
matrix.push()
|
||||
|
||||
when(state[BlockIgneousPlate.FACING_NOT_DOWN]){
|
||||
UP -> {
|
||||
GL.translate(0F, 0F, 1F)
|
||||
GL.rotate(-90F, 1F, 0F, 0F)
|
||||
matrix.translateZ(1.0)
|
||||
matrix.rotateX(-90F)
|
||||
}
|
||||
|
||||
NORTH -> {
|
||||
GL.translate(1F, 0F, 1F)
|
||||
GL.rotate(180F, 0F, 1F, 0F)
|
||||
matrix.translate(1.0, 0.0, 1.0)
|
||||
matrix.rotateY(180F)
|
||||
}
|
||||
|
||||
WEST -> {
|
||||
GL.translate(1F, 0F, 0F)
|
||||
GL.rotate(-90F, 0F, 1F, 0F)
|
||||
matrix.translateX(1.0)
|
||||
matrix.rotateY(-90F)
|
||||
}
|
||||
|
||||
EAST -> {
|
||||
GL.translate(0F, 0F, 1F)
|
||||
GL.rotate(90F, 0F, 1F, 0F)
|
||||
matrix.translateZ(1.0)
|
||||
matrix.rotateY(90F)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
|
||||
GL.enableRescaleNormal()
|
||||
GL.color(1F, 1F, 1F)
|
||||
ModelBlockIgneousPlate.render(matrix, buffer.getBuffer(RENDER_TYPE_OUTER), combinedLight, combinedOverlay, 1F, 1F, 1F, 1F)
|
||||
ModelBlockIgneousPlate.renderInnerBox(matrix, buffer.getBuffer(RENDER_TYPE_INNER), combinedLight, combinedOverlay, getInnerBoxColor(tile.clientCombinedHeat), tile.clientThrustAnimation.get(partialTicks))
|
||||
|
||||
if (destroyStage < 0){
|
||||
ModelBlockIgneousPlate.renderOuterBox()
|
||||
GL.color(getInnerBoxColor(tile.clientCombinedHeat))
|
||||
}
|
||||
|
||||
GL.disableLighting()
|
||||
ModelBlockIgneousPlate.renderInnerBox(tile.clientThrustAnimation.get(partialTicks))
|
||||
GL.enableLighting()
|
||||
|
||||
GL.disableRescaleNormal()
|
||||
GL.popMatrix()
|
||||
|
||||
if (destroyStage >= 0){
|
||||
GL.matrixMode(GL_TEXTURE)
|
||||
GL.popMatrix()
|
||||
GL.matrixMode(GL_MODELVIEW)
|
||||
}
|
||||
matrix.pop()
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.TESSELLATOR
|
||||
import chylex.hee.client.render.util.draw
|
||||
import chylex.hee.client.render.util.RenderStateBuilder
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.LIGHTMAP_ENABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.SHADE_ENABLED
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.block.BlockJarODust
|
||||
import chylex.hee.game.block.entity.TileEntityJarODust
|
||||
@ -11,150 +11,158 @@ import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.forge.SubscribeAllEvents
|
||||
import chylex.hee.system.migration.forge.SubscribeEvent
|
||||
import chylex.hee.system.util.Pos
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.floorToInt
|
||||
import chylex.hee.system.util.getListOfCompounds
|
||||
import chylex.hee.system.util.heeTagOrNull
|
||||
import chylex.hee.system.util.offsetTowards
|
||||
import net.minecraft.client.renderer.BufferBuilder
|
||||
import net.minecraft.client.renderer.RenderHelper
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.Atlases
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.model.IBakedModel
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.inventory.container.PlayerContainer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.client.event.ModelBakeEvent
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent
|
||||
import net.minecraftforge.client.event.TextureStitchEvent
|
||||
import net.minecraftforge.client.model.ModelLoader
|
||||
import net.minecraftforge.client.model.animation.TileEntityRendererFast
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
|
||||
import org.lwjgl.opengl.GL11.GL_QUADS
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
object RenderTileJarODust : TileEntityRendererFast<TileEntityJarODust>(){
|
||||
private val TEX_LAYER = Resource.Custom("block/dust_layer")
|
||||
private const val TEX_MP = 1.6
|
||||
|
||||
private lateinit var SPRITE_LAYER: TextureAtlasSprite
|
||||
|
||||
private val AABB = BlockJarODust.AABB
|
||||
|
||||
private const val EPSILON_Y = 0.025
|
||||
private const val EPSILON_XZ = 0.005
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPre(e: TextureStitchEvent.Pre){
|
||||
if (e.map.basePath == "textures"){
|
||||
e.addSprite(TEX_LAYER)
|
||||
class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityJarODust>(dispatcher){
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
companion object{
|
||||
private val TEX_LAYER = Resource.Custom("block/dust_layer")
|
||||
private const val TEX_MP = 1.6
|
||||
|
||||
private lateinit var SPRITE_LAYER: TextureAtlasSprite
|
||||
|
||||
private val RENDER_TYPE_LAYERS = with(RenderStateBuilder()){
|
||||
tex(PlayerContainer.LOCATION_BLOCKS_TEXTURE, mipmap = true)
|
||||
shade(SHADE_ENABLED)
|
||||
lightmap(LIGHTMAP_ENABLED)
|
||||
buildType("hee:jar_layers", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, drawMode = GL11.GL_QUADS, bufferSize = 256)
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPost(e: TextureStitchEvent.Post){
|
||||
if (e.map.basePath == "textures"){
|
||||
SPRITE_LAYER = e.map.getAtlasSprite(TEX_LAYER.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderTileEntityFast(tile: TileEntityJarODust, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int, buffer: BufferBuilder){
|
||||
val world = tile.world ?: MC.world ?: return
|
||||
val pos = tile.pos
|
||||
|
||||
renderLayers(tile.layers, x, y, z, world.getCombinedLight(pos, 0), buffer, renderBottom = false)
|
||||
}
|
||||
|
||||
private fun renderLayers(layers: DustLayers, x: Double, y: Double, z: Double, combinedLight: Int, buffer: BufferBuilder, renderBottom: Boolean){
|
||||
val contents = layers.contents.takeUnless { it.isEmpty() } ?: return
|
||||
val unit = AABB.let { it.maxY - it.minY - (EPSILON_Y * 2) } / layers.totalCapacity
|
||||
private val AABB = BlockJarODust.AABB
|
||||
|
||||
val sky = (combinedLight shr 16) and 65535
|
||||
val block = combinedLight and 65535
|
||||
private const val EPSILON_Y = 0.025
|
||||
private const val EPSILON_XZ = 0.005
|
||||
|
||||
val minX = x + AABB.minX + EPSILON_XZ
|
||||
val maxX = x + AABB.maxX - EPSILON_XZ
|
||||
|
||||
val minZ = z + AABB.minZ + EPSILON_XZ
|
||||
val maxZ = z + AABB.maxZ - EPSILON_XZ
|
||||
|
||||
val minU = SPRITE_LAYER.minU.toDouble()
|
||||
val maxU = SPRITE_LAYER.let { offsetTowards(it.minU, it.maxU, 0.5F) }.toDouble() // texture is 16x32 to support repeating pattern
|
||||
val minV = SPRITE_LAYER.minV.toDouble()
|
||||
val maxV = SPRITE_LAYER.maxV.toDouble()
|
||||
val texHalfSize = (maxU - minU)
|
||||
|
||||
var relY = 0.0
|
||||
|
||||
for((index, info) in contents.withIndex()){
|
||||
val (dustType, dustAmount) = info
|
||||
|
||||
val color = dustType.color
|
||||
val height = dustAmount * unit
|
||||
|
||||
val texMin = minU + (0.01 + relY * TEX_MP) * texHalfSize
|
||||
val texMax = minU + (0.01 + (relY + height) * TEX_MP) * texHalfSize
|
||||
|
||||
val minY = y + relY + AABB.minY + EPSILON_Y
|
||||
val maxY = minY + height
|
||||
|
||||
val sideR = (color[0] / 1.125F).floorToInt().coerceAtLeast(0)
|
||||
val sideG = (color[1] / 1.125F).floorToInt().coerceAtLeast(0)
|
||||
val sideB = (color[2] / 1.125F).floorToInt().coerceAtLeast(0)
|
||||
|
||||
with(buffer){
|
||||
pos(minX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(sky, block).endVertex()
|
||||
pos(minX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(sky, block).endVertex()
|
||||
pos(minX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(sky, block).endVertex()
|
||||
pos(minX, maxY, minZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(sky, block).endVertex()
|
||||
|
||||
pos(maxX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, maxY, minZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(sky, block).endVertex()
|
||||
|
||||
pos(maxX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(sky, block).endVertex()
|
||||
pos(minX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(sky, block).endVertex()
|
||||
pos(minX, maxY, minZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, maxY, minZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(sky, block).endVertex()
|
||||
|
||||
pos(minX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(sky, block).endVertex()
|
||||
pos(minX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(sky, block).endVertex()
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPre(e: TextureStitchEvent.Pre){
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE){
|
||||
e.addSprite(TEX_LAYER)
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPost(e: TextureStitchEvent.Post){
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE){
|
||||
SPRITE_LAYER = e.map.getSprite(TEX_LAYER)
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderLayers(layers: DustLayers, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int, renderBottom: Boolean){
|
||||
val contents = layers.contents.takeUnless { it.isEmpty() } ?: return
|
||||
val unit = AABB.let { it.maxY - it.minY - (EPSILON_Y * 2) } / layers.totalCapacity
|
||||
|
||||
if (index == 0 && renderBottom){
|
||||
val bottomR = color[0]
|
||||
val bottomG = color[1]
|
||||
val bottomB = color[2]
|
||||
val builder = buffer.getBuffer(RENDER_TYPE_LAYERS)
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
val minX = (AABB.minX + EPSILON_XZ).toFloat()
|
||||
val maxX = (AABB.maxX - EPSILON_XZ).toFloat()
|
||||
|
||||
val minZ = (AABB.minZ + EPSILON_XZ).toFloat()
|
||||
val maxZ = (AABB.maxZ - EPSILON_XZ).toFloat()
|
||||
|
||||
val minU = SPRITE_LAYER.minU
|
||||
val maxU = SPRITE_LAYER.let { offsetTowards(it.minU, it.maxU, 0.5F) }.toFloat() // texture is 16x32 to support repeating pattern
|
||||
val minV = SPRITE_LAYER.minV
|
||||
val maxV = SPRITE_LAYER.maxV
|
||||
val texHalfSize = (maxU - minU)
|
||||
|
||||
var relY = 0.0
|
||||
|
||||
for((index, info) in contents.withIndex()){
|
||||
val (dustType, dustAmount) = info
|
||||
|
||||
with(buffer){
|
||||
pos(maxX, minY, minZ).color(bottomR, bottomG, bottomB, 255).tex(maxU, minV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, minY, maxZ).color(bottomR, bottomG, bottomB, 255).tex(maxU, maxV).lightmap(sky, block).endVertex()
|
||||
pos(minX, minY, maxZ).color(bottomR, bottomG, bottomB, 255).tex(minU, maxV).lightmap(sky, block).endVertex()
|
||||
pos(minX, minY, minZ).color(bottomR, bottomG, bottomB, 255).tex(minU, minV).lightmap(sky, block).endVertex()
|
||||
val color = dustType.color
|
||||
val height = dustAmount * unit
|
||||
|
||||
val texMin = minU + ((0.01 + relY * TEX_MP) * texHalfSize).toFloat()
|
||||
val texMax = minU + ((0.01 + (relY + height) * TEX_MP) * texHalfSize).toFloat()
|
||||
|
||||
val minY = (relY + AABB.minY + EPSILON_Y).toFloat()
|
||||
val maxY = (minY + height).toFloat()
|
||||
|
||||
val sideR = (color[0] / 1.125F).floorToInt().coerceAtLeast(0)
|
||||
val sideG = (color[1] / 1.125F).floorToInt().coerceAtLeast(0)
|
||||
val sideB = (color[2] / 1.125F).floorToInt().coerceAtLeast(0)
|
||||
|
||||
with(builder){
|
||||
pos(mat, minX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, maxY, minZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
|
||||
pos(mat, maxX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, maxY, minZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
|
||||
pos(mat, maxX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, maxY, minZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, maxY, minZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
|
||||
pos(mat, minX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
}
|
||||
}
|
||||
|
||||
if (index == contents.lastIndex){
|
||||
val topR = (color[0] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
val topG = (color[1] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
val topB = (color[2] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
|
||||
with(buffer){
|
||||
pos(minX, maxY, minZ).color(topR, topG, topB, 255).tex(minU, minV).lightmap(sky, block).endVertex()
|
||||
pos(minX, maxY, maxZ).color(topR, topG, topB, 255).tex(minU, maxV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, maxY, maxZ).color(topR, topG, topB, 255).tex(maxU, maxV).lightmap(sky, block).endVertex()
|
||||
pos(maxX, maxY, minZ).color(topR, topG, topB, 255).tex(maxU, minV).lightmap(sky, block).endVertex()
|
||||
if (index == 0 && renderBottom){
|
||||
val bottomR = color[0]
|
||||
val bottomG = color[1]
|
||||
val bottomB = color[2]
|
||||
|
||||
with(builder){
|
||||
pos(mat, maxX, minY, minZ).color(bottomR, bottomG, bottomB, 255).tex(maxU, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, minY, maxZ).color(bottomR, bottomG, bottomB, 255).tex(maxU, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, minY, maxZ).color(bottomR, bottomG, bottomB, 255).tex(minU, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, minY, minZ).color(bottomR, bottomG, bottomB, 255).tex(minU, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
}
|
||||
}
|
||||
|
||||
if (index == contents.lastIndex){
|
||||
val topR = (color[0] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
val topG = (color[1] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
val topB = (color[2] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
|
||||
with(builder){
|
||||
pos(mat, minX, maxY, minZ).color(topR, topG, topB, 255).tex(minU, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, maxY, maxZ).color(topR, topG, topB, 255).tex(minU, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, maxY, maxZ).color(topR, topG, topB, 255).tex(maxU, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, maxY, minZ).color(topR, topG, topB, 255).tex(maxU, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
}
|
||||
}
|
||||
|
||||
relY += height
|
||||
}
|
||||
|
||||
relY += height
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityJarODust, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
renderLayers(tile.layers, matrix, buffer, combinedLight, combinedOverlay, renderBottom = false)
|
||||
}
|
||||
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
object AsItem : ItemStackTileEntityRenderer(){
|
||||
private val RESOURCE_MODEL = Resource.Custom("block/jar_o_dust_simple")
|
||||
@ -172,25 +180,15 @@ object RenderTileJarODust : TileEntityRendererFast<TileEntityJarODust>(){
|
||||
|
||||
private val layers = DustLayers(TileEntityJarODust.DUST_CAPACITY)
|
||||
|
||||
override fun renderByItem(stack: ItemStack){
|
||||
override fun render(stack: ItemStack, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
val nbt = stack.heeTagOrNull?.getListOfCompounds(BlockJarODust.LAYERS_TAG)
|
||||
val player = MC.player ?: return
|
||||
|
||||
GL.enableCull()
|
||||
|
||||
if (nbt != null){
|
||||
layers.deserializeNBT(nbt)
|
||||
RenderHelper.disableStandardItemLighting()
|
||||
|
||||
TESSELLATOR.draw(GL_QUADS, DefaultVertexFormats.BLOCK){
|
||||
renderLayers(layers, 0.0, 0.0, 0.0, world.getCombinedLight(Pos(player), 0), this, renderBottom = true)
|
||||
}
|
||||
|
||||
RenderHelper.enableStandardItemLighting()
|
||||
renderLayers(layers, matrix, buffer, combinedLight, combinedOverlay, renderBottom = true)
|
||||
}
|
||||
|
||||
MC.instance.blockRendererDispatcher.blockModelRenderer.renderModelBrightnessColor(MODEL, 1F, 1F, 1F, 1F)
|
||||
GL.disableCull()
|
||||
MC.instance.blockRendererDispatcher.blockModelRenderer.renderModelBrightnessColor(matrix.last, buffer.getBuffer(Atlases.getTranslucentCullBlockType()), null, MODEL, 1F, 1F, 1F, combinedLight, combinedOverlay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,19 +3,23 @@ import chylex.hee.game.block.entity.TileEntityLootChest
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileLootChest : RenderTileAbstractChest<TileEntityLootChest>(){
|
||||
override val texture = Resource.Custom("textures/entity/loot_chest.png")
|
||||
class RenderTileLootChest(dispatcher: TileEntityRendererDispatcher) : RenderTileAbstractChest<TileEntityLootChest>(dispatcher, TEX){
|
||||
companion object{
|
||||
val TEX = Resource.Custom("entity/loot_chest")
|
||||
}
|
||||
|
||||
object AsItem : ItemStackTileEntityRenderer(){
|
||||
private val tile = TileEntityLootChest()
|
||||
|
||||
override fun renderByItem(stack: ItemStack){
|
||||
TileEntityRendererDispatcher.instance.renderAsItem(tile)
|
||||
override fun render(stack: ItemStack, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
TileEntityRendererDispatcher.instance.renderItem(tile, matrix, buffer, combinedLight, combinedOverlay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +1,38 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.ItemRenderHelper
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.render.util.rotateX
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.block.entity.TileEntityMinersBurialAltar
|
||||
import chylex.hee.init.ModItems
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType.GROUND
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.client.ForgeHooksClient
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileMinersBurialAltar : TileEntityRenderer<TileEntityMinersBurialAltar>(){
|
||||
private val PUZZLE_MEDALLION = ItemStack(ModItems.PUZZLE_MEDALLION)
|
||||
private const val SCALE_XZ = 1.85F
|
||||
class RenderTileMinersBurialAltar(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityMinersBurialAltar>(dispatcher){
|
||||
private companion object{
|
||||
private val PUZZLE_MEDALLION = ItemStack(ModItems.PUZZLE_MEDALLION)
|
||||
private const val SCALE_XZ = 1.85F
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityMinersBurialAltar, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int){
|
||||
override fun render(tile: TileEntityMinersBurialAltar, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
if (!tile.hasMedallion){
|
||||
return
|
||||
}
|
||||
|
||||
ItemRenderHelper.beginItemModel()
|
||||
GL.pushMatrix()
|
||||
GL.translate(x, y, z)
|
||||
GL.pushMatrix()
|
||||
matrix.push()
|
||||
matrix.translate(0.5, 0.7725 - (0.035 * tile.clientMedallionAnimProgress), 0.5 + (0.125 * SCALE_XZ))
|
||||
matrix.rotateX(270F)
|
||||
matrix.scale(SCALE_XZ, SCALE_XZ, 1.5F)
|
||||
|
||||
GL.translate(0.5F, 0.7725F - (0.035F * tile.clientMedallionAnimProgress), 0.625F + 0.125F * (SCALE_XZ - 1F))
|
||||
GL.rotate(270F, 1F, 0F, 0F)
|
||||
GL.scale(SCALE_XZ, SCALE_XZ, 1.5F)
|
||||
MC.itemRenderer.renderItem(PUZZLE_MEDALLION, GROUND, false, matrix, buffer, combinedLight, OverlayTexture.NO_OVERLAY, ModelHelper.getItemModel(PUZZLE_MEDALLION))
|
||||
|
||||
MC.itemRenderer.renderItem(PUZZLE_MEDALLION, ForgeHooksClient.handleCameraTransforms(ItemRenderHelper.getItemModel(PUZZLE_MEDALLION), GROUND, false))
|
||||
|
||||
GL.popMatrix()
|
||||
GL.popMatrix()
|
||||
ItemRenderHelper.endItemModel()
|
||||
matrix.pop()
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,33 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.rotateX
|
||||
import chylex.hee.client.render.util.rotateY
|
||||
import chylex.hee.client.render.util.scale
|
||||
import chylex.hee.client.render.util.translateY
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.block.entity.base.TileEntityBaseSpawner
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import kotlin.math.max
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileSpawner : TileEntityRenderer<TileEntityBaseSpawner>(){
|
||||
override fun render(tile: TileEntityBaseSpawner, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int){
|
||||
class RenderTileSpawner(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityBaseSpawner>(dispatcher){
|
||||
override fun render(tile: TileEntityBaseSpawner, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
val entity = tile.clientEntity
|
||||
val scale = 0.53125F / max(entity.width, entity.height).coerceAtLeast(1F)
|
||||
|
||||
GL.pushMatrix()
|
||||
GL.translate(x + 0.5, y + 0.4, z + 0.5)
|
||||
GL.rotate(tile.clientRotation.get(partialTicks) * 10F, 0F, 1F, 0F)
|
||||
GL.translate(0F, -0.2F, 0F)
|
||||
GL.rotate(-30F, 1F, 0F, 0F)
|
||||
GL.scale(scale, scale, scale)
|
||||
matrix.push()
|
||||
matrix.translate(0.5, 0.4, 0.5)
|
||||
matrix.rotateY(tile.clientRotation.get(partialTicks) * 10F)
|
||||
matrix.translateY(-0.2)
|
||||
matrix.rotateX(-30F)
|
||||
matrix.scale(scale)
|
||||
|
||||
entity.setLocationAndAngles(x, y, z, 0F, 0F)
|
||||
MC.renderManager.renderEntity(entity, 0.0, 0.0, 0.0, 0F, partialTicks, false)
|
||||
MC.renderManager.renderEntityStatic(entity, 0.0, 0.0, 0.0, 0F, partialTicks, matrix, buffer, combinedLight)
|
||||
|
||||
GL.popMatrix()
|
||||
matrix.pop()
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.ItemRenderHelper
|
||||
import chylex.hee.client.render.util.TESSELLATOR
|
||||
import chylex.hee.client.render.util.draw
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.render.util.rotateY
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.block.entity.TileEntityJarODust
|
||||
import chylex.hee.game.block.entity.base.TileEntityBaseTable
|
||||
@ -12,58 +10,58 @@ import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.Vec3
|
||||
import chylex.hee.system.util.addY
|
||||
import chylex.hee.system.util.center
|
||||
import chylex.hee.system.util.color.IntColor.Companion.RGBA
|
||||
import chylex.hee.system.util.getTile
|
||||
import chylex.hee.system.util.lookPosVec
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.ItemRenderer
|
||||
import net.minecraft.client.renderer.LightTexture
|
||||
import net.minecraft.client.renderer.RenderTypeLookup
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType.GUI
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.client.ForgeHooksClient
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil
|
||||
import org.lwjgl.opengl.GL11.GL_QUADS
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileTable : TileEntityRenderer<TileEntityBaseTable>(){
|
||||
private val COLOR = RGBA(180, 180, 180, 120).i
|
||||
private const val Y_OFFSET = 0.8F
|
||||
class RenderTileTable(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityBaseTable>(dispatcher){
|
||||
private companion object{
|
||||
private const val COLOR_SHADE = 80F / 255F
|
||||
private const val COLOR_ALPHA = 30F / 255F
|
||||
private val LIGHT = LightTexture.packLight(15, 0)
|
||||
|
||||
private const val Y_OFFSET = 0.8
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityBaseTable, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int){
|
||||
override fun render(tile: TileEntityBaseTable, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
val world = tile.world ?: return
|
||||
val dustType = tile.tableDustType ?: return
|
||||
|
||||
if (tile.pos.up().getTile<TileEntityJarODust>(world)?.layers?.getDustType(DustLayers.Side.BOTTOM) == dustType){
|
||||
return
|
||||
}
|
||||
|
||||
ItemRenderHelper.beginItemModel()
|
||||
GL.pushMatrix()
|
||||
GL.translate(x, y, z)
|
||||
GL.pushMatrix()
|
||||
|
||||
val rotation = (MC.systemTime % 360000L) / 25F
|
||||
val center = tile.pos.center.addY(Y_OFFSET.toDouble())
|
||||
val center = tile.pos.center.addY(Y_OFFSET)
|
||||
val flip = if (center.subtract(MC.player!!.lookPosVec).dotProduct(Vec3.fromYaw(360F - rotation)) > 0.0) 180F else 0F
|
||||
|
||||
GL.translate(0.5F, 0.5F + Y_OFFSET, 0.5F)
|
||||
GL.rotate(rotation + flip, 0F, 1F, 0F)
|
||||
GL.scale(0.5F, 0.5F, 0.02F)
|
||||
matrix.push()
|
||||
matrix.translate(0.5, 0.5 + Y_OFFSET, 0.5)
|
||||
matrix.rotateY(rotation + flip)
|
||||
matrix.scale(0.5F, 0.5F, 0.02F)
|
||||
matrix.translate(-0.5, -0.5, -0.5)
|
||||
|
||||
val itemStack = ItemStack(dustType.item)
|
||||
val itemModel = ForgeHooksClient.handleCameraTransforms(ItemRenderHelper.getItemModel(itemStack), GUI, false)
|
||||
val itemModel = ForgeHooksClient.handleCameraTransforms(matrix, ModelHelper.getItemModel(itemStack), GUI, false)
|
||||
|
||||
GL.setLightmapCoords(61680F, 0F)
|
||||
GL.translate(-0.5F, -0.5F, -0.5F)
|
||||
val mat = matrix.last
|
||||
val builder = ItemRenderer.getBuffer(buffer, RenderTypeLookup.getRenderType(itemStack), true /* isItem */, false /* hasGlint */)
|
||||
|
||||
TESSELLATOR.draw(GL_QUADS, DefaultVertexFormats.ITEM){
|
||||
val quads = itemModel.getQuads(null, null, tile.wrld.rand)
|
||||
|
||||
for(quad in quads){
|
||||
LightUtil.renderQuadColor(this, quad, COLOR)
|
||||
}
|
||||
for(quad in itemModel.getQuads(null, null, tile.wrld.rand)){
|
||||
builder.addVertexData(mat, quad, COLOR_SHADE, COLOR_SHADE, COLOR_SHADE, COLOR_ALPHA, LIGHT, OverlayTexture.NO_OVERLAY)
|
||||
}
|
||||
|
||||
GL.popMatrix()
|
||||
GL.popMatrix()
|
||||
ItemRenderHelper.endItemModel()
|
||||
matrix.pop()
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,16 @@
|
||||
package chylex.hee.client.render.block
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.ItemRenderHelper
|
||||
import chylex.hee.client.render.util.TESSELLATOR
|
||||
import chylex.hee.client.render.util.draw
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.render.util.GL.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.GL.DF_ZERO
|
||||
import chylex.hee.client.render.util.GL.SF_ONE
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.RenderStateBuilder
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.ALPHA_NONE
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.CULL_DISABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.LIGHTING_ENABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.MASK_COLOR
|
||||
import chylex.hee.client.render.util.rotateY
|
||||
import chylex.hee.client.render.util.translateZ
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.block.BlockTablePedestal
|
||||
import chylex.hee.game.block.entity.TileEntityTablePedestal
|
||||
@ -12,57 +20,64 @@ import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.nextFloat
|
||||
import chylex.hee.system.util.size
|
||||
import chylex.hee.system.util.toRadians
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.ItemRenderer
|
||||
import net.minecraft.client.renderer.Matrix4f
|
||||
import net.minecraft.client.renderer.model.IBakedModel
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType.GROUND
|
||||
import net.minecraft.client.renderer.texture.TextureManager
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.client.ForgeHooksClient
|
||||
import org.lwjgl.opengl.GL11.GL_ALWAYS
|
||||
import org.lwjgl.opengl.GL11.GL_GREATER
|
||||
import org.lwjgl.opengl.GL11.GL_QUADS
|
||||
import org.lwjgl.opengl.GL11
|
||||
import java.util.Collections
|
||||
import java.util.Random
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileTablePedestal : TileEntityRenderer<TileEntityTablePedestal>(){
|
||||
private val TEX_SHADOW = Resource.Vanilla("textures/misc/shadow.png")
|
||||
private val RAND = Random()
|
||||
|
||||
private const val SHADOW_XZ_MIN = 0.325
|
||||
private const val SHADOW_XZ_MAX = 0.675
|
||||
private val SHADOW_Y = BlockTablePedestal.COMBINED_BOX.maxY + 0.0015625 // between the top of the pedestal and the status indicator
|
||||
|
||||
private const val SPREAD_DEPTH_PER_2D_MODEL = 0.09375F
|
||||
private const val SPREAD_RAND_2D = 0.13125F
|
||||
private const val SPREAD_RAND_3D_XZ = 0.2625F
|
||||
private const val SPREAD_RAND_3D_Y = 0.39375F
|
||||
|
||||
private val ITEM_ANGLES = (1..9).run {
|
||||
val section = 360F / endInclusive
|
||||
map { (it - 0.5F) * section }
|
||||
}
|
||||
|
||||
private fun getItemModelCount(stackSize: Int) = when{
|
||||
stackSize > 48 -> 5
|
||||
stackSize > 32 -> 4
|
||||
stackSize > 16 -> 3
|
||||
stackSize > 1 -> 2
|
||||
else -> 1
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityTablePedestal, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int){
|
||||
val textureManager = MC.textureManager
|
||||
val itemRenderer = MC.itemRenderer
|
||||
class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityTablePedestal>(dispatcher){
|
||||
private companion object{
|
||||
private val RAND = Random()
|
||||
|
||||
ItemRenderHelper.beginItemModel()
|
||||
GL.pushMatrix()
|
||||
GL.translate(x, y, z)
|
||||
private val RENDER_TYPE_SHADOW = with(RenderStateBuilder()){
|
||||
tex(Resource.Vanilla("textures/misc/shadow.png"))
|
||||
blend(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA, SF_ONE, DF_ZERO)
|
||||
lighting(LIGHTING_ENABLED)
|
||||
alpha(ALPHA_NONE)
|
||||
cull(CULL_DISABLED)
|
||||
mask(MASK_COLOR)
|
||||
buildType("hee:table_pedestal_shadow", DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, bufferSize = 256)
|
||||
}
|
||||
|
||||
private const val SHADOW_XZ_MIN = 0.325F
|
||||
private const val SHADOW_XZ_MAX = 0.675F
|
||||
private val SHADOW_Y = (BlockTablePedestal.COMBINED_BOX.maxY + 0.0015625).toFloat() // between the top of the pedestal and the status indicator
|
||||
|
||||
private const val SPREAD_DEPTH_PER_2D_MODEL = 0.09375
|
||||
private const val SPREAD_RAND_2D = 0.13125
|
||||
private const val SPREAD_RAND_3D_XZ = 0.2625
|
||||
private const val SPREAD_RAND_3D_Y = 0.39375
|
||||
|
||||
private val ITEM_ANGLES = (1..9).run {
|
||||
val section = 360F / endInclusive
|
||||
map { (it - 0.5F) * section }
|
||||
}
|
||||
|
||||
private fun getItemModelCount(stackSize: Int) = when{
|
||||
stackSize > 48 -> 5
|
||||
stackSize > 32 -> 4
|
||||
stackSize > 16 -> 3
|
||||
stackSize > 1 -> 2
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityTablePedestal, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
val itemRenderer = MC.itemRenderer
|
||||
|
||||
val pos = tile.pos
|
||||
val stacks = tile.stacksForRendering
|
||||
@ -76,20 +91,17 @@ object RenderTileTablePedestal : TileEntityRenderer<TileEntityTablePedestal>(){
|
||||
ITEM_ANGLES.toMutableList()
|
||||
|
||||
val shadowAlpha = if (MC.settings.entityShadows)
|
||||
(0.75 * (1.0 - (MC.renderManager.getDistanceToCamera(x, y, z) / 256.0))).toFloat().coerceAtMost(1F)
|
||||
(0.4 * (1.0 - (MC.renderManager.getDistanceToCamera(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5) / 320.0))).toFloat().coerceIn(0F, 1F)
|
||||
else
|
||||
0F
|
||||
|
||||
for((index, stack) in stacks.withIndex()){
|
||||
renderItemStack(textureManager, itemRenderer, stack, index, itemRotation, baseSeed, offsetAngleIndices, shadowAlpha)
|
||||
renderItemStack(matrix, buffer, itemRenderer, stack, index, itemRotation, baseSeed, offsetAngleIndices, shadowAlpha, combinedLight)
|
||||
}
|
||||
|
||||
GL.popMatrix()
|
||||
ItemRenderHelper.endItemModel()
|
||||
}
|
||||
|
||||
private fun renderItemStack(textureManager: TextureManager, renderer: ItemRenderer, stack: ItemStack, index: Int, baseRotation: Float, baseSeed: Long, offsetAngleIndices: MutableList<Float>, shadowAlpha: Float){
|
||||
GL.pushMatrix()
|
||||
private fun renderItemStack(matrix: MatrixStack, buffer: IRenderTypeBuffer, renderer: ItemRenderer, stack: ItemStack, index: Int, baseRotation: Float, baseSeed: Long, offsetAngleIndices: MutableList<Float>, shadowAlpha: Float, combinedLight: Int){
|
||||
matrix.push()
|
||||
|
||||
var offsetY = 0F
|
||||
var rotationMp = 1F
|
||||
@ -98,82 +110,74 @@ object RenderTileTablePedestal : TileEntityRenderer<TileEntityTablePedestal>(){
|
||||
val seed = baseSeed + (Item.getIdFromItem(stack.item) xor (33867 shl index))
|
||||
RAND.setSeed(seed)
|
||||
|
||||
val locDistance = RAND.nextFloat(0.26F, 0.29F)
|
||||
val locDistance = RAND.nextFloat(0.26, 0.29)
|
||||
val locIndex = RAND.nextInt(offsetAngleIndices.size)
|
||||
val locAngle = (offsetAngleIndices.removeAt(locIndex) + RAND.nextFloat(-3F, 3F)).toRadians()
|
||||
|
||||
GL.translate(cos(locAngle) * locDistance, 0F, sin(locAngle) * locDistance)
|
||||
matrix.translate(cos(locAngle) * locDistance, 0.0, sin(locAngle) * locDistance)
|
||||
|
||||
offsetY = RAND.nextFloat(0F, 0.05F)
|
||||
rotationMp = RAND.nextFloat(0.4F, 1.2F)
|
||||
}
|
||||
|
||||
if (shadowAlpha > 0F){
|
||||
GL.depthMask(false)
|
||||
GL.alphaFunc(GL_ALWAYS, 0F)
|
||||
textureManager.bindTexture(TEX_SHADOW)
|
||||
|
||||
renderShadow(shadowAlpha)
|
||||
|
||||
GL.depthMask(true)
|
||||
GL.alphaFunc(GL_GREATER, 0.1F)
|
||||
textureManager.bindTexture(ItemRenderHelper.TEX_BLOCKS_ITEMS)
|
||||
renderShadow(buffer, matrix.last.matrix, shadowAlpha)
|
||||
}
|
||||
|
||||
val baseModel = ItemRenderHelper.getItemModel(stack)
|
||||
val baseModel = ModelHelper.getItemModel(stack)
|
||||
val isModel3D = baseModel.isGui3d
|
||||
|
||||
val baseY = if (isModel3D) 0.8325F else 1F
|
||||
val baseY = if (isModel3D) 0.8325 else 1.0
|
||||
|
||||
GL.translate(0.5F, baseY + offsetY, 0.5F)
|
||||
GL.rotate(baseRotation * rotationMp, 0F, 1F, 0F)
|
||||
renderItemWithSpread(renderer, stack, ForgeHooksClient.handleCameraTransforms(baseModel, GROUND, false), isModel3D)
|
||||
matrix.translate(0.5, baseY + offsetY, 0.5)
|
||||
matrix.rotateY(baseRotation * rotationMp)
|
||||
renderItemWithSpread(matrix, buffer, renderer, stack, baseModel, isModel3D, combinedLight)
|
||||
|
||||
GL.popMatrix()
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
private fun renderItemWithSpread(renderer: ItemRenderer, stack: ItemStack, model: IBakedModel, isModel3D: Boolean){
|
||||
private fun renderItemWithSpread(matrix: MatrixStack, buffer: IRenderTypeBuffer, renderer: ItemRenderer, stack: ItemStack, model: IBakedModel, isModel3D: Boolean, combinedLight: Int){
|
||||
val extraModels = getItemModelCount(stack.size) - 1
|
||||
|
||||
if (extraModels > 0){
|
||||
RAND.setSeed(Item.getIdFromItem(stack.item).toLong())
|
||||
|
||||
if (!isModel3D){
|
||||
GL.translate(0F, 0F, -SPREAD_DEPTH_PER_2D_MODEL * (extraModels / 2F))
|
||||
matrix.translateZ(-SPREAD_DEPTH_PER_2D_MODEL * (extraModels / 2.0))
|
||||
}
|
||||
}
|
||||
|
||||
renderer.renderItem(stack, model)
|
||||
renderer.renderItem(stack, GROUND, false, matrix, buffer, combinedLight, OverlayTexture.NO_OVERLAY, model)
|
||||
|
||||
repeat(extraModels){
|
||||
GL.pushMatrix()
|
||||
matrix.push()
|
||||
|
||||
if (isModel3D){
|
||||
GL.translate(
|
||||
matrix.translate(
|
||||
RAND.nextFloat(-SPREAD_RAND_3D_XZ, SPREAD_RAND_3D_XZ),
|
||||
RAND.nextFloat(-SPREAD_RAND_3D_Y, SPREAD_RAND_3D_Y),
|
||||
RAND.nextFloat(-SPREAD_RAND_3D_XZ, SPREAD_RAND_3D_XZ)
|
||||
)
|
||||
}
|
||||
else{
|
||||
GL.translate(
|
||||
matrix.translate(
|
||||
RAND.nextFloat(-SPREAD_RAND_2D, SPREAD_RAND_2D),
|
||||
RAND.nextFloat(-SPREAD_RAND_2D, SPREAD_RAND_2D),
|
||||
SPREAD_DEPTH_PER_2D_MODEL * (it + 1)
|
||||
)
|
||||
}
|
||||
|
||||
renderer.renderItem(stack, model)
|
||||
GL.popMatrix()
|
||||
renderer.renderItem(stack, GROUND, false, matrix, buffer, combinedLight, OverlayTexture.NO_OVERLAY, model)
|
||||
matrix.pop()
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderShadow(alpha: Float){
|
||||
TESSELLATOR.draw(GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR){
|
||||
pos(SHADOW_XZ_MIN, SHADOW_Y, SHADOW_XZ_MIN).tex(0.0, 0.0).color(1F, 1F, 1F, alpha).endVertex()
|
||||
pos(SHADOW_XZ_MIN, SHADOW_Y, SHADOW_XZ_MAX).tex(0.0, 1.0).color(1F, 1F, 1F, alpha).endVertex()
|
||||
pos(SHADOW_XZ_MAX, SHADOW_Y, SHADOW_XZ_MAX).tex(1.0, 1.0).color(1F, 1F, 1F, alpha).endVertex()
|
||||
pos(SHADOW_XZ_MAX, SHADOW_Y, SHADOW_XZ_MIN).tex(1.0, 0.0).color(1F, 1F, 1F, alpha).endVertex()
|
||||
private fun renderShadow(buffer: IRenderTypeBuffer, mat: Matrix4f, alpha: Float){
|
||||
with(buffer.getBuffer(RENDER_TYPE_SHADOW)){
|
||||
pos(mat, SHADOW_XZ_MIN, SHADOW_Y, SHADOW_XZ_MIN).color(1F, 1F, 1F, alpha).tex(0F, 0F).endVertex()
|
||||
pos(mat, SHADOW_XZ_MIN, SHADOW_Y, SHADOW_XZ_MAX).color(1F, 1F, 1F, alpha).tex(0F, 1F).endVertex()
|
||||
pos(mat, SHADOW_XZ_MAX, SHADOW_Y, SHADOW_XZ_MAX).color(1F, 1F, 1F, alpha).tex(1F, 1F).endVertex()
|
||||
pos(mat, SHADOW_XZ_MAX, SHADOW_Y, SHADOW_XZ_MIN).color(1F, 1F, 1F, alpha).tex(1F, 0F).endVertex()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,12 @@ import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.closestTickingTile
|
||||
import chylex.hee.system.util.getState
|
||||
import chylex.hee.system.util.math.LerpedFloat
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object RenderTileVoidPortal : RenderTileAbstractPortal<TileEntityPortalInner.Void, IVoidPortalController>(){
|
||||
class RenderTileVoidPortal(dispatcher: TileEntityRendererDispatcher) : RenderTileAbstractPortal<TileEntityPortalInner.Void, IVoidPortalController>(dispatcher){
|
||||
private object ActiveReturnController : IVoidPortalController{
|
||||
override val currentInstance = THE_HUB_INSTANCE
|
||||
override val clientAnimationProgress = LerpedFloat(1F)
|
||||
|
@ -1,22 +1,23 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.model.entity.ModelEntityBossEnderEye
|
||||
import chylex.hee.client.model.entity.ModelEntityBossEnderEye.SCALE
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.scale
|
||||
import chylex.hee.game.entity.living.EntityBossEnderEye
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.RenderLiving
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityBossEnderEye(manager: RenderManager) : RenderLiving<EntityBossEnderEye, ModelEntityBossEnderEye>(manager, ModelEntityBossEnderEye, SCALE){
|
||||
private val texture = Resource.Custom("textures/entity/ender_eye.png")
|
||||
|
||||
override fun preRenderCallback(entity: EntityBossEnderEye, partialTicks: Float){
|
||||
GL.scale(SCALE, SCALE, SCALE)
|
||||
super.preRenderCallback(entity, partialTicks)
|
||||
override fun preRenderCallback(entity: EntityBossEnderEye, matrix: MatrixStack, partialTicks: Float){
|
||||
matrix.scale(SCALE)
|
||||
super.preRenderCallback(entity, matrix, partialTicks)
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityBossEnderEye): ResourceLocation{
|
||||
|
@ -0,0 +1,9 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityItem(manager: RenderManager) : ItemRenderer(manager, MC.itemRenderer)
|
@ -2,10 +2,10 @@ package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.RenderEntityItem
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityItemNoBob(manager: RenderManager) : RenderEntityItem(manager, MC.itemRenderer){
|
||||
class RenderEntityItemNoBob(manager: RenderManager) : ItemRenderer(manager, MC.itemRenderer){
|
||||
override fun shouldBob() = false
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.GL.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.RenderStateBuilder
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.CULL_DISABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.LIGHTING_ENABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.LIGHTMAP_ENABLED
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.MASK_COLOR
|
||||
import chylex.hee.client.render.util.RenderStateBuilder.Companion.OVERLAY_DISABLED
|
||||
import chylex.hee.game.entity.living.EntityMobAbstractEnderman
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
@ -10,24 +15,63 @@ import chylex.hee.system.migration.vanilla.RenderEnderman
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import chylex.hee.system.util.nextFloat
|
||||
import chylex.hee.system.util.totalTime
|
||||
import org.lwjgl.opengl.GL11.GL_GREATER
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer
|
||||
import net.minecraft.client.renderer.entity.model.EndermanModel
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.entity.monster.EndermanEntity
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11
|
||||
import java.util.Random
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
open class RenderEntityMobAbstractEnderman(manager: RenderManager) : RenderEnderman(manager){
|
||||
private val rand = Random()
|
||||
private companion object{
|
||||
private fun RENDER_TYPE_CLONE(tex: ResourceLocation) = with(RenderStateBuilder()){
|
||||
tex(tex)
|
||||
blend(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA)
|
||||
lighting(LIGHTING_ENABLED)
|
||||
alpha(0.004F)
|
||||
cull(CULL_DISABLED)
|
||||
lightmap(LIGHTMAP_ENABLED)
|
||||
overlay(OVERLAY_DISABLED)
|
||||
mask(MASK_COLOR)
|
||||
buildType("hee:enderman_clone", DefaultVertexFormats.ENTITY, GL11.GL_QUADS, bufferSize = 256, useDelegate = true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun doRender(entity: EntityEnderman, x: Double, y: Double, z: Double, rotationYaw: Float, partialTicks: Float){
|
||||
private val rand = Random()
|
||||
private val originalLayerList: List<LayerRenderer<EntityEnderman, EndermanModel<EntityEnderman>>>
|
||||
private var isRenderingClone = false
|
||||
|
||||
init{
|
||||
entityModel = object : EndermanModel<EntityEnderman>(0F){
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
super.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, if (isRenderingClone) rand.nextFloat(0.05F, 0.3F) else alpha)
|
||||
}
|
||||
}
|
||||
|
||||
originalLayerList = ArrayList(layerRenderers)
|
||||
}
|
||||
|
||||
override fun render(entity: EndermanEntity, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
if (entity !is EntityMobAbstractEnderman){
|
||||
return
|
||||
}
|
||||
|
||||
if (entity.isShaking){
|
||||
rand.setSeed(entity.world.totalTime)
|
||||
super.doRender(entity, x + (rand.nextGaussian() * 0.01), y + (rand.nextGaussian() * 0.01), z + (rand.nextGaussian() * 0.01), rotationYaw, partialTicks)
|
||||
|
||||
matrix.push()
|
||||
matrix.translate(rand.nextGaussian() * 0.01, rand.nextGaussian() * 0.01, rand.nextGaussian() * 0.01)
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
matrix.pop()
|
||||
}
|
||||
else{
|
||||
super.doRender(entity, x, y, z, rotationYaw, partialTicks)
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
}
|
||||
|
||||
val cloneCount = getCloneCount(entity)
|
||||
@ -41,13 +85,10 @@ open class RenderEntityMobAbstractEnderman(manager: RenderManager) : RenderEnder
|
||||
val prevPrevPitch = entity.prevRotationPitch
|
||||
val prevPitch = entity.rotationPitch
|
||||
|
||||
isRenderingClone = true
|
||||
layerRenderers.clear()
|
||||
|
||||
repeat(cloneCount){
|
||||
GL.enableBlend()
|
||||
GL.blendFunc(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA)
|
||||
GL.alphaFunc(GL_GREATER, 0.004F)
|
||||
GL.depthMask(false)
|
||||
GL.color(1F, 1F, 1F, rand.nextFloat(0.05F, 0.3F))
|
||||
|
||||
if (rand.nextInt(3) == 0){
|
||||
entity.rotationYawHead += rand.nextFloat(-45F, 45F)
|
||||
entity.prevRotationYawHead = entity.rotationYawHead
|
||||
@ -56,7 +97,10 @@ open class RenderEntityMobAbstractEnderman(manager: RenderManager) : RenderEnder
|
||||
entity.prevRotationPitch = entity.rotationPitch
|
||||
}
|
||||
|
||||
super.doRender(entity, x + rand.nextGaussian() * 0.04, y + rand.nextGaussian() * 0.025, z + rand.nextGaussian() * 0.04, rotationYaw, partialTicks)
|
||||
matrix.push()
|
||||
matrix.translate(rand.nextGaussian() * 0.04, rand.nextGaussian() * 0.025, rand.nextGaussian() * 0.04)
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
entity.prevRotationYawHead = prevPrevYaw
|
||||
@ -65,13 +109,19 @@ open class RenderEntityMobAbstractEnderman(manager: RenderManager) : RenderEnder
|
||||
entity.prevRotationPitch = prevPrevPitch
|
||||
entity.rotationPitch = prevPitch
|
||||
|
||||
GL.depthMask(true)
|
||||
GL.alphaFunc(GL_GREATER, 0.1F)
|
||||
GL.disableBlend()
|
||||
layerRenderers.addAll(originalLayerList)
|
||||
isRenderingClone = false
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun getCloneCount(entity: EntityMobAbstractEnderman): Int{
|
||||
return if (entity.hurtTime == 0 && entity.isAggro) 2 else 0
|
||||
}
|
||||
|
||||
override fun func_230042_a_(entity: EndermanEntity, isVisible: Boolean, isTranslucent: Boolean): RenderType?{
|
||||
return if (isRenderingClone)
|
||||
RENDER_TYPE_CLONE(getEntityTexture(entity))
|
||||
else
|
||||
super.func_230042_a_(entity, isVisible, isTranslucent)
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +1,53 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.render.entity.layer.LayerSpiderlingEyes
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.scale
|
||||
import chylex.hee.game.entity.living.EntityMobSpiderling
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.RenderLiving
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import chylex.hee.system.util.Pos
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.floorToInt
|
||||
import chylex.hee.system.util.isLoaded
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.LightTexture
|
||||
import net.minecraft.client.renderer.entity.model.SpiderModel
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.world.LightType.BLOCK
|
||||
import net.minecraft.world.LightType.SKY
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityMobSpiderling(manager: RenderManager) : RenderLiving<EntityMobSpiderling, SpiderModel<EntityMobSpiderling>>(manager, SpiderModel(), 0.5F){
|
||||
private val texture = Resource.Custom("textures/entity/spiderling.png")
|
||||
|
||||
init{
|
||||
addLayer(LayerSpiderlingEyes(this, (entityModel as SpiderModel).field_78209_a)) // RENAME spiderHead
|
||||
addLayer(LayerSpiderlingEyes(this, (entityModel as SpiderModel).spiderHead))
|
||||
}
|
||||
|
||||
override fun preRenderCallback(entity: EntityMobSpiderling, partialTicks: Float){
|
||||
GL.scale(0.5F, 0.5F, 0.5F)
|
||||
super.preRenderCallback(entity, partialTicks)
|
||||
override fun preRenderCallback(entity: EntityMobSpiderling, matrix: MatrixStack, partialTicks: Float){
|
||||
matrix.scale(0.5F)
|
||||
super.preRenderCallback(entity, matrix, partialTicks)
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityMobSpiderling): ResourceLocation{
|
||||
return texture
|
||||
}
|
||||
|
||||
override fun getPackedLight(entity: EntityMobSpiderling, partialTicks: Float): Int{
|
||||
val world = entity.world
|
||||
val pos = Pos(entity)
|
||||
|
||||
if (!pos.isLoaded(world)){
|
||||
return 0
|
||||
}
|
||||
|
||||
val sky = (world.getLightFor(SKY, pos) * 0.77).floorToInt()
|
||||
val block = (world.getLightFor(BLOCK, pos) * 0.77).floorToInt()
|
||||
|
||||
return LightTexture.packLight(sky, block)
|
||||
}
|
||||
|
||||
override fun getDeathMaxRotation(entity: EntityMobSpiderling): Float{
|
||||
return 180F
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.model.entity.ModelEntityUndread
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.game.entity.living.EntityMobUndread
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.RenderBiped
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.entity.layers.BipedArmorLayer
|
||||
import net.minecraft.client.renderer.entity.model.AbstractZombieModel
|
||||
import net.minecraft.util.ResourceLocation
|
||||
@ -19,9 +19,9 @@ class RenderEntityMobUndread(manager: RenderManager) : RenderBiped<EntityMobUndr
|
||||
addLayer(BipedArmorLayer(this, ModelEntityUndread(0.5125F, true), ModelEntityUndread(1F, true)))
|
||||
}
|
||||
|
||||
override fun preRenderCallback(entity: EntityMobUndread, partialTicks: Float){
|
||||
GL.scale(1.025F, 0.965F, 1.025F)
|
||||
super.preRenderCallback(entity, partialTicks)
|
||||
override fun preRenderCallback(entity: EntityMobUndread, matrix: MatrixStack, partialTicks: Float){
|
||||
matrix.scale(1.025F, 0.965F, 1.025F)
|
||||
super.preRenderCallback(entity, matrix, partialTicks)
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityMobUndread): ResourceLocation{
|
||||
|
@ -1,5 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.scale
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.entity.living.EntityMobVillagerDying
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
@ -8,38 +8,53 @@ import chylex.hee.system.migration.vanilla.RenderLiving
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.totalTime
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.entity.layers.CrossedArmsItemLayer
|
||||
import net.minecraft.client.renderer.entity.layers.HeadLayer
|
||||
import net.minecraft.client.renderer.entity.layers.VillagerHeldItemLayer
|
||||
import net.minecraft.client.renderer.entity.layers.VillagerLevelPendantLayer
|
||||
import net.minecraft.client.renderer.entity.model.VillagerModel
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.resources.IReloadableResourceManager
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import java.util.Random
|
||||
import kotlin.math.min
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityMobVillagerDying(manager: RenderManager) : RenderLiving<EntityMobVillagerDying, VillagerModel<EntityMobVillagerDying>>(manager, VillagerModel(0F), 0.5F){
|
||||
class RenderEntityMobVillagerDying(manager: RenderManager) : RenderLiving<EntityMobVillagerDying, VillagerModel<EntityMobVillagerDying>>(manager, Model, 0.5F){
|
||||
private object Model : VillagerModel<EntityMobVillagerDying>(0F){
|
||||
private val overrideOverlay = OverlayTexture.getPackedUV(OverlayTexture.getU(0F), OverlayTexture.getV(false)) // disable red hurt overlay
|
||||
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
super.render(matrix, builder, combinedLight, overrideOverlay, red, green, blue, alpha)
|
||||
}
|
||||
}
|
||||
|
||||
private val rand = Random()
|
||||
private val texture = Resource.Vanilla("textures/entity/villager/villager.png")
|
||||
|
||||
init{
|
||||
addLayer(HeadLayer(this))
|
||||
addLayer(VillagerLevelPendantLayer(this, MC.instance.resourceManager as IReloadableResourceManager, "villager"))
|
||||
addLayer(VillagerHeldItemLayer(this))
|
||||
addLayer(CrossedArmsItemLayer(this))
|
||||
}
|
||||
|
||||
override fun doRender(entity: EntityMobVillagerDying, x: Double, y: Double, z: Double, rotationYaw: Float, partialTicks: Float){
|
||||
override fun render(entity: EntityMobVillagerDying, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
rand.setSeed(entity.world.totalTime)
|
||||
|
||||
val mp = min(1F, entity.deathTime / 50F) * 0.005F
|
||||
super.doRender(entity, x + (rand.nextGaussian() * mp), y + (rand.nextGaussian() * mp), z + (rand.nextGaussian() * mp), rotationYaw, partialTicks)
|
||||
|
||||
matrix.push()
|
||||
matrix.translate(rand.nextGaussian() * mp, rand.nextGaussian() * mp, rand.nextGaussian() * mp)
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityMobVillagerDying): ResourceLocation{
|
||||
return texture
|
||||
}
|
||||
|
||||
override fun preRenderCallback(entity: EntityMobVillagerDying, partialTicks: Float){
|
||||
override fun preRenderCallback(entity: EntityMobVillagerDying, matrix: MatrixStack, partialTicks: Float){
|
||||
val scale: Float
|
||||
|
||||
if (entity.isChild){
|
||||
@ -51,17 +66,7 @@ class RenderEntityMobVillagerDying(manager: RenderManager) : RenderLiving<Entity
|
||||
shadowSize = 0.5F
|
||||
}
|
||||
|
||||
GL.scale(scale, scale, scale)
|
||||
}
|
||||
|
||||
override fun setBrightness(entity: EntityMobVillagerDying, partialTicks: Float, combineTextures: Boolean): Boolean{
|
||||
val prevDeathTime = entity.deathTime
|
||||
entity.deathTime = 0
|
||||
|
||||
val result = super.setBrightness(entity, partialTicks, combineTextures)
|
||||
|
||||
entity.deathTime = prevDeathTime
|
||||
return result
|
||||
matrix.scale(scale)
|
||||
}
|
||||
|
||||
override fun getDeathMaxRotation(entity: EntityMobVillagerDying): Float{
|
||||
|
@ -3,12 +3,12 @@ import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.Render
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import net.minecraft.client.renderer.culling.ICamera
|
||||
import net.minecraft.client.renderer.culling.ClippingHelperImpl
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityNothing(manager: RenderManager) : Render<Entity>(manager){
|
||||
override fun shouldRender(entity: Entity, camera: ICamera, camX: Double, camY: Double, camZ: Double) = false
|
||||
override fun shouldRender(entity: Entity, camera: ClippingHelperImpl, camX: Double, camY: Double, camZ: Double) = false
|
||||
override fun getEntityTexture(entity: Entity): ResourceLocation? = null
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.ItemRenderHelper
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.render.util.rotateY
|
||||
import chylex.hee.client.render.util.translateY
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.entity.projectile.EntityProjectileEyeOfEnder
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
@ -8,10 +9,13 @@ import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.Items
|
||||
import chylex.hee.system.migration.vanilla.Render
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType.GROUND
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.inventory.container.PlayerContainer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraftforge.client.ForgeHooksClient
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityProjectileEyeOfEnder(manager: RenderManager) : Render<EntityProjectileEyeOfEnder>(manager){
|
||||
@ -19,33 +23,19 @@ class RenderEntityProjectileEyeOfEnder(manager: RenderManager) : Render<EntityPr
|
||||
private val RENDERED_ITEM = ItemStack(Items.ENDER_EYE)
|
||||
}
|
||||
|
||||
override fun doRender(entity: EntityProjectileEyeOfEnder, x: Double, y: Double, z: Double, rotationYaw: Float, partialTicks: Float){
|
||||
ItemRenderHelper.beginItemModel()
|
||||
GL.pushMatrix()
|
||||
override fun render(entity: EntityProjectileEyeOfEnder, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
matrix.push()
|
||||
matrix.translateY(entity.renderBob.get(partialTicks))
|
||||
matrix.rotateY(yaw)
|
||||
|
||||
GL.translate(x, y + entity.renderBob.get(partialTicks), z)
|
||||
GL.rotate(rotationYaw, 0F, 1F, 0F)
|
||||
GL.color(1F, 1F, 1F, 1F)
|
||||
MC.itemRenderer.renderItem(RENDERED_ITEM, GROUND, false, matrix, buffer, combinedLight, OverlayTexture.NO_OVERLAY, ModelHelper.getItemModel(RENDERED_ITEM))
|
||||
|
||||
if (renderOutlines){
|
||||
GL.enableColorMaterial()
|
||||
GL.enableOutlineMode(getTeamColor(entity))
|
||||
}
|
||||
matrix.pop()
|
||||
|
||||
MC.itemRenderer.renderItem(RENDERED_ITEM, ForgeHooksClient.handleCameraTransforms(ItemRenderHelper.getItemModel(RENDERED_ITEM), GROUND, false))
|
||||
|
||||
if (renderOutlines){
|
||||
GL.disableOutlineMode()
|
||||
GL.disableColorMaterial()
|
||||
}
|
||||
|
||||
GL.popMatrix()
|
||||
ItemRenderHelper.endItemModel()
|
||||
|
||||
super.doRender(entity, x, y, z, rotationYaw, partialTicks)
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityProjectileEyeOfEnder): ResourceLocation{
|
||||
return ItemRenderHelper.TEX_BLOCKS_ITEMS
|
||||
return PlayerContainer.LOCATION_BLOCKS_TEXTURE
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import net.minecraft.client.renderer.entity.SpriteRenderer
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.entity.IRendersAsItem
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntitySprite<T>(manager: RenderManager) : SpriteRenderer<T>(manager, MC.itemRenderer) where T : Entity, T : IRendersAsItem
|
@ -1,8 +1,10 @@
|
||||
package chylex.hee.client.render.entity
|
||||
import chylex.hee.client.model.entity.ModelEntityTokenHolder
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.GL.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.rotateX
|
||||
import chylex.hee.client.render.util.rotateY
|
||||
import chylex.hee.client.render.util.rotateZ
|
||||
import chylex.hee.client.render.util.scale
|
||||
import chylex.hee.client.render.util.translateY
|
||||
import chylex.hee.game.entity.item.EntityTokenHolder
|
||||
import chylex.hee.game.item.ItemPortalToken.TokenType.NORMAL
|
||||
import chylex.hee.game.item.ItemPortalToken.TokenType.RARE
|
||||
@ -12,6 +14,10 @@ import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.Render
|
||||
import chylex.hee.system.migration.vanilla.RenderManager
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import kotlin.math.pow
|
||||
|
||||
@ -23,29 +29,24 @@ class RenderEntityTokenHolder(manager: RenderManager) : Render<EntityTokenHolder
|
||||
SOLITARY to Resource.Custom("textures/entity/token_holder_solitary.png")
|
||||
)
|
||||
|
||||
override fun doRender(entity: EntityTokenHolder, x: Double, y: Double, z: Double, rotationYaw: Float, partialTicks: Float){
|
||||
override fun render(entity: EntityTokenHolder, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
val charge = entity.renderCharge.get(partialTicks)
|
||||
val scale = 0.25F + (0.25F * charge.pow(1.5F))
|
||||
val alpha = 0.35F + (0.475F * charge.pow(5.5F))
|
||||
|
||||
GL.pushMatrix()
|
||||
GL.translate(x, y + (entity.height * 0.5F), z)
|
||||
matrix.push()
|
||||
matrix.translateY(entity.height * 0.5)
|
||||
|
||||
GL.pushMatrix()
|
||||
GL.scale(scale, scale, scale)
|
||||
GL.rotate(entity.renderRotation.get(partialTicks), 0F, 1F, 0F)
|
||||
GL.rotate(55F, 1F, 0F, 1F)
|
||||
matrix.push()
|
||||
matrix.scale(scale)
|
||||
matrix.rotateY(entity.renderRotation.get(partialTicks))
|
||||
matrix.rotateX(55F)
|
||||
matrix.rotateZ(55F)
|
||||
|
||||
GL.enableBlend()
|
||||
GL.blendFunc(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA)
|
||||
GL.color(1F, 1F, 1F, alpha)
|
||||
ModelEntityTokenHolder.render(matrix, buffer.getBuffer(RenderType.getEntityTranslucent(getEntityTexture(entity) ?: textures.getValue(NORMAL))), combinedLight, OverlayTexture.NO_OVERLAY, 1F, 1F, 1F, alpha)
|
||||
|
||||
bindEntityTexture(entity)
|
||||
ModelEntityTokenHolder.render()
|
||||
|
||||
GL.popMatrix()
|
||||
GL.disableBlend()
|
||||
GL.popMatrix()
|
||||
matrix.pop()
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityTokenHolder): ResourceLocation?{
|
||||
|
@ -1,56 +1,41 @@
|
||||
package chylex.hee.client.render.entity.layer
|
||||
import chylex.hee.client.render.entity.RenderEntityMobSpiderling
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.render.util.GL.DF_ONE
|
||||
import chylex.hee.client.render.util.GL.SF_ONE
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.client.render.util.scale
|
||||
import chylex.hee.game.entity.living.EntityMobSpiderling
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer
|
||||
import net.minecraft.client.renderer.entity.model.RendererModel
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.entity.layers.AbstractEyesLayer
|
||||
import net.minecraft.client.renderer.entity.model.SpiderModel
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class LayerSpiderlingEyes(spiderlingRenderer: RenderEntityMobSpiderling, private val headRenderer: RendererModel) : LayerRenderer<EntityMobSpiderling, SpiderModel<EntityMobSpiderling>>(spiderlingRenderer){
|
||||
private val texture = Resource.Custom("textures/entity/spiderling_eyes.png")
|
||||
class LayerSpiderlingEyes(spiderlingRenderer: RenderEntityMobSpiderling, private val headRenderer: ModelRenderer) : AbstractEyesLayer<EntityMobSpiderling, SpiderModel<EntityMobSpiderling>>(spiderlingRenderer){
|
||||
private val renderType = RenderType.getEyes(Resource.Custom("textures/entity/spiderling_eyes.png"))
|
||||
|
||||
override fun render(entity: EntityMobSpiderling, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float, ageInTicks: Float, netHeadYaw: Float, headPitch: Float, scale: Float){
|
||||
override fun render(matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, entity: EntityMobSpiderling, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float, age: Float, headYaw: Float, headPitch: Float){
|
||||
if (entity.isSleeping){
|
||||
return
|
||||
}
|
||||
|
||||
bindTexture(texture)
|
||||
|
||||
GL.disableAlpha()
|
||||
GL.enableBlend()
|
||||
GL.blendFunc(SF_ONE, DF_ONE)
|
||||
GL.depthMask(!entity.isInvisible)
|
||||
|
||||
GL.color(1F, 1F, 1F, 1F)
|
||||
GL.setLightmapCoords(61680F, 0F)
|
||||
MC.gameRenderer.setupFogColor(true)
|
||||
val builder = buffer.getBuffer(getRenderType())
|
||||
|
||||
if (headPitch == 0F){
|
||||
GL.pushMatrix()
|
||||
GL.scale(1.001, 1.001, 1.001) // hack around z-fighting
|
||||
headRenderer.render(scale)
|
||||
GL.popMatrix()
|
||||
matrix.push()
|
||||
matrix.scale(1.001F) // hack around z-fighting
|
||||
headRenderer.render(matrix, builder, 15728640, OverlayTexture.NO_OVERLAY, 1F, 1F, 1F, 1F)
|
||||
matrix.pop()
|
||||
}
|
||||
else{
|
||||
headRenderer.render(scale)
|
||||
headRenderer.render(matrix, builder, 15728640, OverlayTexture.NO_OVERLAY, 1F, 1F, 1F, 1F)
|
||||
}
|
||||
|
||||
MC.gameRenderer.setupFogColor(false)
|
||||
func_215334_a(entity) // RENAME resets lightmap
|
||||
|
||||
GL.depthMask(true)
|
||||
GL.disableBlend()
|
||||
GL.enableAlpha()
|
||||
}
|
||||
|
||||
override fun shouldCombineTextures(): Boolean{
|
||||
return false
|
||||
override fun getRenderType(): RenderType{
|
||||
return renderType
|
||||
}
|
||||
}
|
||||
|
@ -8,16 +8,17 @@ import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.remapRange
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.RenderHelper
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import net.minecraftforge.client.IRenderHandler
|
||||
import net.minecraftforge.client.SkyRenderHandler
|
||||
import org.lwjgl.opengl.GL11.GL_QUADS
|
||||
import kotlin.math.pow
|
||||
|
||||
abstract class AbstractEnvironmentRenderer : IRenderHandler{
|
||||
abstract class AbstractEnvironmentRenderer : SkyRenderHandler{
|
||||
companion object{
|
||||
val currentSkyAlpha
|
||||
@Sided(Side.CLIENT)
|
||||
@ -35,24 +36,26 @@ abstract class AbstractEnvironmentRenderer : IRenderHandler{
|
||||
val DEFAULT_COLOR = Vec3d(1.0, 1.0, 1.0)
|
||||
const val DEFAULT_ALPHA = 1F
|
||||
|
||||
fun renderPlane(y: Double, size: Double, rescale: Double){
|
||||
fun renderPlane(matrix: MatrixStack, y: Float, size: Float, rescale: Float){
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
TESSELLATOR.draw(GL_QUADS, DefaultVertexFormats.POSITION_TEX){
|
||||
pos(-size, -y, -size).tex(0.0, 0.0).endVertex()
|
||||
pos(-size, -y, size).tex(0.0, rescale).endVertex()
|
||||
pos( size, -y, size).tex(rescale, rescale).endVertex()
|
||||
pos( size, -y, -size).tex(rescale, 0.0).endVertex()
|
||||
pos(mat, -size, -y, -size).tex(0F, 0F).endVertex()
|
||||
pos(mat, -size, -y, size).tex(0F, rescale).endVertex()
|
||||
pos(mat, size, -y, size).tex(rescale, rescale).endVertex()
|
||||
pos(mat, size, -y, -size).tex(rescale, 0F).endVertex()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
final override fun render(ticks: Int, partialTicks: Float, world: ClientWorld, mc: Minecraft){
|
||||
final override fun render(ticks: Int, partialTicks: Float, matrix: MatrixStack, world: ClientWorld, mc: Minecraft){
|
||||
GL.depthMask(false)
|
||||
RenderHelper.disableStandardItemLighting()
|
||||
render(world, partialTicks)
|
||||
render(world, matrix, partialTicks)
|
||||
GL.depthMask(true)
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
abstract fun render(world: ClientWorld, partialTicks: Float)
|
||||
abstract fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float)
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package chylex.hee.client.render.territory
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
|
||||
class MultiRenderer(private vararg val renderers: AbstractEnvironmentRenderer) : AbstractEnvironmentRenderer(){
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, partialTicks: Float){
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
for(renderer in renderers){
|
||||
renderer.render(world, partialTicks)
|
||||
renderer.render(world, matrix, partialTicks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,19 @@ import chylex.hee.client.render.util.GL.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.GL.DF_ZERO
|
||||
import chylex.hee.client.render.util.GL.SF_ONE
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.rotateX
|
||||
import chylex.hee.client.render.util.rotateZ
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
import org.lwjgl.opengl.GL11.GL_GREATER
|
||||
|
||||
abstract class SkyCubeBase : AbstractEnvironmentRenderer(){
|
||||
protected companion object{
|
||||
const val DEFAULT_RESCALE = 16.0
|
||||
const val DEFAULT_DISTANCE = 125.0
|
||||
const val DEFAULT_RESCALE = 16F
|
||||
const val DEFAULT_DISTANCE = 125F
|
||||
}
|
||||
|
||||
protected open val texture = DEFAULT_TEXTURE
|
||||
@ -24,8 +27,8 @@ abstract class SkyCubeBase : AbstractEnvironmentRenderer(){
|
||||
protected open val distance = DEFAULT_DISTANCE
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, partialTicks: Float){
|
||||
val distance = distance.coerceAtMost(18.5 * MC.settings.renderDistanceChunks)
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
val distance = distance.coerceAtMost(18.5F * MC.settings.renderDistanceChunks)
|
||||
val rescale = rescale
|
||||
|
||||
GL.enableBlend()
|
||||
@ -35,21 +38,21 @@ abstract class SkyCubeBase : AbstractEnvironmentRenderer(){
|
||||
GL.disableFog()
|
||||
|
||||
GL.color(color, alpha * currentSkyAlpha)
|
||||
MC.textureManager.bindTexture(texture)
|
||||
GL.bindTexture(texture)
|
||||
|
||||
for(side in 0..5){
|
||||
GL.pushMatrix()
|
||||
matrix.push()
|
||||
|
||||
when(side){
|
||||
1 -> GL.rotate( 90F, 1F, 0F, 0F)
|
||||
2 -> GL.rotate(-90F, 1F, 0F, 0F)
|
||||
3 -> GL.rotate(180F, 1F, 0F, 0F)
|
||||
4 -> GL.rotate( 90F, 0F, 0F, 1F)
|
||||
5 -> GL.rotate(-90F, 0F, 0F, 1F)
|
||||
1 -> matrix.rotateX( 90F)
|
||||
2 -> matrix.rotateX(-90F)
|
||||
3 -> matrix.rotateX(180F)
|
||||
4 -> matrix.rotateZ( 90F)
|
||||
5 -> matrix.rotateZ(-90F)
|
||||
}
|
||||
|
||||
renderPlane(distance, distance, rescale)
|
||||
GL.popMatrix()
|
||||
renderPlane(matrix, distance, distance, rescale)
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
GL.enableFog()
|
||||
|
@ -6,6 +6,6 @@ class SkyCubeStatic(
|
||||
override val texture: ResourceLocation = DEFAULT_TEXTURE,
|
||||
override val color: Vec3d = DEFAULT_COLOR,
|
||||
override val alpha: Float = DEFAULT_ALPHA,
|
||||
override val rescale: Double = DEFAULT_RESCALE,
|
||||
override val distance: Double = DEFAULT_DISTANCE
|
||||
override val rescale: Float = DEFAULT_RESCALE,
|
||||
override val distance: Float = DEFAULT_DISTANCE
|
||||
) : SkyCubeBase()
|
||||
|
@ -5,11 +5,11 @@ import chylex.hee.client.render.util.GL.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.TESSELLATOR
|
||||
import chylex.hee.client.render.util.draw
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.util.offsetTowards
|
||||
import chylex.hee.system.util.square
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
import org.lwjgl.opengl.GL11.GL_FLAT
|
||||
@ -79,7 +79,9 @@ abstract class SkyDomeBase : AbstractEnvironmentRenderer(){
|
||||
protected open val alpha2 = DEFAULT_ALPHA
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, partialTicks: Float){
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
val color1 = color1
|
||||
val color2 = color2
|
||||
val alpha1 = alpha1 * currentSkyAlpha
|
||||
@ -101,7 +103,7 @@ abstract class SkyDomeBase : AbstractEnvironmentRenderer(){
|
||||
GL.shadeModel(GL_SMOOTH)
|
||||
|
||||
GL.enableTexture()
|
||||
MC.textureManager.bindTexture(texture)
|
||||
GL.bindTexture(texture)
|
||||
|
||||
TESSELLATOR.draw(GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR){
|
||||
for((x, y, z, c, u, v) in Skybox.VERTICES.value){
|
||||
@ -110,8 +112,8 @@ abstract class SkyDomeBase : AbstractEnvironmentRenderer(){
|
||||
val b = offsetTowards(b2, b1, c)
|
||||
val a = offsetTowards(alpha2, alpha1, c)
|
||||
|
||||
pos(x.toDouble(), y.toDouble(), z.toDouble())
|
||||
tex(u.toDouble(), v.toDouble())
|
||||
pos(mat, x, y, z)
|
||||
tex(u.toFloat(), v.toFloat())
|
||||
color(r, g, b, a)
|
||||
endVertex()
|
||||
}
|
||||
|
@ -4,9 +4,11 @@ import chylex.hee.client.render.util.GL.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.GL.DF_ZERO
|
||||
import chylex.hee.client.render.util.GL.SF_ONE
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.rotateX
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.util.math.Vec3d
|
||||
@ -16,13 +18,13 @@ class SkyPlaneTopFoggy(
|
||||
override val texture: ResourceLocation = DEFAULT_TEXTURE,
|
||||
override val color: Vec3d = DEFAULT_COLOR,
|
||||
override val alpha: Float = DEFAULT_ALPHA,
|
||||
override val rescale: Double = DEFAULT_RESCALE,
|
||||
override val distance: Double = DEFAULT_DISTANCE,
|
||||
private val width: Double = distance
|
||||
override val rescale: Float = DEFAULT_RESCALE,
|
||||
override val distance: Float = DEFAULT_DISTANCE,
|
||||
private val width: Float = distance
|
||||
) : SkyCubeBase(){
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, partialTicks: Float){
|
||||
val dist = distance.coerceAtMost(18.5 * MC.settings.renderDistanceChunks)
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
val dist = distance.coerceAtMost(18.5F * MC.settings.renderDistanceChunks)
|
||||
val rescale = rescale
|
||||
|
||||
GL.enableBlend()
|
||||
@ -31,12 +33,12 @@ class SkyPlaneTopFoggy(
|
||||
GL.alphaFunc(GL_GREATER, 0F)
|
||||
|
||||
GL.color(color, alpha * currentSkyAlpha)
|
||||
MC.textureManager.bindTexture(texture)
|
||||
GL.bindTexture(texture)
|
||||
|
||||
GL.pushMatrix()
|
||||
GL.rotate(180F, 1F, 0F, 0F)
|
||||
renderPlane(dist, width, rescale)
|
||||
GL.popMatrix()
|
||||
matrix.push()
|
||||
matrix.rotateX(180F)
|
||||
renderPlane(matrix, dist, width, rescale)
|
||||
matrix.pop()
|
||||
|
||||
GL.disableAlpha()
|
||||
GL.disableBlend()
|
||||
|
@ -5,32 +5,34 @@ import chylex.hee.client.render.util.GL.DF_ONE
|
||||
import chylex.hee.client.render.util.GL.DF_ZERO
|
||||
import chylex.hee.client.render.util.GL.SF_ONE
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.client.render.util.rotateX
|
||||
import chylex.hee.client.render.util.rotateY
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11.GL_GREATER
|
||||
|
||||
abstract class SunBase : AbstractEnvironmentRenderer(){
|
||||
protected companion object{
|
||||
const val DEFAULT_DISTANCE = 100.0
|
||||
const val DEFAULT_DISTANCE = 100F
|
||||
}
|
||||
|
||||
protected abstract val texture: ResourceLocation
|
||||
protected open val color = DEFAULT_COLOR
|
||||
protected open val alpha = DEFAULT_ALPHA
|
||||
protected abstract val size: Double
|
||||
protected abstract val size: Float
|
||||
protected open val distance = DEFAULT_DISTANCE
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
protected open fun setRotation(world: ClientWorld, partialTicks: Float){
|
||||
GL.rotate(-90F, 0F, 1F, 0F)
|
||||
GL.rotate(world.getCelestialAngle(partialTicks) * 360F, 1F, 0F, 0F)
|
||||
protected open fun setRotation(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
matrix.rotateY(-90F)
|
||||
matrix.rotateX(world.getCelestialAngle(partialTicks) * 360F)
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, partialTicks: Float){
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
val width = size
|
||||
val dist = distance
|
||||
|
||||
@ -41,12 +43,12 @@ abstract class SunBase : AbstractEnvironmentRenderer(){
|
||||
GL.disableFog()
|
||||
|
||||
GL.color(color, alpha)
|
||||
MC.textureManager.bindTexture(texture)
|
||||
GL.bindTexture(texture)
|
||||
|
||||
GL.pushMatrix()
|
||||
setRotation(world, partialTicks)
|
||||
renderPlane(dist, width, 1.0)
|
||||
GL.popMatrix()
|
||||
matrix.push()
|
||||
setRotation(world, matrix, partialTicks)
|
||||
renderPlane(matrix, dist, width, 1F)
|
||||
matrix.pop()
|
||||
|
||||
GL.enableFog()
|
||||
GL.disableAlpha()
|
||||
|
@ -6,6 +6,6 @@ class SunStatic(
|
||||
override val texture: ResourceLocation,
|
||||
override val color: Vec3d = DEFAULT_COLOR,
|
||||
override val alpha: Float = DEFAULT_ALPHA,
|
||||
override val size: Double,
|
||||
override val distance: Double = DEFAULT_DISTANCE
|
||||
override val size: Float,
|
||||
override val distance: Float = DEFAULT_DISTANCE
|
||||
) : SunBase()
|
||||
|
@ -1,7 +1,8 @@
|
||||
package chylex.hee.client.render.territory.lightmaps
|
||||
import net.minecraft.client.renderer.Vector3f
|
||||
|
||||
interface ILightmap{
|
||||
fun update(colors: FloatArray, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float)
|
||||
fun update(colors: Vector3f, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float)
|
||||
|
||||
companion object{
|
||||
fun calcLightFactor(light: Float, mp: Float = 0.6F): Float{
|
||||
|
@ -1,36 +1,37 @@
|
||||
package chylex.hee.client.render.territory.lightmaps
|
||||
import net.minecraft.client.renderer.Vector3f
|
||||
import kotlin.math.max
|
||||
|
||||
fun ILightmap.mergeSkyLightIntoBlockLight() = object : ILightmap{
|
||||
override fun update(colors: FloatArray, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
override fun update(colors: Vector3f, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
this@mergeSkyLightIntoBlockLight.update(colors, sunBrightness, skyLight, max(skyLight, blockLight), partialTicks)
|
||||
}
|
||||
}
|
||||
|
||||
fun ILightmap.transformSunBrightness(transformer: (Float) -> Float) = object : ILightmap{
|
||||
override fun update(colors: FloatArray, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
override fun update(colors: Vector3f, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
this@transformSunBrightness.update(colors, transformer(sunBrightness), skyLight, blockLight, partialTicks)
|
||||
}
|
||||
}
|
||||
|
||||
fun ILightmap.transformSkyLight(transformer: (Float) -> Float) = object : ILightmap{
|
||||
override fun update(colors: FloatArray, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
override fun update(colors: Vector3f, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
this@transformSkyLight.update(colors, sunBrightness, transformer(skyLight), blockLight, partialTicks)
|
||||
}
|
||||
}
|
||||
|
||||
fun ILightmap.transformBlockLight(transformer: (Float) -> Float) = object : ILightmap{
|
||||
override fun update(colors: FloatArray, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
override fun update(colors: Vector3f, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
this@transformBlockLight.update(colors, sunBrightness, skyLight, transformer(blockLight), partialTicks)
|
||||
}
|
||||
}
|
||||
|
||||
fun ILightmap.transformColors(red: (Float) -> Float, green: (Float) -> Float, blue: (Float) -> Float) = object : ILightmap{
|
||||
override fun update(colors: FloatArray, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
override fun update(colors: Vector3f, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
this@transformColors.update(colors, sunBrightness, skyLight, blockLight, partialTicks)
|
||||
|
||||
colors[0] = red(colors[0])
|
||||
colors[1] = green(colors[1])
|
||||
colors[2] = blue(colors[2])
|
||||
colors.x = red(colors.x)
|
||||
colors.y = green(colors.y)
|
||||
colors.z = blue(colors.z)
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package chylex.hee.client.render.territory.lightmaps
|
||||
import chylex.hee.client.render.territory.lightmaps.ILightmap.Companion.calcLightFactor
|
||||
import chylex.hee.client.render.territory.lightmaps.ILightmap.Companion.calcLightSqFactor
|
||||
import net.minecraft.client.renderer.Vector3f
|
||||
|
||||
object OverworldLightmap : ILightmap{
|
||||
override fun update(colors: FloatArray, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
override fun update(colors: Vector3f, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
val sunFactor = skyLight * ((sunBrightness * 0.65F) + 0.35F)
|
||||
val blockFactor = calcLightFactor(blockLight)
|
||||
val blockSqFactor = calcLightSqFactor(blockLight)
|
||||
@ -12,8 +13,8 @@ object OverworldLightmap : ILightmap{
|
||||
val green = sunFactor + blockFactor
|
||||
val blue = skyLight + blockSqFactor
|
||||
|
||||
colors[0] = (red * 0.96F) + 0.03F
|
||||
colors[1] = (green * 0.96F) + 0.03F
|
||||
colors[2] = (blue * 0.96F) + 0.03F
|
||||
colors.x = (red * 0.96F) + 0.03F
|
||||
colors.y = (green * 0.96F) + 0.03F
|
||||
colors.z = (blue * 0.96F) + 0.03F
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
package chylex.hee.client.render.territory.lightmaps
|
||||
import chylex.hee.client.render.territory.lightmaps.ILightmap.Companion.calcLightFactor
|
||||
import chylex.hee.client.render.territory.lightmaps.ILightmap.Companion.calcLightSqFactor
|
||||
import net.minecraft.client.renderer.Vector3f
|
||||
|
||||
object VanillaEndLightmap : ILightmap{
|
||||
override fun update(colors: FloatArray, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
override fun update(colors: Vector3f, sunBrightness: Float, skyLight: Float, blockLight: Float, partialTicks: Float){
|
||||
val blockFactor = calcLightFactor(blockLight)
|
||||
val blockSqFactor = calcLightSqFactor(blockLight)
|
||||
|
||||
colors[0] = (blockLight * 0.75F) + 0.22F
|
||||
colors[1] = (blockFactor * 0.75F) + 0.28F
|
||||
colors[2] = (blockSqFactor * 0.75F) + 0.25F
|
||||
colors.x = (blockLight * 0.75F) + 0.22F
|
||||
colors.y = (blockFactor * 0.75F) + 0.28F
|
||||
colors.z = (blockSqFactor * 0.75F) + 0.25F
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,18 @@
|
||||
package chylex.hee.client.render.util
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import com.mojang.blaze3d.platform.GLX
|
||||
import com.mojang.blaze3d.platform.GlStateManager
|
||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor
|
||||
import com.mojang.blaze3d.platform.GlStateManager.FogMode
|
||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor
|
||||
import com.mojang.blaze3d.platform.GlStateManager.TexGen
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import java.nio.FloatBuffer
|
||||
|
||||
typealias GLSM = GlStateManager
|
||||
private typealias GLSM = RenderSystem
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object GL{
|
||||
@ -19,14 +21,6 @@ object GL{
|
||||
|
||||
fun depthMask(enable: Boolean) = GLSM.depthMask(enable)
|
||||
|
||||
fun enableCull() = GLSM.enableCull()
|
||||
fun disableCull() = GLSM.disableCull()
|
||||
|
||||
fun enableRescaleNormal() = GLSM.enableRescaleNormal()
|
||||
fun disableRescaleNormal() = GLSM.disableRescaleNormal()
|
||||
|
||||
fun lineWidth(width: Float) = GLSM.lineWidth(width)
|
||||
|
||||
// Blend
|
||||
|
||||
fun enableBlend() = GLSM.enableBlend()
|
||||
@ -57,29 +51,9 @@ object GL{
|
||||
|
||||
fun shadeModel(model: Int) = GLSM.shadeModel(model)
|
||||
|
||||
// Lightmap
|
||||
|
||||
fun setLightmapCoords(x: Float, y: Float){
|
||||
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, x, y)
|
||||
}
|
||||
|
||||
fun setLightmapCoords(x: Int, y: Int){
|
||||
setLightmapCoords(x.toFloat(), y.toFloat())
|
||||
}
|
||||
|
||||
fun setLightmapCoords(brightness: Int){
|
||||
setLightmapCoords(brightness % 65536, brightness / 65536)
|
||||
}
|
||||
|
||||
// Color
|
||||
|
||||
fun enableColorMaterial() = GLSM.enableColorMaterial()
|
||||
fun disableColorMaterial() = GLSM.disableColorMaterial()
|
||||
|
||||
fun color(red: Float, green: Float, blue: Float) = GLSM.color3f(red, green, blue)
|
||||
fun color(red: Float, green: Float, blue: Float, alpha: Float) = GLSM.color4f(red, green, blue, alpha)
|
||||
|
||||
fun color(color: Vec3d) = GLSM.color3f(color.x.toFloat(), color.y.toFloat(), color.z.toFloat())
|
||||
fun color(color: Vec3d, alpha: Float) = GLSM.color4f(color.x.toFloat(), color.y.toFloat(), color.z.toFloat(), alpha)
|
||||
|
||||
// Texture
|
||||
@ -87,14 +61,13 @@ object GL{
|
||||
fun enableTexture() = GLSM.enableTexture()
|
||||
fun disableTexture() = GLSM.disableTexture()
|
||||
|
||||
fun enableOutlineMode(color: Int) = GLSM.setupSolidRenderingTextureCombine(color)
|
||||
fun disableOutlineMode() = GLSM.tearDownSolidRenderingTextureCombine()
|
||||
fun bindTexture(texture: ResourceLocation) = MC.textureManager.bindTexture(texture)
|
||||
|
||||
fun enableTexGenCoord(tex: TexGen) = GLSM.enableTexGen(tex)
|
||||
fun disableTexGenCoord(tex: TexGen) = GLSM.disableTexGen(tex)
|
||||
fun enableTexGenCoord(tex: TexGen) = GlStateManager.enableTexGen(tex)
|
||||
fun disableTexGenCoord(tex: TexGen) = GlStateManager.disableTexGen(tex)
|
||||
|
||||
fun texGenMode(tex: TexGen, mode: Int) = GLSM.texGenMode(tex, mode)
|
||||
fun texGenParam(tex: TexGen, param: Int, buffer: FloatBuffer) = GLSM.texGenParam(tex, param, buffer)
|
||||
fun texGenMode(tex: TexGen, mode: Int) = GlStateManager.texGenMode(tex, mode)
|
||||
fun texGenParam(tex: TexGen, param: Int, buffer: FloatBuffer) = GlStateManager.texGenParam(tex, param, buffer)
|
||||
|
||||
// Matrix
|
||||
|
||||
@ -108,10 +81,8 @@ object GL{
|
||||
fun translate(x: Double, y: Double, z: Double) = GLSM.translated(x, y, z)
|
||||
|
||||
fun scale(x: Float, y: Float, z: Float) = GLSM.scalef(x, y, z)
|
||||
fun scale(x: Double, y: Double, z: Double) = GLSM.scaled(x, y, z)
|
||||
|
||||
fun rotate(angle: Float, x: Float, y: Float, z: Float) = GLSM.rotatef(angle, x, y, z)
|
||||
fun rotate(angle: Double, x: Double, y: Double, z: Double) = GLSM.rotated(angle, x, y, z)
|
||||
|
||||
// Constants
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
package chylex.hee.client.render.util
|
||||
import chylex.hee.client.render.util.GL.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.util.GL.DF_ZERO
|
||||
import chylex.hee.client.render.util.GL.SF_ONE
|
||||
import chylex.hee.client.render.util.GL.SF_SRC_ALPHA
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import net.minecraft.client.renderer.RenderHelper
|
||||
import net.minecraft.client.renderer.model.IBakedModel
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture
|
||||
import net.minecraft.client.renderer.texture.ITextureObject
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11.GL_GREATER
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object ItemRenderHelper{
|
||||
val TEX_BLOCKS_ITEMS: ResourceLocation = AtlasTexture.LOCATION_BLOCKS_TEXTURE
|
||||
private lateinit var texBlocksItemsObj: ITextureObject
|
||||
|
||||
fun beginItemModel(){
|
||||
with(MC.textureManager){
|
||||
texBlocksItemsObj = getTexture(TEX_BLOCKS_ITEMS).also { it.setBlurMipmap(false, false) }
|
||||
bindTexture(TEX_BLOCKS_ITEMS)
|
||||
}
|
||||
|
||||
RenderHelper.enableStandardItemLighting()
|
||||
GL.alphaFunc(GL_GREATER, 0.1F)
|
||||
GL.enableRescaleNormal()
|
||||
GL.enableBlend()
|
||||
GL.blendFunc(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA, SF_ONE, DF_ZERO)
|
||||
}
|
||||
|
||||
fun getItemModel(stack: ItemStack): IBakedModel{
|
||||
return MC.itemRenderer.getItemModelWithOverrides(stack, MC.world, null)
|
||||
}
|
||||
|
||||
fun endItemModel(){
|
||||
GL.disableBlend()
|
||||
GL.disableRescaleNormal()
|
||||
|
||||
texBlocksItemsObj.restoreLastBlurMipmap()
|
||||
}
|
||||
}
|
43
src/main/java/chylex/hee/client/render/util/MatrixExt.kt
Normal file
43
src/main/java/chylex/hee/client/render/util/MatrixExt.kt
Normal file
@ -0,0 +1,43 @@
|
||||
package chylex.hee.client.render.util
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.renderer.Vector3f
|
||||
|
||||
fun MatrixStack.translateX(amount: Double){
|
||||
this.translate(amount, 0.0, 0.0)
|
||||
}
|
||||
|
||||
fun MatrixStack.translateY(amount: Double){
|
||||
this.translate(0.0, amount, 0.0)
|
||||
}
|
||||
|
||||
fun MatrixStack.translateZ(amount: Double){
|
||||
this.translate(0.0, 0.0, amount)
|
||||
}
|
||||
|
||||
fun MatrixStack.rotateX(degrees: Float){
|
||||
this.rotate(Vector3f.XP.rotationDegrees(degrees))
|
||||
}
|
||||
|
||||
fun MatrixStack.rotateY(degrees: Float){
|
||||
this.rotate(Vector3f.YP.rotationDegrees(degrees))
|
||||
}
|
||||
|
||||
fun MatrixStack.rotateZ(degrees: Float){
|
||||
this.rotate(Vector3f.ZP.rotationDegrees(degrees))
|
||||
}
|
||||
|
||||
fun MatrixStack.scaleX(amount: Float){
|
||||
this.scale(amount, 1F, 1F)
|
||||
}
|
||||
|
||||
fun MatrixStack.scaleY(amount: Float){
|
||||
this.scale(1F, amount, 1F)
|
||||
}
|
||||
|
||||
fun MatrixStack.scaleZ(amount: Float){
|
||||
this.scale(1F, 1F, amount)
|
||||
}
|
||||
|
||||
fun MatrixStack.scale(amount: Float){
|
||||
this.scale(amount, amount, amount)
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package chylex.hee.client.render.util
|
||||
import net.minecraft.client.renderer.entity.model.RendererModel
|
||||
import net.minecraft.client.renderer.model.ModelBox
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
import net.minecraft.client.renderer.model.ModelRenderer.ModelBox
|
||||
|
||||
class ModelBoxBuilder(private val model: RendererModel){
|
||||
class ModelBoxBuilder(private val model: ModelRenderer){
|
||||
private var x = 0F
|
||||
private var y = 0F
|
||||
private var z = 0F
|
||||
@ -46,10 +46,10 @@ class ModelBoxBuilder(private val model: RendererModel){
|
||||
val v = v
|
||||
|
||||
if (u == null || v == null){
|
||||
model.addBox(x, y, z, w, h, d, mirror)
|
||||
model.addBox(x, y, z, w.toFloat(), h.toFloat(), d.toFloat(), mirror)
|
||||
}
|
||||
else{
|
||||
model.cubeList.add(ModelBox(model, u, v, x, y, z, w, h, d, 0F, mirror))
|
||||
model.cubeList.add(ModelBox(u, v, x, y, z, w.toFloat(), h.toFloat(), d.toFloat(), 0F, 0F, 0F, mirror, model.textureWidth, model.textureHeight))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package chylex.hee.client.render.util
|
||||
import net.minecraft.client.renderer.entity.model.RendererModel
|
||||
import net.minecraft.client.renderer.model.ModelBox
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
import net.minecraft.client.renderer.model.ModelRenderer.ModelBox
|
||||
|
||||
val RendererModel.beginBox
|
||||
val ModelRenderer.beginBox
|
||||
get() = ModelBoxBuilder(this)
|
||||
|
||||
fun RendererModel.render(){
|
||||
this.render(1F / 16F)
|
||||
}
|
||||
|
||||
const val FACE_FRONT = 4
|
||||
const val FACE_BACK = 5
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
fun ModelBox.retainFace(face: Int){
|
||||
quads = arrayOf(quads[face])
|
||||
}
|
||||
|
@ -0,0 +1,156 @@
|
||||
package chylex.hee.client.render.util
|
||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor
|
||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import net.minecraft.client.renderer.RenderState
|
||||
import net.minecraft.client.renderer.RenderState.AlphaState
|
||||
import net.minecraft.client.renderer.RenderState.CullState
|
||||
import net.minecraft.client.renderer.RenderState.DiffuseLightingState
|
||||
import net.minecraft.client.renderer.RenderState.FogState
|
||||
import net.minecraft.client.renderer.RenderState.LayerState
|
||||
import net.minecraft.client.renderer.RenderState.LightmapState
|
||||
import net.minecraft.client.renderer.RenderState.LineState
|
||||
import net.minecraft.client.renderer.RenderState.OverlayState
|
||||
import net.minecraft.client.renderer.RenderState.ShadeModelState
|
||||
import net.minecraft.client.renderer.RenderState.TextureState
|
||||
import net.minecraft.client.renderer.RenderState.TexturingState
|
||||
import net.minecraft.client.renderer.RenderState.TransparencyState
|
||||
import net.minecraft.client.renderer.RenderState.WriteMaskState
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.RenderType.State
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import java.util.OptionalDouble
|
||||
|
||||
class RenderStateBuilder{
|
||||
private val state = State.getBuilder()
|
||||
|
||||
fun tex(location: ResourceLocation, blur: Boolean = false, mipmap: Boolean = false){
|
||||
state.texture(TextureState(location, blur, mipmap))
|
||||
}
|
||||
|
||||
fun texturing(texturing: TexturingState){
|
||||
state.texturing(texturing)
|
||||
}
|
||||
|
||||
fun layering(layering: LayerState){
|
||||
state.layer(layering)
|
||||
}
|
||||
|
||||
fun blend(blend: TransparencyState){
|
||||
state.transparency(blend)
|
||||
}
|
||||
|
||||
fun blend(src: SourceFactor, dst: DestFactor){
|
||||
state.transparency(TransparencyState("hee:blend_${src.name}_${dst.name}",
|
||||
{ RenderSystem.enableBlend(); RenderSystem.blendFunc(src, dst) },
|
||||
{ RenderSystem.disableBlend() }
|
||||
))
|
||||
}
|
||||
|
||||
fun blend(srgb: SourceFactor, drgb: DestFactor, sa: SourceFactor, da: DestFactor){
|
||||
state.transparency(TransparencyState("hee:blend_${srgb.name}_${drgb.name}_${sa.name}_${da.name}",
|
||||
{ RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(srgb, drgb, sa, da) },
|
||||
{ RenderSystem.disableBlend() }
|
||||
))
|
||||
}
|
||||
|
||||
fun lighting(lighting: DiffuseLightingState){
|
||||
state.diffuseLighting(lighting)
|
||||
}
|
||||
|
||||
fun shade(shade: ShadeModelState){
|
||||
state.shadeModel(shade)
|
||||
}
|
||||
|
||||
fun alpha(alpha: AlphaState){
|
||||
state.alpha(alpha)
|
||||
}
|
||||
|
||||
fun alpha(greaterThan: Float){
|
||||
state.alpha(AlphaState(greaterThan))
|
||||
}
|
||||
|
||||
fun fog(fog: FogState){
|
||||
state.fog(fog)
|
||||
}
|
||||
|
||||
fun cull(cull: CullState){
|
||||
state.cull(cull)
|
||||
}
|
||||
|
||||
fun lightmap(lightmap: LightmapState){
|
||||
state.lightmap(lightmap)
|
||||
}
|
||||
|
||||
fun overlay(overlay: OverlayState){
|
||||
state.overlay(overlay)
|
||||
}
|
||||
|
||||
fun mask(mask: WriteMaskState){
|
||||
state.writeMask(mask)
|
||||
}
|
||||
|
||||
fun line(thickness: Double){
|
||||
state.line(LineState(OptionalDouble.of(thickness)))
|
||||
}
|
||||
|
||||
fun build(affectsOutline: Boolean = false): State{
|
||||
return state.build(affectsOutline)
|
||||
}
|
||||
|
||||
fun buildType(name: String, vertexFormat: VertexFormat, drawMode: Int, bufferSize: Int, useDelegate: Boolean = false, needsSorting: Boolean = true, affectsOutline: Boolean = false): RenderType{
|
||||
return RenderType.makeType(name, vertexFormat, drawMode, bufferSize, useDelegate, needsSorting, build(affectsOutline))
|
||||
}
|
||||
|
||||
/*
|
||||
* TextureState texture = RenderState.NO_TEXTURE;
|
||||
* TransparencyState transparency = RenderState.NO_TRANSPARENCY;
|
||||
* DiffuseLightingState diffuseLighting = RenderState.DIFFUSE_LIGHTING_DISABLED;
|
||||
* ShadeModelState shadeModel = RenderState.SHADE_DISABLED;
|
||||
* AlphaState alpha = RenderState.ZERO_ALPHA;
|
||||
* DepthTestState depthTest = RenderState.DEPTH_LEQUAL;
|
||||
* CullState cull = RenderState.CULL_ENABLED;
|
||||
* LightmapState lightmap = RenderState.LIGHTMAP_DISABLED;
|
||||
* OverlayState overlay = RenderState.OVERLAY_DISABLED;
|
||||
* FogState fog = RenderState.FOG;
|
||||
* LayerState layer = RenderState.NO_LAYERING;
|
||||
* TargetState target = RenderState.MAIN_TARGET;
|
||||
* TexturingState texturing = RenderState.DEFAULT_TEXTURING;
|
||||
* WriteMaskState writeMask = RenderState.COLOR_DEPTH_WRITE;
|
||||
* LineState line = RenderState.DEFAULT_LINE;
|
||||
*/
|
||||
|
||||
companion object : RenderState(null, null, null){
|
||||
val LAYERING_NONE: LayerState get() = NO_LAYERING
|
||||
val LAYERING_PROJECTION: LayerState get() = PROJECTION_LAYERING
|
||||
|
||||
val BLEND_NONE: TransparencyState get() = NO_TRANSPARENCY
|
||||
|
||||
val LIGHTING_ENABLED: DiffuseLightingState get() = DIFFUSE_LIGHTING_ENABLED
|
||||
val LIGHTING_DISABLED: DiffuseLightingState get() = DIFFUSE_LIGHTING_DISABLED
|
||||
|
||||
val SHADE_ENABLED: ShadeModelState get() = RenderState.SHADE_ENABLED
|
||||
val SHADE_DISABLED: ShadeModelState get() = RenderState.SHADE_DISABLED
|
||||
|
||||
val ALPHA_NONE: AlphaState get() = ZERO_ALPHA
|
||||
val ALPHA_CUTOUT: AlphaState get() = DEFAULT_ALPHA
|
||||
|
||||
val FOG_DISABLED: FogState get() = NO_FOG
|
||||
val FOG_ENABLED: FogState get() = FOG
|
||||
val FOG_BLACK: FogState get() = BLACK_FOG
|
||||
|
||||
val CULL_DISABLED: CullState get() = RenderState.CULL_DISABLED
|
||||
val CULL_ENABLED: CullState get() = RenderState.CULL_ENABLED
|
||||
|
||||
val LIGHTMAP_DISABLED: LightmapState get() = RenderState.LIGHTMAP_DISABLED
|
||||
val LIGHTMAP_ENABLED: LightmapState get() = RenderState.LIGHTMAP_ENABLED
|
||||
|
||||
val OVERLAY_DISABLED: OverlayState get() = RenderState.OVERLAY_DISABLED
|
||||
val OVERLAY_ENABLED: OverlayState get() = RenderState.OVERLAY_ENABLED
|
||||
|
||||
val MASK_COLOR: WriteMaskState get() = COLOR_WRITE
|
||||
val MASK_DEPTH: WriteMaskState get() = DEPTH_WRITE
|
||||
val MASK_COLOR_DEPTH: WriteMaskState get() = COLOR_DEPTH_WRITE
|
||||
}
|
||||
}
|
@ -16,6 +16,9 @@ import chylex.hee.system.util.playUniversal
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.PASS
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.SoundCategory
|
||||
import net.minecraft.util.math.BlockPos
|
||||
@ -59,11 +62,11 @@ abstract class BlockAbstractCauldron(builder: BlockBuilder) : BlockCauldron(buil
|
||||
}
|
||||
}
|
||||
|
||||
final override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
final override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
val item = player.getHeldItem(hand).takeIf { it.isNotEmpty }?.item
|
||||
|
||||
if (item == null){
|
||||
return true
|
||||
return PASS
|
||||
}
|
||||
|
||||
if (item === Items.BUCKET){
|
||||
@ -79,7 +82,7 @@ abstract class BlockAbstractCauldron(builder: BlockBuilder) : BlockCauldron(buil
|
||||
Sounds.ITEM_BUCKET_FILL.playUniversal(player, pos, SoundCategory.BLOCKS)
|
||||
}
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
else if (item === Items.GLASS_BOTTLE){
|
||||
val filledBottle = createFilledBottle()
|
||||
@ -94,10 +97,10 @@ abstract class BlockAbstractCauldron(builder: BlockBuilder) : BlockCauldron(buil
|
||||
Sounds.ITEM_BOTTLE_FILL.playUniversal(player, pos, SoundCategory.BLOCKS)
|
||||
}
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
return false
|
||||
return PASS
|
||||
}
|
||||
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity){}
|
||||
|
@ -19,6 +19,8 @@ import net.minecraft.item.BlockItemUseContext
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.state.StateContainer.Builder
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.Mirror
|
||||
import net.minecraft.util.Rotation
|
||||
@ -60,23 +62,23 @@ abstract class BlockAbstractChest<T : TileEntityBaseChest>(builder: BlockBuilder
|
||||
}
|
||||
}
|
||||
|
||||
final override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
final override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
if (world.isRemote){
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
val posAbove = pos.up()
|
||||
|
||||
if (posAbove.getState(world).isNormalCube(world, posAbove)){
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
if (world.selectExistingEntities.inBox<EntityCat>(AxisAlignedBB(posAbove)).any { it.isSitting }){
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
openChest(world, pos, player)
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
protected open fun openChest(world: World, pos: BlockPos, player: EntityPlayer){
|
||||
@ -104,5 +106,4 @@ abstract class BlockAbstractChest<T : TileEntityBaseChest>(builder: BlockBuilder
|
||||
// Rendering
|
||||
|
||||
final override fun getRenderType(state: BlockState) = ENTITYBLOCK_ANIMATED
|
||||
final override fun hasCustomBreakingProgress(state: BlockState) = true
|
||||
}
|
||||
|
@ -3,10 +3,8 @@ import chylex.hee.game.block.info.BlockBuilder
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.vanilla.TextComponentTranslation
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.client.util.ITooltipFlag
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.BlockRenderLayer.CUTOUT
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
import net.minecraft.world.IBlockReader
|
||||
|
||||
@ -16,14 +14,8 @@ abstract class BlockAbstractTable(builder: BlockBuilder, val tier: Int, val firs
|
||||
require(firstTier <= tier){ "[BlockAbstractTable] firstTier cannot be larger than current tier" }
|
||||
}
|
||||
|
||||
override fun isSolid(state: BlockState): Boolean{
|
||||
return true
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun addInformation(stack: ItemStack, world: IBlockReader?, lines: MutableList<ITextComponent>, flags: ITooltipFlag){
|
||||
lines.add(TextComponentTranslation("block.tooltip.hee.table.tier", tier))
|
||||
}
|
||||
|
||||
override fun getRenderLayer() = CUTOUT
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import net.minecraft.util.math.shapes.VoxelShape
|
||||
import net.minecraft.util.math.shapes.VoxelShapes
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed
|
||||
import java.util.Random
|
||||
@ -44,7 +45,7 @@ class BlockAncientCobweb(builder: BlockBuilder) : BlockWeb(builder.p){
|
||||
}
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
pos.breakBlock(world, true)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@ import chylex.hee.system.util.getTile
|
||||
import chylex.hee.system.util.setBlock
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.BlockRayTraceResult
|
||||
@ -21,9 +23,9 @@ open class BlockBrewingStandCustom(builder: BlockBuilder) : BlockBrewingStand(bu
|
||||
return TileEntityBrewingStandCustom()
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
if (world.isRemote){
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
val tile = pos.getTile<TileEntityBrewingStand>(world)
|
||||
@ -37,6 +39,6 @@ open class BlockBrewingStandCustom(builder: BlockBuilder) : BlockBrewingStand(bu
|
||||
pos.setBlock(world, this)
|
||||
}
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import java.util.Random
|
||||
|
||||
class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder){
|
||||
@ -131,13 +132,13 @@ class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder){
|
||||
world.pendingBlockTicks.scheduleTick(pos, this, tickRateForLevel(state[LEVEL]))
|
||||
}
|
||||
|
||||
override fun randomTick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun randomTick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
if (!world.pendingBlockTicks.isTickScheduled(pos, this)){
|
||||
pos.removeBlock(world)
|
||||
}
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
val level = state[LEVEL]
|
||||
val remainingFacings = Facing6.toMutableList()
|
||||
|
||||
|
@ -2,15 +2,18 @@ package chylex.hee.game.block
|
||||
import chylex.hee.game.block.entity.TileEntityDarkChest
|
||||
import chylex.hee.game.block.info.BlockBuilder
|
||||
import chylex.hee.game.entity.living.ai.AIOcelotSitOverride.IOcelotCanSitOn
|
||||
import chylex.hee.init.ModTileEntities
|
||||
import chylex.hee.system.migration.vanilla.BlockChest
|
||||
import chylex.hee.system.migration.vanilla.TileEntityChest
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.tileentity.TileEntityType
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.IWorldReader
|
||||
import java.util.function.Supplier
|
||||
|
||||
class BlockDarkChest(builder: BlockBuilder) : BlockChest(builder.p), IOcelotCanSitOn{
|
||||
class BlockDarkChest(builder: BlockBuilder) : BlockChest(builder.p, Supplier<TileEntityType<out TileEntityChest>> { ModTileEntities.DARK_CHEST }), IOcelotCanSitOn{
|
||||
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity{
|
||||
return TileEntityDarkChest()
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import net.minecraft.util.math.RayTraceResult
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import net.minecraft.world.storage.loot.LootContext
|
||||
import java.util.Random
|
||||
|
||||
@ -56,7 +57,7 @@ class BlockDeathFlowerDecaying(builder: BlockBuilder) : BlockEndPlant(builder),
|
||||
implOnBlockAdded(world, pos)
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
super.tick(state, world, pos, rand)
|
||||
implUpdateTick(world, pos, state, rand)
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import chylex.hee.system.util.removeBlock
|
||||
import chylex.hee.system.util.setState
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.SoundCategory
|
||||
import net.minecraft.util.math.BlockPos
|
||||
@ -33,6 +35,7 @@ import net.minecraft.util.math.Vec3d
|
||||
import net.minecraft.world.GameRules.DO_TILE_DROPS
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.gen.Heightmap.Type.OCEAN_FLOOR
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import java.util.Random
|
||||
|
||||
class BlockDragonEggOverride(builder: BlockBuilder) : BlockDragonEgg(builder.p){
|
||||
@ -55,7 +58,7 @@ class BlockDragonEggOverride(builder: BlockBuilder) : BlockDragonEgg(builder.p){
|
||||
}
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
if (world.isRemote){
|
||||
return
|
||||
}
|
||||
@ -65,11 +68,11 @@ class BlockDragonEggOverride(builder: BlockBuilder) : BlockDragonEgg(builder.p){
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
val realState = pos.getState(world)
|
||||
|
||||
if (world.isRemote || realState.block !== this){
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
val rand = world.rand
|
||||
@ -99,12 +102,12 @@ class BlockDragonEggOverride(builder: BlockBuilder) : BlockDragonEgg(builder.p){
|
||||
soundVolume = 0.7F
|
||||
).send(world)
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
override fun onBlockClicked(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer){
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.block.info.BlockBuilder
|
||||
import chylex.hee.game.world.territory.TerritoryInstance
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
@ -10,18 +11,18 @@ import net.minecraft.block.BlockState
|
||||
import net.minecraft.client.renderer.color.IBlockColor
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.FoliageColors
|
||||
import net.minecraft.world.IEnviromentBlockReader
|
||||
import net.minecraft.world.ILightReader
|
||||
import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.biome.BiomeColors
|
||||
import net.minecraft.world.biome.Biomes
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import java.util.Random
|
||||
|
||||
class BlockDryVines(builder: BlockBuilder) : BlockVine(builder.p){
|
||||
|
||||
// Custom behavior
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){}
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){}
|
||||
|
||||
override fun isLadder(state: BlockState, world: IWorldReader, pos: BlockPos, entity: EntityLivingBase): Boolean{
|
||||
return !entity.onGround
|
||||
@ -42,7 +43,9 @@ class BlockDryVines(builder: BlockBuilder) : BlockVine(builder.p){
|
||||
).i
|
||||
}
|
||||
|
||||
override fun getColor(state: BlockState, world: IEnviromentBlockReader?, pos: BlockPos?, tintIndex: Int): Int{
|
||||
override fun getColor(state: BlockState, uselessWorld: ILightReader?, pos: BlockPos?, tintIndex: Int): Int{
|
||||
val world = MC.world
|
||||
|
||||
if (world == null || pos == null){
|
||||
return DEFAULT
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import net.minecraft.util.math.shapes.VoxelShape
|
||||
import net.minecraft.util.math.shapes.VoxelShapes
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import java.util.Random
|
||||
|
||||
class BlockDustyStoneUnstable(builder: BlockBuilder) : BlockDustyStone(builder){
|
||||
@ -36,7 +37,7 @@ class BlockDustyStoneUnstable(builder: BlockBuilder) : BlockDustyStone(builder){
|
||||
return player.getHeldItem(MAIN_HAND).let { EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, it) == 0 || isPickaxeOrShovel(it) }
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
// TODO fx
|
||||
|
||||
if (state.block === ModBlocks.DUSTY_STONE_DAMAGED){
|
||||
|
@ -7,10 +7,11 @@ import net.minecraft.block.BlockState
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraftforge.common.PlantType
|
||||
import net.minecraftforge.common.Tags
|
||||
|
||||
open class BlockEndPlant(builder: BlockBuilder) : BlockBush(builder.p){
|
||||
override fun isValidGround(state: BlockState, world: IBlockReader, pos: BlockPos): Boolean{
|
||||
return state.block.let { it === Blocks.END_STONE || it === Blocks.GRASS_BLOCK || isDirt(it) }
|
||||
return state.block.let { it === Blocks.END_STONE || it === Blocks.GRASS_BLOCK || Tags.Blocks.DIRT.contains(it) }
|
||||
}
|
||||
|
||||
override fun getPlantType(world: IBlockReader, pos: BlockPos): PlantType{
|
||||
|
@ -6,10 +6,11 @@ import net.minecraft.block.BlockState
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import java.util.Random
|
||||
|
||||
class BlockEndPortalOverride(builder: BlockBuilder) : BlockEndPortal(builder.p){
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
pos.setAir(world)
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import net.minecraft.util.math.Vec3d
|
||||
import net.minecraft.world.GameRules.DO_FIRE_TICK
|
||||
import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent
|
||||
import java.util.Random
|
||||
@ -54,7 +55,7 @@ class BlockEternalFire(builder: BlockBuilder) : BlockFire(builder.p){
|
||||
override fun tickRate(world: IWorldReader) = super.tickRate(world) * 2
|
||||
override fun canDie(world: World, pos: BlockPos) = false
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
if (!world.gameRules.getBoolean(DO_FIRE_TICK) || !world.isAreaLoaded(pos, 2)){
|
||||
return
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import chylex.hee.system.util.allInCenteredBox
|
||||
import chylex.hee.system.util.getBlock
|
||||
import chylex.hee.system.util.getTile
|
||||
import chylex.hee.system.util.offsetUntil
|
||||
import chylex.hee.system.util.positionY
|
||||
import chylex.hee.system.util.setBlock
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.entity.Entity
|
||||
@ -66,7 +67,7 @@ abstract class BlockExperienceGate(builder: BlockBuilder) : BlockSimple(builder)
|
||||
}
|
||||
|
||||
if (world.isRemote && entity is EntityItem){
|
||||
entity.posY = pos.y + 1.0 - (2.0 * MagicValues.BLOCK_COLLISION_SHRINK) // works around shit physics where items spontaneously sink into blocks
|
||||
entity.positionY = pos.y + 1.0 - (2.0 * MagicValues.BLOCK_COLLISION_SHRINK) // works around shit physics where items spontaneously sink into blocks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IWorld
|
||||
import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import java.util.Random
|
||||
|
||||
class BlockFallingObsidian(builder: BlockBuilder) : BlockSimple(builder){
|
||||
@ -24,7 +25,7 @@ class BlockFallingObsidian(builder: BlockBuilder) : BlockSimple(builder){
|
||||
return super.updatePostPlacement(state, facing, neighborState, world, pos, neighborPos)
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
if (world.isRemote){
|
||||
return
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ import net.minecraft.block.BlockState
|
||||
import net.minecraft.block.Blocks
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.state.StateContainer.Builder
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.PASS
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.BlockRayTraceResult
|
||||
@ -19,6 +22,7 @@ import net.minecraft.util.math.RayTraceResult
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import net.minecraft.world.storage.loot.LootContext
|
||||
import java.util.Random
|
||||
import java.util.function.Supplier
|
||||
@ -61,16 +65,16 @@ class BlockFlowerPotDeathFlowerDecaying(
|
||||
implOnBlockAdded(world, pos)
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
super.tick(state, world, pos, rand)
|
||||
implUpdateTick(world, pos, state, rand)
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
val heldItem = player.getHeldItem(hand)
|
||||
|
||||
if (heldItem.item === ModItems.END_POWDER){
|
||||
return false
|
||||
return PASS
|
||||
}
|
||||
|
||||
val drop = getDrop(state)
|
||||
@ -83,6 +87,6 @@ class BlockFlowerPotDeathFlowerDecaying(
|
||||
}
|
||||
|
||||
pos.setBlock(world, emptyPot)
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.item.BlockItemUseContext
|
||||
import net.minecraft.state.StateContainer.Builder
|
||||
import net.minecraft.util.BlockRenderLayer.CUTOUT
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.Mirror
|
||||
import net.minecraft.util.Rotation
|
||||
@ -95,6 +94,4 @@ class BlockGloomtorch(builder: BlockBuilder) : BlockDirectional(builder.p){
|
||||
override fun getShape(state: BlockState, source: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape{
|
||||
return BOUNDING_BOX[state[FACING]] ?: BOUNDING_BOX.getValue(UP)
|
||||
}
|
||||
|
||||
override fun getRenderLayer() = CUTOUT
|
||||
}
|
||||
|
@ -103,7 +103,8 @@ open class BlockGraveDirt(builder: BlockBuilder) : BlockSimpleShaped(builder, Ax
|
||||
.withParameter(LootParameters.EXPLOSION_RADIUS, explosion.size)
|
||||
.withParameter(LootParameters.TOOL, ItemStack.EMPTY)
|
||||
.withNullableParameter(LootParameters.BLOCK_ENTITY, null)
|
||||
.let { spawnDrops(state, it) }
|
||||
.let(state::getDrops)
|
||||
.forEach { spawnAsEntity(world, pos, it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class BlockHumus(builder: BlockBuilder, mergeBottom: Block) : BlockSimpleMerging
|
||||
}
|
||||
}
|
||||
|
||||
override fun randomTick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun randomTick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
super.randomTick(state, world, pos, rand)
|
||||
|
||||
if (rand.nextInt(5) <= 1){
|
||||
@ -68,7 +68,7 @@ class BlockHumus(builder: BlockBuilder, mergeBottom: Block) : BlockSimpleMerging
|
||||
type == PlantType.Plains ||
|
||||
plant is BlockSapling ||
|
||||
plant is BlockReed ||
|
||||
(plant is BlockBush && super.canSustainPlant(state, world, pos, direction, plant)) // UPDATE 1.14 (check if BlockBush still returns before plantType switch in super method)
|
||||
(plant is BlockBush && super.canSustainPlant(state, world, pos, direction, plant)) // UPDATE 1.15 (check if BlockBush still returns before plantType switch in super method)
|
||||
)
|
||||
}
|
||||
|
||||
@ -103,7 +103,8 @@ class BlockHumus(builder: BlockBuilder, mergeBottom: Block) : BlockSimpleMerging
|
||||
.withParameter(LootParameters.EXPLOSION_RADIUS, explosion.size)
|
||||
.withParameter(LootParameters.TOOL, ItemStack.EMPTY)
|
||||
.withNullableParameter(LootParameters.BLOCK_ENTITY, null)
|
||||
.let { spawnDrops(state, it) }
|
||||
.let(state::getDrops)
|
||||
.forEach { spawnAsEntity(world, pos, it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ import net.minecraft.item.BlockItemUseContext
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.state.StateContainer.Builder
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.PASS
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.Mirror
|
||||
@ -123,7 +126,7 @@ class BlockIgneousPlate(builder: BlockBuilder) : BlockSimple(builder){
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
val heldItem = player.getHeldItem(hand)
|
||||
|
||||
if (heldItem.item === Items.WATER_BUCKET){
|
||||
@ -131,10 +134,10 @@ class BlockIgneousPlate(builder: BlockBuilder) : BlockSimple(builder){
|
||||
player.setHeldItem(hand, ItemStack(Items.BUCKET))
|
||||
}
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
return false
|
||||
return PASS
|
||||
}
|
||||
|
||||
fun tryCoolPlate(world: World, pos: BlockPos, state: BlockState): Boolean{
|
||||
@ -158,5 +161,4 @@ class BlockIgneousPlate(builder: BlockBuilder) : BlockSimple(builder){
|
||||
}
|
||||
|
||||
override fun getRenderType(state: BlockState) = ENTITYBLOCK_ANIMATED
|
||||
override fun hasCustomBreakingProgress(state: BlockState) = true
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.item.BlockItemUseContext
|
||||
import net.minecraft.state.StateContainer.Builder
|
||||
import net.minecraft.util.BlockRenderLayer.TRANSLUCENT
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IWorld
|
||||
@ -56,6 +55,4 @@ class BlockInfusedGlass(builder: BlockBuilder) : BlockAbstractGlass(builder.p){
|
||||
override fun updatePostPlacement(state: BlockState, facing: Direction, neighborState: BlockState, world: IWorld, pos: BlockPos, neighborPos: BlockPos): BlockState{
|
||||
return state.with(CONNECT_MAPPINGS.getValue(facing), pos.offset(facing).getBlock(world) === this)
|
||||
}
|
||||
|
||||
override fun getRenderLayer() = TRANSLUCENT
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import net.minecraft.util.math.RayTraceResult
|
||||
import net.minecraft.world.Explosion
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import net.minecraft.world.storage.loot.LootContext
|
||||
import net.minecraft.world.storage.loot.LootParameters
|
||||
import java.util.Random
|
||||
@ -90,7 +91,7 @@ class BlockInfusedTNT : BlockTNT(Properties.from(Blocks.TNT)), IBlockFireCatchOv
|
||||
world.pendingBlockTicks.scheduleTick(pos, this, 1)
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
super.onBlockAdded(state, world, pos, Blocks.AIR.defaultState, false)
|
||||
}
|
||||
|
||||
@ -120,7 +121,7 @@ class BlockInfusedTNT : BlockTNT(Properties.from(Blocks.TNT)), IBlockFireCatchOv
|
||||
return
|
||||
}
|
||||
|
||||
// UPDATE check if FireBlock still removes the TNT block and tile entity before calling this
|
||||
// UPDATE 1.15 check if FireBlock still removes the TNT block and tile entity before calling this
|
||||
igniteTNT(world, pos, state, igniter, ignoreTrap = false)
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,9 @@ import net.minecraft.block.Blocks
|
||||
import net.minecraft.client.util.ITooltipFlag
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.BlockRenderLayer.TRANSLUCENT
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.PASS
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.SoundCategory
|
||||
@ -132,13 +134,15 @@ class BlockJarODust(builder: BlockBuilder) : BlockSimpleShaped(builder, AABB){
|
||||
|
||||
// Interaction
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
val heldItem = player.getHeldItem(hand)
|
||||
|
||||
return if (heldItem.isEmpty)
|
||||
val result = if (heldItem.isEmpty)
|
||||
tryExtractDust(world, pos, player, hand)
|
||||
else
|
||||
tryInsertDust(world, pos, player, heldItem)
|
||||
|
||||
return if (result) SUCCESS else PASS
|
||||
}
|
||||
|
||||
private fun tryExtractDust(world: World, pos: BlockPos, player: EntityPlayer, hand: Hand): Boolean{
|
||||
@ -190,6 +194,4 @@ class BlockJarODust(builder: BlockBuilder) : BlockSimpleShaped(builder, AABB){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRenderLayer() = TRANSLUCENT
|
||||
}
|
||||
|
@ -22,11 +22,10 @@ import net.minecraft.block.HorizontalBlock.HORIZONTAL_FACING
|
||||
import net.minecraft.client.renderer.color.IBlockColor
|
||||
import net.minecraft.item.BlockItemUseContext
|
||||
import net.minecraft.state.StateContainer.Builder
|
||||
import net.minecraft.util.BlockRenderLayer.CUTOUT
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.IStringSerializable
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IEnviromentBlockReader
|
||||
import net.minecraft.world.ILightReader
|
||||
import net.minecraft.world.World
|
||||
|
||||
sealed class BlockPuzzleLogic(builder: BlockBuilder) : BlockSimple(builder){
|
||||
@ -70,10 +69,6 @@ sealed class BlockPuzzleLogic(builder: BlockBuilder) : BlockSimple(builder){
|
||||
container.add(STATE)
|
||||
}
|
||||
|
||||
override fun isSolid(state: BlockState): Boolean{
|
||||
return true
|
||||
}
|
||||
|
||||
// Logic
|
||||
|
||||
fun onToggled(world: World, pos: BlockPos, facing: Direction): List<Pair<BlockPos, Direction>>{
|
||||
@ -157,11 +152,9 @@ sealed class BlockPuzzleLogic(builder: BlockBuilder) : BlockSimple(builder){
|
||||
|
||||
// Client side
|
||||
|
||||
override fun getRenderLayer() = CUTOUT
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object Color : IBlockColor{
|
||||
override fun getColor(state: BlockState, world: IEnviromentBlockReader?, pos: BlockPos?, tintIndex: Int): Int{
|
||||
override fun getColor(state: BlockState, world: ILightReader?, pos: BlockPos?, tintIndex: Int): Int{
|
||||
if (tintIndex != 1){
|
||||
return NO_TINT
|
||||
}
|
||||
|
@ -21,7 +21,9 @@ import chylex.hee.system.util.getBlock
|
||||
import chylex.hee.system.util.offsetUntil
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.nbt.CompressedStreamTools
|
||||
import net.minecraft.util.BlockRenderLayer.CUTOUT
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.FAIL
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.math.BlockPos
|
||||
@ -37,13 +39,13 @@ import java.nio.file.Files
|
||||
class BlockScaffolding(builder: BlockBuilder) : BlockSimple(builder){
|
||||
var enableShape = true
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
if (world.isRemote && player.isSneaking && !player.abilities.isFlying && Debug.enabled){
|
||||
val palette = CommandClientScaffolding.currentPalette
|
||||
|
||||
if (palette == null){
|
||||
player.sendMessage(TextComponentString("No structure set."))
|
||||
return true
|
||||
return FAIL
|
||||
}
|
||||
|
||||
val minPos = findMinPos(world, pos)?.let { findMinPos(world, it) } // double pass to find min from any side
|
||||
@ -51,7 +53,7 @@ class BlockScaffolding(builder: BlockBuilder) : BlockSimple(builder){
|
||||
|
||||
if (minPos == null || maxPos == null){
|
||||
player.sendMessage(TextComponentString("Could not find structure boundaries."))
|
||||
return true
|
||||
return FAIL
|
||||
}
|
||||
|
||||
val box = BoundingBox(minPos, maxPos)
|
||||
@ -71,10 +73,10 @@ class BlockScaffolding(builder: BlockBuilder) : BlockSimple(builder){
|
||||
}
|
||||
|
||||
player.sendMessage(TextComponentString("Generated structure file of ${box.size}."))
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
return false
|
||||
return FAIL
|
||||
}
|
||||
|
||||
// Helpers
|
||||
@ -137,6 +139,4 @@ class BlockScaffolding(builder: BlockBuilder) : BlockSimple(builder){
|
||||
override fun getAmbientOcclusionLightValue(state: BlockState, world: IBlockReader, pos: BlockPos): Float{
|
||||
return 1F
|
||||
}
|
||||
|
||||
override fun getRenderLayer() = CUTOUT
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ import net.minecraft.item.DyeColor
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.ShulkerBoxTileEntity.AnimationStatus.CLOSED
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.PASS
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.BlockRayTraceResult
|
||||
@ -60,9 +63,9 @@ class BlockShulkerBoxOverride(properties: Properties, color: DyeColor?) : BlockS
|
||||
})
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
if (world.isRemote || player.isSpectator){
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
pos.getTile<TileEntityShulkerBox>(world)?.let {
|
||||
@ -75,7 +78,7 @@ class BlockShulkerBoxOverride(properties: Properties, color: DyeColor?) : BlockS
|
||||
.expand(0.5 * facing.xOffset, 0.5 * facing.yOffset, 0.5 * facing.zOffset)
|
||||
.contract(facing.xOffset.toDouble(), facing.yOffset.toDouble(), facing.zOffset.toDouble())
|
||||
.offset(pos.offset(facing))
|
||||
.let(world::areCollisionShapesEmpty)
|
||||
.let(world::hasNoCollisions)
|
||||
|
||||
else -> true
|
||||
}
|
||||
@ -93,9 +96,9 @@ class BlockShulkerBoxOverride(properties: Properties, color: DyeColor?) : BlockS
|
||||
player.addStat(Stats.OPEN_SHULKER_BOX)
|
||||
}
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
return false
|
||||
return PASS
|
||||
}
|
||||
}
|
||||
|
@ -3,19 +3,12 @@ import chylex.hee.game.block.info.BlockBuilder
|
||||
import chylex.hee.system.util.ceilToInt
|
||||
import chylex.hee.system.util.nextBiasedFloat
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.util.BlockRenderLayer.CUTOUT
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
|
||||
class BlockStardustOre(builder: BlockBuilder) : BlockSimple(builder){
|
||||
override fun isSolid(state: BlockState): Boolean{
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getExpDrop(state: BlockState, world: IWorldReader, pos: BlockPos, fortune: Int, silktouch: Int): Int{
|
||||
return (((world as? World)?.rand ?: RANDOM).nextBiasedFloat(4F) * 6F).ceilToInt()
|
||||
}
|
||||
|
||||
override fun getRenderLayer() = CUTOUT
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ import net.minecraft.client.renderer.color.IBlockColor
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.state.StateContainer.Builder
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.BlockRenderLayer.CUTOUT
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.PASS
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.math.AxisAlignedBB
|
||||
import net.minecraft.util.math.BlockPos
|
||||
@ -28,7 +30,7 @@ import net.minecraft.util.math.shapes.ISelectionContext
|
||||
import net.minecraft.util.math.shapes.VoxelShape
|
||||
import net.minecraft.util.math.shapes.VoxelShapes
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.IEnviromentBlockReader
|
||||
import net.minecraft.world.ILightReader
|
||||
import net.minecraft.world.IWorld
|
||||
import net.minecraft.world.World
|
||||
import java.util.UUID
|
||||
@ -136,16 +138,16 @@ class BlockTablePedestal(builder: BlockBuilder) : BlockSimpleShaped(builder, COM
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
if (world.isRemote){
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
val tile = pos.getTile<TileEntityTablePedestal>(world) ?: return true
|
||||
val tile = pos.getTile<TileEntityTablePedestal>(world) ?: return SUCCESS
|
||||
val heldItem = player.getHeldItem(hand)
|
||||
|
||||
if (heldItem.item === ModItems.TABLE_LINK){
|
||||
return false
|
||||
return PASS
|
||||
}
|
||||
|
||||
if (heldItem.isEmpty){
|
||||
@ -163,7 +165,7 @@ class BlockTablePedestal(builder: BlockBuilder) : BlockSimpleShaped(builder, COM
|
||||
tile.addToInput(heldItem.copyIf { player.isCreative })
|
||||
}
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
override fun onBlockHarvested(world: World, pos: BlockPos, state: BlockState, player: EntityPlayer){
|
||||
@ -204,11 +206,9 @@ class BlockTablePedestal(builder: BlockBuilder) : BlockSimpleShaped(builder, COM
|
||||
|
||||
// Client side
|
||||
|
||||
override fun getRenderLayer() = CUTOUT
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object Color : IBlockColor{
|
||||
override fun getColor(state: BlockState, world: IEnviromentBlockReader?, pos: BlockPos?, tintIndex: Int): Int{
|
||||
override fun getColor(state: BlockState, world: ILightReader?, pos: BlockPos?, tintIndex: Int): Int{
|
||||
if (world == null || pos == null){
|
||||
return NO_TINT
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import chylex.hee.system.migration.vanilla.EntityPlayer
|
||||
import chylex.hee.system.util.getTile
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.ActionResultType.SUCCESS
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.math.AxisAlignedBB
|
||||
import net.minecraft.util.math.BlockPos
|
||||
@ -27,15 +29,15 @@ class BlockVoidPortalStorage(builder: BlockBuilder, aabb: AxisAlignedBB) : Block
|
||||
BlockAbstractPortal.spawnInnerBlocks(world, pos, ModBlocks.VOID_PORTAL_FRAME, ModBlocks.VOID_PORTAL_INNER, minSize = 1)
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
if (world.isRemote){
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
pos.getTile<TileEntityVoidPortalStorage>(world)?.let {
|
||||
ModContainers.open(player, it, pos)
|
||||
}
|
||||
|
||||
return true
|
||||
return SUCCESS
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import chylex.hee.init.ModBlocks
|
||||
import chylex.hee.system.migration.vanilla.EntityPlayer
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.ActionResultType
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.math.AxisAlignedBB
|
||||
import net.minecraft.util.math.BlockPos
|
||||
@ -24,7 +25,8 @@ class BlockVoidPortalStorageCrafted(builder: BlockBuilder, aabb: AxisAlignedBB)
|
||||
BlockAbstractPortal.spawnInnerBlocks(world, pos, ModBlocks.VOID_PORTAL_FRAME_CRAFTED, ModBlocks.VOID_PORTAL_INNER, minSize = 3)
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): Boolean{
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
@Suppress("DEPRECATION")
|
||||
return ModBlocks.VOID_PORTAL_STORAGE.onBlockActivated(state, world, pos, player, hand, hit)
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import net.minecraft.block.material.MaterialColor
|
||||
import net.minecraft.entity.EntityType
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.BlockRenderLayer.CUTOUT
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.World
|
||||
@ -31,6 +30,4 @@ class BlockWhitebarkLeaves(builder: BlockBuilder, private val color: MaterialCol
|
||||
override fun getMaterialColor(state: BlockState, world: IBlockReader, pos: BlockPos): MaterialColor{
|
||||
return color
|
||||
}
|
||||
|
||||
override fun getRenderLayer() = CUTOUT
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import net.minecraft.util.math.shapes.ISelectionContext
|
||||
import net.minecraft.util.math.shapes.VoxelShape
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import java.util.Random
|
||||
|
||||
class BlockWhitebarkSapling(builder: BlockBuilder, private val generator: WhitebarkTreeGenerator<*>) : BlockEndPlant(builder), IGrowable{
|
||||
@ -50,7 +51,7 @@ class BlockWhitebarkSapling(builder: BlockBuilder, private val generator: Whiteb
|
||||
|
||||
// Growth rules
|
||||
|
||||
override fun tick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
super.tick(state, world, pos, rand)
|
||||
|
||||
if (rand.nextInt(7) == 0){
|
||||
@ -66,7 +67,7 @@ class BlockWhitebarkSapling(builder: BlockBuilder, private val generator: Whiteb
|
||||
return rand.nextFloat() < 0.45F
|
||||
}
|
||||
|
||||
override fun grow(world: World, rand: Random, pos: BlockPos, state: BlockState){
|
||||
override fun grow(world: ServerWorld, rand: Random, pos: BlockPos, state: BlockState){
|
||||
val stage = state[STAGE]
|
||||
|
||||
if (stage < STAGE.allowedValues.max()!!){
|
||||
|
@ -127,7 +127,7 @@ interface IBlockDeathFlowerDecaying{
|
||||
if (testPos != null){
|
||||
enderman.setLocationAndAngles(testPos.x + rand.nextFloat(-0.5, 0.5), testPos.y + 0.01, testPos.z + rand.nextFloat(-0.5, 0.5), yaw, 0F)
|
||||
|
||||
if (world.isCollisionBoxesEmpty(enderman, enderman.boundingBox.grow(0.2, 0.0, 0.2))){
|
||||
if (world.hasNoCollisions(enderman, enderman.boundingBox.grow(0.2, 0.0, 0.2))){
|
||||
world.addEntity(enderman)
|
||||
break
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package chylex.hee.game.block.dispenser
|
||||
import chylex.hee.system.migration.vanilla.ItemArmor
|
||||
import chylex.hee.system.util.isNotEmpty
|
||||
import net.minecraft.dispenser.IBlockSource
|
||||
import net.minecraft.dispenser.OptionalDispenseBehavior
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object DispenseEndermanHead : OptionalDispenseBehavior(){
|
||||
override fun dispenseStack(source: IBlockSource, stack: ItemStack): ItemStack{
|
||||
successful = ItemArmor.dispenseArmor(source, stack).isNotEmpty
|
||||
successful = ItemArmor.func_226626_a_(source, stack) // RENAME dispenseArmor
|
||||
return stack
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class TileEntityBrewingStandCustom : TileEntityBrewingStand(){
|
||||
const val SLOT_MODIFIER = 4
|
||||
|
||||
const val TOTAL_SLOTS = 5
|
||||
const val TOTAL_FIELDS = 2 // UPDATE 1.14
|
||||
const val TOTAL_FIELDS = 2 // UPDATE 1.15
|
||||
|
||||
private val POTION_SLOTS = SLOTS_POTIONS.toList().toIntArray()
|
||||
|
||||
|
@ -100,7 +100,7 @@ class TileEntityExperienceGate(type: TileEntityType<TileEntityExperienceGate>) :
|
||||
val FX_CONSUME = object : FxEntityHandler(){
|
||||
override fun handle(entity: Entity, rand: Random){
|
||||
val offset = if (entity is EntityItem && entity !is EntityItemNoBob){
|
||||
0.35 + (sin((entity.age + 1.0) / 10.0 + entity.hoverStart) * 0.1) // UPDATE 1.14 (taken from ItemRenderer)
|
||||
0.35 + (sin((entity.age + 1.0) / 10.0 + entity.hoverStart) * 0.1) // UPDATE 1.15 (taken from ItemRenderer)
|
||||
}
|
||||
else{
|
||||
entity.height * 0.5
|
||||
|
@ -77,7 +77,7 @@ class TileEntityLootChest(type: TileEntityType<TileEntityLootChest>) : TileEntit
|
||||
// Command handling
|
||||
|
||||
fun resetPlayerInventories(): Int{
|
||||
val total = playerInventories.count()
|
||||
val total = playerInventories.size
|
||||
playerInventories.clear()
|
||||
return total
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ class TileEntitySpawnerObsidianTower(type: TileEntityType<TileEntitySpawnerObsid
|
||||
return
|
||||
}
|
||||
|
||||
val spawnedEndermen = getEntitiesInSpawnArea<EntityMobEnderman>(searchArea).count()
|
||||
val spawnedEndermen = getEntitiesInSpawnArea<EntityMobEnderman>(searchArea).size
|
||||
val maxEndermen = level.mobLimitInSpawnArea
|
||||
|
||||
if (spawnedEndermen >= maxEndermen){
|
||||
|
@ -6,7 +6,7 @@ import net.minecraft.block.material.MaterialColor
|
||||
import net.minecraft.fluid.Fluid
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IEnviromentBlockReader
|
||||
import net.minecraft.world.ILightReader
|
||||
import net.minecraftforge.fluids.FluidAttributes
|
||||
import net.minecraftforge.fluids.FluidAttributes.Builder
|
||||
import net.minecraftforge.fluids.FluidStack
|
||||
@ -44,6 +44,6 @@ abstract class FluidBase(fluidName: String, val rgbColor: IntColor, val mapColor
|
||||
// keep the color property, but stop it from tinting the texture
|
||||
|
||||
override fun getColor(stack: FluidStack) = RGB(255u).i
|
||||
override fun getColor(world: IEnviromentBlockReader, pos: BlockPos) = RGB(255u).i
|
||||
override fun getColor(world: ILightReader, pos: BlockPos) = RGB(255u).i
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import chylex.hee.init.ModItems
|
||||
import chylex.hee.system.util.color.IntColor.Companion.RGB
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import net.minecraft.block.material.MaterialColor
|
||||
import net.minecraft.util.BlockRenderLayer.SOLID
|
||||
import net.minecraftforge.fluids.FluidAttributes.Builder
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid.Properties
|
||||
|
||||
@ -26,7 +25,6 @@ object FluidEnderGoo : FluidBase(
|
||||
override fun props(properties: Properties): Properties = with(properties){
|
||||
block { ModBlocks.ENDER_GOO }
|
||||
bucket { ModItems.ENDER_GOO_BUCKET }
|
||||
renderLayer(SOLID)
|
||||
}
|
||||
|
||||
override fun constructFlowingFluid(properties: Properties) = FlowingFluid5(properties)
|
||||
|
@ -5,7 +5,6 @@ import chylex.hee.init.ModItems
|
||||
import chylex.hee.system.util.color.IntColor.Companion.RGB
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import net.minecraft.block.material.MaterialColor
|
||||
import net.minecraft.util.BlockRenderLayer.SOLID
|
||||
import net.minecraftforge.fluids.FluidAttributes.Builder
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid.Properties
|
||||
|
||||
@ -26,7 +25,6 @@ object FluidEnderGooPurified : FluidBase(
|
||||
override fun props(properties: Properties): Properties = with(properties){
|
||||
block { ModBlocks.PURIFIED_ENDER_GOO }
|
||||
bucket { ModItems.PURIFIED_ENDER_GOO_BUCKET }
|
||||
renderLayer(SOLID /* UPDATE this should be translucent but it's not rendering */)
|
||||
}
|
||||
|
||||
override fun constructFlowingFluid(properties: Properties) = FlowingFluid5(properties)
|
||||
|
@ -7,6 +7,8 @@ import net.minecraftforge.common.ToolType
|
||||
|
||||
class BlockBuilder(val material: Material, var color: MaterialColor, var sound: SoundType){
|
||||
constructor(original: BlockBuilder) : this(original.material, original.color, original.sound){
|
||||
isSolid = original.isSolid
|
||||
|
||||
harvestTool = original.harvestTool
|
||||
harvestHardness = original.harvestHardness
|
||||
explosionResistance = original.explosionResistance
|
||||
@ -18,6 +20,8 @@ class BlockBuilder(val material: Material, var color: MaterialColor, var sound:
|
||||
noDrops = original.noDrops
|
||||
}
|
||||
|
||||
var isSolid = true
|
||||
|
||||
var harvestTool: Pair<Int, ToolType?> = Pair(-1, null)
|
||||
var harvestHardness: Float = 0F
|
||||
var explosionResistance: Float = 0F
|
||||
@ -42,8 +46,16 @@ class BlockBuilder(val material: Material, var color: MaterialColor, var sound:
|
||||
slipperiness(slipperiness)
|
||||
sound(sound)
|
||||
|
||||
if (!isSolid){
|
||||
notSolid()
|
||||
}
|
||||
|
||||
if (!material.blocksMovement()){
|
||||
doesNotBlockMovement()
|
||||
|
||||
if (isSolid){
|
||||
throw UnsupportedOperationException("[BlockBuilder] cannot create a block that does not block movement and is solid at the same time")
|
||||
}
|
||||
}
|
||||
|
||||
if (randomTicks){
|
||||
|
@ -204,6 +204,7 @@ object BlockBuilders{
|
||||
val buildIgneousPlate = BlockBuilder(Materials.IGNEOUS_ROCK_PLATE, MaterialColor.AIR, SoundType.STONE)
|
||||
|
||||
val buildBrewingStand = BlockBuilder(Material.IRON, MaterialColor.YELLOW, SoundType.STONE).apply {
|
||||
isSolid = false
|
||||
harvestHardness = 0.5F
|
||||
explosionResistance = 0.5F
|
||||
lightLevel = 2
|
||||
@ -240,11 +241,13 @@ object BlockBuilders{
|
||||
// Decorative (Trees)
|
||||
|
||||
val buildWhitebarkSapling = BlockBuilder(Material.PLANTS, MaterialColor.FOLIAGE, SoundType.PLANT).apply {
|
||||
isSolid = false
|
||||
harvestHardness = 0F
|
||||
explosionResistance = 0F
|
||||
}
|
||||
|
||||
val buildWhitebarkLeaves = BlockBuilder(Material.LEAVES, MaterialColor.AIR, SoundType.PLANT).apply {
|
||||
isSolid = false
|
||||
harvestHardness = 0.2F
|
||||
explosionResistance = 0.2F
|
||||
}
|
||||
@ -252,11 +255,13 @@ object BlockBuilders{
|
||||
// Decorative (Plants)
|
||||
|
||||
val buildPlant = BlockBuilder(Material.PLANTS, MaterialColor.AIR, SoundType.PLANT).apply {
|
||||
isSolid = false
|
||||
harvestHardness = 0F
|
||||
explosionResistance = 0F
|
||||
}
|
||||
|
||||
val buildFlowerPot = BlockBuilder(Material.MISCELLANEOUS, MaterialColor.AIR, SoundType.STONE).apply {
|
||||
isSolid = false
|
||||
harvestHardness = 0F
|
||||
explosionResistance = 0F
|
||||
}
|
||||
@ -264,17 +269,20 @@ object BlockBuilders{
|
||||
// Decorative (Uncategorized)
|
||||
|
||||
val buildAncientCobweb = BlockBuilder(Materials.ANCIENT_COBWEB, MaterialColor.WOOL, SoundType.STONE).apply {
|
||||
isSolid = false
|
||||
harvestHardness = 0.2F
|
||||
explosionResistance = 0.2F
|
||||
}
|
||||
|
||||
val buildDryVines = BlockBuilder(Material.TALL_PLANTS, MaterialColor.FOLIAGE, SoundType.PLANT).apply {
|
||||
isSolid = false
|
||||
harvestTool = Pair(WOOD, AXE)
|
||||
harvestHardness = 0.1F
|
||||
explosionResistance = 0.1F
|
||||
}
|
||||
|
||||
val buildEndermanHead = BlockBuilder(Material.MISCELLANEOUS, MaterialColor.BLACK, SoundType.STONE).apply {
|
||||
isSolid = false
|
||||
harvestHardness = 1.0F
|
||||
explosionResistance = 1.0F
|
||||
}
|
||||
@ -282,6 +290,7 @@ object BlockBuilders{
|
||||
// Spawners
|
||||
|
||||
val buildSpawnerObsidianTowers = BlockBuilder(Material.ROCK, MaterialColor.STONE, SoundType.METAL).apply {
|
||||
isSolid = false
|
||||
harvestTool = Pair(STONE, PICKAXE)
|
||||
harvestHardness = 8.0F
|
||||
explosionResistance = 8.0F
|
||||
@ -292,6 +301,7 @@ object BlockBuilders{
|
||||
|
||||
val buildPortalInner = BlockBuilder(Material.PORTAL, MaterialColor.BLACK, SoundType.STONE).apply {
|
||||
makeIndestructible()
|
||||
isSolid = false
|
||||
lightLevel = 15
|
||||
}
|
||||
|
||||
@ -308,11 +318,13 @@ object BlockBuilders{
|
||||
// Energy
|
||||
|
||||
val buildEnergyCluster = BlockBuilder(Materials.ENERGY_CLUSTER, MaterialColor.SNOW, SoundType.GLASS.clone(volume = 1.25F, pitch = 1.35F)).apply {
|
||||
isSolid = false
|
||||
lightLevel = 13
|
||||
noDrops = true
|
||||
}
|
||||
|
||||
val buildCorruptedEnergy = BlockBuilder(Materials.CORRUPTED_ENERGY, MaterialColor.PURPLE, SoundType.SAND).apply {
|
||||
isSolid = false
|
||||
randomTicks = true // just to be safe
|
||||
noDrops = true
|
||||
}
|
||||
@ -333,6 +345,7 @@ object BlockBuilders{
|
||||
// Utilities
|
||||
|
||||
val buildEternalFire = BlockBuilder(Material.FIRE, MaterialColor.AIR, SoundType.CLOTH).apply {
|
||||
isSolid = false
|
||||
harvestHardness = 0F
|
||||
explosionResistance = 0F
|
||||
noDrops = true
|
||||
@ -341,17 +354,20 @@ object BlockBuilders{
|
||||
|
||||
val buildScaffolding = BlockBuilder(Materials.SCAFFOLDING, MaterialColor.AIR, SoundType.STONE).apply {
|
||||
makeIndestructible()
|
||||
isSolid = false
|
||||
}
|
||||
|
||||
// Overrides
|
||||
|
||||
val buildEndPortalOverride = BlockBuilder(Material.PORTAL, MaterialColor.BLACK, SoundType.STONE).apply {
|
||||
makeIndestructible()
|
||||
isSolid = false
|
||||
lightLevel = 15
|
||||
randomTicks = true
|
||||
}
|
||||
|
||||
val buildDragonEgg = BlockBuilder(Material.DRAGON_EGG, MaterialColor.BLACK, SoundType.STONE).apply {
|
||||
isSolid = false
|
||||
harvestHardness = INDESTRUCTIBLE_HARDNESS
|
||||
explosionResistance = 9F
|
||||
lightLevel = 2
|
||||
|
@ -1,32 +1,21 @@
|
||||
package chylex.hee.game.container.slot
|
||||
import chylex.hee.game.mechanics.trinket.ITrinketItem
|
||||
import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.init.ModAtlases
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.items.IItemHandler
|
||||
import net.minecraftforge.items.SlotItemHandler
|
||||
|
||||
open class SlotTrinketItem(trinketHandler: IItemHandler, slotIndex: Int, x: Int, y: Int) : SlotItemHandler(trinketHandler, slotIndex, x, y){
|
||||
@Sided(Side.CLIENT)
|
||||
protected object Client{
|
||||
val TEX_SLOT = Resource.Custom("textures/gui/trinket.png")
|
||||
|
||||
const val TEX_SLOT_W = 64
|
||||
const val TEX_SLOT_H = 32
|
||||
|
||||
val TEX_DEFINITION = object : TextureAtlasSprite(TEX_SLOT, TEX_SLOT_W, TEX_SLOT_H){
|
||||
override fun getMinU() = 19F / TEX_SLOT_W
|
||||
override fun getMaxU() = 35F / TEX_SLOT_W
|
||||
override fun getMinV() = 1F / TEX_SLOT_H
|
||||
override fun getMaxV() = 17F / TEX_SLOT_H
|
||||
}
|
||||
companion object{
|
||||
val TEX_SLOT_OVERLAY = Resource.Custom("gui/slot_trinket")
|
||||
}
|
||||
|
||||
init{
|
||||
@Suppress("LeakingThis")
|
||||
setBackground(ModAtlases.ATLAS_GUIS, TEX_SLOT_OVERLAY)
|
||||
}
|
||||
|
||||
override fun isItemValid(stack: ItemStack) = (stack.item as? ITrinketItem)?.canPlaceIntoTrinketSlot(stack) == true
|
||||
override fun getSlotStackLimit() = 1
|
||||
|
||||
@Sided(Side.CLIENT) override fun getBackgroundLocation() = Client.TEX_SLOT
|
||||
@Sided(Side.CLIENT) override fun getBackgroundSprite() = Client.TEX_DEFINITION
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package chylex.hee.game.container.slot
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.render.util.GL
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.container.slot.SlotTrinketItemInventory.Client.isRenderingGUI
|
||||
import chylex.hee.network.server.PacketServerShiftClickTrinket
|
||||
@ -8,6 +9,7 @@ import chylex.hee.system.migration.forge.Side
|
||||
import chylex.hee.system.migration.forge.Sided
|
||||
import chylex.hee.system.migration.forge.SubscribeAllEvents
|
||||
import chylex.hee.system.migration.forge.SubscribeEvent
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import net.minecraft.client.gui.AbstractGui
|
||||
import net.minecraft.client.gui.screen.Screen
|
||||
import net.minecraft.client.gui.screen.inventory.InventoryScreen
|
||||
@ -19,6 +21,11 @@ import net.minecraftforge.items.IItemHandler
|
||||
|
||||
class SlotTrinketItemInventory(trinketHandler: IItemHandler, slotNumber: Int) : SlotTrinketItem(trinketHandler, 0, -2000, -2000){
|
||||
companion object{
|
||||
private val TEX_SLOT_BACKGROUND = Resource.Custom("textures/gui/slot_background.png")
|
||||
|
||||
private const val TEX_SLOT_W = 32
|
||||
private const val TEX_SLOT_H = 32
|
||||
|
||||
fun findTrinketSlot(allSlots: List<Slot>): Slot?{
|
||||
return allSlots.asReversed().firstOrNull { it is SlotTrinketItemInventory }
|
||||
}
|
||||
@ -42,11 +49,8 @@ class SlotTrinketItemInventory(trinketHandler: IItemHandler, slotNumber: Int) :
|
||||
isRenderingGUI = false
|
||||
|
||||
RenderHelper.disableStandardItemLighting()
|
||||
|
||||
MC.textureManager.bindTexture(SlotTrinketItem.Client.TEX_SLOT)
|
||||
AbstractGui.blit(xPos - 1, yPos - 1, 18, 18, 0F, 0F, 18, 18, SlotTrinketItem.Client.TEX_SLOT_W, SlotTrinketItem.Client.TEX_SLOT_H)
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting()
|
||||
GL.bindTexture(TEX_SLOT_BACKGROUND)
|
||||
AbstractGui.blit(xPos - 1, yPos - 1, 18, 18, 0F, 0F, 18, 18, TEX_SLOT_W, TEX_SLOT_H)
|
||||
}
|
||||
|
||||
return true
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user