Skip to content

Commit

Permalink
Port Kibe 1.10 to Minecraft 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaargolo committed Jul 16, 2023
1 parent 209392d commit c72f019
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/io/github/lucaargolo/kibe/KibeModClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry
import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.minecraft.client.MinecraftClient
import net.minecraft.client.particle.FlameParticle
Expand All @@ -45,6 +44,7 @@ import net.minecraft.client.util.SpriteIdentifier
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.network.PacketByteBuf
import net.minecraft.resource.ResourceManager
import net.minecraft.screen.PlayerScreenHandler
import net.minecraft.util.Identifier
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ChunkLoaderScreen(be: ChunkLoaderBlockEntity): Screen(Text.translatable("s
val toggle = Text.translatable("tooltip.kibe.check_for_owner")
context.matrices.push()
context.matrices.scale(0.5f, 0.5f, 0.5f)
context.drawText(textRenderer, toggle, (x+16)*2f, (y+20f)*2f, 4210752)
context.drawText(textRenderer, toggle, (x+16)*2, (y+20)*2, 4210752, false)
context.matrices.pop()
}

Expand All @@ -103,8 +103,7 @@ class ChunkLoaderScreen(be: ChunkLoaderBlockEntity): Screen(Text.translatable("s
context.fill(x+7+((it.first+2)*16), y+28+((it.second+2)*16), x+7+((it.first+2)*16)+16, y+28+((it.second+2)*16)+16, -2147418368)
}
if(entity.checkForOwner) {
RenderSystem.setShaderTexture(0, texture)
drawTexture(matrices, x+7, y+18, 94, 0, 7, 7)
context.drawTexture(texture, x+7, y+18, 94, 0, 7, 7)
}
if(mouseX in (x+7 until x+87) && mouseY in (y+28 until y+109)) {
val chunkX = (mouseX-(x+7))/16
Expand All @@ -115,15 +114,15 @@ class ChunkLoaderScreen(be: ChunkLoaderBlockEntity): Screen(Text.translatable("s
tooltip.add(Text.translatable("tooltip.kibe.forced").append(Text.translatable(if(entity.enabledChunks.contains(Pair(chunkX-2, chunkZ-2))) "tooltip.kibe.enabled" else "tooltip.kibe.disabled")))
context.drawTooltip(textRenderer, tooltip, mouseX, mouseY)
}else if(mouseX in (x+7 until x+14) && mouseY in (y+18 until y+25)) {
DrawableHelper.fill(matrices, x+7, y+18, x+14, y+25, -2130706433)
context.fill(x+7, y+18, x+14, y+25, -2130706433)
val tooltip = mutableListOf<Text>()
tooltip.add(Text.translatable("tooltip.kibe.check_for_owner_status", if (entity.checkForOwner) Text.translatable("tooltip.kibe.enabled") else Text.translatable("tooltip.kibe.disabled")))
if(notOwner) {
tooltip.add(Text.translatable("tooltip.kibe.lore.not_owner"))
}else {
tooltip.add(Text.translatable("tooltip.kibe.lore.check_for_owner"))
}
renderTooltip(matrices, tooltip, mouseX, mouseY)
context.drawTooltip(textRenderer, tooltip, mouseX, mouseY)
}else{
notOwner = false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.lucaargolo.kibe.blocks.miscellaneous

import io.github.lucaargolo.kibe.utils.FakePlayerEntity
import net.fabricmc.fabric.api.entity.FakePlayer
import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings
import net.minecraft.block.Block
import net.minecraft.block.BlockState
Expand Down Expand Up @@ -58,7 +58,7 @@ class Igniter: Block(FabricBlockSettings.copyOf(Blocks.COBBLESTONE)) {

override fun scheduledTick(state: BlockState, world: ServerWorld, pos: BlockPos, random: Random) {
val facing = state[Properties.FACING]
val fakePlayer = FakePlayerEntity(world)
val fakePlayer = FakePlayer.get(world)
fakePlayer.setStackInHand(Hand.MAIN_HAND, Items.FLINT_AND_STEEL.defaultStack)
var facingPos = pos.offset(facing)
val facingState = world.getBlockState(facingPos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class Spikes(private val type: Type, settings: Settings): Block(settings) {
}

override fun rotate(state: BlockState, rotation: BlockRotation): BlockState {
return state.with(DispenserBlock.FACING, rotation.rotate(state[DispenserBlock.FACING]))
return state.with(Properties.FACING, rotation.rotate(state[Properties.FACING]))
}

override fun mirror(state: BlockState, mirror: BlockMirror): BlockState {
return state.rotate(mirror.getRotation(state[DispenserBlock.FACING]))
return state.rotate(mirror.getRotation(state[Properties.FACING]))
}

override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import net.fabricmc.fabric.api.client.model.ModelVariantProvider
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType
import net.minecraft.client.gui.screen.ingame.HandledScreen
import net.minecraft.client.gui.screen.ingame.HandledScreens
import net.minecraft.client.item.ClampedModelPredicateProvider
import net.minecraft.client.item.ModelPredicateProviderRegistry
import net.minecraft.client.item.UnclampedModelPredicateProvider
import net.minecraft.client.render.model.*
import net.minecraft.client.texture.Sprite
import net.minecraft.client.util.SpriteIdentifier
Expand Down Expand Up @@ -86,7 +86,7 @@ interface Identified {
val identifier: Identifier
}

interface IdentifiedModelPredicateProvider : UnclampedModelPredicateProvider, Identified
interface IdentifiedModelPredicateProvider : ClampedModelPredicateProvider, Identified

class ItemInfo (
val identifier: Identifier,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package io.github.lucaargolo.kibe.items.cooler

import net.minecraft.client.font.TextRenderer
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.gui.tooltip.BundleTooltipComponent
import net.minecraft.client.item.BundleTooltipData
import net.minecraft.client.render.item.ItemRenderer
import net.minecraft.client.util.math.MatrixStack

class CoolerTooltipComponent(data: BundleTooltipData) : BundleTooltipComponent(data) {

override fun drawSlot(x: Int, y: Int, index: Int, shouldBlock: Boolean, textRenderer: TextRenderer, matrices: MatrixStack, itemRenderer: ItemRenderer, z: Int) {
override fun drawSlot(x: Int, y: Int, index: Int, shouldBlock: Boolean, context: DrawContext, textRenderer: TextRenderer) {
val itemStack = inventory[index]
draw(matrices, x, y, z, Sprite.SLOT)
itemRenderer.renderInGuiWithOverrides(itemStack, x + 1, y + 1, index)
itemRenderer.renderGuiItemOverlay(textRenderer, itemStack, x + 1, y + 1)
draw(context, x, y, Sprite.SLOT)
context.drawItem(itemStack, x + 1, y + 1, index)
context.drawItemInSlot(textRenderer, itemStack, x + 1, y + 1)
}

override fun getColumns() = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class Lasso(settings: Settings): Item(settings) {

override fun useOnEntity(stack: ItemStack, user: PlayerEntity, entity: LivingEntity, hand: Hand): ActionResult {
if (stack.nbt == null || !stack.orCreateNbt.contains("Entity")) {
if (entity is MobEntity && canStoreEntity(entity.type) && MOD_CONFIG.miscellaneousModule.lassoDenyList.contains(Registry.ENTITY_TYPE.getId(entity.type).toString())) {
if (entity is MobEntity && canStoreEntity(entity.type) && MOD_CONFIG.miscellaneousModule.lassoDenyList.contains(Registries.ENTITY_TYPE.getId(entity.type).toString())) {
if(!user.world.isClient) {
if (entity.isLeashed) entity.detachLeash(true, true)
entity.fallDistance = 0f
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/kibe.accesswidener
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
accessWidener v1 named
extendable method net/minecraft/client/gui/tooltip/BundleTooltipComponent getColumns ()I
extendable method net/minecraft/client/gui/tooltip/BundleTooltipComponent getRows ()I
extendable method net/minecraft/client/gui/tooltip/BundleTooltipComponent drawSlot (IIIZLnet/minecraft/client/font/TextRenderer;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/item/ItemRenderer;I)V
extendable method net/minecraft/client/gui/tooltip/BundleTooltipComponent draw (Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/gui/tooltip/BundleTooltipComponent$Sprite;)V
extendable method net/minecraft/client/gui/tooltip/BundleTooltipComponent drawSlot (IIIZLnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/font/TextRenderer;)V
extendable method net/minecraft/client/gui/tooltip/BundleTooltipComponent draw (Lnet/minecraft/client/gui/DrawContext;IILnet/minecraft/client/gui/tooltip/BundleTooltipComponent$Sprite;)V
accessible field net/minecraft/client/gui/tooltip/BundleTooltipComponent inventory Lnet/minecraft/util/collection/DefaultedList;
accessible class net/minecraft/client/gui/tooltip/BundleTooltipComponent$Sprite

0 comments on commit c72f019

Please sign in to comment.