From 34d51993037b44d335430c323eebc993ce6a7f4b Mon Sep 17 00:00:00 2001 From: lucaargolo Date: Tue, 13 Jun 2023 19:21:49 -0300 Subject: [PATCH] Port to 1.20 --- README.md | 7 +- build.gradle.kts | 43 ++-- gradle.properties | 30 +-- .../mixin/ClientPlayNetworkHandlerMixin.java | 2 +- .../mixin/CraftingTableContainerMixin.java | 3 +- .../kibe/mixin/HeldItemRendererMixin.java | 6 +- .../kibe/mixin/LivingEntityMixin.java | 20 +- .../kibe/mixin/PlayerEntityMixin.java | 6 +- .../kibe/mixin/PlayerEntityRendererMixin.java | 8 +- .../kibe/mixin/ShapedRecipeMixin.java | 10 +- .../io/github/lucaargolo/kibe/KibeMod.kt | 22 +- .../github/lucaargolo/kibe/KibeModClient.kt | 10 - .../lucaargolo/kibe/blocks/BlockCompendium.kt | 14 +- .../kibe/blocks/bigtorch/BigTorch.kt | 3 +- .../blocks/bigtorch/BigTorchBlockEntity.kt | 3 +- .../kibe/blocks/bigtorch/BigTorchScreen.kt | 23 +- .../blocks/bigtorch/BigTorchScreenHandler.kt | 2 +- .../lucaargolo/kibe/blocks/breaker/Breaker.kt | 4 +- .../kibe/blocks/breaker/BreakerScreen.kt | 21 +- .../blocks/breaker/BreakerScreenHandler.kt | 2 +- .../kibe/blocks/chunkloader/ChunkLoader.kt | 2 +- .../blocks/chunkloader/ChunkLoaderScreen.kt | 32 ++- .../blocks/chunkloader/ChunkLoaderState.kt | 6 +- .../lucaargolo/kibe/blocks/cooler/Cooler.kt | 4 +- .../kibe/blocks/cooler/CoolerScreen.kt | 20 +- .../kibe/blocks/cooler/CoolerScreenHandler.kt | 2 +- .../kibe/blocks/drawbridge/Drawbridge.kt | 2 +- .../drawbridge/DrawbridgeBlockEntity.kt | 7 +- .../drawbridge/DrawbridgeCustomModel.kt | 34 +-- .../blocks/drawbridge/DrawbridgeScreen.kt | 22 +- .../drawbridge/DrawbridgeScreenHandler.kt | 2 +- .../blocks/entangledchest/EntangledChest.kt | 4 +- .../EntangledChestEntityRenderer.kt | 12 +- .../entangledchest/EntangledChestScreen.kt | 26 +-- .../EntangledChestScreenHandler.kt | 2 +- .../blocks/entangledtank/EntangledTank.kt | 4 +- .../entangledtank/EntangledTankEntity.kt | 2 +- .../EntangledTankEntityRenderer.kt | 7 +- .../BlockGeneratorBlockEntity.kt | 15 +- .../miscellaneous/BlockGeneratorScreen.kt | 64 +++--- .../BlockGeneratorScreenHandler.kt | 2 +- .../kibe/blocks/miscellaneous/ConveyorBelt.kt | 4 +- .../kibe/blocks/miscellaneous/CursedDirt.kt | 15 +- .../kibe/blocks/miscellaneous/Dehumidifier.kt | 2 +- .../kibe/blocks/miscellaneous/Elevator.kt | 4 +- .../kibe/blocks/miscellaneous/FluidHopper.kt | 7 +- .../miscellaneous/FluidHopperBlockEntity.kt | 4 +- .../kibe/blocks/miscellaneous/Heater.kt | 2 +- .../blocks/miscellaneous/HeaterBlockEntity.kt | 3 +- .../kibe/blocks/miscellaneous/Igniter.kt | 4 +- .../kibe/blocks/miscellaneous/LightSource.kt | 6 +- .../blocks/miscellaneous/RedstoneTimer.kt | 2 +- .../RedstoneTimerEntityRenderer.kt | 34 +-- .../kibe/blocks/miscellaneous/Spikes.kt | 9 +- .../kibe/blocks/miscellaneous/XpDrain.kt | 4 +- .../kibe/blocks/miscellaneous/XpShower.kt | 4 +- .../miscellaneous/XpShowerBlockEntity.kt | 2 +- .../lucaargolo/kibe/blocks/placer/Placer.kt | 6 +- .../kibe/blocks/placer/PlacerScreen.kt | 20 +- .../kibe/blocks/placer/PlacerScreenHandler.kt | 2 +- .../lucaargolo/kibe/blocks/tank/Tank.kt | 2 +- .../kibe/blocks/tank/TankBlockEntity.kt | 2 +- .../blocks/tank/TankBlockEntityRenderer.kt | 4 +- .../kibe/blocks/tank/TankCustomModel.kt | 5 +- .../kibe/blocks/trashcan/TrashCan.kt | 2 +- .../kibe/blocks/trashcan/TrashCanScreen.kt | 20 +- .../blocks/trashcan/TrashCanScreenHandler.kt | 2 +- .../kibe/blocks/vacuum/VacuumHopper.kt | 6 +- .../kibe/blocks/vacuum/VacuumHopperEntity.kt | 6 +- .../vacuum/VacuumHopperEntityRenderer.kt | 2 +- .../kibe/blocks/vacuum/VacuumHopperScreen.kt | 38 ++-- .../vacuum/VacuumHopperScreenHandler.kt | 2 +- .../blocks/witherbuilder/WitherBuilder.kt | 14 +- .../witherbuilder/WitherBuilderBlockEntity.kt | 2 +- .../witherbuilder/WitherBuilderScreen.kt | 22 +- .../WitherBuilderScreenHandler.kt | 4 +- .../compat/trinkets/TrinketAbilityRing.kt | 3 +- .../kibe/effects/EffectCompendium.kt | 5 +- .../kibe/entities/EntityCompendium.kt | 5 +- .../lucaargolo/kibe/fluids/FluidCompendium.kt | 21 +- .../kibe/fluids/miscellaneous/ModdedFluid.kt | 3 +- .../lucaargolo/kibe/items/ItemCompendium.kt | 208 +++++++++--------- .../items/cooler/CoolerBlockItemScreen.kt | 20 +- .../cooler/CoolerBlockItemScreenHandler.kt | 2 +- .../items/entangledbag/EntangledBagScreen.kt | 26 +-- .../entangledbag/EntangledBagScreenHandler.kt | 2 +- .../items/entangledbucket/EntangledBucket.kt | 9 +- .../EntangledChestBlockItemDynamicRenderer.kt | 3 +- .../EntangledTankBlockItemDynamicRenderer.kt | 3 +- .../miscellaneous/GliderDynamicRenderer.kt | 9 +- .../kibe/items/miscellaneous/Lasso.kt | 5 +- .../kibe/items/miscellaneous/Magnet.kt | 6 +- .../miscellaneous/PocketCraftingTable.kt | 4 +- .../kibe/items/miscellaneous/SleepingBag.kt | 2 +- .../kibe/items/miscellaneous/SlimeBoots.kt | 6 +- .../kibe/items/miscellaneous/VoidBucket.kt | 6 +- .../items/trashcan/PocketTrashCanScreen.kt | 22 +- .../trashcan/PocketTrashCanScreenHandler.kt | 2 +- .../kibe/recipes/RecipeSerializers.kt | 5 +- .../lucaargolo/kibe/recipes/RecipeTypes.kt | 5 +- .../kibe/recipes/vacuum/VacuumHopperRecipe.kt | 9 +- .../vacuum/VacuumHopperRecipeSerializer.kt | 5 +- .../lucaargolo/kibe/utils/CreativeTab.kt | 19 +- ...yerEntity.kt => FakeClientPlayerEntity.kt} | 2 +- .../github/lucaargolo/kibe/utils/FluidUtil.kt | 38 ---- .../lucaargolo/kibe/utils/RingAbilities.kt | 2 +- .../kibe/utils/SyncableBlockEntity.kt | 2 +- src/main/resources/fabric.mod.json | 6 +- 108 files changed, 598 insertions(+), 644 deletions(-) rename src/main/kotlin/io/github/lucaargolo/kibe/utils/{FakePlayerEntity.kt => FakeClientPlayerEntity.kt} (78%) diff --git a/README.md b/README.md index d1db4ac6..4900c734 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,14 @@

- +

- - + +

+ ## Features For a complete list of features please check the mods [official page](https://www.curseforge.com/minecraft/mc-mods/kibe) diff --git a/build.gradle.kts b/build.gradle.kts index 777ac2dc..f527970b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,8 +5,6 @@ import com.matthewprenger.cursegradle.CurseProject import com.matthewprenger.cursegradle.CurseArtifact import com.matthewprenger.cursegradle.CurseRelation import com.matthewprenger.cursegradle.Options -import com.modrinth.minotaur.TaskModrinthUpload -import com.modrinth.minotaur.request.VersionType buildscript { dependencies { @@ -43,8 +41,8 @@ group = project["maven_group"] val environment: Map = System.getenv() val releaseName = "${name.split("-").joinToString(" ") { it.capitalize() }} ${(version as String).split("+")[0]}" -val releaseType = (version as String).split("+")[0].split("-").let { if(it.isNotEmpty()) if(it[1] == "BETA" || it[1] == "ALPHA") it[1] else "ALPHA" else "RELEASE" } -val releaseFile = "${buildDir}/libs/${base.archivesBaseName}-${version}.jar" +val releaseType = (version as String).split("+")[0].split("-").let { if(it.size > 1) if(it[1] == "BETA" || it[1] == "ALPHA") it[1] else "ALPHA" else "RELEASE" } +val releaseFile = "${buildDir}/libs/${base.archivesName.get()}-${version}.jar" val cfGameVersion = (version as String).split("+")[1].let{ if(!project["minecraft_version"].contains("-") && project["minecraft_version"].startsWith(it)) project["minecraft_version"] else "$it-Snapshot"} fun getChangeLog(): String { @@ -100,11 +98,7 @@ dependencies { modImplementation("net.fabricmc.fabric-api:fabric-api:${project["fabric_version"]}") modImplementation("net.fabricmc:fabric-language-kotlin:${project["fabric_kotlin_version"]}") - modCompileOnly ("com.github.emilyalexandra:trinkets:${project["trinkets_version"]}") { - exclude(group = "net.fabricmc.fabric-api") - exclude(group = "dev.onyxstudios.cardinal-components-api") - exclude(group = "com.terraformersmc") - } + modImplementation("dev.emi:trinkets:${project["trinkets_version"]}") modImplementation("io.github.ladysnake:PlayerAbilityLib:${project["pal_version"]}") include("io.github.ladysnake:PlayerAbilityLib:${project["pal_version"]}") @@ -197,24 +191,25 @@ curseforge { } //Modrinth publishing -task("modrinth") { - dependsOn(tasks.remapJar) - group = "upload" +modrinth { + environment["MODRINTH_TOKEN"]?.let { token.set(it) } - onlyIf { - environment.containsKey("MODRINTH_TOKEN") - } - token = environment["MODRINTH_TOKEN"] + projectId.set(project["modrinth_id"]) + changelog.set(getChangeLog()) - projectId = project["modrinth_id"] - changelog = getChangeLog() + versionNumber.set(version as String) + versionName.set(releaseName) + versionType.set(releaseType.toLowerCase()) - versionNumber = version as String - versionName = releaseName - versionType = VersionType.valueOf(releaseType) + uploadFile.set(tasks.remapJar.get()) - uploadFile = file(releaseFile) + gameVersions.add(project["minecraft_version"]) + loaders.add("fabric") - addGameVersion(project["minecraft_version"]) - addLoader("fabric") + dependencies { + required.project("fabric-api") + } +} +tasks.modrinth.configure { + group = "upload" } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4c39d1b5..385ca3e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,32 +2,32 @@ org.gradle.jvmargs=-Xmx4G # Gradle Plugins -kotlin_version=1.7.0 -loom_version=0.12-SNAPSHOT -grgit_version=4.1.1 +kotlin_version=1.8.22 +loom_version=1.1-SNAPSHOT +grgit_version=5.0.0 cursegradle_version=1.4.0 -modrinth_version=1.2.1 -github_api_version=1.114 +modrinth_version=2.7.3 +github_api_version=1.314 # Mod Properties -mod_version=1.9.11-BETA+1.19 +mod_version=1.9.11-BETA+1.20 maven_group=io.github.lucaargolo # Fabric Properties -minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.12 -loader_version=0.14.9 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.1 +loader_version=0.14.21 #Fabric api -fabric_version=0.61.0+1.19.2 -fabric_kotlin_version=1.8.0+kotlin.1.7.0 +fabric_version=0.83.1+1.20.1 +fabric_kotlin_version=1.9.5+kotlin.1.8.22 # Libraries -pal_version=1.6.0 -trinkets_version=3.4.0 +pal_version=1.8.0 +trinkets_version=3.7.0 dashloader_version=2.0 -modmenu_version=4.0.6 -rei_version=9.1.550 +modmenu_version=7.0.1 +rei_version=12.0.613 # Publishing curseforge_id=388832 diff --git a/src/main/java/io/github/lucaargolo/kibe/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/io/github/lucaargolo/kibe/mixin/ClientPlayNetworkHandlerMixin.java index 63264d7b..f0694ede 100644 --- a/src/main/java/io/github/lucaargolo/kibe/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/io/github/lucaargolo/kibe/mixin/ClientPlayNetworkHandlerMixin.java @@ -26,7 +26,7 @@ public class ClientPlayNetworkHandlerMixin { @Inject(at = @At("TAIL"), method = "onEntitySpawn") public void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo ci) { double x = packet.getX(), y = packet.getY(), z = packet.getZ(); - EntityType entityType = packet.getEntityTypeId(); + EntityType entityType = packet.getEntityType(); Entity entity = null; if(entityType == EntityCompendiumKt.getTHROWN_TORCH()) { diff --git a/src/main/java/io/github/lucaargolo/kibe/mixin/CraftingTableContainerMixin.java b/src/main/java/io/github/lucaargolo/kibe/mixin/CraftingTableContainerMixin.java index abdf3945..1b6b4fc6 100644 --- a/src/main/java/io/github/lucaargolo/kibe/mixin/CraftingTableContainerMixin.java +++ b/src/main/java/io/github/lucaargolo/kibe/mixin/CraftingTableContainerMixin.java @@ -3,6 +3,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingResultInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.screen.CraftingScreenHandler; import net.minecraft.screen.ScreenHandlerContext; import org.spongepowered.asm.mixin.Mixin; @@ -12,7 +13,7 @@ public interface CraftingTableContainerMixin { @Accessor - CraftingInventory getInput(); + RecipeInputInventory getInput(); @Accessor CraftingResultInventory getResult(); @Accessor diff --git a/src/main/java/io/github/lucaargolo/kibe/mixin/HeldItemRendererMixin.java b/src/main/java/io/github/lucaargolo/kibe/mixin/HeldItemRendererMixin.java index 9d331411..5bac6c07 100644 --- a/src/main/java/io/github/lucaargolo/kibe/mixin/HeldItemRendererMixin.java +++ b/src/main/java/io/github/lucaargolo/kibe/mixin/HeldItemRendererMixin.java @@ -8,7 +8,7 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -46,11 +46,11 @@ private void updateHeldItems(CallbackInfo info) { } } - @Inject(at = @At("HEAD"), method = "renderFirstPersonItem", cancellable = true) + @Inject(at = @At("HEAD"), method = "renderFirstPersonItem") private void renderFirstPersonItemPre(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) { if(player.getStackInHand(hand).getItem() instanceof Glider && Glider.Companion.isEnabled(player.getStackInHand(hand))) { matrices.push(); - matrices.multiply(Vec3f.NEGATIVE_X.getDegreesQuaternion(360 - player.getPitch(tickDelta))); + matrices.multiply(RotationAxis.NEGATIVE_X.rotationDegrees(360 - player.getPitch(tickDelta))); } } diff --git a/src/main/java/io/github/lucaargolo/kibe/mixin/LivingEntityMixin.java b/src/main/java/io/github/lucaargolo/kibe/mixin/LivingEntityMixin.java index 55e9dbde..68b324d8 100644 --- a/src/main/java/io/github/lucaargolo/kibe/mixin/LivingEntityMixin.java +++ b/src/main/java/io/github/lucaargolo/kibe/mixin/LivingEntityMixin.java @@ -51,14 +51,14 @@ private void isSleepingInBed(CallbackInfoReturnable info) { } } - @Inject(at = @At("HEAD"), method = "jump", cancellable = true) + @Inject(at = @At("HEAD"), method = "jump") private void jump(CallbackInfo info) { BlockPos pos = this.getBlockPos(); - Block block = this.world.getBlockState(pos.down()).getBlock(); - if (block instanceof Elevator && world.getBlockState(pos).getCollisionShape(world, pos).isEmpty()) { - while(pos.getY() < world.getTopY()) { - if(world.getBlockState(pos.up()).getBlock().equals(block) && Elevator.Companion.isElevatorValid(world, pos.up())) { - world.playSound(null, pos, SoundEvents.BLOCK_PISTON_EXTEND, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.25F + 0.6F); + Block block = this.getWorld().getBlockState(pos.down()).getBlock(); + if (block instanceof Elevator && getWorld().getBlockState(pos).getCollisionShape(getWorld(), pos).isEmpty()) { + while(pos.getY() < getWorld().getTopY()) { + if(getWorld().getBlockState(pos.up()).getBlock().equals(block) && Elevator.Companion.isElevatorValid(getWorld(), pos.up())) { + getWorld().playSound(null, pos, SoundEvents.BLOCK_PISTON_EXTEND, SoundCategory.BLOCKS, 0.5F, getWorld().random.nextFloat() * 0.25F + 0.6F); this.teleport(this.getPos().x, pos.up().getY()+1.15, this.getPos().z); break; }else{ @@ -74,7 +74,7 @@ private void jump(CallbackInfo info) { Licensed under the MIT license available at: https://tldrlegal.com/license/mit-license */ @SuppressWarnings("ConstantConditions") - @Inject(at = @At("HEAD"), method = "handleFallDamage", cancellable = true) + @Inject(at = @At("HEAD"), method = "handleFallDamage") private void handleFallDamage(float fallDistance, float damageMultiplier, DamageSource source, CallbackInfoReturnable info) { if((Object) this instanceof PlayerEntity) { PlayerEntity player = ((PlayerEntity) ((Object) this)); @@ -82,10 +82,10 @@ private void handleFallDamage(float fallDistance, float damageMultiplier, Damage if(!isSneaking() && fallDistance > 2) { this.fallDistance = 0; - if(world.isClient) { + if(getWorld().isClient) { setVelocity(getVelocity().x, getVelocity().y*-0.9, getVelocity().z); velocityDirty = true; - onGround = false; + setOnGround(false); double f = 0.91d + 0.04d; setVelocity(getVelocity().x/f, getVelocity().y, getVelocity().z/f); }else{ @@ -95,7 +95,7 @@ private void handleFallDamage(float fallDistance, float damageMultiplier, Damage this.playSound(SoundEvents.ENTITY_SLIME_SQUISH, 1f, 1f); SlimeBounceHandler.Companion.addBounceHandler(player, getVelocity().y); - }else if(!world.isClient && isSneaking()) { + }else if(!getWorld().isClient && isSneaking()) { if(fallDistance > 5) this.fallDistance = 5; } } diff --git a/src/main/java/io/github/lucaargolo/kibe/mixin/PlayerEntityMixin.java b/src/main/java/io/github/lucaargolo/kibe/mixin/PlayerEntityMixin.java index 0d407216..296576c9 100644 --- a/src/main/java/io/github/lucaargolo/kibe/mixin/PlayerEntityMixin.java +++ b/src/main/java/io/github/lucaargolo/kibe/mixin/PlayerEntityMixin.java @@ -135,12 +135,12 @@ private void tick(CallbackInfo info) { Licensed under the MIT license available at: https://tldrlegal.com/license/mit-license */ Iterator keyIt; - if(world.isClient) keyIt = SlimeBounceHandler.Companion.getClientBouncingEntities().keySet().iterator(); + if(getWorld().isClient) keyIt = SlimeBounceHandler.Companion.getClientBouncingEntities().keySet().iterator(); else keyIt = SlimeBounceHandler.Companion.getServerBouncingEntities().keySet().iterator(); while(keyIt.hasNext()) { Entity entity = keyIt.next(); SlimeBounceHandler bounce; - if(world.isClient) bounce = SlimeBounceHandler.Companion.getClientBouncingEntities().get(entity); + if(getWorld().isClient) bounce = SlimeBounceHandler.Companion.getClientBouncingEntities().get(entity); else bounce = SlimeBounceHandler.Companion.getServerBouncingEntities().get(entity); if(player.equals(entity) && !player.isFallFlying()) { if(player.age == bounce.getBounceTick()) { @@ -174,7 +174,7 @@ private void tick(CallbackInfo info) { } } //Ring logic - if(!world.isClient && this instanceof PlayerAbilityView) { + if(!getWorld().isClient && this instanceof PlayerAbilityView) { for(PlayerAbility pa : RingAbilitiesKt.getPotionToAbilityMap().keySet()) { if(pa.isEnabledFor(player)) { StatusEffect se = RingAbilitiesKt.getPotionToAbilityMap().get(pa); diff --git a/src/main/java/io/github/lucaargolo/kibe/mixin/PlayerEntityRendererMixin.java b/src/main/java/io/github/lucaargolo/kibe/mixin/PlayerEntityRendererMixin.java index b0f717d1..08e97222 100644 --- a/src/main/java/io/github/lucaargolo/kibe/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/io/github/lucaargolo/kibe/mixin/PlayerEntityRendererMixin.java @@ -6,7 +6,7 @@ import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.PlayerEntityRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -27,11 +27,11 @@ private void renderPre(AbstractClientPlayerEntity abstractClientPlayerEntity, fl float interpolatedYaw = abstractClientPlayerEntity.prevHeadYaw + (abstractClientPlayerEntity.headYaw - abstractClientPlayerEntity.prevHeadYaw) * partialTicks; matrixStack.push(); - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-interpolatedYaw)); + matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-interpolatedYaw)); matrixStack.translate(0f, abstractClientPlayerEntity.getHeight() / 2f, 0f); - matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90f)); + matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90f)); matrixStack.translate(0f, -abstractClientPlayerEntity.getHeight() / 2f, 0f); - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(interpolatedYaw)); + matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(interpolatedYaw)); GliderHelper.INSTANCE.setPlayerRenderPoppingNeeds(abstractClientPlayerEntity, true); } diff --git a/src/main/java/io/github/lucaargolo/kibe/mixin/ShapedRecipeMixin.java b/src/main/java/io/github/lucaargolo/kibe/mixin/ShapedRecipeMixin.java index 81dadbab..5c116475 100644 --- a/src/main/java/io/github/lucaargolo/kibe/mixin/ShapedRecipeMixin.java +++ b/src/main/java/io/github/lucaargolo/kibe/mixin/ShapedRecipeMixin.java @@ -2,8 +2,10 @@ import io.github.lucaargolo.kibe.items.ItemCompendiumKt; import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.ShapedRecipe; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -13,12 +15,12 @@ @Mixin(ShapedRecipe.class) public abstract class ShapedRecipeMixin { - @Shadow public abstract ItemStack getOutput(); + @Shadow @Final ItemStack output; @Inject(at = @At("HEAD"), method = "matchesPattern", cancellable = true) - private void matchesSmall(CraftingInventory inv, int offsetX, int offsetY, boolean bl, CallbackInfoReturnable info) { - if(getOutput().getItem() == ItemCompendiumKt.getGLIDER_LEFT_WING() || getOutput().getItem() == ItemCompendiumKt.getGLIDER_RIGHT_WING()) { - if(bl) info.setReturnValue(false); + private void matchesSmall(RecipeInputInventory inv, int offsetX, int offsetY, boolean flipped, CallbackInfoReturnable cir) { + if(output.getItem() == ItemCompendiumKt.getGLIDER_LEFT_WING() || output.getItem() == ItemCompendiumKt.getGLIDER_RIGHT_WING()) { + if(flipped) cir.setReturnValue(false); } } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/KibeMod.kt b/src/main/kotlin/io/github/lucaargolo/kibe/KibeMod.kt index 35907449..352ce6d3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/KibeMod.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/KibeMod.kt @@ -59,7 +59,8 @@ import net.minecraft.server.MinecraftServer import net.minecraft.util.DyeColor import net.minecraft.util.Identifier import net.minecraft.util.math.ChunkPos -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger import java.io.File @@ -68,6 +69,7 @@ import java.nio.file.Files import java.util.* const val MOD_ID = "kibe" +const val MOD_NAME = "Kibe" val FAKE_PLAYER_UUID: UUID = UUID.randomUUID() val CHUNK_MAP_CLICK = Identifier(MOD_ID, "chunk_map_click") val REQUEST_DIRTY_TANK_STATES = Identifier(MOD_ID, "request_dirty_tank_states") @@ -75,7 +77,7 @@ val SYNCHRONIZE_DIRTY_TANK_STATES = Identifier(MOD_ID, "synchronize_dirty_tank_s val CLIENT: Boolean by lazy { FabricLoader.getInstance().environmentType == EnvType.CLIENT } val TRINKET: Boolean by lazy { FabricLoader.getInstance().isModLoaded("trinkets") } val WATER_DROPS: DefaultParticleType by lazy { - Registry.register(Registry.PARTICLE_TYPE, Identifier(MOD_ID, "water_drops"), FabricParticleTypes.simple()) + Registry.register(Registries.PARTICLE_TYPE, Identifier(MOD_ID, "water_drops"), FabricParticleTypes.simple()) } val LOGGER: Logger = LogManager.getLogger("Kibe") val MOD_CONFIG: ModConfig by lazy { @@ -83,27 +85,27 @@ val MOD_CONFIG: ModConfig by lazy { val gson = GsonBuilder().setPrettyPrinting().create() val configFile = File("${FabricLoader.getInstance().configDir}${File.separator}$MOD_ID.json") var finalConfig: ModConfig - LOGGER.info("Trying to read config file...") + LOGGER.info("[$MOD_NAME] Trying to read config file...") try { if (configFile.createNewFile()) { - LOGGER.info("No config file found, creating a new one...") + LOGGER.info("[$MOD_NAME] No config file found, creating a new one...") val json: String = gson.toJson(parser.parse(gson.toJson(ModConfig()))) PrintWriter(configFile).use { out -> out.println(json) } finalConfig = ModConfig() - LOGGER.info("Successfully created default config file.") + LOGGER.info("[$MOD_NAME] Successfully created default config file.") } else { - LOGGER.info("A config file was found, loading it..") + LOGGER.info("[$MOD_NAME] A config file was found, loading it..") finalConfig = gson.fromJson(String(Files.readAllBytes(configFile.toPath())), ModConfig::class.java) if (finalConfig == null) { - throw NullPointerException("The config file was empty.") + throw NullPointerException("[$MOD_NAME] The config file was empty.") } else { - LOGGER.info("Successfully loaded config file.") + LOGGER.info("[$MOD_NAME] Successfully loaded config file.") } } } catch (exception: Exception) { - LOGGER.error("There was an error creating/loading the config file!", exception) + LOGGER.error("[$MOD_NAME] There was an error creating/loading the config file!", exception) finalConfig = ModConfig() - LOGGER.warn("Defaulting to original config.") + LOGGER.warn("[$MOD_NAME] Defaulting to original config.") } finalConfig } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/KibeModClient.kt b/src/main/kotlin/io/github/lucaargolo/kibe/KibeModClient.kt index 22f6c9ef..b25ae099 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/KibeModClient.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/KibeModClient.kt @@ -29,14 +29,12 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant import net.minecraft.client.particle.FlameParticle import net.minecraft.client.render.RenderLayer import net.minecraft.client.util.ModelIdentifier import net.minecraft.network.PacketByteBuf import net.minecraft.resource.ResourceManager -import net.minecraft.screen.PlayerScreenHandler import net.minecraft.util.Identifier import java.util.function.Consumer @@ -110,14 +108,6 @@ fun initExtrasClient() { EntangledTankState.CURRENT_CLIENT_PLAYER_REQUESTS = linkedSetOf() } } - ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register(ClientSpriteRegistryCallback { _, registry -> - registry.register(Identifier(MOD_ID, "block/entangled_chest")) - registry.register(Identifier(MOD_ID, "block/entangled_chest_runes")) - (0..15).forEach { - registry.register(Identifier(MOD_ID, "block/redstone_timer_$it")) - } - registry.register(Identifier(MOD_ID, "block/tank")) - }) ModelLoadingRegistry.INSTANCE.registerModelProvider { _: ResourceManager, out: Consumer -> out.accept(ModelIdentifier(Identifier(MOD_ID, "redstone_timer_structure"), "")) out.accept(ModelIdentifier(Identifier(MOD_ID, "glider_active"), "inventory")) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/BlockCompendium.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/BlockCompendium.kt index f1f4ec9e..d01103bc 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/BlockCompendium.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/BlockCompendium.kt @@ -43,7 +43,6 @@ import io.github.lucaargolo.kibe.blocks.witherbuilder.WitherBuilder import io.github.lucaargolo.kibe.blocks.witherbuilder.WitherBuilderBlockEntity import io.github.lucaargolo.kibe.blocks.witherbuilder.WitherBuilderScreen import io.github.lucaargolo.kibe.blocks.witherbuilder.WitherBuilderScreenHandler -import io.github.lucaargolo.kibe.utils.CREATIVE_TAB import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType @@ -64,7 +63,8 @@ import net.minecraft.screen.ScreenHandlerType import net.minecraft.sound.BlockSoundGroup import net.minecraft.text.Text import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import java.util.function.Supplier import kotlin.reflect.KClass @@ -93,7 +93,7 @@ class ContainerInfo( handler = handlerClass.java.constructors[0].newInstance(i, playerInventory, be, ScreenHandlerContext.create(world, pos)) as T handler } - Registry.register(Registry.SCREEN_HANDLER, id, handlerType) + Registry.register(Registries.SCREEN_HANDLER, id, handlerType) } fun initClient() { @@ -113,14 +113,14 @@ class BlockInfo ( ){ fun init() { - Registry.register(Registry.BLOCK, identifier, block) + Registry.register(Registries.BLOCK, identifier, block) if(hasBlockItem) { if(blockItem != null) - Registry.register(Registry.ITEM, identifier, blockItem.java.constructors[0].newInstance(block, Item.Settings().group(CREATIVE_TAB)) as BlockItem) + Registry.register(Registries.ITEM, identifier, blockItem.java.constructors[0].newInstance(block, Item.Settings()) as BlockItem) else - Registry.register(Registry.ITEM, identifier, BlockItem(block, Item.Settings().group(CREATIVE_TAB))) + Registry.register(Registries.ITEM, identifier, BlockItem(block, Item.Settings())) } - if(entity != null) Registry.register(Registry.BLOCK_ENTITY_TYPE, identifier, entity) + if(entity != null) Registry.register(Registries.BLOCK_ENTITY_TYPE, identifier, entity) containers.forEach { it.init(identifier) } } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorch.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorch.kt index 40fbf33c..3aac3231 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorch.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorch.kt @@ -2,6 +2,7 @@ package io.github.lucaargolo.kibe.blocks.bigtorch import io.github.lucaargolo.kibe.blocks.getEntityType import io.github.lucaargolo.kibe.utils.BlockScreenHandlerFactory +import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings import net.minecraft.block.* import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.BlockEntityTicker @@ -26,7 +27,7 @@ import net.minecraft.world.World import kotlin.math.cos import kotlin.math.sin -class BigTorch: BlockWithEntity(Settings.of(Material.DECORATION).strength(0.5f).luminance{15}.sounds(BlockSoundGroup.WOOD)) { +class BigTorch: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.TORCH).strength(0.5f).luminance{15}.sounds(BlockSoundGroup.WOOD)) { override fun appendProperties(stateManager: StateManager.Builder) { stateManager.add(Properties.LEVEL_8) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchBlockEntity.kt index 1edfb641..45a140cf 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchBlockEntity.kt @@ -16,7 +16,8 @@ import net.minecraft.util.collection.DefaultedList import net.minecraft.util.math.BlockPos import net.minecraft.util.math.ChunkPos import net.minecraft.util.math.Direction -import net.minecraft.util.registry.RegistryKey +import net.minecraft.registry.Registry +import net.minecraft.registry.RegistryKey import net.minecraft.world.World import kotlin.math.min import kotlin.math.sqrt diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchScreen.kt index ae26971e..e4dee4a3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchScreen.kt @@ -1,6 +1,7 @@ package io.github.lucaargolo.kibe.blocks.bigtorch import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -21,29 +22,29 @@ class BigTorchScreen(handler: BigTorchScreenHandler, inventory: PlayerInventory, y = height/2-backgroundHeight/2 } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) if(mouseX in (x+8..x+168) && mouseY in (y+19..y+33)) { val list = listOf( Text.translatable("tooltip.kibe.torch_percentage").append(Text.literal("${(handler.entity.torchPercentage*100).toInt()}%").formatted(Formatting.GRAY)), Text.translatable("tooltip.kibe.chunk_radius").append(Text.literal("${handler.entity.chunkRadius}").formatted(Formatting.GRAY)) //Text.translatable("tooltip.kibe.suppressed_spawns").append(Text.literal("${handler.entity.suppressedSpawns}").formatted(Formatting.GRAY)) ) - renderTooltip(matrices, list, mouseX, mouseY) + context.drawTooltip(textRenderer, list, mouseX, mouseY) } } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - textRenderer.draw(matrices, title, 8f, 6f, 4210752) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 4210752) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawText(textRenderer, title, 8, 6, 4210752, false) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 4210752, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, 176, 150) - drawTexture(matrices, x+8, y+19, 0, 150, (159*handler.entity.torchPercentage).toInt(), 14) + context.drawTexture(texture, x, y, 0, 0, 176, 150) + context.drawTexture(texture, x+8, y+19, 0, 150, (159*handler.entity.torchPercentage).toInt(), 14) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchScreenHandler.kt index 5b1fedea..9af07dff 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/bigtorch/BigTorchScreenHandler.kt @@ -42,7 +42,7 @@ class BigTorchScreenHandler (syncId: Int, playerInventory: PlayerInventory, val entity.updateValues() } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/Breaker.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/Breaker.kt index bf5d3d39..a40bec2c 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/Breaker.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/Breaker.kt @@ -39,7 +39,7 @@ class Breaker: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)) { val isReceivingPower = world.isReceivingRedstonePower(pos) || world.isReceivingRedstonePower(pos.up()) val triggered = state[DispenserBlock.TRIGGERED] if (isReceivingPower && !triggered) { - world.createAndScheduleBlockTick(pos, this, 4) + world.scheduleBlockTick(pos, this, 4) world.setBlockState(pos, state.with(DispenserBlock.TRIGGERED, true) as BlockState, 4) } else if (!isReceivingPower && triggered) { world.setBlockState(pos, state.with(DispenserBlock.TRIGGERED, false) as BlockState, 4) @@ -61,7 +61,7 @@ class Breaker: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)) { if (stk.isEmpty) { it.setStack(slot, stack.copy()) stack.decrement(stack.count) - } else if (ItemStack.areItemsEqual(stack, stk) && ItemStack.areNbtEqual(stack, stk)) { + } else if (ItemStack.canCombine(stack, stk)) { if (stk.count + stack.count < stk.maxCount) { stk.increment(stack.count) stack.decrement(stack.count) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/BreakerScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/BreakerScreen.kt index b5d07233..99ce7cbd 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/BreakerScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/BreakerScreen.kt @@ -1,8 +1,8 @@ package io.github.lucaargolo.kibe.blocks.breaker import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen -import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory import net.minecraft.text.Text import net.minecraft.util.Identifier @@ -11,19 +11,18 @@ class BreakerScreen(handler: BreakerScreenHandler, inventory: PlayerInventory, t private val texture = Identifier("kibe:textures/gui/breaker.png") - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - textRenderer.draw(matrices, title, ((backgroundWidth / 2) - (textRenderer.getWidth(title)/2)).toFloat(), 6f, 4210752) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 4210752) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawText(textRenderer, title, (backgroundWidth / 2) - (textRenderer.getWidth(title)/2), 6, 4210752, false) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 4210752, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, 176, 168) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, x, y, 0, 0, 176, 168) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/BreakerScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/BreakerScreenHandler.kt index d165e2e6..aef17aa1 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/BreakerScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/breaker/BreakerScreenHandler.kt @@ -41,7 +41,7 @@ class BreakerScreenHandler(syncId: Int, val playerInventory: PlayerInventory, va } } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoader.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoader.kt index 378c2f68..3fc7a82d 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoader.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoader.kt @@ -25,7 +25,7 @@ import net.minecraft.util.shape.VoxelShapes import net.minecraft.world.BlockView import net.minecraft.world.World -class ChunkLoader: BlockWithEntity(FabricBlockSettings.of(Material.STONE).requiresTool().strength(22.0F, 600.0F)) { +class ChunkLoader: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.ENCHANTING_TABLE).requiresTool().strength(22.0F, 600.0F)) { init { defaultState = stateManager.defaultState.with(Properties.ENABLED, false) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoaderScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoaderScreen.kt index 9fccb272..cbdbc08b 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoaderScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoaderScreen.kt @@ -1,16 +1,14 @@ package io.github.lucaargolo.kibe.blocks.chunkloader -import com.mojang.blaze3d.systems.RenderSystem import io.github.lucaargolo.kibe.CHUNK_MAP_CLICK import io.netty.buffer.Unpooled import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking import net.minecraft.block.MapColor import net.minecraft.client.MinecraftClient -import net.minecraft.client.gui.DrawableHelper +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.Screen import net.minecraft.client.texture.NativeImage import net.minecraft.client.texture.NativeImageBackedTexture -import net.minecraft.client.util.math.MatrixStack import net.minecraft.network.PacketByteBuf import net.minecraft.text.Text @@ -78,38 +76,36 @@ class ChunkLoaderScreen(be: ChunkLoaderBlockEntity): Screen(Text.translatable("s private val texture = Identifier("kibe:textures/gui/chunk_loader.png") @Suppress("UNUSED_PARAMETER") - private fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - textRenderer.draw(matrices, title, (x+47 - textRenderer.getWidth(title) / 2f), y+6f, 4210752) + private fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawText(textRenderer, title, x+47 - textRenderer.getWidth(title) / 2, y+6, 4210752, false) } @Suppress("UNUSED_PARAMETER") - private fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, backgroundWidth, backgroundHeight) + private fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, x, y, 0, 0, backgroundWidth, backgroundHeight) } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - drawBackground(matrices, delta, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + drawBackground(context, delta, mouseX, mouseY) if(identifier == null) createImage() identifier?.let { - RenderSystem.setShaderTexture(0, it) - drawTexture(matrices, x+7, y+15, 0, 0, 80, 80) + context.drawTexture(it, x+7, y+15, 0, 0, 80, 80) } entity.enabledChunks.forEach { - DrawableHelper.fill(matrices, x+7+((it.first+2)*16), y+15+((it.second+2)*16), x+7+((it.first+2)*16)+16, y+15+((it.second+2)*16)+16, -2147418368) + context.fill(x+7+((it.first+2)*16), y+15+((it.second+2)*16), x+7+((it.first+2)*16)+16, y+15+((it.second+2)*16)+16, -2147418368) } if(mouseX in (x+7 until x+87) && mouseY in (y+15 until y+95)) { val chunkX = (mouseX-(x+7))/16 val chunkZ = (mouseY-(y+15))/16 - DrawableHelper.fill(matrices, x+7+(chunkX*16), y+15+(chunkZ*16), x+7+(chunkX*16)+16, y+15+(chunkZ*16)+16, -2130706433) + context.fill(x+7+(chunkX*16), y+15+(chunkZ*16), x+7+(chunkX*16)+16, y+15+(chunkZ*16)+16, -2130706433) val tooltip = mutableListOf() tooltip.add(Text.translatable("tooltip.kibe.chunk_at").append(Text.literal("${chunkPos.x+chunkX-2}, ${chunkPos.z+chunkZ-2}"))) 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"))) - renderTooltip(matrices, tooltip, mouseX, mouseY) + context.drawTooltip(textRenderer, tooltip, mouseX, mouseY) } - super.render(matrices, mouseX, mouseY, delta) - drawForeground(matrices, mouseX, mouseY) + super.render(context, mouseX, mouseY, delta) + drawForeground(context, mouseX, mouseY) } override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoaderState.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoaderState.kt index 2af5b4d2..7d4620ce 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoaderState.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/chunkloader/ChunkLoaderState.kt @@ -7,8 +7,8 @@ import net.minecraft.util.Identifier import net.minecraft.util.math.BlockPos import net.minecraft.util.math.ChunkPos import net.minecraft.util.math.Vec3d -import net.minecraft.util.registry.Registry -import net.minecraft.util.registry.RegistryKey +import net.minecraft.registry.RegistryKey +import net.minecraft.registry.RegistryKeys import net.minecraft.world.PersistentState import net.minecraft.world.World import java.util.* @@ -139,7 +139,7 @@ class ChunkLoaderState(val server: MinecraftServer): PersistentState(){ } state.loadedChunkMap = mutableMapOf() tag.keys.forEach { key -> - val registryKey = RegistryKey.of(Registry.WORLD_KEY, Identifier(key)) + val registryKey = RegistryKey.of(RegistryKeys.WORLD, Identifier(key)) val world = server.getWorld(registryKey) world?.let { _ -> state.loadedChunkMap[registryKey] = mutableListOf() diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/Cooler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/Cooler.kt index dfbdbe65..b7d4213d 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/Cooler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/Cooler.kt @@ -19,7 +19,7 @@ import net.minecraft.util.shape.VoxelShape import net.minecraft.world.BlockView import net.minecraft.world.World -class Cooler: BlockWithEntity(FabricBlockSettings.of(Material.METAL, MapColor.PALE_PURPLE).strength(0.2F).sounds(BlockSoundGroup.SNOW)) { +class Cooler: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.SNOW_BLOCK).strength(0.2F).sounds(BlockSoundGroup.SNOW)) { override fun createBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return CoolerBlockEntity(this, blockPos, blockState) @@ -30,7 +30,7 @@ class Cooler: BlockWithEntity(FabricBlockSettings.of(Material.METAL, MapColor.PA } override fun getPlacementState(ctx: ItemPlacementContext): BlockState? { - return defaultState.with(Properties.HORIZONTAL_FACING, ctx.playerFacing.opposite) + return defaultState.with(Properties.HORIZONTAL_FACING, ctx.horizontalPlayerFacing.opposite) } override fun onUse(state: BlockState?, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand?, hit: BlockHitResult?): ActionResult { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/CoolerScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/CoolerScreen.kt index 38fcdc85..3a898f5f 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/CoolerScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/CoolerScreen.kt @@ -1,6 +1,7 @@ package io.github.lucaargolo.kibe.blocks.cooler import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -18,20 +19,19 @@ class CoolerScreen(handler: CoolerScreenHandler, inventory: PlayerInventory, tit y = height/2-backgroundHeight/2 } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - drawCenteredText(matrices, textRenderer, title.string,backgroundWidth/2, 6, 0xFFFFFF) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 4210752) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawCenteredTextWithShadow(textRenderer, title.string,backgroundWidth/2, 6, 0xFFFFFF) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 4210752, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, 176, 131) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, x, y, 0, 0, 176, 131) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/CoolerScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/CoolerScreenHandler.kt index c0c8b114..c35665ce 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/CoolerScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/cooler/CoolerScreenHandler.kt @@ -35,7 +35,7 @@ class CoolerScreenHandler(syncId: Int, playerInventory: PlayerInventory, val ent } } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/Drawbridge.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/Drawbridge.kt index ac566387..72d47a7c 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/Drawbridge.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/Drawbridge.kt @@ -22,7 +22,7 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.MathHelper import net.minecraft.world.World -class Drawbridge: BlockWithEntity(FabricBlockSettings.of(Material.METAL, MapColor.IRON_GRAY).requiresTool().strength(5.0F, 6.0F).sounds(BlockSoundGroup.METAL).nonOpaque()) { +class Drawbridge: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).requiresTool().strength(5.0F, 6.0F).sounds(BlockSoundGroup.METAL).nonOpaque()) { override fun createBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return DrawbridgeBlockEntity(this, blockPos, blockState) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeBlockEntity.kt index 526f7b5e..bd91122b 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeBlockEntity.kt @@ -23,7 +23,8 @@ import net.minecraft.util.collection.DefaultedList import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.util.math.Vec3i -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import net.minecraft.world.World class DrawbridgeBlockEntity(drawbridge: Drawbridge, pos: BlockPos, state: BlockState): SyncableBlockEntity(getEntityType(drawbridge), pos, state), SidedInventory { @@ -45,7 +46,7 @@ class DrawbridgeBlockEntity(drawbridge: Drawbridge, pos: BlockPos, state: BlockS override fun writeNbt(tag: NbtCompound) { tag.putString("state", state.name) - tag.putString("extendedBlock", extendedBlock?.let { Registry.BLOCK.getId(it).toString() } ?: "yeet") + tag.putString("extendedBlock", extendedBlock?.let { Registries.BLOCK.getId(it).toString() } ?: "yeet") tag.putInt("extendedBlocks", extendedBlocks) val nbtList = NbtList() for (i in inventory.indices) { @@ -65,7 +66,7 @@ class DrawbridgeBlockEntity(drawbridge: Drawbridge, pos: BlockPos, state: BlockS }catch (e: IllegalArgumentException) { State.CONTRACTED } - extendedBlock = Registry.BLOCK.get(Identifier(tag.getString("extendedBlock"))) + extendedBlock = Registries.BLOCK.get(Identifier(tag.getString("extendedBlock"))) extendedBlocks = tag.getInt("extendedBlocks") Inventories.readNbt(tag, inventory) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeCustomModel.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeCustomModel.kt index a7cf5820..953b1382 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeCustomModel.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeCustomModel.kt @@ -40,19 +40,19 @@ class DrawbridgeCustomModel: UnbakedModel, BakedModel, FabricBakedModel { override fun getModelDependencies(): Collection = listOf() - override fun getTextureDependencies(unbakedModelGetter: Function, unresolvedTextureReferences: MutableSet>) = spriteIdList + override fun setParents(modelLoader: Function?) { } lateinit var modelTransformation: ModelTransformation - override fun bake(loader: ModelLoader, textureGetter: Function, rotationContainer: ModelBakeSettings?, modelId: Identifier?): BakedModel { - val model = loader.getOrLoadModel(modelIdList[0]) + override fun bake(baker: Baker, textureGetter: Function, rotationContainer: ModelBakeSettings, modelId: Identifier): BakedModel { + val model = baker.getOrLoadModel(modelIdList[0]) - modelList.add(model.bake(loader, textureGetter, ModelRotation.X0_Y0, modelId)!!) // NORTH - modelList.add(model.bake(loader, textureGetter, ModelRotation.X0_Y180, modelId)!!) // SOUTH - modelList.add(model.bake(loader, textureGetter, ModelRotation.X0_Y270, modelId)!!) // WEST - modelList.add(model.bake(loader, textureGetter, ModelRotation.X0_Y90, modelId)!!) // EAST - modelList.add(model.bake(loader, textureGetter, ModelRotation.X270_Y0, modelId)!!) // UP - modelList.add(model.bake(loader, textureGetter, ModelRotation.X90_Y0, modelId)!!) // DOWN + modelList.add(model.bake(baker, textureGetter, ModelRotation.X0_Y0, modelId)!!) // NORTH + modelList.add(model.bake(baker, textureGetter, ModelRotation.X0_Y180, modelId)!!) // SOUTH + modelList.add(model.bake(baker, textureGetter, ModelRotation.X0_Y270, modelId)!!) // WEST + modelList.add(model.bake(baker, textureGetter, ModelRotation.X0_Y90, modelId)!!) // EAST + modelList.add(model.bake(baker, textureGetter, ModelRotation.X270_Y0, modelId)!!) // UP + modelList.add(model.bake(baker, textureGetter, ModelRotation.X90_Y0, modelId)!!) // DOWN modelTransformation = modelList[0].transformation @@ -80,7 +80,7 @@ class DrawbridgeCustomModel: UnbakedModel, BakedModel, FabricBakedModel { context.pushTransform { q -> val rawColor = ColorProviderRegistry.BLOCK[coverState.block]!!.getColor(coverState, world, pos, 0) val color = 255 shl 24 or rawColor - q.spriteColor(0, color, color, color, color) + q.color(color, color, color, color) true } @@ -90,18 +90,18 @@ class DrawbridgeCustomModel: UnbakedModel, BakedModel, FabricBakedModel { } when(state[Properties.FACING]) { - Direction.NORTH -> context.fallbackConsumer().accept(modelList[0]) - Direction.SOUTH -> context.fallbackConsumer().accept(modelList[1]) - Direction.WEST -> context.fallbackConsumer().accept(modelList[2]) - Direction.EAST -> context.fallbackConsumer().accept(modelList[3]) - Direction.UP -> context.fallbackConsumer().accept(modelList[4]) - Direction.DOWN -> context.fallbackConsumer().accept(modelList[5]) + Direction.NORTH -> context.bakedModelConsumer().accept(modelList[0]) + Direction.SOUTH -> context.bakedModelConsumer().accept(modelList[1]) + Direction.WEST -> context.bakedModelConsumer().accept(modelList[2]) + Direction.EAST -> context.bakedModelConsumer().accept(modelList[3]) + Direction.UP -> context.bakedModelConsumer().accept(modelList[4]) + Direction.DOWN -> context.bakedModelConsumer().accept(modelList[5]) else -> {} } } override fun emitItemQuads(stack: ItemStack, randomSupplier: Supplier, context: RenderContext) { - context.fallbackConsumer().accept(modelList[4]) + context.bakedModelConsumer().accept(modelList[4]) } @Suppress("DEPRECATION") diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeScreen.kt index 4afcd6fb..315da42d 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeScreen.kt @@ -2,6 +2,7 @@ package io.github.lucaargolo.kibe.blocks.drawbridge import com.mojang.blaze3d.systems.RenderSystem import io.github.lucaargolo.kibe.blocks.DRAWBRIDGE +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -20,21 +21,20 @@ class DrawbridgeScreen(handler: DrawbridgeScreenHandler, inventory: PlayerInvent y = height / 2 - backgroundHeight / 2 } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - drawCenteredText(matrices, textRenderer, title.string, backgroundWidth / 2, 6, 0xFFE000) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 0xFFE000) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawCenteredTextWithShadow(textRenderer, title.string, backgroundWidth / 2, 6, 0xFFE000) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 0xFFE000, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, 176, 131) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, x, y, 0, 0, 176, 131) if(handler.inventory.getStack(1)?.isEmpty == true) - itemRenderer.renderInGuiWithOverrides(ItemStack(DRAWBRIDGE.asItem()), x+134, y+18) + context.drawItem(ItemStack(DRAWBRIDGE.asItem()), x+134, y+18) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeScreenHandler.kt index cb7df6fd..a317e621 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/drawbridge/DrawbridgeScreenHandler.kt @@ -62,7 +62,7 @@ class DrawbridgeScreenHandler(syncId: Int, val playerInventory: PlayerInventory, } } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChest.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChest.kt index 84be1a99..07e6377c 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChest.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChest.kt @@ -27,14 +27,14 @@ import net.minecraft.util.shape.VoxelShapes import net.minecraft.world.BlockView import net.minecraft.world.World -class EntangledChest: BlockWithEntity(FabricBlockSettings.of(Material.STONE).requiresTool().strength(22.0F, 600.0F)) { +class EntangledChest: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).requiresTool().strength(22.0F, 600.0F)) { override fun appendProperties(stateManager: StateManager.Builder) { stateManager.add(Properties.HORIZONTAL_FACING) } override fun getPlacementState(ctx: ItemPlacementContext): BlockState? { - return defaultState.with(Properties.HORIZONTAL_FACING, ctx.playerFacing) + return defaultState.with(Properties.HORIZONTAL_FACING, ctx.horizontalPlayerFacing) } override fun getRenderType(state: BlockState?): BlockRenderType { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestEntityRenderer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestEntityRenderer.kt index e4758d12..7d725ca9 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestEntityRenderer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestEntityRenderer.kt @@ -22,8 +22,8 @@ import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.hit.HitResult import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -import net.minecraft.util.math.Matrix4f -import net.minecraft.util.math.Vec3f +import net.minecraft.util.math.RotationAxis +import org.joml.Matrix4f import java.util.* class EntangledChestEntityRenderer(private val arg: BlockEntityRendererFactory.Context): BlockEntityRenderer { @@ -119,7 +119,7 @@ class EntangledChestEntityRenderer(private val arg: BlockEntityRendererFactory.C matrices.push() val f = (blockState.get(Properties.HORIZONTAL_FACING) as Direction).asRotation() matrices.translate(0.5, 0.5, 0.5) - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-f)) + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-f)) matrices.translate(-0.5, -0.5, -0.5) val chestIdentifier = SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, Identifier("kibe:block/entangled_chest")) @@ -138,18 +138,18 @@ class EntangledChestEntityRenderer(private val arg: BlockEntityRendererFactory.C when(currentState) { AnimationState.GOING_UP -> { counter += tickDelta - matrices.multiply(Vec3f(0F, 1F, 0F).getDegreesQuaternion(counter*6)) + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(counter*6)) matrices.translate(0.0, counter/90.0, 0.0) if(counter >= 30f) currentState = AnimationState.UP } AnimationState.GOING_DOWN -> { counter += tickDelta - matrices.multiply(Vec3f(0F, 1F, 0F).getDegreesQuaternion(360-counter*6)) + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(360-counter*6)) matrices.translate(0.0, 0.333-counter/90.0, 0.0) if(counter >= 30f) currentState = AnimationState.DOWN } AnimationState.UP -> { - matrices.multiply(Vec3f(0F, 1F, 0F).getDegreesQuaternion(360f)) + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(360f)) matrices.translate(0.0, 30.0/90.0, 0.0) counter = 0f } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestScreen.kt index 87bc4302..157c4050 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestScreen.kt @@ -2,6 +2,7 @@ package io.github.lucaargolo.kibe.blocks.entangledchest import com.mojang.blaze3d.systems.RenderSystem import io.github.lucaargolo.kibe.items.miscellaneous.Rune +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -22,27 +23,26 @@ class EntangledChestScreen(screenHandler: EntangledChestScreenHandler, inventory startY = height/2-backgroundHeight/2 } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - drawRunes() - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + drawRunes(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - private fun drawRunes() { + private fun drawRunes(context: DrawContext) { handler.entity.runeColors.forEach { (n, color) -> - itemRenderer.renderGuiItemIcon(ItemStack(Rune.getRuneByColor(color)), startX+87+(n-1)*10, startY+2) + context.drawItem(ItemStack(Rune.getRuneByColor(color)), startX+87+(n-1)*10, startY+2) } } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - textRenderer.draw(matrices, title, 8.0f, 6.0f, 0xFFFFFF) - textRenderer.draw(matrices, playerInventoryTitle, 8.0f, (backgroundHeight - 96 + 4).toFloat(), 0xFFFFFF) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawText(textRenderer, title, 8, 6, 0xFFFFFF, false) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 0xFFFFFF, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, startX, startY, 0, 0, 176, 166) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, startX, startY, 0, 0, 176, 166) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestScreenHandler.kt index 328bd55a..7c39c2e8 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledchest/EntangledChestScreenHandler.kt @@ -92,7 +92,7 @@ class EntangledChestScreenHandler(syncId: Int, playerInventory: PlayerInventory, }, true) } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTank.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTank.kt index db330bd8..4bfbcdfb 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTank.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTank.kt @@ -26,7 +26,7 @@ import net.minecraft.util.shape.VoxelShapes import net.minecraft.world.BlockView import net.minecraft.world.World -class EntangledTank: BlockWithEntity(FabricBlockSettings.of(Material.STONE).requiresTool().strength(22.0F, 600.0F).luminance { state -> state[Properties.LEVEL_15] }) { +class EntangledTank: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).requiresTool().strength(22.0F, 600.0F).luminance { state -> state[Properties.LEVEL_15] }) { override fun appendProperties(stateManager: StateManager.Builder) { stateManager.add(Properties.LEVEL_15) @@ -34,7 +34,7 @@ class EntangledTank: BlockWithEntity(FabricBlockSettings.of(Material.STONE).requ } override fun getPlacementState(ctx: ItemPlacementContext): BlockState? { - return defaultState.with(Properties.LEVEL_15, 0).with(Properties.HORIZONTAL_FACING, ctx.playerFacing) + return defaultState.with(Properties.LEVEL_15, 0).with(Properties.HORIZONTAL_FACING, ctx.horizontalPlayerFacing) } override fun getRenderType(state: BlockState?): BlockRenderType { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTankEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTankEntity.kt index 95b4853d..1dcab83d 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTankEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTankEntity.kt @@ -119,7 +119,7 @@ class EntangledTankEntity(chest: EntangledTank, pos: BlockPos, state: BlockState override fun writeClientNbt(tag: NbtCompound) = tag.also { writeNbt(it) } companion object { - fun getFluidStorage(be: EntangledTankEntity, dir: Direction): Storage { + fun getFluidStorage(be: EntangledTankEntity, dir: Direction?): Storage { return be.getTank() } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTankEntityRenderer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTankEntityRenderer.kt index 804ee001..d1ef7a71 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTankEntityRenderer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/entangledtank/EntangledTankEntityRenderer.kt @@ -22,7 +22,8 @@ import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.hit.HitResult import net.minecraft.util.math.Direction import net.minecraft.util.math.MathHelper -import net.minecraft.util.math.Vec3f +import net.minecraft.util.math.RotationAxis +import org.joml.Vector3f import java.awt.Color class EntangledTankEntityRenderer(private val arg: BlockEntityRendererFactory.Context): BlockEntityRenderer { @@ -45,7 +46,7 @@ class EntangledTankEntityRenderer(private val arg: BlockEntityRendererFactory.Co val f = (blockState.get(Properties.HORIZONTAL_FACING) as Direction).asRotation() matrices.translate(0.5, 0.5, 0.5) - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-f)) + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-f)) matrices.translate(-0.5, -0.5, -0.5) val chestIdentifier = SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, Identifier("kibe:block/entangled_chest")) @@ -122,7 +123,7 @@ class EntangledTankEntityRenderer(private val arg: BlockEntityRendererFactory.Co } - private fun renderVertices(bb: VertexConsumer, entry: MatrixStack.Entry, normal: Vec3f, color: Color, overlay: Int, light: Int, uv: TankBlockEntityRenderer.UV, f: Float, g: Float, h: Float, i: Float, j: Float, k: Float, l: Float, m: Float) { + private fun renderVertices(bb: VertexConsumer, entry: MatrixStack.Entry, normal: Vector3f, color: Color, overlay: Int, light: Int, uv: TankBlockEntityRenderer.UV, f: Float, g: Float, h: Float, i: Float, j: Float, k: Float, l: Float, m: Float) { bb.vertex(entry.positionMatrix, f, h, j).color(color.red / 255f, color.green / 255f, color.blue / 255f, 1f).texture(uv.maxU, uv.minV).overlay(overlay).light(light).normal(entry.normalMatrix, normal.x, normal.y, normal.z).next() bb.vertex(entry.positionMatrix, g, h, k).color(color.red / 255f, color.green / 255f, color.blue / 255f, 1f).texture(uv.minU, uv.minV).overlay(overlay).light(light).normal(entry.normalMatrix, normal.x, normal.y, normal.z).next() bb.vertex(entry.positionMatrix, g, i, l).color(color.red / 255f, color.green / 255f, color.blue / 255f, 1f).texture(uv.minU, uv.maxV).overlay(overlay).light(light).normal(entry.normalMatrix, normal.x, normal.y, normal.z).next() diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorBlockEntity.kt index ae166273..dc0ef183 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorBlockEntity.kt @@ -14,7 +14,8 @@ import net.minecraft.util.collection.DefaultedList import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.util.math.MathHelper -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import net.minecraft.world.World class BlockGeneratorBlockEntity(var generator: BlockGenerator, var block: Block, var rate: Float, pos: BlockPos, state: BlockState): SyncableBlockEntity(getEntityType(generator), pos, state), SidedInventory { @@ -26,8 +27,8 @@ class BlockGeneratorBlockEntity(var generator: BlockGenerator, var block: Block, override fun writeNbt(tag: NbtCompound) { Inventories.writeNbt(tag, inventory) - tag.putString("generator", Registry.BLOCK.getId(generator).toString()) - tag.putString("block", Registry.BLOCK.getId(block).toString()) + tag.putString("generator", Registries.BLOCK.getId(generator).toString()) + tag.putString("block", Registries.BLOCK.getId(block).toString()) tag.putFloat("rate", rate) tag.putFloat("progress", progress) } @@ -35,20 +36,20 @@ class BlockGeneratorBlockEntity(var generator: BlockGenerator, var block: Block, override fun readNbt(tag: NbtCompound) { super.readNbt(tag) Inventories.readNbt(tag, inventory) - generator = Registry.BLOCK.get(Identifier(tag.getString("generator"))) as BlockGenerator - block = Registry.BLOCK.get(Identifier(tag.getString("block"))) + generator = Registries.BLOCK.get(Identifier(tag.getString("generator"))) as BlockGenerator + block = Registries.BLOCK.get(Identifier(tag.getString("block"))) rate = tag.getFloat("rate") progress = tag.getFloat("progress") } override fun writeClientNbt(tag: NbtCompound): NbtCompound { - tag.putString("block", Registry.BLOCK.getId(block).toString()) + tag.putString("block", Registries.BLOCK.getId(block).toString()) tag.putFloat("rate", rate) return tag } override fun readClientNbt(tag: NbtCompound) { - block = Registry.BLOCK.get(Identifier(tag.getString("block"))) + block = Registries.BLOCK.get(Identifier(tag.getString("block"))) rate = tag.getFloat("rate") } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorScreen.kt index e125a419..2db5c139 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorScreen.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry import net.minecraft.block.Block import net.minecraft.block.Blocks +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.render.* import net.minecraft.client.texture.Sprite @@ -17,7 +18,8 @@ import net.minecraft.screen.PlayerScreenHandler import net.minecraft.text.Text import net.minecraft.util.Identifier import net.minecraft.util.math.MathHelper -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import org.lwjgl.opengl.GL11 class BlockGeneratorScreen(handler: BlockGeneratorScreenHandler, inventory: PlayerInventory, title: Text): HandledScreen(handler, inventory, title) { @@ -38,80 +40,80 @@ class BlockGeneratorScreen(handler: BlockGeneratorScreenHandler, inventory: Play atlasHeight = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT).toFloat() } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - textRenderer.draw(matrices, title, 8f, 6f, 4210752) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 4210752) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawText(textRenderer, title, 8, 6, 4210752, false) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 4210752, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, 176, 186) - itemRenderer.renderInGuiWithOverrides(ItemStack(handler.entity.block), x+80, y+18) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, x, y, 0, 0, 176, 186) + context.drawItem(ItemStack(handler.entity.block), x+80, y+18) //Draw fluids - RenderSystem.setShader(GameRenderer::getPositionColorTexShader) + RenderSystem.setShader(GameRenderer::getPositionColorTexProgram) RenderSystem.setShaderTexture(0, atlas) if(handler.entity.block == Blocks.BASALT) { - drawBlockBar(matrices, delta, Blocks.BLUE_ICE, true) + drawBlockBar(context, delta, Blocks.BLUE_ICE, true) }else{ - drawFluidBar(matrices, delta, Fluids.WATER, true) + drawFluidBar(context, delta, Fluids.WATER, true) } - drawFluidBar(matrices, delta, Fluids.LAVA, false) + drawFluidBar(context, delta, Fluids.LAVA, false) } - private fun drawBlockBar(matrices: MatrixStack, delta: Float, block: Block, left: Boolean) { - val blockId = Registry.BLOCK.getId(block) + private fun drawBlockBar(context: DrawContext, delta: Float, block: Block, left: Boolean) { + val blockId = Registries.BLOCK.getId(block) val supposedBlockSpriteId = SpriteIdentifier(atlas, Identifier(blockId.namespace, "block/${blockId.path}")) val sprite = supposedBlockSpriteId.sprite - drawBar(matrices, delta, sprite, -1, left) + drawBar(context, delta, sprite, -1, left) } - private fun drawFluidBar(matrices: MatrixStack, delta: Float, fluid: Fluid, left: Boolean) { + private fun drawFluidBar(context: DrawContext, delta: Float, fluid: Fluid, left: Boolean) { val fluidRenderHandler = FluidRenderHandlerRegistry.INSTANCE.get(fluid) ?: return val sprite = fluidRenderHandler.getFluidSprites(handler.entity.world, handler.entity.pos, fluid.defaultState)[0] val color = fluidRenderHandler.getFluidColor(handler.entity.world, handler.entity.pos, fluid.defaultState) - drawBar(matrices, delta, sprite, color, left) + drawBar(context, delta, sprite, color, left) } - private fun drawBar(matrices: MatrixStack, delta: Float, sprite: Sprite, color: Int, left: Boolean) { + private fun drawBar(context: DrawContext, delta: Float, sprite: Sprite, color: Int, left: Boolean) { var off = 0 handler.entity.lastRenderProgress = MathHelper.lerp(delta, handler.entity.lastRenderProgress, handler.entity.renderProgress) var bar = handler.entity.lastRenderProgress*70f % 70f - while(bar > sprite.width) { + while(bar > sprite.contents.width) { if(left) { - drawColoredTextureQuad(matrices, x+8f+off, x+8f+off+16f, y+19f, y+19f+14f, sprite.minU, sprite.maxU, sprite.minV, sprite.maxV-2f/atlasHeight, color) + drawColoredTextureQuad(context, x+8f+off, x+8f+off+16f, y+19f, y+19f+14f, sprite.minU, sprite.maxU, sprite.minV, sprite.maxV-2f/atlasHeight, color) }else{ - drawColoredTextureQuad(matrices, x+168f-off-16f, x+168f-off, y+19f, y+19f+14f, sprite.minU, sprite.maxU, sprite.minV, sprite.maxV-2f/atlasHeight, color) + drawColoredTextureQuad(context, x+168f-off-16f, x+168f-off, y+19f, y+19f+14f, sprite.minU, sprite.maxU, sprite.minV, sprite.maxV-2f/atlasHeight, color) } off += 16 bar -= 16 } if(left) { - drawColoredTextureQuad(matrices, x+8f+off, x+8f+off+bar, y+19f, y+19f+14f, sprite.minU, sprite.maxU-(16f-bar)/atlasWidth, sprite.minV, sprite.maxV-2f/atlasHeight, color) + drawColoredTextureQuad(context, x+8f+off, x+8f+off+bar, y+19f, y+19f+14f, sprite.minU, sprite.maxU-(16f-bar)/atlasWidth, sprite.minV, sprite.maxV-2f/atlasHeight, color) }else{ - drawColoredTextureQuad(matrices, x+168f-off-bar, x+168f-off, y+19f, y+19f+14f, sprite.minU+(16f-bar)/atlasWidth, sprite.maxU, sprite.minV, sprite.maxV-2f/atlasHeight, color) + drawColoredTextureQuad(context, x+168f-off-bar, x+168f-off, y+19f, y+19f+14f, sprite.minU+(16f-bar)/atlasWidth, sprite.maxU, sprite.minV, sprite.maxV-2f/atlasHeight, color) } } - private fun drawColoredTextureQuad(matrices: MatrixStack, x0: Float, x1: Float, y0: Float, y1: Float, u0: Float, u1: Float, v0: Float, v1: Float, color: Int) { - val z = zOffset.toFloat() + private fun drawColoredTextureQuad(context: DrawContext, x0: Float, x1: Float, y0: Float, y1: Float, u0: Float, u1: Float, v0: Float, v1: Float, color: Int) { + val z = 0f val r = (color shr 16 and 255)/255f val g = (color shr 8 and 255)/255f val b = (color and 255)/255f - val matrix = matrices.peek().positionMatrix + + val matrix = context.matrices.peek().positionMatrix val bufferBuilder = Tessellator.getInstance().buffer bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE) bufferBuilder.vertex(matrix, x0, y1, z).color(r, g, b, 1.0f).texture(u0, v1).next() bufferBuilder.vertex(matrix, x1, y1, z).color(r, g, b, 1.0f).texture(u1, v1).next() bufferBuilder.vertex(matrix, x1, y0, z).color(r, g, b, 1.0f).texture(u1, v0).next() bufferBuilder.vertex(matrix, x0, y0, z).color(r, g, b, 1.0f).texture(u0, v0).next() - BufferRenderer.drawWithoutShader(bufferBuilder.end()) + BufferRenderer.draw(bufferBuilder.end()) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorScreenHandler.kt index fb65ee3b..9dfeb35a 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/BlockGeneratorScreenHandler.kt @@ -39,7 +39,7 @@ class BlockGeneratorScreenHandler(syncId: Int, val playerInventory: PlayerInvent } } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { val slot = this.slots[invSlot] if (slot.hasStack() && invSlot < 27) { val itemStack = slot.stack diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/ConveyorBelt.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/ConveyorBelt.kt index 2e45d6a1..c74f7375 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/ConveyorBelt.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/ConveyorBelt.kt @@ -18,7 +18,7 @@ import net.minecraft.world.World import net.minecraft.world.WorldAccess import kotlin.math.abs -class ConveyorBelt(private val speed: Double): Block(FabricBlockSettings.of(Material.METAL, MapColor.IRON_GRAY).requiresTool().strength(5.0F, 6.0F).sounds(BlockSoundGroup.METAL)) { +class ConveyorBelt(private val speed: Double): Block(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).mapColor(MapColor.IRON_GRAY).requiresTool().strength(5.0F, 6.0F).sounds(BlockSoundGroup.METAL)) { init { defaultState = stateManager.defaultState.with(Properties.HORIZONTAL_FACING, Direction.NORTH) @@ -53,7 +53,7 @@ class ConveyorBelt(private val speed: Double): Block(FabricBlockSettings.of(Mate .with(HorizontalConnectingBlock.SOUTH, ctx.world.getBlockState(ctx.blockPos.north()).block is ConveyorBelt) .with(HorizontalConnectingBlock.EAST, ctx.world.getBlockState(ctx.blockPos.west()).block is ConveyorBelt) .with(HorizontalConnectingBlock.WEST, ctx.world.getBlockState(ctx.blockPos.east()).block is ConveyorBelt) - .with(Properties.HORIZONTAL_FACING, ctx.playerFacing) + .with(Properties.HORIZONTAL_FACING, ctx.horizontalPlayerFacing) } @Suppress("DEPRECATION") diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/CursedDirt.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/CursedDirt.kt index d79cbd4f..d1bae6b1 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/CursedDirt.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/CursedDirt.kt @@ -31,13 +31,14 @@ import net.minecraft.util.math.Box import net.minecraft.util.math.Direction import net.minecraft.util.math.Vec3i import net.minecraft.util.math.random.Random -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import net.minecraft.world.* import net.minecraft.world.biome.SpawnSettings import net.minecraft.world.chunk.light.ChunkLightProvider import java.util.* -class CursedDirt: GrassBlock(FabricBlockSettings.of(Material.SOLID_ORGANIC).ticksRandomly().strength(0.6F).sounds(BlockSoundGroup.GRASS)) { +class CursedDirt: GrassBlock(FabricBlockSettings.copyOf(Blocks.GRASS_BLOCK).ticksRandomly().strength(0.6F).sounds(BlockSoundGroup.GRASS)) { init { defaultState = stateManager.defaultState.with(Properties.LEVEL_15, 15).with(Properties.SNOWY, false) @@ -87,7 +88,7 @@ class CursedDirt: GrassBlock(FabricBlockSettings.of(Material.SOLID_ORGANIC).tick } //I dont really know what this does - world.createAndScheduleBlockTick(pos, state.block, random.nextInt(200)) + world.scheduleBlockTick(pos, state.block, random.nextInt(200)) //Dont spawn mobs in peaceful, in non water liquids or when doMobSpawning is set to false if ((world.getFluidState(pos.up()).fluid !is EmptyFluid && world.getFluidState(pos.up()).fluid != Fluids.WATER && world.getFluidState(pos.up()).fluid != Fluids.FLOWING_WATER) || world.difficulty == Difficulty.PEACEFUL || !world.gameRules[GameRules.DO_MOB_SPAWNING].get()) return @@ -102,14 +103,14 @@ class CursedDirt: GrassBlock(FabricBlockSettings.of(Material.SOLID_ORGANIC).tick val location = if(world.getFluidState(pos.up()).fluid is EmptyFluid) SpawnRestriction.Location.ON_GROUND else SpawnRestriction.Location.IN_WATER if(SpawnHelper.canSpawn(location, world, pos.up(), mob)) { val tag = getSpawnTag() - tag.putString("id", Registry.ENTITY_TYPE.getId(mob).toString()) + tag.putString("id", Registries.ENTITY_TYPE.getId(mob).toString()) val entity = EntityType.loadEntityWithPassengers(tag, world) { it.refreshPositionAndAngles(pos.x+.5, pos.y+1.0, pos.z+.5, it.yaw, it.pitch) if(it.isInsideWall) null else if (!world.tryLoadEntity(it)) null else it } if(entity is MobEntity) { - entity.initialize(world, world.getLocalDifficulty(BlockPos(entity.pos)), SpawnReason.NATURAL, null, null) + entity.initialize(world, world.getLocalDifficulty(BlockPos.ofFloored(entity.pos)), SpawnReason.NATURAL, null, null) } } } @@ -117,7 +118,7 @@ class CursedDirt: GrassBlock(FabricBlockSettings.of(Material.SOLID_ORGANIC).tick private fun getSpawnTag(): NbtCompound { val activeEffect = NbtCompound() - activeEffect.putInt("Id", Registry.STATUS_EFFECT.getRawId(CURSED_EFFECT)) + activeEffect.putInt("Id", Registries.STATUS_EFFECT.getRawId(CURSED_EFFECT)) activeEffect.putInt("Amplifier", 1) activeEffect.putInt("Duration", 300) val activeEffects = NbtList() @@ -144,7 +145,7 @@ class CursedDirt: GrassBlock(FabricBlockSettings.of(Material.SOLID_ORGANIC).tick private fun getSpawnableMonster(world: ServerWorld, pos: BlockPos, random: Random): EntityType<*>? { val optionalEntry: Optional = SpawnHelperInvoker.pickRandomSpawnEntry(world, world.structureAccessor, world.chunkManager.chunkGenerator, SpawnGroup.MONSTER, random, pos) val entry = if(optionalEntry.isPresent) optionalEntry.get() else null ?: return null - if(MOD_CONFIG.miscellaneousModule.cursedDirtBlacklist.contains(Registry.ENTITY_TYPE.getId(entry.type).toString())) return null + if(MOD_CONFIG.miscellaneousModule.cursedDirtBlacklist.contains(Registries.ENTITY_TYPE.getId(entry.type).toString())) return null BigTorchBlockEntity.setException(true) SpawnRestriction.canSpawn(entry.type, world, SpawnReason.NATURAL, pos, world.random).let { BigTorchBlockEntity.setException(false) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Dehumidifier.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Dehumidifier.kt index 0c4db7fa..5fbb3de3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Dehumidifier.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Dehumidifier.kt @@ -40,7 +40,7 @@ class Dehumidifier: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.COBBLESTON if (!world.isClient) { val isEnabled = state[Properties.ENABLED] if (isEnabled != world.isReceivingRedstonePower(pos)) { - if (isEnabled) world.createAndScheduleBlockTick(pos, this, 4) + if (isEnabled) world.scheduleBlockTick(pos, this, 4) else world.setBlockState(pos, state.cycle(Properties.ENABLED), 2) } } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Elevator.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Elevator.kt index 44c8ce99..2cb86138 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Elevator.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Elevator.kt @@ -2,12 +2,12 @@ package io.github.lucaargolo.kibe.blocks.miscellaneous import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings import net.minecraft.block.Block +import net.minecraft.block.Blocks import net.minecraft.block.MapColor -import net.minecraft.block.Material import net.minecraft.util.math.BlockPos import net.minecraft.world.World -class Elevator: Block(FabricBlockSettings.of(Material.STONE, MapColor.STONE_GRAY).requiresTool().strength(1.5F, 6.0F)) { +class Elevator: Block(FabricBlockSettings.copyOf(Blocks.STONE).mapColor(MapColor.STONE_GRAY).requiresTool().strength(1.5F, 6.0F)) { companion object { fun isElevatorValid(world: World, pos: BlockPos): Boolean { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/FluidHopper.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/FluidHopper.kt index 7f31936a..ed4d7b47 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/FluidHopper.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/FluidHopper.kt @@ -8,10 +8,7 @@ import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil -import net.minecraft.block.BlockState -import net.minecraft.block.HopperBlock -import net.minecraft.block.MapColor -import net.minecraft.block.Material +import net.minecraft.block.* import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.BlockEntityTicker import net.minecraft.block.entity.BlockEntityType @@ -27,7 +24,7 @@ import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos import net.minecraft.world.World -class FluidHopper: HopperBlock(FabricBlockSettings.of(Material.METAL, MapColor.STONE_GRAY).requiresTool().strength(3.0F, 4.8F).sounds(BlockSoundGroup.METAL).nonOpaque()) { +class FluidHopper: HopperBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).mapColor(MapColor.STONE_GRAY).requiresTool().strength(3.0F, 4.8F).sounds(BlockSoundGroup.METAL).nonOpaque()) { override fun createBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return FluidHopperBlockEntity(this, blockPos, blockState) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/FluidHopperBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/FluidHopperBlockEntity.kt index 0bbe581d..d599537d 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/FluidHopperBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/FluidHopperBlockEntity.kt @@ -35,8 +35,8 @@ class FluidHopperBlockEntity(block: FluidHopper, pos: BlockPos, state: BlockStat } } - private var topContainerFinder: BlockApiCache, Direction>? = null - private var toContainerFinder: BlockApiCache, Direction>? = null + private var topContainerFinder: BlockApiCache, Direction?>? = null + private var toContainerFinder: BlockApiCache, Direction?>? = null private var cachedDirection: Direction? = null private var extractionBump = CAPACITY diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Heater.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Heater.kt index ac31009e..4c059fb3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Heater.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Heater.kt @@ -47,7 +47,7 @@ class Heater: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.COBBLESTONE).lum if (!world.isClient) { val isEnabled = state[Properties.ENABLED] if (isEnabled != world.isReceivingRedstonePower(pos)) { - if (isEnabled) world.createAndScheduleBlockTick(pos, this, 4) + if (isEnabled) world.scheduleBlockTick(pos, this, 4) else world.setBlockState(pos, state.cycle(Properties.ENABLED), 2) } } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/HeaterBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/HeaterBlockEntity.kt index 98101230..354a5669 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/HeaterBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/HeaterBlockEntity.kt @@ -7,7 +7,8 @@ import net.minecraft.server.world.ServerWorld import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos import net.minecraft.util.math.ChunkPos -import net.minecraft.util.registry.RegistryKey +import net.minecraft.registry.Registry +import net.minecraft.registry.RegistryKey import net.minecraft.world.World class HeaterBlockEntity(heater: Heater, pos: BlockPos, state: BlockState): BlockEntity(getEntityType(heater), pos, state) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Igniter.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Igniter.kt index 474ed4d1..8ce9e8a3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Igniter.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Igniter.kt @@ -35,7 +35,7 @@ class Igniter: Block(FabricBlockSettings.copyOf(Blocks.COBBLESTONE)) { val isReceivingPower = world.isReceivingRedstonePower(pos) || world.isReceivingRedstonePower(pos.up()) val triggered = state[DispenserBlock.TRIGGERED] if (isReceivingPower && !triggered) { - world.createAndScheduleBlockTick(pos, this, 4) + world.scheduleBlockTick(pos, this, 4) world.setBlockState(pos, state.with(DispenserBlock.TRIGGERED, true) as BlockState, 4) } else if (!isReceivingPower && triggered) { world.setBlockState(pos, state.with(DispenserBlock.TRIGGERED, false) as BlockState, 4) @@ -45,7 +45,7 @@ class Igniter: Block(FabricBlockSettings.copyOf(Blocks.COBBLESTONE)) { override fun scheduledTick(state: BlockState, world: ServerWorld, pos: BlockPos, random: Random) { val facingPos = pos.offset(state[Properties.FACING]) val facingState = world.getBlockState(facingPos) - if(facingState.material.isReplaceable && !facingState.isOf(Blocks.FIRE)) { + if(facingState.isReplaceable && !facingState.isOf(Blocks.FIRE)) { world.setBlockState(facingPos, Blocks.FIRE.defaultState) world.playSound(null, pos.x+0.0, pos.y+0.0, pos.z+0.0, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0f, random.nextFloat() * 0.4f + 0.8f,) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/LightSource.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/LightSource.kt index 4c694142..5f82a07c 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/LightSource.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/LightSource.kt @@ -6,9 +6,9 @@ import net.minecraft.fluid.FluidState import net.minecraft.fluid.Fluids import net.minecraft.item.ItemPlacementContext import net.minecraft.particle.ParticleTypes +import net.minecraft.registry.tag.FluidTags import net.minecraft.state.StateManager import net.minecraft.state.property.Properties -import net.minecraft.tag.FluidTags import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.util.math.random.Random @@ -17,7 +17,7 @@ import net.minecraft.world.BlockView import net.minecraft.world.World import net.minecraft.world.WorldAccess -class LightSource: Block(FabricBlockSettings.of(Material.GLASS).luminance(15).ticksRandomly().collidable(false)), Waterloggable { +class LightSource: Block(FabricBlockSettings.copyOf(Blocks.GLASS).luminance(15).ticksRandomly().collidable(false)), Waterloggable { init { defaultState = stateManager.defaultState.with(Properties.WATERLOGGED, false) @@ -42,7 +42,7 @@ class LightSource: Block(FabricBlockSettings.of(Material.GLASS).luminance(15).ti @Suppress("DEPRECATION") override fun getStateForNeighborUpdate(state: BlockState, direction: Direction, newState: BlockState, world: WorldAccess, pos: BlockPos?, posFrom: BlockPos?): BlockState? { if (state.get(HorizontalConnectingBlock.WATERLOGGED) as Boolean) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)) + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)) } return super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/RedstoneTimer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/RedstoneTimer.kt index 0ea0d708..0b434cb6 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/RedstoneTimer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/RedstoneTimer.kt @@ -18,7 +18,7 @@ import net.minecraft.util.math.Direction import net.minecraft.world.BlockView import net.minecraft.world.World -class RedstoneTimer: BlockWithEntity(FabricBlockSettings.of(Material.STONE, MapColor.STONE_GRAY).requiresTool().strength(1.5F, 6.0F).nonOpaque()) { +class RedstoneTimer: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.STONE).requiresTool().strength(1.5F, 6.0F).nonOpaque()) { override fun createBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return RedstoneTimerEntity(this, blockPos, blockState) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/RedstoneTimerEntityRenderer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/RedstoneTimerEntityRenderer.kt index 32430dd8..bed88c34 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/RedstoneTimerEntityRenderer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/RedstoneTimerEntityRenderer.kt @@ -14,7 +14,7 @@ import net.minecraft.client.util.math.MatrixStack import net.minecraft.screen.PlayerScreenHandler import net.minecraft.util.Identifier import net.minecraft.util.math.Direction -import net.minecraft.util.math.Vec3f +import net.minecraft.util.math.RotationAxis import net.minecraft.util.math.random.Random class RedstoneTimerEntityRenderer(private val arg: BlockEntityRendererFactory.Context): BlockEntityRenderer { @@ -64,12 +64,12 @@ class RedstoneTimerEntityRenderer(private val arg: BlockEntityRendererFactory.Co matrices.push() matrices.translate(0.5, 0.5, 0.5) matrices.multiply(when(direction) { - Direction.NORTH -> Vec3f.POSITIVE_Y.getDegreesQuaternion(0f) - Direction.SOUTH -> Vec3f.POSITIVE_Y.getDegreesQuaternion(180f) - Direction.WEST -> Vec3f.POSITIVE_Y.getDegreesQuaternion(90f) - Direction.EAST -> Vec3f.POSITIVE_Y.getDegreesQuaternion(270f) - Direction.UP -> Vec3f.POSITIVE_Z.getDegreesQuaternion(90f) - Direction.DOWN -> Vec3f.POSITIVE_Z.getDegreesQuaternion(270f) + Direction.NORTH -> RotationAxis.POSITIVE_Y.rotationDegrees(0f) + Direction.SOUTH -> RotationAxis.POSITIVE_Y.rotationDegrees(180f) + Direction.WEST -> RotationAxis.POSITIVE_Y.rotationDegrees(90f) + Direction.EAST -> RotationAxis.POSITIVE_Y.rotationDegrees(270f) + Direction.UP -> RotationAxis.POSITIVE_Z.rotationDegrees(90f) + Direction.DOWN -> RotationAxis.POSITIVE_Z.rotationDegrees(270f) }) matrices.translate(-0.5, -0.5, -0.5) @@ -83,19 +83,19 @@ class RedstoneTimerEntityRenderer(private val arg: BlockEntityRendererFactory.Co matrices.translate(0.5, 0.5, 0.5) val rot1 = when(direction) { - Direction.NORTH -> Vec3f.POSITIVE_Y.getDegreesQuaternion(0f) - Direction.SOUTH -> Vec3f.POSITIVE_Y.getDegreesQuaternion(180f) - Direction.WEST -> Vec3f.POSITIVE_Y.getDegreesQuaternion(90f) - Direction.EAST -> Vec3f.POSITIVE_Y.getDegreesQuaternion(270f) - Direction.UP -> Vec3f.POSITIVE_X.getDegreesQuaternion(90f) - Direction.DOWN -> Vec3f.POSITIVE_X.getDegreesQuaternion(270f) + Direction.NORTH -> RotationAxis.POSITIVE_Y.rotationDegrees(0f) + Direction.SOUTH -> RotationAxis.POSITIVE_Y.rotationDegrees(180f) + Direction.WEST -> RotationAxis.POSITIVE_Y.rotationDegrees(90f) + Direction.EAST -> RotationAxis.POSITIVE_Y.rotationDegrees(270f) + Direction.UP -> RotationAxis.POSITIVE_X.rotationDegrees(90f) + Direction.DOWN -> RotationAxis.POSITIVE_X.rotationDegrees(270f) } vec.rotate(rot1) matrices.multiply(rot1) val rot2 = when(direction) { - Direction.UP -> Vec3f.POSITIVE_Z.getDegreesQuaternion(90f) - Direction.DOWN -> Vec3f.POSITIVE_Z.getDegreesQuaternion(270f) + Direction.UP -> RotationAxis.POSITIVE_Z.rotationDegrees(90f) + Direction.DOWN -> RotationAxis.POSITIVE_Z.rotationDegrees(270f) else -> null } @@ -134,9 +134,9 @@ class RedstoneTimerEntityRenderer(private val arg: BlockEntityRendererFactory.Co val ironTexture = SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, Identifier("block/iron_block")) val ironConsumer = ironTexture.getVertexConsumer(vertexConsumers, { texture: Identifier? -> RenderLayer.getEntitySolid(texture) }) - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180f)) + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180f)) matrices.translate(0.0, -1.0, -1.0) - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(-90f)) + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-90f)) matrices.translate(0.0, -1.0, 0.0) selector.render(matrices, ironConsumer, light, overlay) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Spikes.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Spikes.kt index 24f8fbc9..f01e9bab 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Spikes.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Spikes.kt @@ -1,7 +1,7 @@ package io.github.lucaargolo.kibe.blocks.miscellaneous -import io.github.lucaargolo.kibe.utils.FakePlayerEntity import io.github.lucaargolo.kibe.utils.SpikeHelper +import net.fabricmc.fabric.api.entity.FakePlayer import net.minecraft.block.Block import net.minecraft.block.BlockRenderType import net.minecraft.block.BlockState @@ -10,6 +10,7 @@ import net.minecraft.entity.Entity import net.minecraft.entity.LivingEntity import net.minecraft.entity.damage.DamageSource import net.minecraft.item.ItemPlacementContext +import net.minecraft.server.world.ServerWorld import net.minecraft.state.StateManager import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos @@ -40,11 +41,11 @@ class Spikes(private val type: Type, settings: Settings): Block(settings) { } override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) { - if(!world.isClient && entity is LivingEntity) { + if(world is ServerWorld && entity is LivingEntity) { SpikeHelper.setSpike(entity, type) when(type) { - Type.IRON, Type.STONE -> entity.damage(DamageSource.GENERIC, type.damage) - Type.GOLD, Type.DIAMOND -> entity.damage(DamageSource.player(FakePlayerEntity(world)), type.damage) + Type.IRON, Type.STONE -> entity.damage(world.damageSources.generic(), type.damage) + Type.GOLD, Type.DIAMOND -> entity.damage(world.damageSources.playerAttack(FakePlayer.get(world)), type.damage) } SpikeHelper.setSpike(entity, null) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpDrain.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpDrain.kt index 1fadcf15..2362260f 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpDrain.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpDrain.kt @@ -18,14 +18,14 @@ import net.minecraft.world.BlockView import net.minecraft.world.World import kotlin.math.pow -class XpDrain: Block(FabricBlockSettings.of(Material.STONE, MapColor.STONE_GRAY).requiresTool().strength(1.5F, 6.0F)) { +class XpDrain: Block(FabricBlockSettings.copyOf(Blocks.STONE).requiresTool().strength(1.5F, 6.0F)) { override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) { if(!world.isClient && entity is PlayerEntity) { val insertable = FluidStorage.SIDED.find(world, pos.down(), Direction.UP) var i = 3 + world.random.nextInt(5) + world.random.nextInt(5) - i = MathHelper.fastFloor(i*MOD_CONFIG.miscellaneousModule.xpDrainSpeedMultiplier) + i = MathHelper.floor(i*MOD_CONFIG.miscellaneousModule.xpDrainSpeedMultiplier) while (i > 0) { val j = ExperienceOrbEntity.roundToOrbSize(i) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpShower.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpShower.kt index 5b34218e..c478a3ea 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpShower.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpShower.kt @@ -18,7 +18,7 @@ import net.minecraft.util.shape.VoxelShapes import net.minecraft.world.BlockView import net.minecraft.world.World -class XpShower: BlockWithEntity(FabricBlockSettings.of(Material.STONE, MapColor.STONE_GRAY).requiresTool().strength(1.5F, 6.0F)) { +class XpShower: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.STONE).requiresTool().strength(1.5F, 6.0F)) { override fun createBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return XpShowerBlockEntity(this, blockPos, blockState) @@ -47,7 +47,7 @@ class XpShower: BlockWithEntity(FabricBlockSettings.of(Material.STONE, MapColor. if (!world.isClient) { val isEnabled = state[Properties.ENABLED] if (isEnabled != world.isReceivingRedstonePower(pos)) { - if (isEnabled) world.createAndScheduleBlockTick(pos, this, 4) + if (isEnabled) world.scheduleBlockTick(pos, this, 4) else world.setBlockState(pos, state.cycle(Properties.ENABLED), 2) } } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpShowerBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpShowerBlockEntity.kt index 760fbb66..fb34e98e 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpShowerBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/XpShowerBlockEntity.kt @@ -32,7 +32,7 @@ class XpShowerBlockEntity(xpShower: XpShower, pos: BlockPos, state: BlockState): val extractable = FluidStorage.SIDED.find(world, pos.add(dir.vector), dir.opposite) var i = 3 + world.random.nextInt(5) + world.random.nextInt(5) - i = MathHelper.fastFloor(i* MOD_CONFIG.miscellaneousModule.xpShowerSpeedMultiplier) + i = MathHelper.floor(i* MOD_CONFIG.miscellaneousModule.xpShowerSpeedMultiplier) while (i > 0) { val j = ExperienceOrbEntity.roundToOrbSize(i) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/Placer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/Placer.kt index 15b14c80..dcfc8607 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/Placer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/Placer.kt @@ -1,7 +1,7 @@ package io.github.lucaargolo.kibe.blocks.placer import io.github.lucaargolo.kibe.utils.BlockScreenHandlerFactory -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.* import net.minecraft.entity.player.PlayerEntity @@ -42,7 +42,7 @@ class Placer: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)) { val isReceivingPower = world.isReceivingRedstonePower(pos) || world.isReceivingRedstonePower(pos.up()) val triggered = state[DispenserBlock.TRIGGERED] if (isReceivingPower && !triggered) { - world.createAndScheduleBlockTick(pos, this, 4) + world.scheduleBlockTick(pos, this, 4) world.setBlockState(pos, state.with(DispenserBlock.TRIGGERED, true) as BlockState, 4) } else if (!isReceivingPower && triggered) { world.setBlockState(pos, state.with(DispenserBlock.TRIGGERED, false) as BlockState, 4) @@ -60,7 +60,7 @@ class Placer: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)) { if(index < 9) { val stack = it.getStack(index) val item = stack.item as? BlockItem ?: return - val fakePlayer = FakePlayerEntity(world) + val fakePlayer = FakePlayer.get(world) fakePlayer.setStackInHand(Hand.MAIN_HAND, stack) val fakeHitPos = Vec3d(facingPos.x + 0.5, facingPos.y + 0.0, facingPos.z + 0.5) item.useOnBlock(ItemUsageContext(fakePlayer, Hand.MAIN_HAND, BlockHitResult(fakeHitPos, facing.opposite, facingPos, false))) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/PlacerScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/PlacerScreen.kt index e9bb4431..97bfe076 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/PlacerScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/PlacerScreen.kt @@ -1,6 +1,7 @@ package io.github.lucaargolo.kibe.blocks.placer import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -11,19 +12,18 @@ class PlacerScreen(handler: PlacerScreenHandler, inventory: PlayerInventory, tit private val texture = Identifier("kibe:textures/gui/placer.png") - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - textRenderer.draw(matrices, title, ((backgroundWidth / 2) - (textRenderer.getWidth(title)/2)).toFloat(), 6f, 4210752) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 4210752) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawText(textRenderer, title, (backgroundWidth / 2) - (textRenderer.getWidth(title)/2), 6, 4210752, false) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 4210752, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, 176, 168) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, x, y, 0, 0, 176, 168) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/PlacerScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/PlacerScreenHandler.kt index 1ad193bb..f4e9389d 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/PlacerScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/placer/PlacerScreenHandler.kt @@ -41,7 +41,7 @@ class PlacerScreenHandler(syncId: Int, val playerInventory: PlayerInventory, val } } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/Tank.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/Tank.kt index bf80fcf1..c400cdc3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/Tank.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/Tank.kt @@ -18,7 +18,7 @@ import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos import net.minecraft.world.World -class Tank: BlockWithEntity(FabricBlockSettings.of(Material.GLASS).strength(0.5F).nonOpaque().luminance { state -> state[Properties.LEVEL_15] }.sounds(BlockSoundGroup.GLASS)) { +class Tank: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.GLASS).strength(0.5F).nonOpaque().luminance { state -> state[Properties.LEVEL_15] }.sounds(BlockSoundGroup.GLASS)) { init { defaultState = stateManager.defaultState.with(Properties.LEVEL_15, 0) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankBlockEntity.kt index 35322f32..48548913 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankBlockEntity.kt @@ -55,7 +55,7 @@ class TankBlockEntity(tank: Tank, pos: BlockPos, state: BlockState): SyncableBlo override fun readClientNbt(tag: NbtCompound) = readNbt(tag) companion object { - fun getFluidStorage(be: TankBlockEntity, dir: Direction): Storage { + fun getFluidStorage(be: TankBlockEntity, dir: Direction?): Storage { return be.tank } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankBlockEntityRenderer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankBlockEntityRenderer.kt index e3f5b8f1..c0f4da82 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankBlockEntityRenderer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankBlockEntityRenderer.kt @@ -16,7 +16,7 @@ import net.minecraft.fluid.Fluids import net.minecraft.screen.PlayerScreenHandler import net.minecraft.util.math.Direction import net.minecraft.util.math.MathHelper -import net.minecraft.util.math.Vec3f +import org.joml.Vector3f import java.awt.Color class TankBlockEntityRenderer(private val arg: BlockEntityRendererFactory.Context): BlockEntityRenderer { @@ -66,7 +66,7 @@ class TankBlockEntityRenderer(private val arg: BlockEntityRendererFactory.Contex } - private fun renderVertices(bb: VertexConsumer, entry: MatrixStack.Entry, normal: Vec3f, color: Color, overlay: Int, light: Int, uv: UV, f: Float, g: Float, h: Float, i: Float, j: Float, k: Float, l: Float, m: Float) { + private fun renderVertices(bb: VertexConsumer, entry: MatrixStack.Entry, normal: Vector3f, color: Color, overlay: Int, light: Int, uv: UV, f: Float, g: Float, h: Float, i: Float, j: Float, k: Float, l: Float, m: Float) { bb.vertex(entry.positionMatrix, f, h, j).color(color.red/255f, color.green/255f, color.blue/255f, 1f).texture(uv.maxU, uv.minV).overlay(overlay).light(light).normal(entry.normalMatrix, normal.x, normal.y, normal.z).next() bb.vertex(entry.positionMatrix, g, h, k).color(color.red/255f, color.green/255f, color.blue/255f, 1f).texture(uv.minU, uv.minV).overlay(overlay).light(light).normal(entry.normalMatrix, normal.x, normal.y, normal.z).next() bb.vertex(entry.positionMatrix, g, i, l).color(color.red/255f, color.green/255f, color.blue/255f, 1f).texture(uv.minU, uv.maxV).overlay(overlay).light(light).normal(entry.normalMatrix, normal.x, normal.y, normal.z).next() diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankCustomModel.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankCustomModel.kt index 31e6bca1..c87c6a3d 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankCustomModel.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/tank/TankCustomModel.kt @@ -31,9 +31,10 @@ class TankCustomModel: UnbakedModel, BakedModel, FabricBakedModel { override fun getModelDependencies(): Collection = listOf() - override fun getTextureDependencies(unbakedModelGetter: Function, unresolvedTextureReferences: MutableSet>) = spriteIdList + override fun setParents(modelLoader: Function?) { + } - override fun bake(loader: ModelLoader, textureGetter: Function, rotationContainer: ModelBakeSettings, modelId: Identifier): BakedModel { + override fun bake(baker: Baker, textureGetter: Function, rotationContainer: ModelBakeSettings, modelId: Identifier): BakedModel { spriteIdList.forEach { spriteIdentifier -> spriteList.add(textureGetter.apply(spriteIdentifier)) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCan.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCan.kt index 63d9831a..f72a7266 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCan.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCan.kt @@ -13,7 +13,7 @@ import net.minecraft.util.shape.VoxelShape import net.minecraft.world.BlockView import net.minecraft.world.World -class TrashCan: BlockWithEntity(FabricBlockSettings.of(Material.STONE, MapColor.STONE_GRAY).requiresTool().strength(1.5F, 6.0F)) { +class TrashCan: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.STONE).requiresTool().strength(1.5F, 6.0F)) { override fun createBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return TrashCanEntity(this, blockPos, blockState) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCanScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCanScreen.kt index 0b097b1a..7f0e1f98 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCanScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCanScreen.kt @@ -1,6 +1,7 @@ package io.github.lucaargolo.kibe.blocks.trashcan import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -20,20 +21,19 @@ class TrashCanScreen(screenHandler: TrashCanScreenHandler, inventory: PlayerInve startY = height/2-backgroundHeight/2 } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - drawCenteredText(matrices, textRenderer, title.string,backgroundWidth/2, 6, 0xFFFFFF) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 0xFFFFFF) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawCenteredTextWithShadow(textRenderer, title.string,backgroundWidth/2, 6, 0xFFFFFF) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 0xFFFFFF, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, startX, startY, 0, 0, 176, 166) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, startX, startY, 0, 0, 176, 166) } } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCanScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCanScreenHandler.kt index fd0e59a5..c037b483 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCanScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/trashcan/TrashCanScreenHandler.kt @@ -96,7 +96,7 @@ class TrashCanScreenHandler(syncId: Int, playerInventory: PlayerInventory, val e }, true) } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopper.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopper.kt index 619dfe48..bf6cd3a0 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopper.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopper.kt @@ -26,7 +26,7 @@ import net.minecraft.util.math.random.Random import net.minecraft.world.BlockView import net.minecraft.world.World -class VacuumHopper: BlockWithEntity(FabricBlockSettings.of(Material.METAL, MapColor.IRON_GRAY).requiresTool().strength(5.0F, 6.0F).sounds(BlockSoundGroup.METAL).nonOpaque()) { +class VacuumHopper: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).requiresTool().strength(5.0F, 6.0F).sounds(BlockSoundGroup.METAL).nonOpaque()) { override fun createBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return VacuumHopperEntity(this, blockPos, blockState) @@ -52,7 +52,7 @@ class VacuumHopper: BlockWithEntity(FabricBlockSettings.of(Material.METAL, MapCo if (!world.isClient) { val isEnabled = state[Properties.ENABLED] if (isEnabled == world.isReceivingRedstonePower(pos)) { - if (isEnabled) world.createAndScheduleBlockTick(pos, this, 4) + if (isEnabled) world.scheduleBlockTick(pos, this, 4) else world.setBlockState(pos, state.cycle(Properties.ENABLED), 2) } } @@ -125,7 +125,7 @@ class VacuumHopper: BlockWithEntity(FabricBlockSettings.of(Material.METAL, MapCo return output } - override fun isTranslucent(state: BlockState?, view: BlockView?, pos: BlockPos?): Boolean { + override fun isTransparent(state: BlockState?, world: BlockView?, pos: BlockPos?): Boolean { return true } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperEntity.kt index ea75a5db..68157a26 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperEntity.kt @@ -108,7 +108,7 @@ class VacuumHopperEntity(vacuumHopper: VacuumHopper, pos: BlockPos, state: Block inventory[id] = modifiableStack modifiableStack = ItemStack.EMPTY }else{ - if(ItemStack.areItemsEqual(stk, modifiableStack) && ItemStack.areNbtEqual(stk, modifiableStack)) { + if(ItemStack.canCombine(stk, modifiableStack)) { when { stk.count+modifiableStack.count > stk.maxCount -> { val aux = stk.maxCount-stk.count @@ -168,7 +168,7 @@ class VacuumHopperEntity(vacuumHopper: VacuumHopper, pos: BlockPos, state: Block override fun canExtract(slot: Int, stack: ItemStack?, dir: Direction?) = slot != 9 companion object { - fun getFluidStorage(be: VacuumHopperEntity, dir: Direction): Storage { + fun getFluidStorage(be: VacuumHopperEntity, dir: Direction?): Storage { return be.tank } @@ -189,7 +189,7 @@ class VacuumHopperEntity(vacuumHopper: VacuumHopper, pos: BlockPos, state: Block if(recipe.matches(entity, serverWorld)) { entity.totalProcessingTicks = recipe.ticks if(entity.processingTicks++ >= recipe.ticks) { - recipe.craft(entity) + recipe.craft(entity, world.registryManager) entity.processingRecipe = null entity.processingTicks = 0 entity.totalProcessingTicks = 0 diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperEntityRenderer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperEntityRenderer.kt index 1e71748b..f4f7db87 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperEntityRenderer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperEntityRenderer.kt @@ -7,7 +7,7 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer import net.minecraft.client.render.block.entity.BlockEntityRendererFactory import net.minecraft.client.util.math.MatrixStack import net.minecraft.state.property.Properties -import net.minecraft.util.math.Matrix4f +import org.joml.Matrix4f import java.util.* class VacuumHopperEntityRenderer(private val arg: BlockEntityRendererFactory.Context): BlockEntityRenderer { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperScreen.kt index 8dcc9372..57ca4a6a 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperScreen.kt @@ -7,6 +7,7 @@ import io.github.lucaargolo.kibe.utils.getMb import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes import net.minecraft.client.MinecraftClient +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.render.GameRenderer import net.minecraft.client.render.Tessellator @@ -33,35 +34,33 @@ class VacuumHopperScreen(screenHandler: VacuumHopperScreenHandler, inventory: Pl startY = height/2-backgroundHeight/2 } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) val p = ((handler.processingTicks/handler.totalProcessingTicks.toFloat())*14).toInt() - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, startX+120, startY+37, 184, 0, 8, p) - drawMouseoverTooltip(matrices, mouseX, mouseY) + context.drawTexture(texture, startX+120, startY+37, 184, 0, 8, p) + drawMouseoverTooltip(context, mouseX, mouseY) if(mouseX in (startX+100..startX+112) && mouseY in (startY+18..startY+70)) { val tank = handler.entity.tank val stored = tank.amount val capacity = tank.capacity - renderTooltip(matrices, listOf(if(tank.isResourceBlank) Text.translatable("tooltip.kibe.empty") else FluidVariantAttributes.getName(tank.variant), Text.literal("${getMb(stored)} / ${capacity/81} mB").formatted(Formatting.GRAY)), mouseX, mouseY) + context.drawTooltip(textRenderer, listOf(if(tank.isResourceBlank) Text.translatable("tooltip.kibe.empty") else FluidVariantAttributes.getName(tank.variant), Text.literal("${getMb(stored)} / ${capacity/81} mB").formatted(Formatting.GRAY)), mouseX, mouseY) } } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - drawCenteredText(matrices, textRenderer, title.string,backgroundWidth/2, 6, 0xFFFFFF) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 0xFFFFFF) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawCenteredTextWithShadow(textRenderer, title.string,backgroundWidth/2, 6, 0xFFFFFF) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 0xFFFFFF, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, startX, startY, 0, 0, 176, 166) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, startX, startY, 0, 0, 176, 166) val tank = handler.entity.tank val oldShader = RenderSystem.getShader() RenderSystem.setShaderTexture(0, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE) - RenderSystem.setShader(GameRenderer::getPositionColorTexShader) + RenderSystem.setShader(GameRenderer::getPositionColorTexProgram) FluidRenderHandlerRegistry.INSTANCE.get(tank.resource.fluid)?.let { fluidRenderHandler -> val fluidColor = fluidRenderHandler.getFluidColor(MinecraftClient.getInstance().world, MinecraftClient.getInstance().player!!.blockPos, tank.resource.fluid.defaultState) val sprite = fluidRenderHandler.getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, tank.resource.fluid.defaultState)[0] @@ -70,7 +69,7 @@ class VacuumHopperScreen(screenHandler: VacuumHopperScreenHandler, inventory: Pl val b = (fluidColor and 255)/255f val tess = Tessellator.getInstance() val bb = tess.buffer - val matrix = matrices.peek().positionMatrix + val matrix = context.matrices.peek().positionMatrix var percentage = (tank.amount/tank.capacity.toFloat())*52f @@ -79,17 +78,16 @@ class VacuumHopperScreen(screenHandler: VacuumHopperScreenHandler, inventory: Pl bb.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE) bb.vertex(matrix, startX+100f, startY+70f-(index*16f), 0f).color(r, g, b, 1f).texture(sprite.maxU, sprite.minV).next() bb.vertex(matrix, startX+112f, startY+70f-(index*16f), 0f).color(r, g, b, 1f).texture(sprite.minU, sprite.minV).next() - val atlasHeight = sprite.height/(sprite.maxV - sprite.minV) - bb.vertex(matrix, startX+112f, startY+70f-p-(index*16f), 0f).color(r, g, b, 1f).texture(sprite.minU, (sprite.maxV-((sprite.height-p)/atlasHeight))).next() - bb.vertex(matrix, startX+100f, startY+70f-p-(index*16f), 0f).color(r, g, b, 1f).texture(sprite.maxU, (sprite.maxV-((sprite.height-p)/atlasHeight))).next() + val atlasHeight = sprite.contents.height/(sprite.maxV - sprite.minV) + bb.vertex(matrix, startX+112f, startY+70f-p-(index*16f), 0f).color(r, g, b, 1f).texture(sprite.minU, (sprite.maxV-((sprite.contents.height-p)/atlasHeight))).next() + bb.vertex(matrix, startX+100f, startY+70f-p-(index*16f), 0f).color(r, g, b, 1f).texture(sprite.maxU, (sprite.maxV-((sprite.contents.height-p)/atlasHeight))).next() tess.draw() percentage -= p } } RenderSystem.setShader { oldShader } - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, startX+100, startY+18, 172, 0, 12, 52) + context.drawTexture(texture, startX+100, startY+18, 172, 0, 12, 52) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperScreenHandler.kt index edf94c90..baa006b6 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/vacuum/VacuumHopperScreenHandler.kt @@ -111,7 +111,7 @@ class VacuumHopperScreenHandler (syncId: Int, playerInventory: PlayerInventory, }, true) } - override fun transferSlot(player: PlayerEntity, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilder.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilder.kt index 485ffe83..6cbab65f 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilder.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilder.kt @@ -1,7 +1,7 @@ package io.github.lucaargolo.kibe.blocks.witherbuilder import io.github.lucaargolo.kibe.utils.BlockScreenHandlerFactory -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.* import net.minecraft.entity.player.PlayerEntity @@ -44,9 +44,9 @@ class WitherBuilder: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.OBSIDIAN) override fun getPlacementState(ctx: ItemPlacementContext): BlockState? { return when(ctx.playerLookDirection.opposite) { - Direction.UP -> defaultState.with(Properties.HORIZONTAL_FACING, ctx.playerFacing.opposite).with(VERTICAL, true).with(VERTICAL_FACING, Direction.UP) - Direction.DOWN -> defaultState.with(Properties.HORIZONTAL_FACING, ctx.playerFacing.opposite).with(VERTICAL, true).with(VERTICAL_FACING, Direction.DOWN) - else -> defaultState.with(Properties.HORIZONTAL_FACING, ctx.playerFacing.opposite).with(VERTICAL, false) + Direction.UP -> defaultState.with(Properties.HORIZONTAL_FACING, ctx.horizontalPlayerFacing.opposite).with(VERTICAL, true).with(VERTICAL_FACING, Direction.UP) + Direction.DOWN -> defaultState.with(Properties.HORIZONTAL_FACING, ctx.horizontalPlayerFacing.opposite).with(VERTICAL, true).with(VERTICAL_FACING, Direction.DOWN) + else -> defaultState.with(Properties.HORIZONTAL_FACING, ctx.horizontalPlayerFacing.opposite).with(VERTICAL, false) } } @@ -54,7 +54,7 @@ class WitherBuilder: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.OBSIDIAN) val isReceivingPower = world.isReceivingRedstonePower(pos) || world.isReceivingRedstonePower(pos.up()) val triggered = state[DispenserBlock.TRIGGERED] if (isReceivingPower && !triggered) { - world.createAndScheduleBlockTick(pos, this, 4) + world.scheduleBlockTick(pos, this, 4) world.setBlockState(pos, state.with(DispenserBlock.TRIGGERED, true) as BlockState, 4) } else if (!isReceivingPower && triggered) { world.setBlockState(pos, state.with(DispenserBlock.TRIGGERED, false) as BlockState, 4) @@ -75,13 +75,13 @@ class WitherBuilder: BlockWithEntity(FabricBlockSettings.copyOf(Blocks.OBSIDIAN) facingPos.add(0, 2, 0), facingPos.add(xOffset, 2, zOffset), facingPos.add(-xOffset, 2, -zOffset) - ).map { world.getBlockState(it).material.isReplaceable }.none { !it } + ).map { world.getBlockState(it).isReplaceable }.none { !it } if(shouldRun) { (world.getBlockEntity(pos) as? WitherBuilderBlockEntity)?.let { blockEntity -> val minCount = (blockEntity.inventory.map { if (it.isEmpty) 0 else it.count }.minOrNull() ?: 0) if(minCount > 0) { - val fakePlayer = FakePlayerEntity(world) + val fakePlayer = FakePlayer.get(world) (0..6).forEach { slot -> val stack = blockEntity.getStack(slot) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderBlockEntity.kt index 8c94b5df..69f2e3db 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderBlockEntity.kt @@ -10,7 +10,7 @@ import net.minecraft.item.BlockItem import net.minecraft.item.ItemStack import net.minecraft.item.Items import net.minecraft.nbt.NbtCompound -import net.minecraft.tag.BlockTags +import net.minecraft.registry.tag.BlockTags import net.minecraft.util.collection.DefaultedList import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderScreen.kt index 1ab090b7..1689056e 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderScreen.kt @@ -1,8 +1,7 @@ package io.github.lucaargolo.kibe.blocks.witherbuilder -import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen -import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory import net.minecraft.text.Text import net.minecraft.util.Identifier @@ -11,19 +10,18 @@ class WitherBuilderScreen(handler: WitherBuilderScreenHandler, inventory: Player private val texture = Identifier("kibe:textures/gui/wither_builder.png") - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - textRenderer.draw(matrices, title, ((backgroundWidth / 2) - (textRenderer.getWidth(title)/2)).toFloat(), 6f, 4210752) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 4210752) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawText(textRenderer, title, (backgroundWidth / 2) - (textRenderer.getWidth(title)/2), 6, 4210752, false) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 4210752, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, 176, 168) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, x, y, 0, 0, 176, 168) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderScreenHandler.kt index c714d04a..dd3b27b3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/blocks/witherbuilder/WitherBuilderScreenHandler.kt @@ -8,10 +8,10 @@ import net.minecraft.entity.player.PlayerInventory import net.minecraft.item.BlockItem import net.minecraft.item.ItemStack import net.minecraft.item.Items +import net.minecraft.registry.tag.BlockTags import net.minecraft.screen.ScreenHandler import net.minecraft.screen.ScreenHandlerContext import net.minecraft.screen.slot.Slot -import net.minecraft.tag.BlockTags import net.minecraft.util.math.BlockPos import net.minecraft.world.World @@ -47,7 +47,7 @@ class WitherBuilderScreenHandler(syncId: Int, val playerInventory: PlayerInvento } } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/compat/trinkets/TrinketAbilityRing.kt b/src/main/kotlin/io/github/lucaargolo/kibe/compat/trinkets/TrinketAbilityRing.kt index 0326f0b6..61601124 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/compat/trinkets/TrinketAbilityRing.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/compat/trinkets/TrinketAbilityRing.kt @@ -4,6 +4,7 @@ import dev.emi.trinkets.api.SlotReference import dev.emi.trinkets.api.Trinket import dev.emi.trinkets.api.TrinketsApi import io.github.ladysnake.pal.PlayerAbility +import io.github.lucaargolo.kibe.MOD_NAME import io.github.lucaargolo.kibe.items.miscellaneous.AbilityRing import io.github.lucaargolo.kibe.mixed.PlayerEntityMixed import net.minecraft.entity.LivingEntity @@ -12,7 +13,7 @@ import net.minecraft.item.ItemStack class TrinketAbilityRing(settings: Settings, ability: PlayerAbility) : AbilityRing(settings, ability), Trinket { init { - io.github.lucaargolo.kibe.LOGGER.info("creating Trinket AbilityRing for ${ability.id}") + io.github.lucaargolo.kibe.LOGGER.info("[$MOD_NAME] Creating Trinket AbilityRing for ${ability.id}") TrinketsApi.registerTrinket(this, this) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/effects/EffectCompendium.kt b/src/main/kotlin/io/github/lucaargolo/kibe/effects/EffectCompendium.kt index 68f49e32..b61a860f 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/effects/EffectCompendium.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/effects/EffectCompendium.kt @@ -3,7 +3,8 @@ package io.github.lucaargolo.kibe.effects import io.github.lucaargolo.kibe.MOD_ID import net.minecraft.entity.effect.StatusEffect import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries val effectRegistry = mutableMapOf() @@ -15,5 +16,5 @@ private fun register(identifier: Identifier, effect: StatusEffect): StatusEffect } fun initEffects() { - effectRegistry.forEach{ Registry.register(Registry.STATUS_EFFECT, it.key, it.value) } + effectRegistry.forEach{ Registry.register(Registries.STATUS_EFFECT, it.key, it.value) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/entities/EntityCompendium.kt b/src/main/kotlin/io/github/lucaargolo/kibe/entities/EntityCompendium.kt index 72cde1be..43a65aa3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/entities/EntityCompendium.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/entities/EntityCompendium.kt @@ -10,7 +10,8 @@ import net.minecraft.entity.EntityDimensions import net.minecraft.entity.EntityType import net.minecraft.entity.SpawnGroup import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import net.minecraft.world.World val entityRegistry = mutableMapOf>() @@ -26,7 +27,7 @@ private fun register(identifier: Identifier, entityType: EntityType< } fun initEntities() { - entityRegistry.forEach{ Registry.register(Registry.ENTITY_TYPE, it.key, it.value) } + entityRegistry.forEach{ Registry.register(Registries.ENTITY_TYPE, it.key, it.value) } } fun initEntitiesClient() { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/fluids/FluidCompendium.kt b/src/main/kotlin/io/github/lucaargolo/kibe/fluids/FluidCompendium.kt index d15f98aa..d0001d6e 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/fluids/FluidCompendium.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/fluids/FluidCompendium.kt @@ -6,7 +6,6 @@ import io.github.lucaargolo.kibe.fluids.miscellaneous.ModdedFluid import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings import net.fabricmc.fabric.api.resource.ResourceManagerHelper import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener @@ -16,7 +15,6 @@ import net.minecraft.block.FluidBlock import net.minecraft.client.MinecraftClient import net.minecraft.client.render.RenderLayer import net.minecraft.client.texture.Sprite -import net.minecraft.client.texture.SpriteAtlasTexture import net.minecraft.fluid.FlowableFluid import net.minecraft.fluid.Fluid import net.minecraft.fluid.FluidState @@ -28,7 +26,8 @@ import net.minecraft.resource.ResourceType import net.minecraft.screen.PlayerScreenHandler import net.minecraft.util.Identifier import net.minecraft.util.math.BlockPos -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import net.minecraft.world.BlockRenderView import java.util.function.Function @@ -53,13 +52,13 @@ fun initFluids() { val identifierStill = it.key val fluidStill = it.value if(!identifierStill.path.startsWith("flowing_")) { - val registeredFluid = Registry.register(Registry.FLUID, identifierStill, fluidStill) + val registeredFluid = Registry.register(Registries.FLUID, identifierStill, fluidStill) val identifierFlowing = Identifier(MOD_ID, "flowing_" + identifierStill.path) val fluidFlowing = fluidRegistry[identifierFlowing]!! - Registry.register(Registry.FLUID, identifierFlowing, fluidFlowing) - fluidBucketMap[fluidStill] = Registry.register(Registry.ITEM, Identifier(it.key.namespace, "${identifierStill.path}_bucket"), BucketItem(fluidStill, Item.Settings().recipeRemainder(Items.BUCKET).maxCount(1))) + Registry.register(Registries.FLUID, identifierFlowing, fluidFlowing) + fluidBucketMap[fluidStill] = Registry.register(Registries.ITEM, Identifier(it.key.namespace, "${identifierStill.path}_bucket"), BucketItem(fluidStill, Item.Settings().recipeRemainder(Items.BUCKET).maxCount(1))) fluidBucketMap[fluidFlowing] = fluidBucketMap[fluidStill]!! - fluidBlockMap[fluidStill] = Registry.register(Registry.BLOCK, it.key, object : FluidBlock(registeredFluid as FlowableFluid, FabricBlockSettings.copy(Blocks.LAVA)) {}) + fluidBlockMap[fluidStill] = Registry.register(Registries.BLOCK, it.key, object : FluidBlock(registeredFluid as FlowableFluid, FabricBlockSettings.copy(Blocks.LAVA)) {}) fluidBlockMap[fluidFlowing] = fluidBlockMap[fluidStill]!! } } @@ -85,13 +84,7 @@ private fun setupFluidRendering(still: Fluid?, flowing: Fluid?, textureFluidId: val stillSpriteId = Identifier(textureFluidId.namespace, "block/" + textureFluidId.path + "_still") val flowingSpriteId = Identifier(textureFluidId.namespace, "block/" + textureFluidId.path + "_flow") - ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE) - .register(ClientSpriteRegistryCallback { _: SpriteAtlasTexture?, registry: ClientSpriteRegistryCallback.Registry -> - registry.register(stillSpriteId) - registry.register(flowingSpriteId) - }) - - val fluidId = Registry.FLUID.getId(still) + val fluidId = Registries.FLUID.getId(still) val listenerId = Identifier(fluidId.namespace, fluidId.path + "_reload_listener") val fluidSprites = arrayOf(null, null) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/fluids/miscellaneous/ModdedFluid.kt b/src/main/kotlin/io/github/lucaargolo/kibe/fluids/miscellaneous/ModdedFluid.kt index c970464a..fd5d52fe 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/fluids/miscellaneous/ModdedFluid.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/fluids/miscellaneous/ModdedFluid.kt @@ -11,6 +11,7 @@ import net.minecraft.item.Item import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.world.BlockView +import net.minecraft.world.World import net.minecraft.world.WorldAccess import net.minecraft.world.WorldView @@ -28,7 +29,7 @@ abstract class ModdedFluid: FlowableFluid() { return fluid === still || fluid === flowing } - override fun isInfinite(): Boolean { + override fun isInfinite(world: World?): Boolean { return false } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/ItemCompendium.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/ItemCompendium.kt index 5aee75ab..1b1ee941 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/ItemCompendium.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/ItemCompendium.kt @@ -2,7 +2,6 @@ package io.github.lucaargolo.kibe.items -import com.mojang.datafixers.util.Pair import io.github.ladysnake.pal.VanillaAbilities import io.github.lucaargolo.kibe.MOD_CONFIG import io.github.lucaargolo.kibe.MOD_ID @@ -23,7 +22,6 @@ import io.github.lucaargolo.kibe.items.tank.TankBlockItemBakedModel import io.github.lucaargolo.kibe.items.trashcan.PocketTrashCan import io.github.lucaargolo.kibe.items.trashcan.PocketTrashCanScreen import io.github.lucaargolo.kibe.items.trashcan.PocketTrashCanScreenHandler -import io.github.lucaargolo.kibe.utils.CREATIVE_TAB import io.github.lucaargolo.kibe.utils.INFINITE_FIRE_RESISTENCE import io.github.lucaargolo.kibe.utils.INFINITE_WATER_BREATHING import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry @@ -31,10 +29,7 @@ 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.render.model.BakedModel -import net.minecraft.client.render.model.ModelBakeSettings -import net.minecraft.client.render.model.ModelLoader -import net.minecraft.client.render.model.UnbakedModel +import net.minecraft.client.render.model.* import net.minecraft.client.texture.Sprite import net.minecraft.client.util.SpriteIdentifier import net.minecraft.item.FoodComponent @@ -49,7 +44,8 @@ import net.minecraft.util.DyeColor import net.minecraft.util.Hand import net.minecraft.util.Identifier import net.minecraft.util.Rarity -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import java.util.function.Function import java.util.function.Supplier import kotlin.reflect.KClass @@ -77,7 +73,7 @@ class ContainerInfo( handler = handlerClass.java.constructors[0].newInstance(i, playerInventory, hand, playerInventory.player.world, tag) as T handler } - Registry.register(Registry.SCREEN_HANDLER, id, handlerType) + Registry.register(Registries.SCREEN_HANDLER, id, handlerType) } fun initClient() { @@ -94,7 +90,7 @@ class ItemInfo ( ){ fun init() { - Registry.register(Registry.ITEM, identifier, item) + Registry.register(Registries.ITEM, identifier, item) containers.forEach { it.init(identifier) } } @@ -106,8 +102,8 @@ class ItemInfo ( if(modelIdentifier.namespace == identifier.namespace && modelIdentifier.path == identifier.path && modelIdentifier.variant == "inventory") { return@ModelVariantProvider object : UnbakedModel { override fun getModelDependencies(): MutableCollection = mutableListOf() - override fun bake(loader: ModelLoader, textureGetter: Function, rotationScreenHandler: ModelBakeSettings, modelId: Identifier) = bakedModel.invoke() - override fun getTextureDependencies(unbakedModelGetter: Function?, unresolvedTextureReferences: MutableSet>?): MutableCollection = mutableListOf() + override fun setParents(modelLoader: Function?) {} + override fun bake(baker: Baker?, textureGetter: Function?, rotationContainer: ModelBakeSettings?, modelId: Identifier?) = bakedModel.invoke() } } return@ModelVariantProvider null @@ -130,102 +126,100 @@ fun getContainerInfo(item: Item, identifier: Identifier): ContainerInfo<*>? { return null } -val KIBE = register(Identifier(MOD_ID, "kibe"), Item(settingsWithTab().rarity(Rarity.COMMON).food(FoodComponent.Builder().hunger(6).saturationModifier(0.8F).meat().build()))) -val GOLDEN_KIBE = register(Identifier(MOD_ID, "golden_kibe"), Item(settingsWithTab().rarity(Rarity.UNCOMMON).food(FoodComponent.Builder().hunger(8).saturationModifier(1.2F).meat().build()))) -val CURSED_KIBE = register(Identifier(MOD_ID, "cursed_kibe"), Item(settingsWithTab().rarity(Rarity.UNCOMMON).food(FoodComponent.Builder().hunger(10).saturationModifier(1.2F).meat().build()))) -val DIAMOND_KIBE = register(Identifier(MOD_ID, "diamond_kibe"), Item(settingsWithTab().rarity(Rarity.RARE).food(FoodComponent.Builder().hunger(16).saturationModifier(1F).meat().build()))) - -val CURSED_DROPLETS = register(Identifier(MOD_ID, "cursed_droplets"), Item(settingsWithTab())) -val CURSED_SEEDS = register(Identifier(MOD_ID, "cursed_seeds"), CursedSeeds(settingsWithTab())) - -val MAGNET = register(Identifier(MOD_ID, "magnet"), Magnet.create(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) - -val DIAMOND_RING = register(Identifier(MOD_ID, "diamond_ring"), Item(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) -val ANGEL_RING = register(Identifier(MOD_ID, "angel_ring"), AbilityRing.create(settingsWithTab().maxCount(1).rarity(Rarity.EPIC), VanillaAbilities.ALLOW_FLYING)) -val MAGMA_RING = register(Identifier(MOD_ID, "magma_ring"), AbilityRing.create(settingsWithTab().maxCount(1).rarity(Rarity.RARE), INFINITE_FIRE_RESISTENCE)) -val WATER_RING = register(Identifier(MOD_ID, "water_ring"), AbilityRing.create(settingsWithTab().maxCount(1).rarity(Rarity.RARE), INFINITE_WATER_BREATHING)) -val LIGHT_RING = register(Identifier(MOD_ID, "light_ring"), LightRing(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) - -val GOLDEN_LASSO = register(Identifier(MOD_ID, "golden_lasso"), Lasso.GoldenLasso(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) -val CURSED_LASSO = register(Identifier(MOD_ID, "cursed_lasso"), Lasso.CursedLasso(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) -val DIAMOND_LASSO = register(Identifier(MOD_ID, "diamond_lasso"), Lasso.DiamondLasso(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) - -val WHITE_RUNE = register(Identifier(MOD_ID, "white_rune"), Rune(DyeColor.WHITE, settingsWithTab())) -val ORANGE_RUNE = register(Identifier(MOD_ID, "orange_rune"), Rune(DyeColor.ORANGE, settingsWithTab())) -val MAGENTA_RUNE = register(Identifier(MOD_ID, "magenta_rune"), Rune(DyeColor.MAGENTA, settingsWithTab())) -val LIGHT_BLUE_RUNE = register(Identifier(MOD_ID, "light_blue_rune"), Rune(DyeColor.LIGHT_BLUE, settingsWithTab())) -val YELLOW_RUNE = register(Identifier(MOD_ID, "yellow_rune"), Rune(DyeColor.YELLOW, settingsWithTab())) -val LIME_RUNE = register(Identifier(MOD_ID, "lime_rune"), Rune(DyeColor.LIME, settingsWithTab())) -val PINK_RUNE = register(Identifier(MOD_ID, "pink_rune"), Rune(DyeColor.PINK, settingsWithTab())) -val GRAY_RUNE = register(Identifier(MOD_ID, "gray_rune"), Rune(DyeColor.GRAY, settingsWithTab())) -val LIGHT_GRAY_RUNE = register(Identifier(MOD_ID, "light_gray_rune"), Rune(DyeColor.LIGHT_GRAY, settingsWithTab())) -val CYAN_RUNE = register(Identifier(MOD_ID, "cyan_rune"), Rune(DyeColor.CYAN, settingsWithTab())) -val BLUE_RUNE = register(Identifier(MOD_ID, "blue_rune"), Rune(DyeColor.BLUE, settingsWithTab())) -val PURPLE_RUNE = register(Identifier(MOD_ID, "purple_rune"), Rune(DyeColor.PURPLE, settingsWithTab())) -val GREEN_RUNE = register(Identifier(MOD_ID, "green_rune"), Rune(DyeColor.GREEN, settingsWithTab())) -val BROWN_RUNE = register(Identifier(MOD_ID, "brown_rune"), Rune(DyeColor.BROWN, settingsWithTab())) -val RED_RUNE = register(Identifier(MOD_ID, "red_rune"), Rune(DyeColor.RED, settingsWithTab())) -val BLACK_RUNE = register(Identifier(MOD_ID, "black_rune"), Rune(DyeColor.BLACK, settingsWithTab())) - -val SLIME_BOOTS = register(Identifier(MOD_ID, "slime_boots"), SlimeBoots(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) -val SLIME_SLING = register(Identifier(MOD_ID, "slime_sling"), SlimeSling(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) - -val TORCH_SLING = register(Identifier(MOD_ID, "torch_sling"), TorchSling(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) -val ESCAPE_ROPE = register(Identifier(MOD_ID, "escape_rope"), EscapeRope(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON))) - -val WOODEN_BUCKET = register(Identifier(MOD_ID, "wooden_bucket"), WoodenBucket.Empty(settingsWithTab().maxCount(16))) -val WATER_WOODEN_BUCKET = register(Identifier(MOD_ID, "water_wooden_bucket"), WoodenBucket.Water(settingsWithTab().maxCount(1))) - -val GLIDER_LEFT_WING = register(Identifier(MOD_ID, "glider_left_wing"), Item(settingsWithTab())) -val GLIDER_RIGHT_WING = register(Identifier(MOD_ID, "glider_right_wing"), Item(settingsWithTab())) - -val WHITE_GLIDER = register(Identifier(MOD_ID, "white_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val ORANGE_GLIDER = register(Identifier(MOD_ID, "orange_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val MAGENTA_GLIDER = register(Identifier(MOD_ID, "magenta_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val LIGHT_BLUE_GLIDER = register(Identifier(MOD_ID, "light_blue_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val YELLOW_GLIDER = register(Identifier(MOD_ID, "yellow_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val LIME_GLIDER = register(Identifier(MOD_ID, "lime_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val PINK_GLIDER = register(Identifier(MOD_ID, "pink_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val GRAY_GLIDER = register(Identifier(MOD_ID, "gray_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val LIGHT_GRAY_GLIDER = register(Identifier(MOD_ID, "light_gray_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val CYAN_GLIDER = register(Identifier(MOD_ID, "cyan_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val BLUE_GLIDER = register(Identifier(MOD_ID, "blue_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val PURPLE_GLIDER = register(Identifier(MOD_ID, "purple_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val GREEN_GLIDER = register(Identifier(MOD_ID, "green_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val BROWN_GLIDER = register(Identifier(MOD_ID, "brown_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val RED_GLIDER = register(Identifier(MOD_ID, "red_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) -val BLACK_GLIDER = register(Identifier(MOD_ID, "black_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) - -val VOID_BUCKET = register(Identifier(MOD_ID, "void_bucket"), VoidBucket(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) - -val POCKET_CRAFTING_TABLE = register(Identifier(MOD_ID, "pocket_crafting_table"), PocketCraftingTable(settingsWithTab().maxCount(1))) -val POCKET_TRASH_CAN = register(Identifier(MOD_ID, "pocket_trash_can"), PocketTrashCan(settingsWithTab().maxCount(1)), containers = listOf(ContainerInfo(PocketTrashCanScreenHandler::class, { PocketTrashCanScreen::class }))) - -val ENTANGLED_CHEST = register(Identifier(MOD_ID, "entangled_chest"), EntangledChestBlockItem(settingsWithTab())) -val ENTANGLED_TANK = register(Identifier(MOD_ID, "entangled_tank"), EntangledTankBlockItem(settingsWithTab())) -val ENTANGLED_BAG = register(Identifier(MOD_ID, "entangled_bag"), EntangledBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE)), { EntangledBagBakedModel() }, listOf(ContainerInfo(EntangledBagScreenHandler::class, { EntangledBagScreen::class }))) -val ENTANGLED_BUCKET = register(Identifier(MOD_ID, "entangled_bucket"), EntangledBucket(settingsWithTab().maxCount(1).rarity(Rarity.RARE)), { EntangledBucketBakedModel() }) -val COOLER = register(Identifier(MOD_ID, "cooler"), CoolerBlockItem(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)), containers = listOf(ContainerInfo(CoolerBlockItemScreenHandler::class, { CoolerBlockItemScreen::class }, identifier = Identifier(MOD_ID, "cooler_item")))) -val TANK = register(Identifier(MOD_ID, "tank"), TankBlockItem(settingsWithTab()), { TankBlockItemBakedModel() } ) - -val WHITE_SLEEPING_BAG = register(Identifier(MOD_ID, "white_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val ORANGE_SLEEPING_BAG = register(Identifier(MOD_ID, "orange_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val MAGENTA_SLEEPING_BAG = register(Identifier(MOD_ID, "magenta_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val LIGHT_BLUE_SLEEPING_BAG = register(Identifier(MOD_ID, "light_blue_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val YELLOW_SLEEPING_BAG = register(Identifier(MOD_ID, "yellow_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val LIME_SLEEPING_BAG = register(Identifier(MOD_ID, "lime_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val PINK_SLEEPING_BAG = register(Identifier(MOD_ID, "pink_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val GRAY_SLEEPING_BAG = register(Identifier(MOD_ID, "gray_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val LIGHT_GRAY_SLEEPING_BAG = register(Identifier(MOD_ID, "light_gray_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val CYAN_SLEEPING_BAG = register(Identifier(MOD_ID, "cyan_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val BLUE_SLEEPING_BAG = register(Identifier(MOD_ID, "sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val PURPLE_SLEEPING_BAG = register(Identifier(MOD_ID, "purple_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val GREEN_SLEEPING_BAG = register(Identifier(MOD_ID, "green_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val BROWN_SLEEPING_BAG = register(Identifier(MOD_ID, "brown_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val RED_SLEEPING_BAG = register(Identifier(MOD_ID, "red_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) -val BLACK_SLEEPING_BAG = register(Identifier(MOD_ID, "black_sleeping_bag"), SleepingBag(settingsWithTab().maxCount(1).rarity(Rarity.RARE))) - -private fun settingsWithTab() = Settings().group(CREATIVE_TAB) +val KIBE = register(Identifier(MOD_ID, "kibe"), Item(Settings().rarity(Rarity.COMMON).food(FoodComponent.Builder().hunger(6).saturationModifier(0.8F).meat().build()))) +val GOLDEN_KIBE = register(Identifier(MOD_ID, "golden_kibe"), Item(Settings().rarity(Rarity.UNCOMMON).food(FoodComponent.Builder().hunger(8).saturationModifier(1.2F).meat().build()))) +val CURSED_KIBE = register(Identifier(MOD_ID, "cursed_kibe"), Item(Settings().rarity(Rarity.UNCOMMON).food(FoodComponent.Builder().hunger(10).saturationModifier(1.2F).meat().build()))) +val DIAMOND_KIBE = register(Identifier(MOD_ID, "diamond_kibe"), Item(Settings().rarity(Rarity.RARE).food(FoodComponent.Builder().hunger(16).saturationModifier(1F).meat().build()))) + +val CURSED_DROPLETS = register(Identifier(MOD_ID, "cursed_droplets"), Item(Settings())) +val CURSED_SEEDS = register(Identifier(MOD_ID, "cursed_seeds"), CursedSeeds(Settings())) + +val MAGNET = register(Identifier(MOD_ID, "magnet"), Magnet.create(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) + +val DIAMOND_RING = register(Identifier(MOD_ID, "diamond_ring"), Item(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) +val ANGEL_RING = register(Identifier(MOD_ID, "angel_ring"), AbilityRing.create(Settings().maxCount(1).rarity(Rarity.EPIC), VanillaAbilities.ALLOW_FLYING)) +val MAGMA_RING = register(Identifier(MOD_ID, "magma_ring"), AbilityRing.create(Settings().maxCount(1).rarity(Rarity.RARE), INFINITE_FIRE_RESISTENCE)) +val WATER_RING = register(Identifier(MOD_ID, "water_ring"), AbilityRing.create(Settings().maxCount(1).rarity(Rarity.RARE), INFINITE_WATER_BREATHING)) +val LIGHT_RING = register(Identifier(MOD_ID, "light_ring"), LightRing(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) + +val GOLDEN_LASSO = register(Identifier(MOD_ID, "golden_lasso"), Lasso.GoldenLasso(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) +val CURSED_LASSO = register(Identifier(MOD_ID, "cursed_lasso"), Lasso.CursedLasso(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) +val DIAMOND_LASSO = register(Identifier(MOD_ID, "diamond_lasso"), Lasso.DiamondLasso(Settings().maxCount(1).rarity(Rarity.RARE))) + +val WHITE_RUNE = register(Identifier(MOD_ID, "white_rune"), Rune(DyeColor.WHITE, Settings())) +val ORANGE_RUNE = register(Identifier(MOD_ID, "orange_rune"), Rune(DyeColor.ORANGE, Settings())) +val MAGENTA_RUNE = register(Identifier(MOD_ID, "magenta_rune"), Rune(DyeColor.MAGENTA, Settings())) +val LIGHT_BLUE_RUNE = register(Identifier(MOD_ID, "light_blue_rune"), Rune(DyeColor.LIGHT_BLUE, Settings())) +val YELLOW_RUNE = register(Identifier(MOD_ID, "yellow_rune"), Rune(DyeColor.YELLOW, Settings())) +val LIME_RUNE = register(Identifier(MOD_ID, "lime_rune"), Rune(DyeColor.LIME, Settings())) +val PINK_RUNE = register(Identifier(MOD_ID, "pink_rune"), Rune(DyeColor.PINK, Settings())) +val GRAY_RUNE = register(Identifier(MOD_ID, "gray_rune"), Rune(DyeColor.GRAY, Settings())) +val LIGHT_GRAY_RUNE = register(Identifier(MOD_ID, "light_gray_rune"), Rune(DyeColor.LIGHT_GRAY, Settings())) +val CYAN_RUNE = register(Identifier(MOD_ID, "cyan_rune"), Rune(DyeColor.CYAN, Settings())) +val BLUE_RUNE = register(Identifier(MOD_ID, "blue_rune"), Rune(DyeColor.BLUE, Settings())) +val PURPLE_RUNE = register(Identifier(MOD_ID, "purple_rune"), Rune(DyeColor.PURPLE, Settings())) +val GREEN_RUNE = register(Identifier(MOD_ID, "green_rune"), Rune(DyeColor.GREEN, Settings())) +val BROWN_RUNE = register(Identifier(MOD_ID, "brown_rune"), Rune(DyeColor.BROWN, Settings())) +val RED_RUNE = register(Identifier(MOD_ID, "red_rune"), Rune(DyeColor.RED, Settings())) +val BLACK_RUNE = register(Identifier(MOD_ID, "black_rune"), Rune(DyeColor.BLACK, Settings())) + +val SLIME_BOOTS = register(Identifier(MOD_ID, "slime_boots"), SlimeBoots(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) +val SLIME_SLING = register(Identifier(MOD_ID, "slime_sling"), SlimeSling(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) + +val TORCH_SLING = register(Identifier(MOD_ID, "torch_sling"), TorchSling(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) +val ESCAPE_ROPE = register(Identifier(MOD_ID, "escape_rope"), EscapeRope(Settings().maxCount(1).rarity(Rarity.UNCOMMON))) + +val WOODEN_BUCKET = register(Identifier(MOD_ID, "wooden_bucket"), WoodenBucket.Empty(Settings().maxCount(16))) +val WATER_WOODEN_BUCKET = register(Identifier(MOD_ID, "water_wooden_bucket"), WoodenBucket.Water(Settings().maxCount(1))) + +val GLIDER_LEFT_WING = register(Identifier(MOD_ID, "glider_left_wing"), Item(Settings())) +val GLIDER_RIGHT_WING = register(Identifier(MOD_ID, "glider_right_wing"), Item(Settings())) + +val WHITE_GLIDER = register(Identifier(MOD_ID, "white_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val ORANGE_GLIDER = register(Identifier(MOD_ID, "orange_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val MAGENTA_GLIDER = register(Identifier(MOD_ID, "magenta_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val LIGHT_BLUE_GLIDER = register(Identifier(MOD_ID, "light_blue_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val YELLOW_GLIDER = register(Identifier(MOD_ID, "yellow_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val LIME_GLIDER = register(Identifier(MOD_ID, "lime_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val PINK_GLIDER = register(Identifier(MOD_ID, "pink_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val GRAY_GLIDER = register(Identifier(MOD_ID, "gray_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val LIGHT_GRAY_GLIDER = register(Identifier(MOD_ID, "light_gray_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val CYAN_GLIDER = register(Identifier(MOD_ID, "cyan_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val BLUE_GLIDER = register(Identifier(MOD_ID, "blue_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val PURPLE_GLIDER = register(Identifier(MOD_ID, "purple_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val GREEN_GLIDER = register(Identifier(MOD_ID, "green_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val BROWN_GLIDER = register(Identifier(MOD_ID, "brown_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val RED_GLIDER = register(Identifier(MOD_ID, "red_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) +val BLACK_GLIDER = register(Identifier(MOD_ID, "black_glider"), Glider(Settings().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability))) + +val VOID_BUCKET = register(Identifier(MOD_ID, "void_bucket"), VoidBucket(Settings().maxCount(1).rarity(Rarity.RARE))) + +val POCKET_CRAFTING_TABLE = register(Identifier(MOD_ID, "pocket_crafting_table"), PocketCraftingTable(Settings().maxCount(1))) +val POCKET_TRASH_CAN = register(Identifier(MOD_ID, "pocket_trash_can"), PocketTrashCan(Settings().maxCount(1)), containers = listOf(ContainerInfo(PocketTrashCanScreenHandler::class, { PocketTrashCanScreen::class }))) + +val ENTANGLED_CHEST = register(Identifier(MOD_ID, "entangled_chest"), EntangledChestBlockItem(Settings())) +val ENTANGLED_TANK = register(Identifier(MOD_ID, "entangled_tank"), EntangledTankBlockItem(Settings())) +val ENTANGLED_BAG = register(Identifier(MOD_ID, "entangled_bag"), EntangledBag(Settings().maxCount(1).rarity(Rarity.RARE)), { EntangledBagBakedModel() }, listOf(ContainerInfo(EntangledBagScreenHandler::class, { EntangledBagScreen::class }))) +val ENTANGLED_BUCKET = register(Identifier(MOD_ID, "entangled_bucket"), EntangledBucket(Settings().maxCount(1).rarity(Rarity.RARE)), { EntangledBucketBakedModel() }) +val COOLER = register(Identifier(MOD_ID, "cooler"), CoolerBlockItem(Settings().maxCount(1).rarity(Rarity.UNCOMMON)), containers = listOf(ContainerInfo(CoolerBlockItemScreenHandler::class, { CoolerBlockItemScreen::class }, identifier = Identifier(MOD_ID, "cooler_item")))) +val TANK = register(Identifier(MOD_ID, "tank"), TankBlockItem(Settings()), { TankBlockItemBakedModel() } ) + +val WHITE_SLEEPING_BAG = register(Identifier(MOD_ID, "white_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val ORANGE_SLEEPING_BAG = register(Identifier(MOD_ID, "orange_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val MAGENTA_SLEEPING_BAG = register(Identifier(MOD_ID, "magenta_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val LIGHT_BLUE_SLEEPING_BAG = register(Identifier(MOD_ID, "light_blue_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val YELLOW_SLEEPING_BAG = register(Identifier(MOD_ID, "yellow_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val LIME_SLEEPING_BAG = register(Identifier(MOD_ID, "lime_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val PINK_SLEEPING_BAG = register(Identifier(MOD_ID, "pink_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val GRAY_SLEEPING_BAG = register(Identifier(MOD_ID, "gray_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val LIGHT_GRAY_SLEEPING_BAG = register(Identifier(MOD_ID, "light_gray_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val CYAN_SLEEPING_BAG = register(Identifier(MOD_ID, "cyan_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val BLUE_SLEEPING_BAG = register(Identifier(MOD_ID, "sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val PURPLE_SLEEPING_BAG = register(Identifier(MOD_ID, "purple_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val GREEN_SLEEPING_BAG = register(Identifier(MOD_ID, "green_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val BROWN_SLEEPING_BAG = register(Identifier(MOD_ID, "brown_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val RED_SLEEPING_BAG = register(Identifier(MOD_ID, "red_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) +val BLACK_SLEEPING_BAG = register(Identifier(MOD_ID, "black_sleeping_bag"), SleepingBag(Settings().maxCount(1).rarity(Rarity.RARE))) fun register(identifier: Identifier, item: Item, bakedModel: (() -> BakedModel)? = null, containers: List> = listOf()): Item { val info = ItemInfo(identifier, item, bakedModel, containers) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/cooler/CoolerBlockItemScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/cooler/CoolerBlockItemScreen.kt index 5dff076f..3565dbed 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/cooler/CoolerBlockItemScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/cooler/CoolerBlockItemScreen.kt @@ -1,6 +1,7 @@ package io.github.lucaargolo.kibe.items.cooler import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -18,20 +19,19 @@ class CoolerBlockItemScreen(handler: CoolerBlockItemScreenHandler, inventory: Pl y = height/2-backgroundHeight/2 } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - drawCenteredText(matrices, textRenderer, title.string,backgroundWidth/2, 6, 0xFFFFFF) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 4210752) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawCenteredTextWithShadow(textRenderer, title.string,backgroundWidth/2, 6, 0xFFFFFF) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 4210752, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, x, y, 0, 0, 176, 131) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, x, y, 0, 0, 176, 131) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/cooler/CoolerBlockItemScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/cooler/CoolerBlockItemScreenHandler.kt index 4c0c51a6..57949c68 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/cooler/CoolerBlockItemScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/cooler/CoolerBlockItemScreenHandler.kt @@ -72,7 +72,7 @@ class CoolerBlockItemScreenHandler(syncId: Int, val playerInventory: PlayerInven } } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { if(hand == Hand.MAIN_HAND && invSlot in 0..slots.size && getSlot(invSlot).stack == playerInventory.mainHandStack) return ItemStack.EMPTY var itemStack = ItemStack.EMPTY diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbag/EntangledBagScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbag/EntangledBagScreen.kt index 4887ff48..0b57c80c 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbag/EntangledBagScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbag/EntangledBagScreen.kt @@ -2,6 +2,7 @@ package io.github.lucaargolo.kibe.items.entangledbag import com.mojang.blaze3d.systems.RenderSystem import io.github.lucaargolo.kibe.items.miscellaneous.Rune +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -23,28 +24,27 @@ class EntangledBagScreen(screenHandler: EntangledBagScreenHandler, inventory: Pl startY = height/2-backgroundHeight/2 } - override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - drawRunes() - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + drawRunes(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - private fun drawRunes() { + private fun drawRunes(context: DrawContext) { (1..8).forEach { val color = DyeColor.byName(handler.tag.getString("rune$it"), DyeColor.WHITE) ?: DyeColor.WHITE - itemRenderer.renderGuiItemIcon(ItemStack(Rune.getRuneByColor(color)), startX+87+(it-1)*10, startY+2) + context.drawItem(ItemStack(Rune.getRuneByColor(color)), startX+87+(it-1)*10, startY+2) } } - override fun drawForeground(matrices: MatrixStack, mouseX: Int, mouseY: Int) { - textRenderer.draw(matrices, title, 8.0f, 6.0f, 0xFFFFFF) - textRenderer.draw(matrices, playerInventoryTitle, 8.0f, (backgroundHeight - 96 + 4).toFloat(), 0xFFFFFF) + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { + context.drawText(textRenderer, title, 8, 6, 0xFFFFFF, false) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 0xFFFFFF, false) } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, startX, startY, 0, 0, 176, 166) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, startX, startY, 0, 0, 176, 166) } fun hasSameColors(map: MutableMap): Boolean { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbag/EntangledBagScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbag/EntangledBagScreenHandler.kt index ccd9be83..c66551c7 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbag/EntangledBagScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbag/EntangledBagScreenHandler.kt @@ -109,7 +109,7 @@ class EntangledBagScreenHandler(syncId: Int, playerInventory: PlayerInventory, @ return true } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbucket/EntangledBucket.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbucket/EntangledBucket.kt index 026a0575..3fd9811e 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbucket/EntangledBucket.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledbucket/EntangledBucket.kt @@ -7,9 +7,10 @@ import io.github.lucaargolo.kibe.blocks.entangledtank.EntangledTankEntity import io.github.lucaargolo.kibe.blocks.entangledtank.EntangledTankState import io.github.lucaargolo.kibe.items.ENTANGLED_BUCKET import io.github.lucaargolo.kibe.mixin.BucketItemAccessor -import io.github.lucaargolo.kibe.utils.FakePlayerEntity +import io.github.lucaargolo.kibe.utils.FakeClientPlayerEntity import io.github.lucaargolo.kibe.utils.getMb import io.github.lucaargolo.kibe.utils.writeTank +import net.fabricmc.fabric.api.entity.FakePlayer import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage @@ -27,13 +28,13 @@ import net.minecraft.fluid.Fluid import net.minecraft.fluid.Fluids import net.minecraft.item.* import net.minecraft.nbt.NbtCompound +import net.minecraft.registry.tag.FluidTags import net.minecraft.server.network.ServerPlayerEntity import net.minecraft.server.world.ServerWorld import net.minecraft.sound.SoundCategory import net.minecraft.sound.SoundEvents import net.minecraft.stat.Stats import net.minecraft.state.property.Properties -import net.minecraft.tag.FluidTags import net.minecraft.text.Text import net.minecraft.text.TextColor import net.minecraft.util.* @@ -141,7 +142,7 @@ class EntangledBucket(settings: Settings): Item(settings) { val state = serverWorld.server.overworld.persistentStateManager.getOrCreate({EntangledTankState.createFromTag(it, serverWorld, key)}, { EntangledTankState(serverWorld, key) }, key) val stateInv = state.getOrCreateInventory(colorCode) Transaction.openOuter().also { - val containedFluidStorage = ContainerItemContext.withInitial(drainedFluid).find(FluidStorage.ITEM) + val containedFluidStorage = ContainerItemContext.withConstant(drainedFluid).find(FluidStorage.ITEM) StorageUtil.findExtractableContent(containedFluidStorage, it)?.let { extractableContent -> stateInv.insert(extractableContent.resource, extractableContent.amount, it) } @@ -185,7 +186,7 @@ class EntangledBucket(settings: Settings): Item(settings) { } private fun fakeInteraction(bucketItem: BucketItem, world: World, pos: BlockPos, blockHitResult: BlockHitResult): Fluid? { - val fakePlayer = FakePlayerEntity(world) + val fakePlayer = if(world is ServerWorld) FakePlayer.get(world) else FakeClientPlayerEntity(world) fakePlayer.setStackInHand(Hand.MAIN_HAND, ItemStack(bucketItem)) val blockState = world.getBlockState(pos) val block = blockState.block diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledchest/EntangledChestBlockItemDynamicRenderer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledchest/EntangledChestBlockItemDynamicRenderer.kt index bdb48e6d..46130fc0 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledchest/EntangledChestBlockItemDynamicRenderer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledchest/EntangledChestBlockItemDynamicRenderer.kt @@ -9,13 +9,14 @@ import net.minecraft.client.MinecraftClient import net.minecraft.client.render.VertexConsumerProvider import net.minecraft.client.render.block.entity.BlockEntityRendererFactory import net.minecraft.client.render.model.json.ModelTransformation +import net.minecraft.client.render.model.json.ModelTransformationMode import net.minecraft.client.util.math.MatrixStack import net.minecraft.item.ItemStack import net.minecraft.util.math.BlockPos class EntangledChestBlockItemDynamicRenderer: BuiltinItemRendererRegistry.DynamicItemRenderer { - override fun render(stack: ItemStack, mode: ModelTransformation.Mode, matrixStack: MatrixStack, vertexConsumerProvider: VertexConsumerProvider, lightmap: Int, overlay: Int) { + override fun render(stack: ItemStack, mode: ModelTransformationMode, matrixStack: MatrixStack, vertexConsumerProvider: VertexConsumerProvider, lightmap: Int, overlay: Int) { val dummyChest = EntangledChestEntity(ENTANGLED_CHEST as EntangledChest, BlockPos.ORIGIN, ENTANGLED_CHEST.defaultState) stack.nbt?.getCompound("BlockEntityTag")?.let { dummyChest.readClientNbt(it) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledtank/EntangledTankBlockItemDynamicRenderer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledtank/EntangledTankBlockItemDynamicRenderer.kt index 7f047113..26bdaf0a 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledtank/EntangledTankBlockItemDynamicRenderer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/entangledtank/EntangledTankBlockItemDynamicRenderer.kt @@ -17,6 +17,7 @@ import net.minecraft.client.render.RenderLayer import net.minecraft.client.render.VertexConsumerProvider import net.minecraft.client.render.block.entity.BlockEntityRendererFactory import net.minecraft.client.render.model.json.ModelTransformation +import net.minecraft.client.render.model.json.ModelTransformationMode import net.minecraft.client.util.ModelIdentifier import net.minecraft.client.util.math.MatrixStack import net.minecraft.item.ItemStack @@ -28,7 +29,7 @@ import net.minecraft.util.math.random.Random class EntangledTankBlockItemDynamicRenderer: BuiltinItemRendererRegistry.DynamicItemRenderer { - override fun render(stack: ItemStack, mode: ModelTransformation.Mode, matrixStack: MatrixStack, vertexConsumerProvider: VertexConsumerProvider, lightmap: Int, overlay: Int) { + override fun render(stack: ItemStack, mode: ModelTransformationMode, matrixStack: MatrixStack, vertexConsumerProvider: VertexConsumerProvider, lightmap: Int, overlay: Int) { val tag = if(stack.hasNbt() && stack.nbt!!.contains("BlockEntityTag") ) { stack.orCreateNbt.get("BlockEntityTag") as NbtCompound }else{ diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/GliderDynamicRenderer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/GliderDynamicRenderer.kt index e9c5d1a8..c0f7f9bf 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/GliderDynamicRenderer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/GliderDynamicRenderer.kt @@ -8,6 +8,7 @@ import net.minecraft.client.render.RenderLayer import net.minecraft.client.render.VertexConsumerProvider import net.minecraft.client.render.model.json.JsonUnbakedModel import net.minecraft.client.render.model.json.ModelTransformation +import net.minecraft.client.render.model.json.ModelTransformationMode import net.minecraft.client.util.ModelIdentifier import net.minecraft.client.util.math.MatrixStack import net.minecraft.item.ItemStack @@ -45,16 +46,16 @@ class GliderDynamicRenderer: BuiltinItemRendererRegistry.DynamicItemRenderer { loadTransformFromJson(Identifier("minecraft:models/item/generated")) } - override fun render(stack: ItemStack, mode: ModelTransformation.Mode, matrixStack: MatrixStack, vertexConsumerProvider: VertexConsumerProvider, lightmap: Int, overlay: Int) { + override fun render(stack: ItemStack, mode: ModelTransformationMode, matrixStack: MatrixStack, vertexConsumerProvider: VertexConsumerProvider, lightmap: Int, overlay: Int) { val isEnabled = Glider.isEnabled(stack) - val isGui = (mode == ModelTransformation.Mode.GUI || mode == ModelTransformation.Mode.FIXED) - val force3d = (mode == ModelTransformation.Mode.GROUND || mode == ModelTransformation.Mode.HEAD || mode == ModelTransformation.Mode.NONE) + val isGui = (mode == ModelTransformationMode.GUI || mode == ModelTransformationMode.FIXED) + val force3d = (mode == ModelTransformationMode.GROUND || mode == ModelTransformationMode.HEAD || mode == ModelTransformationMode.NONE) matrixStack.pop() matrixStack.push() - val leftHanded = (mode == ModelTransformation.Mode.FIRST_PERSON_LEFT_HAND || mode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND) + val leftHanded = (mode == ModelTransformationMode.FIRST_PERSON_LEFT_HAND || mode == ModelTransformationMode.THIRD_PERSON_LEFT_HAND) if(force3d || (isEnabled && !isGui)) { deployedTransform?.getTransformation(mode)?.apply(leftHanded, matrixStack) }else{ diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/Lasso.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/Lasso.kt index 8ca08063..d65e680c 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/Lasso.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/Lasso.kt @@ -19,7 +19,8 @@ import net.minecraft.text.Text import net.minecraft.util.ActionResult import net.minecraft.util.Hand import net.minecraft.util.math.Direction -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries import net.minecraft.world.World abstract class Lasso(settings: Settings): Item(settings) { @@ -105,7 +106,7 @@ abstract class Lasso(settings: Settings): Item(settings) { class CursedLasso(settings: Settings): Lasso(settings) { override fun addToTag(tag: NbtCompound): NbtCompound { val activeEffect = NbtCompound() - activeEffect.putInt("Id", Registry.STATUS_EFFECT.getRawId(CURSED_EFFECT)) + activeEffect.putInt("Id", Registries.STATUS_EFFECT.getRawId(CURSED_EFFECT)) activeEffect.putInt("Amplifier", 1) activeEffect.putInt("Duration", 999999) val activeEffects = if(tag.contains("ActiveEffects")) tag.get("ActiveEffects") as NbtList else NbtList() diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/Magnet.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/Magnet.kt index 9570a0e7..4f2796fd 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/Magnet.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/Magnet.kt @@ -9,11 +9,11 @@ import net.minecraft.entity.ExperienceOrbEntity import net.minecraft.entity.ItemEntity import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.ItemStack -import net.minecraft.tag.TagKey import net.minecraft.util.Identifier import net.minecraft.util.math.Box import net.minecraft.util.math.Vec3d -import net.minecraft.util.registry.Registry +import net.minecraft.registry.RegistryKeys +import net.minecraft.registry.tag.TagKey import net.minecraft.world.World open class Magnet(settings: Settings) : BooleanItem(settings) { @@ -36,7 +36,7 @@ open class Magnet(settings: Settings) : BooleanItem(settings) { companion object { - val MAGNET_INHIBITOR_TAG = TagKey.of(Registry.BLOCK_KEY, Identifier(MOD_ID, "magnet_inhibitor")) + val MAGNET_INHIBITOR_TAG = TagKey.of(RegistryKeys.BLOCK, Identifier(MOD_ID, "magnet_inhibitor")) fun create(settings: Settings): Magnet = if (TRINKET) TrinketMagnet(settings) else Magnet(settings) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/PocketCraftingTable.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/PocketCraftingTable.kt index a1691042..69a1b37e 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/PocketCraftingTable.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/PocketCraftingTable.kt @@ -24,8 +24,8 @@ class PocketCraftingTable(settings: Settings): Item(settings) { updateResult(this, world, (this as CraftingTableContainerMixin).player, (this as CraftingTableContainerMixin).input, (this as CraftingTableContainerMixin).result) } - override fun close(player: PlayerEntity?) { - super.close(player) + override fun onClosed(player: PlayerEntity?) { + super.onClosed(player) dropInventory(player, (this as CraftingTableContainerMixin).input) } } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/SleepingBag.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/SleepingBag.kt index 771c095a..0f99280f 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/SleepingBag.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/SleepingBag.kt @@ -41,7 +41,7 @@ class SleepingBag(settings: Settings): Item(settings) { val rayTraceContext = player.raycast(4.5, 1.0f, false) val sleepingPos = rayTraceContext.run { if(this.type == HitResult.Type.BLOCK) { - return@run BlockPos(this.pos) + return@run BlockPos.ofFloored(this.pos) }else if(player.isOnGround){ return@run player.blockPos }else{ diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/SlimeBoots.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/SlimeBoots.kt index e0f030e6..cf825b45 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/SlimeBoots.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/SlimeBoots.kt @@ -13,7 +13,7 @@ class SlimeBoots(settings: Settings) : ArmorItem(object : ArmorMaterial { override fun getKnockbackResistance() = 0F override fun getEquipSound() = SoundEvents.ITEM_ARMOR_EQUIP_GENERIC override fun getName() = "slime" - override fun getDurability(slot: EquipmentSlot) = 128 + override fun getDurability(type: Type) = 128 override fun getEnchantability() = 9 - override fun getProtectionAmount(slot: EquipmentSlot?) = 2 -}, EquipmentSlot.FEET, settings) \ No newline at end of file + override fun getProtection(type: Type) = 2 +}, Type.BOOTS, settings) \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/VoidBucket.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/VoidBucket.kt index fcdbc4a7..eea31fff 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/VoidBucket.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/VoidBucket.kt @@ -1,7 +1,8 @@ package io.github.lucaargolo.kibe.items.miscellaneous import io.github.lucaargolo.kibe.items.VOID_BUCKET -import io.github.lucaargolo.kibe.utils.FakePlayerEntity +import io.github.lucaargolo.kibe.utils.FakeClientPlayerEntity +import net.fabricmc.fabric.api.entity.FakePlayer import net.minecraft.advancement.criterion.Criteria import net.minecraft.block.FluidDrainable import net.minecraft.entity.player.PlayerEntity @@ -10,6 +11,7 @@ import net.minecraft.item.Item import net.minecraft.item.ItemStack import net.minecraft.item.Items import net.minecraft.server.network.ServerPlayerEntity +import net.minecraft.server.world.ServerWorld import net.minecraft.sound.SoundEvents import net.minecraft.stat.Stats import net.minecraft.util.Hand @@ -57,7 +59,7 @@ class VoidBucket(settings: Settings): Item(settings) { @Suppress("DEPRECATION") private fun fakeInteraction(world: World, pos: BlockPos, blockHitResult: BlockHitResult): Boolean { - val fakePlayer = FakePlayerEntity(world) + val fakePlayer = if(world is ServerWorld) FakePlayer.get(world) else FakeClientPlayerEntity(world) fakePlayer.setStackInHand(Hand.MAIN_HAND, ItemStack(Items.BUCKET)) val blockState = world.getBlockState(pos) val block = blockState.block diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/trashcan/PocketTrashCanScreen.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/trashcan/PocketTrashCanScreen.kt index d1f9ab4f..c9898ebd 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/trashcan/PocketTrashCanScreen.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/trashcan/PocketTrashCanScreen.kt @@ -2,6 +2,7 @@ package io.github.lucaargolo.kibe.items.trashcan import com.mojang.blaze3d.systems.RenderSystem import joptsimple.internal.Strings +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -22,23 +23,22 @@ class PocketTrashCanScreen(screenHandler: PocketTrashCanScreenHandler, inventory } - override fun render(matrices: MatrixStack?, mouseX: Int, mouseY: Int, delta: Float) { - this.renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + this.renderBackground(context) + super.render(context, mouseX, mouseY, delta) + drawMouseoverTooltip(context, mouseX, mouseY) } - override fun drawBackground(matrices: MatrixStack?, delta: Float, mouseX: Int, mouseY: Int) { - RenderSystem.setShaderTexture(0, texture) - drawTexture(matrices, startX, startY, 0, 0, 176, 166) + override fun drawBackground(context: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { + context.drawTexture(texture, startX, startY, 0, 0, 176, 166) } - override fun drawForeground(matrices: MatrixStack?, mouseX: Int, mouseY: Int) { + override fun drawForeground(context: DrawContext, mouseX: Int, mouseY: Int) { val stringArray = title.string.split(" ").toMutableList() - drawCenteredText(matrices, textRenderer, stringArray[0],backgroundWidth/2, 6, 0xFFFFFF) + context.drawCenteredTextWithShadow(textRenderer, stringArray[0],backgroundWidth/2, 6, 0xFFFFFF) stringArray.removeAt(0) - drawCenteredText(matrices, textRenderer, Strings.join(stringArray, " "),backgroundWidth/2, 17, 0xFFFFFF) - textRenderer.draw(matrices, playerInventoryTitle, 8f, backgroundHeight - 96 + 4f, 0xFFFFFF) + context.drawCenteredTextWithShadow(textRenderer, Strings.join(stringArray, " "),backgroundWidth/2, 17, 0xFFFFFF) + context.drawText(textRenderer, playerInventoryTitle, 8, backgroundHeight - 96 + 4, 0xFFFFFF, false) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/trashcan/PocketTrashCanScreenHandler.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/trashcan/PocketTrashCanScreenHandler.kt index 55547348..374e09d3 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/trashcan/PocketTrashCanScreenHandler.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/trashcan/PocketTrashCanScreenHandler.kt @@ -77,7 +77,7 @@ class PocketTrashCanScreenHandler(syncId: Int, playerInventory: PlayerInventory, return true } - override fun transferSlot(player: PlayerEntity?, invSlot: Int): ItemStack? { + override fun quickMove(player: PlayerEntity?, invSlot: Int): ItemStack? { var itemStack = ItemStack.EMPTY val slot = this.slots[invSlot] if (slot.hasStack()) { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/recipes/RecipeSerializers.kt b/src/main/kotlin/io/github/lucaargolo/kibe/recipes/RecipeSerializers.kt index 9d72acc9..d5c0c438 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/recipes/RecipeSerializers.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/recipes/RecipeSerializers.kt @@ -5,13 +5,14 @@ import io.github.lucaargolo.kibe.recipes.vacuum.VacuumHopperRecipe import io.github.lucaargolo.kibe.recipes.vacuum.VacuumHopperRecipeSerializer import net.minecraft.recipe.Recipe import net.minecraft.recipe.RecipeSerializer -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries lateinit var VACUUM_HOPPER_RECIPE_SERIALIZER: RecipeSerializer @Suppress("SameParameterValue") private fun , T: Recipe<*>>register(id: String, serializer: S): S { - return Registry.register(Registry.RECIPE_SERIALIZER, "$MOD_ID:$id", serializer) + return Registry.register(Registries.RECIPE_SERIALIZER, "$MOD_ID:$id", serializer) } fun initRecipeSerializers() { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/recipes/RecipeTypes.kt b/src/main/kotlin/io/github/lucaargolo/kibe/recipes/RecipeTypes.kt index 578ff1e3..329446b9 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/recipes/RecipeTypes.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/recipes/RecipeTypes.kt @@ -4,13 +4,14 @@ import io.github.lucaargolo.kibe.MOD_ID import io.github.lucaargolo.kibe.recipes.vacuum.VacuumHopperRecipe import net.minecraft.recipe.Recipe import net.minecraft.recipe.RecipeType -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries lateinit var VACUUM_HOPPER_RECIPE_TYPE: RecipeType @Suppress("SameParameterValue") private fun > register(id: String): RecipeType { - return Registry.register(Registry.RECIPE_TYPE, "$MOD_ID:$id", object : RecipeType { override fun toString() = "$MOD_ID:$id" }) + return Registry.register(Registries.RECIPE_TYPE, "$MOD_ID:$id", object : RecipeType { override fun toString() = "$MOD_ID:$id" }) } fun initRecipeTypes() { diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/recipes/vacuum/VacuumHopperRecipe.kt b/src/main/kotlin/io/github/lucaargolo/kibe/recipes/vacuum/VacuumHopperRecipe.kt index 5642cd1b..6e622a3f 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/recipes/vacuum/VacuumHopperRecipe.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/recipes/vacuum/VacuumHopperRecipe.kt @@ -9,23 +9,24 @@ import net.minecraft.item.ItemStack import net.minecraft.item.Items import net.minecraft.recipe.Ingredient import net.minecraft.recipe.Recipe +import net.minecraft.registry.DynamicRegistryManager import net.minecraft.util.Identifier import net.minecraft.util.collection.DefaultedList import net.minecraft.world.World -class VacuumHopperRecipe(private val id: Identifier, val ticks: Int, val xpInput: Long, val input: Ingredient, private val output: ItemStack) : Recipe { +class VacuumHopperRecipe(private val id: Identifier, val ticks: Int, val xpInput: Long, val input: Ingredient, val output: ItemStack) : Recipe { override fun getId() = id override fun matches(inv: VacuumHopperEntity, world: World): Boolean { val inputStack = inv.getStack(9) val hasSpace = inv.getStack(10).let { - it.isEmpty || (ItemStack.areItemsEqual(it, output) && ItemStack.areNbtEqual(it, output) && it.count < it.maxCount) + it.isEmpty || (ItemStack.canCombine(it, output) && it.count < it.maxCount) } return input.test(inputStack) && inv.tank.amount >= xpInput * 81 && hasSpace } - override fun craft(inv: VacuumHopperEntity): ItemStack { + override fun craft(inv: VacuumHopperEntity, registryManager: DynamicRegistryManager): ItemStack { inv.getStack(9).decrement(1) inv.tank.amount -= xpInput * 81 if(inv.getStack(10).isEmpty) { @@ -43,7 +44,7 @@ class VacuumHopperRecipe(private val id: Identifier, val ticks: Int, val xpInput override fun getSerializer() = VACUUM_HOPPER_RECIPE_SERIALIZER - override fun getOutput(): ItemStack = output + override fun getOutput(registryManager: DynamicRegistryManager): ItemStack = output override fun createIcon(): ItemStack = Items.EXPERIENCE_BOTTLE.defaultStack diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/recipes/vacuum/VacuumHopperRecipeSerializer.kt b/src/main/kotlin/io/github/lucaargolo/kibe/recipes/vacuum/VacuumHopperRecipeSerializer.kt index dd2dcc59..f4b0eadc 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/recipes/vacuum/VacuumHopperRecipeSerializer.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/recipes/vacuum/VacuumHopperRecipeSerializer.kt @@ -6,7 +6,8 @@ import net.minecraft.network.PacketByteBuf import net.minecraft.recipe.Ingredient import net.minecraft.recipe.RecipeSerializer import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registry +import net.minecraft.registry.Registries class VacuumHopperRecipeSerializer : RecipeSerializer { @@ -22,7 +23,7 @@ class VacuumHopperRecipeSerializer : RecipeSerializer { val xpInput = json.getAsJsonPrimitive("xp").asLong val input = Ingredient.fromJson(json.get("input")) val output: ItemStack = json.getAsJsonPrimitive("output").asString.let { itemId -> - val item = Registry.ITEM.getOrEmpty(Identifier(itemId)) + val item = Registries.ITEM.getOrEmpty(Identifier(itemId)) if(item.isPresent) { ItemStack(item.get()) } else null diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/utils/CreativeTab.kt b/src/main/kotlin/io/github/lucaargolo/kibe/utils/CreativeTab.kt index ee086142..7600d58b 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/utils/CreativeTab.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/utils/CreativeTab.kt @@ -11,27 +11,26 @@ import io.github.lucaargolo.kibe.blocks.TANK import io.github.lucaargolo.kibe.fluids.LIQUID_XP import io.github.lucaargolo.kibe.fluids.getFluidBucket import io.github.lucaargolo.kibe.items.* -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants import net.minecraft.block.Block import net.minecraft.fluid.Fluid import net.minecraft.fluid.Fluids import net.minecraft.item.Item -import net.minecraft.item.ItemGroup import net.minecraft.item.ItemStack import net.minecraft.nbt.NbtCompound +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry +import net.minecraft.text.Text import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry -import java.util.function.Consumer - -var CREATIVE_TAB: ItemGroup? = null fun initCreativeTab() { - CREATIVE_TAB = FabricItemGroupBuilder - .create(Identifier(MOD_ID, "creative_tab")) + Registry.register(Registries.ITEM_GROUP, Identifier(MOD_ID, "creative_tab"), FabricItemGroup.builder() .icon { ItemStack(KIBE) } - .appendItems(Consumer { it.addAll(appendItems()) }) + .displayName(Text.translatable("itemGroup.kibe.creative_tab")) + .entries { _, entries -> entries.addAll(appendItems()) } .build() + ) } private fun appendItems(): List { @@ -63,7 +62,7 @@ private fun appendItems(): List { else -> ItemStack.EMPTY }) } - Registry.FLUID.indexedEntries.forEach { fluidEntry -> + Registries.FLUID.indexedEntries.forEach { fluidEntry -> val fluid = fluidEntry.value() val fluidKey = fluidEntry.key.get() val itemStack = ItemStack(TANK) diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/utils/FakePlayerEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/utils/FakeClientPlayerEntity.kt similarity index 78% rename from src/main/kotlin/io/github/lucaargolo/kibe/utils/FakePlayerEntity.kt rename to src/main/kotlin/io/github/lucaargolo/kibe/utils/FakeClientPlayerEntity.kt index 69eff687..76ecfdde 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/utils/FakePlayerEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/utils/FakeClientPlayerEntity.kt @@ -7,7 +7,7 @@ import net.minecraft.entity.player.PlayerEntity import net.minecraft.util.math.BlockPos import net.minecraft.world.World -class FakePlayerEntity(world: World): PlayerEntity(world, BlockPos.ORIGIN, 0f, GameProfile(FAKE_PLAYER_UUID, "fake"), null) { +class FakeClientPlayerEntity(world: World): PlayerEntity(world, BlockPos.ORIGIN, 0f, GameProfile(FAKE_PLAYER_UUID, "fake")) { override fun isSpectator() = true override fun isCreative() = true diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/utils/FluidUtil.kt b/src/main/kotlin/io/github/lucaargolo/kibe/utils/FluidUtil.kt index 1479c701..3831cdf8 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/utils/FluidUtil.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/utils/FluidUtil.kt @@ -2,54 +2,16 @@ package io.github.lucaargolo.kibe.utils -import io.github.lucaargolo.kibe.LOGGER import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorageUtil import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant import net.fabricmc.fabric.api.transfer.v1.storage.Storage import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage import net.minecraft.entity.player.PlayerEntity -import net.minecraft.fluid.Fluids import net.minecraft.nbt.NbtCompound -import net.minecraft.nbt.NbtList import net.minecraft.util.ActionResult import net.minecraft.util.Hand -import net.minecraft.util.Identifier -import net.minecraft.util.math.MathHelper -import net.minecraft.util.registry.Registry -import org.apache.commons.lang3.math.Fraction fun readTank(tag: NbtCompound, tank: SingleVariantStorage) { - //Read legacy lba values - ((tag.getCompound("fluidInv").get("tanks") as? NbtList) ?: (tag.get("tanks") as? NbtList))?.let { - if(it.size > 0) { - val addendum = if(tag.contains("x") && tag.contains("y") && tag.contains("z")) { - "(at x: ${tag.getInt("x")}, y: ${tag.getInt("y")}, z: ${tag.getInt("z")})" - }else{ - "(unknown coordinates, entangled tank?)" - } - LOGGER.info("Found old lba tank $addendum. Converting it") - val oldTank = it.getCompound(0) - val amount = oldTank.getCompound("AmountF") - val fluidId = oldTank.getString("ObjName") - val fluid = Registry.FLUID.get(Identifier(fluidId)) - if(fluid != Fluids.EMPTY) { - val fraction = Fraction.getFraction(amount.getLong("w").toInt(), amount.getLong("n").toInt(), amount.getLong("d").toInt()) - val newAmount = MathHelper.floor(fraction.toFloat()*81000f) - if(newAmount <= tank.capacity) { - LOGGER.info("Successfully converted tank with $newAmount droplets of $fluidId") - tank.variant = FluidVariant.of(fluid) - tank.amount = newAmount.toLong() - tag.remove("fluidInv") - tag.remove("tanks") - return - }else{ - LOGGER.info("Tank had $newAmount droplets while maximum accepted was ${tank.capacity}") - } - }else{ - LOGGER.info("Tank was empty.") - } - } - } tank.variant = FluidVariant.fromNbt(tag.getCompound("variant")) tank.amount = tag.getLong("amount") } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/utils/RingAbilities.kt b/src/main/kotlin/io/github/lucaargolo/kibe/utils/RingAbilities.kt index d2af8c27..c22bb227 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/utils/RingAbilities.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/utils/RingAbilities.kt @@ -14,7 +14,7 @@ val ringAbilitySource: AbilitySource = Pal.getAbilitySource(Identifier("kibe", " val potionToAbilityMap = mutableMapOf() private fun registerEffect(playerAbility: PlayerAbility, status: StatusEffect): PlayerAbility { - potionToAbilityMap.put(playerAbility, status) + potionToAbilityMap[playerAbility] = status return playerAbility } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/utils/SyncableBlockEntity.kt b/src/main/kotlin/io/github/lucaargolo/kibe/utils/SyncableBlockEntity.kt index d76ae6ad..19bf7bb7 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/utils/SyncableBlockEntity.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/utils/SyncableBlockEntity.kt @@ -4,8 +4,8 @@ import net.minecraft.block.BlockState import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.BlockEntityType import net.minecraft.nbt.NbtCompound -import net.minecraft.network.Packet import net.minecraft.network.listener.ClientPlayPacketListener +import net.minecraft.network.packet.Packet import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket import net.minecraft.server.world.ServerWorld import net.minecraft.util.math.BlockPos diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4d4720d9..0db935ce 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -46,8 +46,8 @@ ], "depends": { "fabricloader": ">=0.14.5", - "fabric": ">=0.61.0", - "fabric-language-kotlin": ">=1.8.0", - "minecraft": "1.19.x" + "fabric": ">=0.83.1", + "fabric-language-kotlin": ">=1.9.5", + "minecraft": "1.20.x" } }