diff --git a/build.gradle b/build.gradle index 72e9de273..ff85c3ef9 100644 --- a/build.gradle +++ b/build.gradle @@ -118,7 +118,7 @@ dependencies { //modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:6.0.254-alpha" //modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:6.0.254-alpha" - modCompileOnly "maven.modrinth:iris:1.19.x-v1.2.5" + modCompileOnly "maven.modrinth:iris:1.19.3-v1.4.6" // For running with Iris. Can be ignored most of the time. // modRuntimeOnly "maven.modrinth:iris:1.19.x-v1.2.5" diff --git a/gradle.properties b/gradle.properties index a07ef6d51..ba4482496 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,12 +2,12 @@ org.gradle.jvmargs=-Xmx3G # Mod properties -mod_version=1.101.2 +mod_version=1.102.0 # Minecraft properties -mc_version=1.19.1 -fabric_api_version=0.58.5+1.19.1 -fabric_loader_version=0.14.8 +mc_version=1.19.3 +fabric_api_version=0.68.1+1.19.3 +fabric_loader_version=0.14.11 -modmenu_version=4.0.5 +modmenu_version=5.0.1 netty_http_version=4.1.77.Final diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 3fcc7c378..449d8b8bf 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -28,6 +28,7 @@ import net.fabricmc.fabric.api.resource.ResourcePackActivationType; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -103,20 +104,20 @@ public final class ComputerCraft public static void onInitialize() { ComputerCraftProxyCommon.init(); - Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "colour" ), ColourableRecipe.SERIALIZER ); - Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "computer_upgrade" ), ComputerUpgradeRecipe.SERIALIZER ); - Registry.register( Registry.RECIPE_SERIALIZER, + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "colour" ), ColourableRecipe.SERIALIZER ); + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "computer_upgrade" ), ComputerUpgradeRecipe.SERIALIZER ); + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer_upgrade" ), PocketComputerUpgradeRecipe.SERIALIZER ); - Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "disk" ), DiskRecipe.SERIALIZER ); - Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "printout" ), PrintoutRecipe.SERIALIZER ); - Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), TurtleRecipe.SERIALIZER ); - Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "turtle_upgrade" ), TurtleUpgradeRecipe.SERIALIZER ); - Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shaped" ), ImpostorRecipe.SERIALIZER ); - Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shapeless" ), ImpostorShapelessRecipe.SERIALIZER ); - Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "block_named" ), BlockNamedEntityLootCondition.TYPE ); - Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "player_creative" ), PlayerCreativeLootCondition.TYPE ); - Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "has_id" ), HasComputerIdLootCondition.TYPE ); + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "disk" ), DiskRecipe.SERIALIZER ); + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "printout" ), PrintoutRecipe.SERIALIZER ); + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), TurtleRecipe.SERIALIZER ); + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "turtle_upgrade" ), TurtleUpgradeRecipe.SERIALIZER ); + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shaped" ), ImpostorRecipe.SERIALIZER ); + Registry.register( BuiltInRegistries.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shapeless" ), ImpostorShapelessRecipe.SERIALIZER ); + Registry.register( BuiltInRegistries.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "block_named" ), BlockNamedEntityLootCondition.TYPE ); + Registry.register( BuiltInRegistries.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "player_creative" ), PlayerCreativeLootCondition.TYPE ); + Registry.register( BuiltInRegistries.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "has_id" ), HasComputerIdLootCondition.TYPE ); init(); GameInstanceUtils.init(); FabricLoader.getInstance().getModContainer( MOD_ID ).ifPresent( modContainer -> { diff --git a/src/main/java/dan200/computercraft/api/ComputerCraftTags.java b/src/main/java/dan200/computercraft/api/ComputerCraftTags.java index ab3064c8f..c30f2f7fa 100644 --- a/src/main/java/dan200/computercraft/api/ComputerCraftTags.java +++ b/src/main/java/dan200/computercraft/api/ComputerCraftTags.java @@ -6,7 +6,7 @@ package dan200.computercraft.api; import dan200.computercraft.ComputerCraft; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; @@ -26,7 +26,7 @@ public static class Items private static TagKey make( String name ) { - return TagKey.create( Registry.ITEM_REGISTRY, new ResourceLocation( ComputerCraft.MOD_ID, name ) ); + return TagKey.create( Registries.ITEM, new ResourceLocation( ComputerCraft.MOD_ID, name ) ); } } @@ -59,7 +59,7 @@ public static class Blocks private static TagKey make( String name ) { - return TagKey.create( Registry.BLOCK_REGISTRY, new ResourceLocation( ComputerCraft.MOD_ID, name ) ); + return TagKey.create( Registries.BLOCK, new ResourceLocation( ComputerCraft.MOD_ID, name ) ); } } } diff --git a/src/main/java/dan200/computercraft/api/client/TransformedModel.java b/src/main/java/dan200/computercraft/api/client/TransformedModel.java index 0c00d97f9..63a277218 100644 --- a/src/main/java/dan200/computercraft/api/client/TransformedModel.java +++ b/src/main/java/dan200/computercraft/api/client/TransformedModel.java @@ -7,7 +7,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; @@ -15,6 +14,7 @@ import net.minecraft.client.resources.model.ModelManager; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.world.item.ItemStack; +import org.joml.Vector3f; import javax.annotation.Nonnull; import java.util.Objects; diff --git a/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java b/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java index ef1669a14..c992bce7b 100644 --- a/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java +++ b/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java @@ -42,7 +42,7 @@ public abstract class FakePlayer extends ServerPlayer { public FakePlayer( ServerLevel world, GameProfile gameProfile ) { - super( world.getServer(), world, gameProfile, null ); + super( world.getServer(), world, gameProfile ); connection = new FakeNetHandler( this ); } @@ -209,12 +209,6 @@ public void teleportTo( double x, double y, double z ) // { // } - - @Override - public void sendChatMessage( OutgoingPlayerChatMessage outgoingPlayerChatMessage, boolean bl, ChatType.Bound bound ) - { - } - @Override public void sendSystemMessage( Component component, boolean bl ) { @@ -265,4 +259,9 @@ public void untrackChunk( ChunkPos chunkPos ) public void playNotifySound( SoundEvent soundEvent, SoundSource soundCategory, float volume, float pitch ) { } + + @Override + public void sendChatMessage( OutgoingChatMessage outgoingChatMessage, boolean bl, ChatType.Bound bound ) + { + } } diff --git a/src/main/java/dan200/computercraft/client/ClientRegistry.java b/src/main/java/dan200/computercraft/client/ClientRegistry.java index b18aa103a..ea0427875 100644 --- a/src/main/java/dan200/computercraft/client/ClientRegistry.java +++ b/src/main/java/dan200/computercraft/client/ClientRegistry.java @@ -13,14 +13,10 @@ import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.util.Colour; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.resources.model.*; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ResourceManager; -import java.util.HashSet; import java.util.function.Consumer; /** @@ -65,13 +61,6 @@ public final class ClientRegistry private ClientRegistry() {} - public static void onTextureStitchEvent( TextureAtlas atlasTexture, ClientSpriteRegistryCallback.Registry registry ) - { - for( String extra : EXTRA_TEXTURES ) - { - registry.register( new ResourceLocation( ComputerCraft.MOD_ID, extra ) ); - } - } @SuppressWarnings( "NewExpressionSideOnly" ) public static void onModelBakeEvent( ResourceManager manager, Consumer out ) @@ -111,7 +100,7 @@ public static void onItemColours() Registry.ModBlocks.TURTLE_ADVANCED ); } - private static BakedModel bake( ModelBakery loader, UnbakedModel model, ResourceLocation identifier ) + /*private static BakedModel bake( ModelBakery loader, UnbakedModel model, ResourceLocation identifier ) { model.getMaterials( loader::getModel, new HashSet<>() ); return model.bake( loader, @@ -120,5 +109,5 @@ private static BakedModel bake( ModelBakery loader, UnbakedModel model, Resource .apply( spriteIdentifier.texture() ), BlockModelRotation.X0_Y0, identifier ); - } + }*/ } diff --git a/src/main/java/dan200/computercraft/client/gui/ComputerScreenBase.java b/src/main/java/dan200/computercraft/client/gui/ComputerScreenBase.java index 0e39444e2..4be8dec36 100644 --- a/src/main/java/dan200/computercraft/client/gui/ComputerScreenBase.java +++ b/src/main/java/dan200/computercraft/client/gui/ComputerScreenBase.java @@ -60,7 +60,6 @@ public ComputerScreenBase( T container, Inventory player, Component title, int s protected void init() { super.init(); - minecraft.keyboardHandler.setSendRepeatsToGui( true ); terminal = addRenderableWidget( createTerminal() ); ComputerSidebar.addButtons( this, computer, this::addRenderableWidget, leftPos, topPos + sidebarYOffset ); @@ -71,7 +70,6 @@ protected void init() public void removed() { super.removed(); - minecraft.keyboardHandler.setSendRepeatsToGui( false ); } @Override diff --git a/src/main/java/dan200/computercraft/client/gui/GuiComputer.java b/src/main/java/dan200/computercraft/client/gui/GuiComputer.java index 14c24a9e1..10708266e 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiComputer.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiComputer.java @@ -77,7 +77,7 @@ public void renderBg( @Nonnull PoseStack stack, float partialTicks, int mouseX, { // Draw a border around the terminal ComputerBorderRenderer.renderFromGui( - ComputerBorderRenderer.getTexture( family ), terminal.x, terminal.y, getBlitOffset(), + ComputerBorderRenderer.getTexture( family ), terminal.getX(), terminal.getY(), getBlitOffset(), FULL_BRIGHT_LIGHTMAP, terminal.getWidth(), terminal.getHeight() ); ComputerSidebar.renderBackground( stack, leftPos, topPos + sidebarYOffset ); diff --git a/src/main/java/dan200/computercraft/client/gui/NoTermComputerScreen.java b/src/main/java/dan200/computercraft/client/gui/NoTermComputerScreen.java index f1da4670f..6768e261f 100644 --- a/src/main/java/dan200/computercraft/client/gui/NoTermComputerScreen.java +++ b/src/main/java/dan200/computercraft/client/gui/NoTermComputerScreen.java @@ -51,7 +51,6 @@ protected void init() KeyMapping.releaseAll(); super.init(); - minecraft.keyboardHandler.setSendRepeatsToGui( true ); terminal = addWidget( new WidgetTerminal( (ClientComputer) menu.getComputer(), 0, 0, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight ) ); terminal.visible = false; @@ -63,7 +62,6 @@ protected void init() public final void removed() { super.removed(); - minecraft.keyboardHandler.setSendRepeatsToGui( false ); } @Override diff --git a/src/main/java/dan200/computercraft/client/gui/OptionScreen.java b/src/main/java/dan200/computercraft/client/gui/OptionScreen.java index a02df3952..32c3f67b6 100644 --- a/src/main/java/dan200/computercraft/client/gui/OptionScreen.java +++ b/src/main/java/dan200/computercraft/client/gui/OptionScreen.java @@ -78,8 +78,8 @@ public void init() int x = (width - buttonWidth) / 2; for( AbstractWidget button : buttons ) { - button.x = x; - button.y = y + textHeight; + button.setX( x ); + button.setY( y + textHeight ); addRenderableWidget( button ); x += BUTTON_WIDTH + PADDING; @@ -112,7 +112,7 @@ public void onClose() public static AbstractWidget newButton( Component component, Button.OnPress clicked ) { - return new Button( 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, component, clicked ); + return Button.builder( component, clicked ).pos( 0, 0 ).width( BUTTON_WIDTH ).build(); } public void disable() diff --git a/src/main/java/dan200/computercraft/client/gui/widgets/DynamicImageButton.java b/src/main/java/dan200/computercraft/client/gui/widgets/DynamicImageButton.java index bf7968a87..1dc26229a 100644 --- a/src/main/java/dan200/computercraft/client/gui/widgets/DynamicImageButton.java +++ b/src/main/java/dan200/computercraft/client/gui/widgets/DynamicImageButton.java @@ -52,7 +52,7 @@ public DynamicImageButton( OnPress onPress, NonNullSupplier> tooltip ) { - super( x, y, width, height, Component.empty(), onPress ); + super( x, y, width, height, Component.empty(), onPress, DEFAULT_NARRATION ); this.screen = screen; this.textureWidth = textureWidth; this.textureHeight = textureHeight; @@ -72,7 +72,7 @@ public void renderButton( @Nonnull PoseStack stack, int mouseX, int mouseY, floa int yTex = yTexStart; if( isHoveredOrFocused() ) yTex += yDiffTex; - blit( stack, x, y, xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight ); + blit( stack, getX(), getY(), xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight ); RenderSystem.enableDepthTest(); if( isHovered ) renderToolTip( stack, mouseX, mouseY ); @@ -86,7 +86,6 @@ public Component getMessage() return tooltip.isEmpty() ? Component.empty() : tooltip.get( 0 ); } - @Override public void renderToolTip( @Nonnull PoseStack stack, int mouseX, int mouseY ) { List tooltip = this.tooltip.get(); diff --git a/src/main/java/dan200/computercraft/client/gui/widgets/WidgetTerminal.java b/src/main/java/dan200/computercraft/client/gui/widgets/WidgetTerminal.java index 33ef2f54f..c53f8631b 100644 --- a/src/main/java/dan200/computercraft/client/gui/widgets/WidgetTerminal.java +++ b/src/main/java/dan200/computercraft/client/gui/widgets/WidgetTerminal.java @@ -330,14 +330,14 @@ public void render( @Nonnull PoseStack transform, int mouseX, int mouseY, float } else { - FixedWidthFontRenderer.drawEmptyTerminal( emitter, (float) x, (float) y, (float) width, (float) height ); + FixedWidthFontRenderer.drawEmptyTerminal( emitter, (float) getX(), (float) getY(), (float) width, (float) height ); } bufferSource.endBatch(); } @Override - public void updateNarration( @Nonnull NarrationElementOutput output ) + protected void updateWidgetNarration( NarrationElementOutput narrationElementOutput ) { // I'm not sure what the right option is here. } diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index 11c702413..668f0ca7f 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -35,7 +35,6 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.multiplayer.ClientLevel; @@ -44,7 +43,6 @@ import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; @@ -97,8 +95,6 @@ public void onInitializeClient() BlockEntityRendererRegistry.register( Registry.ModBlockEntities.TURTLE_NORMAL, TileEntityTurtleRenderer::new ); BlockEntityRendererRegistry.register( Registry.ModBlockEntities.TURTLE_ADVANCED, TileEntityTurtleRenderer::new ); - ClientSpriteRegistryCallback.event( InventoryMenu.BLOCK_ATLAS ) - .register( ClientRegistry::onTextureStitchEvent ); ModelLoadingRegistry.INSTANCE.registerModelProvider( ClientRegistry::onModelBakeEvent ); ModelLoadingRegistry.INSTANCE.registerResourceProvider( loader -> ( name, context ) -> TurtleModelLoader.INSTANCE.accepts( name ) ? TurtleModelLoader.INSTANCE.loadModel( diff --git a/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java b/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java index ccb44319b..575f48f70 100644 --- a/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java @@ -7,8 +7,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; import dan200.computercraft.shared.Registry; import dan200.computercraft.shared.peripheral.modem.wired.BlockCable; import dan200.computercraft.shared.peripheral.modem.wired.CableShapes; @@ -24,6 +22,8 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; +import org.joml.Matrix3f; +import org.joml.Matrix4f; @Environment( EnvType.CLIENT ) public final class CableHighlightRenderer diff --git a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java index a807934cc..dae160100 100644 --- a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java @@ -8,13 +8,13 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.computer.core.ComputerFamily; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.resources.ResourceLocation; +import org.joml.Matrix3f; +import org.joml.Matrix4f; import javax.annotation.Nonnull; @@ -29,7 +29,7 @@ public class ComputerBorderRenderer static { - IDENTITY.setIdentity(); + IDENTITY.identity(); } /** diff --git a/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java index d487e0850..bf11129f4 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java @@ -6,7 +6,7 @@ package dan200.computercraft.client.render; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import dan200.computercraft.fabric.mixin.ItemInHandRendererAccess; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemInHandRenderer; @@ -74,7 +74,7 @@ private void renderItemFirstPersonSide( PoseStack transform, MultiBufferSource r if( !minecraft.player.isInvisible() ) { transform.pushPose(); - transform.mulPose( Vector3f.ZP.rotationDegrees( offset * 10f ) ); + transform.mulPose( Axis.ZP.rotationDegrees( offset * 10f ) ); ((ItemInHandRendererAccess) minecraft.getEntityRenderDispatcher().getItemInHandRenderer()).callRenderPlayerArm( transform, render, combinedLight, equipProgress, swingProgress, side ); transform.popPose(); } @@ -89,8 +89,8 @@ private void renderItemFirstPersonSide( PoseStack transform, MultiBufferSource r float f4 = 0.4f * Mth.sin( f1 * ((float) Math.PI * 2f) ); float f5 = -0.3f * Mth.sin( swingProgress * (float) Math.PI ); transform.translate( offset * f3, f4 - 0.3f * f2, f5 ); - transform.mulPose( Vector3f.XP.rotationDegrees( f2 * -45f ) ); - transform.mulPose( Vector3f.YP.rotationDegrees( offset * f2 * -30f ) ); + transform.mulPose( Axis.XP.rotationDegrees( f2 * -45f ) ); + transform.mulPose( Axis.YP.rotationDegrees( offset * f2 * -30f ) ); renderItem( transform, render, stack, combinedLight ); @@ -124,18 +124,18 @@ private void renderItemFirstPersonCenter( PoseStack transform, MultiBufferSource ItemInHandRendererAccess access = (ItemInHandRendererAccess) renderer; float pitchAngle = access.callCalculateMapTilt( pitch ); transform.translate( 0, 0.04F + equipProgress * -1.2f + pitchAngle * -0.5f, -0.72f ); - transform.mulPose( Vector3f.XP.rotationDegrees( pitchAngle * -85.0f ) ); + transform.mulPose( Axis.XP.rotationDegrees( pitchAngle * -85.0f ) ); if( !minecraft.player.isInvisible() ) { transform.pushPose(); - transform.mulPose( Vector3f.YP.rotationDegrees( 90.0F ) ); + transform.mulPose( Axis.YP.rotationDegrees( 90.0F ) ); access.callRenderMapHand( transform, render, combinedLight, HumanoidArm.RIGHT ); access.callRenderMapHand( transform, render, combinedLight, HumanoidArm.LEFT ); transform.popPose(); } float rX = Mth.sin( swingRt * (float) Math.PI ); - transform.mulPose( Vector3f.XP.rotationDegrees( rX * 20.0F ) ); + transform.mulPose( Axis.XP.rotationDegrees( rX * 20.0F ) ); transform.scale( 2.0F, 2.0F, 2.0F ); renderItem( transform, render, stack, combinedLight ); diff --git a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java index 02847e27f..5aa70ee7e 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java @@ -7,8 +7,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import dan200.computercraft.ComputerCraft; import dan200.computercraft.client.render.text.FixedWidthFontRenderer; import dan200.computercraft.core.terminal.Terminal; @@ -19,6 +18,7 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import org.joml.Matrix4f; import static dan200.computercraft.client.render.ComputerBorderRenderer.*; import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_HEIGHT; @@ -59,14 +59,19 @@ protected void renderItem( PoseStack transform, MultiBufferSource bufferSource, // Setup various transformations. Note that these are partially adapted from the corresponding method // in ItemRenderer transform.pushPose(); - transform.mulPose( Vector3f.YP.rotationDegrees( 180f ) ); - transform.mulPose( Vector3f.ZP.rotationDegrees( 180f ) ); + transform.mulPose( Axis.YP.rotationDegrees( 180f ) ); + transform.mulPose( Axis.ZP.rotationDegrees( 180f ) ); transform.scale( 0.5f, 0.5f, 0.5f ); float scale = 0.75f / Math.max( width + BORDER * 2, height + BORDER * 2 + LIGHT_HEIGHT ); // Avoid PoseStack#scale to preserve normal matrix, and fix the normals ourselves. - transform.last().pose().multiply( Matrix4f.createScaleMatrix( scale, scale, -1.0f ) ); - transform.last().normal().mul( -1.0f ); + Matrix4f scaleMat = new Matrix4f(); + scaleMat.m00( scale ); + scaleMat.m11( scale ); + scaleMat.m22( -1.0f ); + + transform.last().pose().mul0( scaleMat ); + transform.last().normal().scale( -1.0f ); transform.translate( -0.5 * width, -0.5 * height, 0 ); // Render the main frame diff --git a/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java index da43dd393..14780655c 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java @@ -6,11 +6,11 @@ package dan200.computercraft.client.render; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import dan200.computercraft.shared.media.items.ItemPrintout; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.world.item.ItemStack; +import org.joml.Matrix4f; import static dan200.computercraft.client.render.PrintoutRenderer.*; import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_HEIGHT; @@ -35,10 +35,15 @@ public boolean renderInFrame( PoseStack transform, MultiBufferSource renderer, I // Move a little bit forward to ensure we're not clipping with the frame transform.translate( 0.0f, 0.0f, -0.001f ); - transform.mulPose( Vector3f.ZP.rotationDegrees( 180f ) ); + transform.mulPose( Axis.ZP.rotationDegrees( 180f ) ); // Avoid PoseStack#scale to preserve normal matrix, and fix the normals ourselves. - transform.last().pose().multiply( Matrix4f.createScaleMatrix( 0.95f, 0.95f, -0.95f ) ); - transform.last().normal().mul( -1.0f ); + Matrix4f scaleMat = new Matrix4f(); + scaleMat.m00( 0.95f ); + scaleMat.m11( 0.95f ); + scaleMat.m22( -0.95f ); + + transform.last().pose().mul0( scaleMat ); + transform.last().normal().scale( -1.0f ); //transform.last().normal().mul( -1.0f ); transform.translate( -0.5f, -0.5f, 0.0f ); @@ -51,10 +56,15 @@ public boolean renderInFrame( PoseStack transform, MultiBufferSource renderer, I @Override protected void renderItem( PoseStack transform, MultiBufferSource renderer, ItemStack stack, int light ) { - transform.mulPose( Vector3f.XP.rotationDegrees( 180f ) ); + transform.mulPose( Axis.XP.rotationDegrees( 180f ) ); // Avoid PoseStack#scale to preserve normal matrix, and fix the normals ourselves. - transform.last().pose().multiply( Matrix4f.createScaleMatrix( 0.42f, 0.42f, -0.42f ) ); - transform.last().normal().mul( -1.0f ); + Matrix4f scaleMat = new Matrix4f(); + scaleMat.m00( 0.42f ); + scaleMat.m11( 0.42f ); + scaleMat.m22( -0.42f ); + + transform.last().pose().mul0( scaleMat ); + transform.last().normal().scale( -1.0f ); transform.translate( -0.5f, -0.48f, 0.0f ); drawPrintout( transform, renderer, stack, light ); diff --git a/src/main/java/dan200/computercraft/client/render/ModelTransformer.java b/src/main/java/dan200/computercraft/client/render/ModelTransformer.java index 2ac6713bd..77a8c2ee1 100644 --- a/src/main/java/dan200/computercraft/client/render/ModelTransformer.java +++ b/src/main/java/dan200/computercraft/client/render/ModelTransformer.java @@ -8,11 +8,11 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.blaze3d.vertex.VertexFormatElement; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector4f; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BakedQuad; +import org.joml.Matrix4f; +import org.joml.Vector4f; import java.util.List; @@ -27,7 +27,7 @@ public final class ModelTransformer static { identity = new Matrix4f(); - identity.setIdentity(); + identity.identity(); } private ModelTransformer() @@ -73,7 +73,7 @@ private static BakedQuad doTransformQuad( VertexFormat format, BakedQuad quad, M 1 ); // Transform the position - pos.transform( transform ); + pos.mulTranspose( transform ); // Insert the position vertexData[start] = Float.floatToRawIntBits( pos.x() ); diff --git a/src/main/java/dan200/computercraft/client/render/MonitorHighlightRenderer.java b/src/main/java/dan200/computercraft/client/render/MonitorHighlightRenderer.java index 60acec8d0..603b0f0ce 100644 --- a/src/main/java/dan200/computercraft/client/render/MonitorHighlightRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/MonitorHighlightRenderer.java @@ -7,8 +7,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; import dan200.computercraft.shared.peripheral.monitor.TileMonitor; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -20,6 +18,8 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; +import org.joml.Matrix3f; +import org.joml.Matrix4f; import java.util.EnumSet; diff --git a/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java b/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java index 7561b0a50..204f0fb43 100644 --- a/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java @@ -7,12 +7,12 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; import dan200.computercraft.client.render.text.FixedWidthFontRenderer; import dan200.computercraft.core.terminal.TextBuffer; import dan200.computercraft.shared.util.Palette; import net.minecraft.client.renderer.texture.OverlayTexture; +import org.joml.Matrix3f; +import org.joml.Matrix4f; import static dan200.computercraft.client.render.text.FixedWidthFontRenderer.FONT_HEIGHT; import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE; diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java index 5225f58b1..50ee99b9f 100644 --- a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java @@ -10,9 +10,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import dan200.computercraft.ComputerCraft; import dan200.computercraft.client.FrameInfo; import dan200.computercraft.client.render.text.DirectFixedWidthFontRenderer; @@ -30,6 +28,8 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import org.joml.Matrix3f; +import org.joml.Matrix4f; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL31; @@ -54,7 +54,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer { - private static final ModelResourceLocation NORMAL_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_normal", "inventory" ); - private static final ModelResourceLocation ADVANCED_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_advanced", "inventory" ); - private static final ModelResourceLocation COLOUR_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_colour", "inventory" ); - private static final ModelResourceLocation ELF_OVERLAY_MODEL = new ModelResourceLocation( "computercraft:turtle_elf_overlay", "inventory" ); + private static final ModelResourceLocation NORMAL_TURTLE_MODEL = new ModelResourceLocation( "computercraft", "turtle_normal", "inventory" ); + private static final ModelResourceLocation ADVANCED_TURTLE_MODEL = new ModelResourceLocation( "computercraft", "turtle_advanced", "inventory" ); + private static final ModelResourceLocation COLOUR_TURTLE_MODEL = new ModelResourceLocation( "computercraft", "turtle_colour", "inventory" ); + private static final ModelResourceLocation ELF_OVERLAY_MODEL = new ModelResourceLocation( "computercraft", "turtle_elf_overlay", "inventory" ); private final RandomSource random = RandomSource.create(); @@ -106,7 +106,7 @@ public void render( @Nonnull TileTurtle turtle, float partialTicks, @Nonnull Pos transform.translate( offset.x, offset.y, offset.z ); transform.translate( 0.5f, 0.5f, 0.5f ); - transform.mulPose( Vector3f.YP.rotationDegrees( 180.0f - yaw ) ); + transform.mulPose( Axis.YP.rotationDegrees( 180.0f - yaw ) ); if( label != null && (label.equals( "Dinnerbone" ) || label.equals( "Grumm" )) ) { // Flip the model @@ -144,7 +144,7 @@ private void renderUpgrade( @Nonnull PoseStack transform, @Nonnull VertexConsume float toolAngle = turtle.getToolRenderAngle( side, f ); transform.translate( 0.0f, 0.5f, 0.5f ); - transform.mulPose( Vector3f.XN.rotationDegrees( toolAngle ) ); + transform.mulPose( Axis.XN.rotationDegrees( toolAngle ) ); transform.translate( 0.0f, -0.5f, -0.5f ); TransformedModel model = upgrade.getModel( turtle.getAccess(), side ); diff --git a/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java b/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java index 75b207344..52620f962 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java @@ -5,7 +5,6 @@ */ package dan200.computercraft.client.render; -import com.mojang.datafixers.util.Pair; import dan200.computercraft.ComputerCraft; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -16,9 +15,7 @@ import javax.annotation.Nonnull; import java.util.Arrays; import java.util.Collection; -import java.util.Set; import java.util.function.Function; -import java.util.stream.Collectors; @Environment( EnvType.CLIENT ) public final class TurtleModelLoader @@ -67,27 +64,21 @@ private TurtleModel( ResourceLocation family ) this.family = family; } + @Nonnull @Override - public Collection getMaterials( Function modelGetter, - Set> missingTextureErrors ) + public Collection getDependencies() { - return getDependencies() - .stream() - .flatMap( x -> modelGetter.apply( x ) - .getMaterials( modelGetter, missingTextureErrors ) - .stream() ) - .collect( Collectors.toSet() ); + return Arrays.asList( family, COLOUR_TURTLE_MODEL ); } - @Nonnull @Override - public Collection getDependencies() + public void resolveParents( Function function ) { - return Arrays.asList( family, COLOUR_TURTLE_MODEL ); + } @Override - public BakedModel bake( @Nonnull ModelBakery loader, @Nonnull Function spriteGetter, @Nonnull ModelState state, + public BakedModel bake( @Nonnull ModelBaker loader, @Nonnull Function spriteGetter, @Nonnull ModelState state, ResourceLocation modelId ) { return new TurtleSmartItemModel( loader.getModel( family ) diff --git a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java index 28b3eb853..018894c22 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java @@ -75,7 +75,7 @@ public TurtleSmartItemModel( BakedModel familyModel, BakedModel colourModel ) this.colourModel = colourModel; // this actually works I think, trust me - overrides = new ItemOverrides( null, null, null, Collections.emptyList() ) + overrides = new ItemOverrides( null, null, Collections.emptyList() ) { @Nonnull @Override diff --git a/src/main/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java b/src/main/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java index e4f01d676..333cac577 100644 --- a/src/main/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java @@ -7,8 +7,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; import dan200.computercraft.client.FrameInfo; import dan200.computercraft.core.terminal.Terminal; import dan200.computercraft.core.terminal.TextBuffer; @@ -16,6 +14,8 @@ import dan200.computercraft.shared.util.Palette; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.resources.ResourceLocation; +import org.joml.Matrix4f; +import org.joml.Vector3f; import javax.annotation.Nonnull; @@ -248,12 +248,12 @@ public static void drawEmptyTerminal( @Nonnull QuadEmitter emitter, float x, flo drawQuad( emitter, x, y, 0, width, height, BLACK, FULL_BRIGHT_LIGHTMAP ); } - public record QuadEmitter(Matrix4f poseMatrix, Vector3f normal, VertexConsumer consumer ) {} + public record QuadEmitter( Matrix4f poseMatrix, Vector3f normal, VertexConsumer consumer ) {} public static QuadEmitter toVertexConsumer( PoseStack transform, VertexConsumer consumer ) { var normal = new Vector3f( 0f, 0f, 1f ); - normal.transform( transform.last().normal() ); + normal.mulTranspose( transform.last().normal() ); return new QuadEmitter( transform.last().pose(), normal, consumer ); } diff --git a/src/main/java/dan200/computercraft/client/util/DirectVertexBuffer.java b/src/main/java/dan200/computercraft/client/util/DirectVertexBuffer.java index 3b4e8a79c..a83aa9102 100644 --- a/src/main/java/dan200/computercraft/client/util/DirectVertexBuffer.java +++ b/src/main/java/dan200/computercraft/client/util/DirectVertexBuffer.java @@ -10,9 +10,9 @@ import com.mojang.blaze3d.vertex.BufferUploader; import com.mojang.blaze3d.vertex.VertexBuffer; import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.math.Matrix4f; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ShaderInstance; +import org.joml.Matrix4f; import org.lwjgl.opengl.GL32C; import java.nio.ByteBuffer; diff --git a/src/main/java/dan200/computercraft/data/BlockModelProvider.java b/src/main/java/dan200/computercraft/data/BlockModelProvider.java index 1ffc05762..cea6bf60a 100644 --- a/src/main/java/dan200/computercraft/data/BlockModelProvider.java +++ b/src/main/java/dan200/computercraft/data/BlockModelProvider.java @@ -13,7 +13,7 @@ import dan200.computercraft.shared.peripheral.modem.wireless.BlockWirelessModem; import dan200.computercraft.shared.peripheral.monitor.BlockMonitor; import dan200.computercraft.shared.peripheral.monitor.MonitorEdgeState; -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; import net.minecraft.core.Direction; import net.minecraft.data.models.BlockModelGenerators; @@ -30,7 +30,7 @@ import static net.minecraft.data.models.model.ModelLocationUtils.getModelLocation; import static net.minecraft.data.models.model.TextureMapping.getBlockTexture; -public class BlockModelProvider extends FabricModelProvider +class BlockModelProvider extends FabricModelProvider { private static final ModelTemplate MONITOR_BASE = new ModelTemplate( Optional.of( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) ), @@ -43,7 +43,7 @@ public class BlockModelProvider extends FabricModelProvider TextureSlot.FRONT, TextureSlot.BACK ); - public BlockModelProvider( FabricDataGenerator dataGenerator ) + BlockModelProvider( FabricDataOutput dataGenerator ) { super( dataGenerator ); } diff --git a/src/main/java/dan200/computercraft/data/BlockTagsGenerator.java b/src/main/java/dan200/computercraft/data/BlockTagsGenerator.java index 5905987d2..30d506a96 100644 --- a/src/main/java/dan200/computercraft/data/BlockTagsGenerator.java +++ b/src/main/java/dan200/computercraft/data/BlockTagsGenerator.java @@ -6,25 +6,28 @@ package dan200.computercraft.data; import dan200.computercraft.shared.Registry; -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.minecraft.core.HolderLookup; import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import org.jetbrains.annotations.NotNull; +import java.util.concurrent.CompletableFuture; + import static dan200.computercraft.api.ComputerCraftTags.Blocks.*; class BlockTagsGenerator extends FabricTagProvider.BlockTagProvider { - BlockTagsGenerator( FabricDataGenerator generator ) + BlockTagsGenerator( FabricDataOutput output, CompletableFuture registriesFuture ) { - super( generator ); + super( output, registriesFuture ); } @Override - protected void generateTags() + protected void addTags( HolderLookup.Provider arg ) { // Items tag( COMPUTER ).add( @@ -76,7 +79,7 @@ protected void generateTags() } @Override - protected FabricTagProvider.FabricTagBuilder tag( @NotNull TagKey tagKey ) + protected FabricTagProvider.FabricTagBuilder tag( @NotNull TagKey tagKey ) { // Fun mapping weirdness here! return super.getOrCreateTagBuilder( tagKey ); diff --git a/src/main/java/dan200/computercraft/data/Generators.java b/src/main/java/dan200/computercraft/data/Generators.java index d933ffeb9..70ac3d3d6 100644 --- a/src/main/java/dan200/computercraft/data/Generators.java +++ b/src/main/java/dan200/computercraft/data/Generators.java @@ -13,12 +13,13 @@ public class Generators implements DataGeneratorEntrypoint @Override public void onInitializeDataGenerator( FabricDataGenerator generator ) { - generator.addProvider( new RecipeGenerator( generator ) ); - generator.addProvider( new LootTableGenerator( generator ) ); - generator.addProvider( new BlockModelProvider( generator ) ); + FabricDataGenerator.Pack pack = generator.createPack(); - BlockTagsGenerator blockTags = new BlockTagsGenerator( generator ); - generator.addProvider( blockTags ); - generator.addProvider( new ItemTagsGenerator( generator, blockTags ) ); + pack.addProvider( RecipeGenerator::new ); + pack.addProvider( LootTableGenerator::new ); + pack.addProvider( BlockModelProvider::new ); + + pack.addProvider( BlockTagsGenerator::new ); + pack.addProvider( ItemTagsGenerator::new ); } } diff --git a/src/main/java/dan200/computercraft/data/ItemTagsGenerator.java b/src/main/java/dan200/computercraft/data/ItemTagsGenerator.java index a1c63534c..a4f9a3993 100644 --- a/src/main/java/dan200/computercraft/data/ItemTagsGenerator.java +++ b/src/main/java/dan200/computercraft/data/ItemTagsGenerator.java @@ -7,61 +7,65 @@ import dan200.computercraft.api.ComputerCraftTags.Blocks; import dan200.computercraft.shared.Registry; -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.minecraft.core.HolderLookup; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.Items; +import java.util.concurrent.CompletableFuture; + import static dan200.computercraft.api.ComputerCraftTags.Items.*; class ItemTagsGenerator extends FabricTagProvider.ItemTagProvider { - ItemTagsGenerator( FabricDataGenerator generator, BlockTagsGenerator blockTags ) + + ItemTagsGenerator( FabricDataOutput output, CompletableFuture completableFuture ) { - super( generator, blockTags ); + super( output, completableFuture ); } @Override - protected void generateTags() + protected void addTags( HolderLookup.Provider arg ) { copy( Blocks.COMPUTER, COMPUTER ); copy( Blocks.TURTLE, TURTLE ); - tag( WIRED_MODEM ).add( Registry.ModItems.WIRED_MODEM, Registry.ModItems.WIRED_MODEM_FULL ); + tag( WIRED_MODEM ).add( reverseLookup( Registry.ModItems.WIRED_MODEM ), reverseLookup( Registry.ModItems.WIRED_MODEM_FULL ) ); copy( Blocks.MONITOR, MONITOR ); tag( ItemTags.PIGLIN_LOVED ).add( - Registry.ModItems.COMPUTER_ADVANCED, Registry.ModItems.TURTLE_ADVANCED, - Registry.ModItems.WIRELESS_MODEM_ADVANCED, Registry.ModItems.POCKET_COMPUTER_ADVANCED, - Registry.ModItems.MONITOR_ADVANCED + reverseLookup( Registry.ModItems.COMPUTER_ADVANCED ), reverseLookup( Registry.ModItems.TURTLE_ADVANCED ), + reverseLookup( Registry.ModItems.WIRELESS_MODEM_ADVANCED ), reverseLookup( Registry.ModItems.POCKET_COMPUTER_ADVANCED ), + reverseLookup( Registry.ModItems.MONITOR_ADVANCED ) ); - tag( ExtraConventionalItemTags.ENDER_PEARLS ).add( Items.ENDER_PEARL ); - tag( ExtraConventionalItemTags.GOLD_BLOCKS ).add( Items.GOLD_BLOCK ); + tag( ExtraConventionalItemTags.ENDER_PEARLS ).add( reverseLookup( Items.ENDER_PEARL ) ); + tag( ExtraConventionalItemTags.GOLD_BLOCKS ).add( reverseLookup( Items.GOLD_BLOCK ) ); tag( ExtraConventionalItemTags.SKULLS ).add( - Items.CREEPER_HEAD, - Items.DRAGON_HEAD, - Items.PLAYER_HEAD, - Items.SKELETON_SKULL, - Items.WITHER_SKELETON_SKULL, - Items.ZOMBIE_HEAD + reverseLookup( Items.CREEPER_HEAD ), + reverseLookup( Items.DRAGON_HEAD ), + reverseLookup( Items.PLAYER_HEAD ), + reverseLookup( Items.SKELETON_SKULL ), + reverseLookup( Items.WITHER_SKELETON_SKULL ), + reverseLookup( Items.ZOMBIE_HEAD ) ); tag( ExtraConventionalItemTags.STONES ).add( - Items.ANDESITE, - Items.DIORITE, - Items.GRANITE, - Items.INFESTED_STONE, - Items.STONE, - Items.POLISHED_ANDESITE, - Items.POLISHED_DIORITE, - Items.POLISHED_GRANITE, - Items.DEEPSLATE, - Items.POLISHED_DEEPSLATE, - Items.INFESTED_DEEPSLATE, - Items.TUFF + reverseLookup( Items.ANDESITE ), + reverseLookup( Items.DIORITE ), + reverseLookup( Items.GRANITE ), + reverseLookup( Items.INFESTED_STONE ), + reverseLookup( Items.STONE ), + reverseLookup( Items.POLISHED_ANDESITE ), + reverseLookup( Items.POLISHED_DIORITE ), + reverseLookup( Items.POLISHED_GRANITE ), + reverseLookup( Items.DEEPSLATE ), + reverseLookup( Items.POLISHED_DEEPSLATE ), + reverseLookup( Items.INFESTED_DEEPSLATE ), + reverseLookup( Items.TUFF ) ); tag( ExtraConventionalItemTags.WOODEN_CHESTS ).add( - Items.CHEST, - Items.TRAPPED_CHEST + reverseLookup( Items.CHEST ), + reverseLookup( Items.TRAPPED_CHEST ) ); } } diff --git a/src/main/java/dan200/computercraft/data/LootTableGenerator.java b/src/main/java/dan200/computercraft/data/LootTableGenerator.java index 1ac4c1dab..597e5fb67 100644 --- a/src/main/java/dan200/computercraft/data/LootTableGenerator.java +++ b/src/main/java/dan200/computercraft/data/LootTableGenerator.java @@ -12,8 +12,8 @@ import dan200.computercraft.shared.data.PlayerCreativeLootCondition; import dan200.computercraft.shared.peripheral.modem.wired.BlockCable; import dan200.computercraft.shared.peripheral.modem.wired.CableModemVariant; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.minecraft.advancements.critereon.StatePropertiesPredicate; -import net.minecraft.data.DataGenerator; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.storage.loot.LootPool; @@ -30,9 +30,10 @@ class LootTableGenerator extends LootTableProvider { - LootTableGenerator( DataGenerator generator ) + + LootTableGenerator( FabricDataOutput output ) { - super( generator ); + super( output ); } @Override diff --git a/src/main/java/dan200/computercraft/data/LootTableProvider.java b/src/main/java/dan200/computercraft/data/LootTableProvider.java index 9a078bc74..34e157fba 100644 --- a/src/main/java/dan200/computercraft/data/LootTableProvider.java +++ b/src/main/java/dan200/computercraft/data/LootTableProvider.java @@ -7,8 +7,8 @@ import com.google.common.collect.Multimap; import dan200.computercraft.ComputerCraft; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.minecraft.data.CachedOutput; -import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.storage.loot.LootTable; @@ -17,10 +17,10 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import javax.annotation.Nonnull; -import java.io.IOException; import java.nio.file.Path; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; /** @@ -28,15 +28,15 @@ */ abstract class LootTableProvider implements DataProvider { - private final DataGenerator generator; + private final FabricDataOutput output; - LootTableProvider( DataGenerator generator ) + LootTableProvider( FabricDataOutput output ) { - this.generator = generator; + this.output = output; } @Override - public void run( @Nonnull CachedOutput cache ) + public CompletableFuture run( @Nonnull CachedOutput cache ) { Map tables = new HashMap<>(); ValidationContext validation = new ValidationContext( LootContextParamSets.ALL_PARAMS, x -> null, tables::get ); @@ -62,11 +62,16 @@ public void run( @Nonnull CachedOutput cache ) { DataProvider.saveStable( cache, LootTables.serialize( value ), path ); } - catch( IOException e ) + catch( Throwable e ) { ComputerCraft.log.error( "Couldn't save loot table {}", path, e ); } } ); + + CompletableFuture future = new CompletableFuture<>(); + future.complete( null ); + + return future; } protected abstract void registerLoot( BiConsumer add ); @@ -80,7 +85,7 @@ public String getName() private Path getPath( ResourceLocation id ) { - return generator.getOutputFolder() + return output.getOutputFolder() .resolve( "data" ).resolve( id.getNamespace() ).resolve( "loot_tables" ) .resolve( id.getPath() + ".json" ); } diff --git a/src/main/java/dan200/computercraft/data/RecipeGenerator.java b/src/main/java/dan200/computercraft/data/RecipeGenerator.java index adba89d4e..f98c3f97d 100644 --- a/src/main/java/dan200/computercraft/data/RecipeGenerator.java +++ b/src/main/java/dan200/computercraft/data/RecipeGenerator.java @@ -21,21 +21,19 @@ import dan200.computercraft.shared.util.Colour; import dan200.computercraft.shared.util.ImpostorRecipe; import dan200.computercraft.shared.util.ImpostorShapelessRecipe; -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags; import net.minecraft.advancements.critereon.InventoryChangeTrigger; import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.data.recipes.FinishedRecipe; -import net.minecraft.data.recipes.ShapedRecipeBuilder; -import net.minecraft.data.recipes.ShapelessRecipeBuilder; -import net.minecraft.data.recipes.SpecialRecipeBuilder; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.data.recipes.*; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.*; import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.SimpleRecipeSerializer; +import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Blocks; @@ -48,13 +46,14 @@ class RecipeGenerator extends FabricRecipeProvider { - RecipeGenerator( FabricDataGenerator generator ) + + RecipeGenerator( FabricDataOutput output ) { - super( generator ); + super( output ); } @Override - protected void generateRecipes( @Nonnull Consumer add ) + public void buildRecipes( @Nonnull Consumer add ) { basicRecipes( add ); diskColours( add ); @@ -78,7 +77,7 @@ private void diskColours( @Nonnull Consumer add ) for( Colour colour : Colour.VALUES ) { ShapelessRecipeBuilder - .shapeless( Registry.ModItems.DISK ) + .shapeless( RecipeCategory.REDSTONE, Registry.ModItems.DISK ) .requires( ConventionalItemTags.REDSTONE_DUSTS ) .requires( Items.PAPER ) .requires( DyeItem.byColor( ofColour( colour ) ) ) @@ -108,7 +107,7 @@ private void turtleUpgrades( @Nonnull Consumer add ) TurtleUpgrades.getVanillaUpgrades().forEach( upgrade -> { ItemStack result = TurtleItemFactory.create( -1, null, -1, family, null, upgrade, -1, null ); ShapedRecipeBuilder - .shaped( result.getItem() ) + .shaped( RecipeCategory.REDSTONE, result.getItem() ) .group( String.format( "%s:turtle_%s", ComputerCraft.MOD_ID, nameId ) ) .pattern( "#T" ) .define( 'T', base.getItem() ) @@ -142,7 +141,7 @@ private void pocketUpgrades( @Nonnull Consumer add ) PocketUpgrades.getVanillaUpgrades().forEach( upgrade -> { ItemStack result = PocketComputerItemFactory.create( -1, null, -1, family, upgrade ); ShapedRecipeBuilder - .shaped( result.getItem() ) + .shaped( RecipeCategory.REDSTONE, result.getItem() ) .group( String.format( "%s:pocket_%s", ComputerCraft.MOD_ID, nameId ) ) .pattern( "#" ) .pattern( "P" ) @@ -163,7 +162,7 @@ private void pocketUpgrades( @Nonnull Consumer add ) private void basicRecipes( @Nonnull Consumer add ) { ShapedRecipeBuilder - .shaped( Registry.ModItems.CABLE, 6 ) + .shaped( RecipeCategory.REDSTONE, Registry.ModItems.CABLE, 6 ) .pattern( " # " ) .pattern( "#R#" ) .pattern( " # " ) @@ -174,7 +173,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.COMPUTER_NORMAL ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.COMPUTER_NORMAL ) .pattern( "###" ) .pattern( "#R#" ) .pattern( "#G#" ) @@ -185,7 +184,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.COMPUTER_ADVANCED ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.COMPUTER_ADVANCED ) .pattern( "###" ) .pattern( "#R#" ) .pattern( "#G#" ) @@ -196,7 +195,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.COMPUTER_COMMAND ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.COMPUTER_COMMAND ) .pattern( "###" ) .pattern( "#R#" ) .pattern( "#G#" ) @@ -207,7 +206,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.DISK_DRIVE ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.DISK_DRIVE ) .pattern( "###" ) .pattern( "#R#" ) .pattern( "#R#" ) @@ -217,7 +216,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.MONITOR_NORMAL ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.MONITOR_NORMAL ) .pattern( "###" ) .pattern( "#G#" ) .pattern( "###" ) @@ -227,7 +226,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.MONITOR_ADVANCED, 4 ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.MONITOR_ADVANCED, 4 ) .pattern( "###" ) .pattern( "#G#" ) .pattern( "###" ) @@ -237,7 +236,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModItems.POCKET_COMPUTER_NORMAL ) + .shaped( RecipeCategory.REDSTONE, Registry.ModItems.POCKET_COMPUTER_NORMAL ) .pattern( "###" ) .pattern( "#A#" ) .pattern( "#G#" ) @@ -249,7 +248,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModItems.POCKET_COMPUTER_ADVANCED ) + .shaped( RecipeCategory.REDSTONE, Registry.ModItems.POCKET_COMPUTER_ADVANCED ) .pattern( "###" ) .pattern( "#A#" ) .pattern( "#G#" ) @@ -261,7 +260,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.PRINTER ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.PRINTER ) .pattern( "###" ) .pattern( "#R#" ) .pattern( "#D#" ) @@ -272,7 +271,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.SPEAKER ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.SPEAKER ) .pattern( "###" ) .pattern( "#N#" ) .pattern( "#R#" ) @@ -283,7 +282,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModItems.WIRED_MODEM ) + .shaped( RecipeCategory.REDSTONE, Registry.ModItems.WIRED_MODEM ) .pattern( "###" ) .pattern( "#R#" ) .pattern( "###" ) @@ -294,18 +293,18 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapelessRecipeBuilder - .shapeless( Registry.ModBlocks.WIRED_MODEM_FULL ) + .shapeless( RecipeCategory.REDSTONE, Registry.ModBlocks.WIRED_MODEM_FULL ) .requires( Registry.ModItems.WIRED_MODEM ) .unlockedBy( "has_modem", inventoryChange( WIRED_MODEM ) ) .save( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_from" ) ); ShapelessRecipeBuilder - .shapeless( Registry.ModItems.WIRED_MODEM ) + .shapeless( RecipeCategory.REDSTONE, Registry.ModItems.WIRED_MODEM ) .requires( Registry.ModBlocks.WIRED_MODEM_FULL ) .unlockedBy( "has_modem", inventoryChange( WIRED_MODEM ) ) .save( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_to" ) ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.WIRELESS_MODEM_NORMAL ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.WIRELESS_MODEM_NORMAL ) .pattern( "###" ) .pattern( "#E#" ) .pattern( "###" ) @@ -315,7 +314,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapedRecipeBuilder - .shaped( Registry.ModBlocks.WIRELESS_MODEM_ADVANCED ) + .shaped( RecipeCategory.REDSTONE, Registry.ModBlocks.WIRELESS_MODEM_ADVANCED ) .pattern( "###" ) .pattern( "#E#" ) .pattern( "###" ) @@ -326,7 +325,7 @@ private void basicRecipes( @Nonnull Consumer add ) .save( add ); ShapelessRecipeBuilder - .shapeless( Items.PLAYER_HEAD ) + .shapeless( RecipeCategory.REDSTONE, Items.PLAYER_HEAD ) .requires( ExtraConventionalItemTags.SKULLS ) .requires( Registry.ModItems.MONITOR_NORMAL ) .unlockedBy( "has_monitor", inventoryChange( Registry.ModItems.MONITOR_NORMAL ) ) @@ -336,7 +335,7 @@ private void basicRecipes( @Nonnull Consumer add ) ); ShapelessRecipeBuilder - .shapeless( Items.PLAYER_HEAD ) + .shapeless( RecipeCategory.REDSTONE, Items.PLAYER_HEAD ) .requires( ExtraConventionalItemTags.SKULLS ) .requires( Registry.ModItems.COMPUTER_NORMAL ) .unlockedBy( "has_computer", inventoryChange( Registry.ModItems.COMPUTER_NORMAL ) ) @@ -346,14 +345,14 @@ private void basicRecipes( @Nonnull Consumer add ) ); ShapelessRecipeBuilder - .shapeless( Registry.ModItems.PRINTED_PAGES ) + .shapeless( RecipeCategory.REDSTONE, Registry.ModItems.PRINTED_PAGES ) .requires( Registry.ModItems.PRINTED_PAGE, 2 ) .requires( Items.STRING ) .unlockedBy( "has_printer", inventoryChange( Registry.ModBlocks.PRINTER ) ) .save( RecipeWrapper.wrap( ImpostorShapelessRecipe.SERIALIZER, add ) ); ShapelessRecipeBuilder - .shapeless( Registry.ModItems.PRINTED_BOOK ) + .shapeless( RecipeCategory.REDSTONE, Registry.ModItems.PRINTED_BOOK ) .requires( Items.LEATHER ) .requires( Registry.ModItems.PRINTED_PAGE, 1 ) .requires( Items.STRING ) @@ -387,9 +386,9 @@ private static CompoundTag playerHead( String name, String uuid ) return tag; } - private static void addSpecial( Consumer add, SimpleRecipeSerializer special ) + private static void addSpecial( Consumer add, SimpleCraftingRecipeSerializer special ) { - var key = net.minecraft.core.Registry.RECIPE_SERIALIZER.getKey( special ); + var key = BuiltInRegistries.RECIPE_SERIALIZER.getKey( special ); SpecialRecipeBuilder.special( special ).save( add, key.toString() ); } } diff --git a/src/main/java/dan200/computercraft/fabric/mixin/MixinGameRenderer.java b/src/main/java/dan200/computercraft/fabric/mixin/MixinGameRenderer.java index 1165cff70..85c00e1d5 100644 --- a/src/main/java/dan200/computercraft/fabric/mixin/MixinGameRenderer.java +++ b/src/main/java/dan200/computercraft/fabric/mixin/MixinGameRenderer.java @@ -11,7 +11,7 @@ import dan200.computercraft.client.render.RenderTypes; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.ShaderInstance; -import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.ResourceProvider; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -26,10 +26,10 @@ public class MixinGameRenderer { @Inject( method = "reloadShaders", at = @At( value = "INVOKE_ASSIGN", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 53 ), locals = LocalCapture.CAPTURE_FAILSOFT ) - private void reloadShaders( ResourceManager manager, CallbackInfo info, List list, List>> list2 ) throws IOException + private void reloadShaders( ResourceProvider resourceProvider, CallbackInfo ci, List list, List>> list2 ) throws IOException { list2.add( Pair.of( new MonitorTextureBufferShader( - manager, + resourceProvider, "monitor_tbo", RenderTypes.MONITOR_TBO.format() ), shader -> RenderTypes.monitorTboShader = (MonitorTextureBufferShader) shader ) ); diff --git a/src/main/java/dan200/computercraft/fabric/mixin/MixinItemFrameRenderer.java b/src/main/java/dan200/computercraft/fabric/mixin/MixinItemFrameRenderer.java index 828be8dc8..89ebe7b43 100644 --- a/src/main/java/dan200/computercraft/fabric/mixin/MixinItemFrameRenderer.java +++ b/src/main/java/dan200/computercraft/fabric/mixin/MixinItemFrameRenderer.java @@ -28,7 +28,7 @@ public class MixinItemFrameRenderer method = "render", at = @At( value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/PoseStack;mulPose(Lcom/mojang/math/Quaternion;)V", + target = "Lcom/mojang/blaze3d/vertex/PoseStack;mulPose(Lorg/joml/Quaternionf;)V", ordinal = 2, shift = At.Shift.AFTER ), diff --git a/src/main/java/dan200/computercraft/fabric/mixin/MixinMatrix4f.java b/src/main/java/dan200/computercraft/fabric/mixin/MixinMatrix4f.java deleted file mode 100644 index 0aa216dae..000000000 --- a/src/main/java/dan200/computercraft/fabric/mixin/MixinMatrix4f.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package dan200.computercraft.fabric.mixin; - -import com.mojang.math.Matrix4f; -import dan200.computercraft.fabric.mixininterface.IMatrix4f; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin( Matrix4f.class ) -public class MixinMatrix4f implements IMatrix4f -{ - @Shadow - protected float m00; - @Shadow - protected float m01; - @Shadow - protected float m02; - @Shadow - protected float m03; - @Shadow - protected float m10; - @Shadow - protected float m11; - @Shadow - protected float m12; - @Shadow - protected float m13; - @Shadow - protected float m20; - @Shadow - protected float m21; - @Shadow - protected float m22; - @Shadow - protected float m23; - @Shadow - protected float m30; - @Shadow - protected float m31; - @Shadow - protected float m32; - @Shadow - protected float m33; - - @Override - public void setFloatArray( float[] values ) - { - m00 = values[0]; - m01 = values[1]; - m02 = values[2]; - m03 = values[3]; - m10 = values[4]; - m11 = values[5]; - m12 = values[6]; - m13 = values[7]; - m20 = values[8]; - m21 = values[9]; - m22 = values[10]; - m23 = values[11]; - m30 = values[12]; - m31 = values[13]; - m32 = values[14]; - m33 = values[15]; - } -} diff --git a/src/main/java/dan200/computercraft/shared/Registry.java b/src/main/java/dan200/computercraft/shared/Registry.java index 453685261..014e76b89 100644 --- a/src/main/java/dan200/computercraft/shared/Registry.java +++ b/src/main/java/dan200/computercraft/shared/Registry.java @@ -48,10 +48,12 @@ import dan200.computercraft.shared.turtle.upgrades.TurtleModem; import dan200.computercraft.shared.turtle.upgrades.TurtleSpeaker; import dan200.computercraft.shared.turtle.upgrades.TurtleTool; -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; +import dan200.computercraft.shared.util.Colour; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.minecraft.core.BlockPos; import net.minecraft.core.cauldron.CauldronInteraction; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; @@ -67,7 +69,6 @@ import java.util.function.BiFunction; -import static net.minecraft.core.Registry.BLOCK_ENTITY_TYPE; public final class Registry { @@ -95,7 +96,7 @@ public static final class ModBlocks { public static T register( String id, T value ) { - return net.minecraft.core.Registry.register( net.minecraft.core.Registry.BLOCK, new ResourceLocation( MOD_ID, id ), value ); + return net.minecraft.core.Registry.register( BuiltInRegistries.BLOCK, new ResourceLocation( MOD_ID, id ), value ); } public static final BlockMonitor MONITOR_NORMAL = @@ -167,7 +168,7 @@ public static class ModBlockEntities private static BlockEntityType ofBlock( Block block, String id, BiFunction factory ) { BlockEntityType blockEntityType = FabricBlockEntityTypeBuilder.create( factory::apply, block ).build(); - return net.minecraft.core.Registry.register( BLOCK_ENTITY_TYPE, new ResourceLocation( MOD_ID, id ), blockEntityType ); + return net.minecraft.core.Registry.register( BuiltInRegistries.BLOCK_ENTITY_TYPE, new ResourceLocation( MOD_ID, id ), blockEntityType ); } public static final BlockEntityType MONITOR_NORMAL = @@ -215,11 +216,6 @@ private static BlockEntityType ofBlock( Block block, public static final class ModItems { - private static final CreativeModeTab mainItemGroup = FabricItemGroupBuilder.build( - new ResourceLocation( MOD_ID, "main" ), - () -> new ItemStack( ModBlocks.COMPUTER_NORMAL ) - ).setRecipeFolderName( MOD_ID ); - public static final ItemComputer COMPUTER_NORMAL = ofBlock( ModBlocks.COMPUTER_NORMAL, ItemComputer::new ); @@ -286,20 +282,69 @@ public static final class ModItems public static final ItemBlockCable.WiredModem WIRED_MODEM = register( "wired_modem", new ItemBlockCable.WiredModem( ModBlocks.CABLE, properties() ) ); + private static final CreativeModeTab mainItemGroup = FabricItemGroup.builder( new ResourceLocation( MOD_ID, "main" ) ) + .icon( () -> new ItemStack( ModBlocks.COMPUTER_NORMAL ) ) + .displayItems( ( featureFlagSet, output, operator ) -> { + output.accept( COMPUTER_NORMAL ); + output.accept( COMPUTER_ADVANCED ); + + if ( operator ) + { + output.accept( COMPUTER_COMMAND ); + } + + output.accept( POCKET_COMPUTER_NORMAL.create( -1, null, -1, null ) ); + dan200.computercraft.shared.PocketUpgrades.getVanillaUpgrades().map( x -> POCKET_COMPUTER_NORMAL.create( -1, null, -1, x ) ).forEach( output::accept ); + + output.accept( POCKET_COMPUTER_ADVANCED.create( -1, null, -1, null ) ); + dan200.computercraft.shared.PocketUpgrades.getVanillaUpgrades().map( x -> POCKET_COMPUTER_ADVANCED.create( -1, null, -1, x ) ).forEach( output::accept ); + + + output.accept( TURTLE_NORMAL.create( -1, null, -1, null, null, 0, null ) ); + dan200.computercraft.shared.TurtleUpgrades.getVanillaUpgrades() + .map( x -> TURTLE_NORMAL.create( -1, null, -1, null, x, 0, null ) ) + .forEach( output::accept ); + + output.accept( TURTLE_ADVANCED.create( -1, null, -1, null, null, 0, null ) ); + dan200.computercraft.shared.TurtleUpgrades.getVanillaUpgrades() + .map( x -> TURTLE_ADVANCED.create( -1, null, -1, null, x, 0, null ) ) + .forEach( output::accept ); + + for( int colour = 0; colour < 16; colour++ ) + { + output.accept( DISK.createFromIDAndColour( -1, null, Colour.VALUES[colour].getHex() ) ); + } + + output.accept( PRINTED_PAGE ); + output.accept( PRINTED_PAGES ); + output.accept( PRINTED_BOOK ); + + output.accept( SPEAKER ); + output.accept( DISK_DRIVE ); + output.accept( PRINTER ); + output.accept( MONITOR_NORMAL ); + output.accept( MONITOR_ADVANCED ); + output.accept( WIRELESS_MODEM_NORMAL ); + output.accept( WIRELESS_MODEM_ADVANCED ); + output.accept( WIRED_MODEM_FULL ); + output.accept( WIRED_MODEM ); + output.accept( CABLE ); + } ) + .build(); private static I ofBlock( B parent, BiFunction supplier ) { - return net.minecraft.core.Registry.register( net.minecraft.core.Registry.ITEM, net.minecraft.core.Registry.BLOCK.getKey( parent ), supplier.apply( parent, properties() ) ); + return net.minecraft.core.Registry.register( BuiltInRegistries.ITEM, BuiltInRegistries.BLOCK.getKey( parent ), supplier.apply( parent, properties() ) ); } private static Item.Properties properties() { - return new Item.Properties().tab( mainItemGroup ); + return new Item.Properties(); } private static T register( String id, T item ) { - return net.minecraft.core.Registry.register( net.minecraft.core.Registry.ITEM, new ResourceLocation( MOD_ID, id ), item ); + return net.minecraft.core.Registry.register( BuiltInRegistries.ITEM, new ResourceLocation( MOD_ID, id ), item ); } } @@ -331,7 +376,7 @@ public static class ModContainers private static MenuType registerSimple( String id, MenuType.MenuSupplier function ) { - return net.minecraft.core.Registry.register( net.minecraft.core.Registry.MENU, new ResourceLocation( MOD_ID, id ), new MenuType( function ) ); + return net.minecraft.core.Registry.register( BuiltInRegistries.MENU, new ResourceLocation( MOD_ID, id ), new MenuType( function ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/command/arguments/ArgumentSerializers.java b/src/main/java/dan200/computercraft/shared/command/arguments/ArgumentSerializers.java index 11c25c330..0c5df8d9c 100644 --- a/src/main/java/dan200/computercraft/shared/command/arguments/ArgumentSerializers.java +++ b/src/main/java/dan200/computercraft/shared/command/arguments/ArgumentSerializers.java @@ -10,7 +10,7 @@ import dan200.computercraft.fabric.mixin.ArgumentTypeInfosAccessor; import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.SingletonArgumentInfo; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; public final class ArgumentSerializers @@ -18,17 +18,17 @@ public final class ArgumentSerializers @SuppressWarnings( "unchecked" ) private static > void registerUnsafe( ResourceLocation id, Class type, ArgumentTypeInfo serializer ) { - ArgumentTypeInfosAccessor.callRegister( Registry.COMMAND_ARGUMENT_TYPE, id.toString(), type, serializer ); + ArgumentTypeInfosAccessor.callRegister( BuiltInRegistries.COMMAND_ARGUMENT_TYPE, id.toString(), type, serializer ); } private static > void register( ResourceLocation id, Class type, ArgumentTypeInfo serializer ) { - ArgumentTypeInfosAccessor.callRegister( Registry.COMMAND_ARGUMENT_TYPE, id.toString(), type, serializer ); + ArgumentTypeInfosAccessor.callRegister( BuiltInRegistries.COMMAND_ARGUMENT_TYPE, id.toString(), type, serializer ); } private static > void register( ResourceLocation id, T instance ) { - ArgumentTypeInfosAccessor.callRegister( Registry.COMMAND_ARGUMENT_TYPE, id.toString(), instance.getClass(), SingletonArgumentInfo.contextFree( () -> instance ) ); + ArgumentTypeInfosAccessor.callRegister( BuiltInRegistries.COMMAND_ARGUMENT_TYPE, id.toString(), instance.getClass(), SingletonArgumentInfo.contextFree( () -> instance ) ); } public static void register() diff --git a/src/main/java/dan200/computercraft/shared/command/arguments/RepeatArgumentType.java b/src/main/java/dan200/computercraft/shared/command/arguments/RepeatArgumentType.java index 8b1d27ed9..be5ee1500 100644 --- a/src/main/java/dan200/computercraft/shared/command/arguments/RepeatArgumentType.java +++ b/src/main/java/dan200/computercraft/shared/command/arguments/RepeatArgumentType.java @@ -17,7 +17,7 @@ import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -134,7 +134,7 @@ public static class Serializer implements ArgumentTypeInfo getSerializer() return SERIALIZER; } - public static final SimpleRecipeSerializer SERIALIZER = new SimpleRecipeSerializer<>( ColourableRecipe::new ); + public static final SimpleCraftingRecipeSerializer SERIALIZER = new SimpleCraftingRecipeSerializer<>( ColourableRecipe::new ); } diff --git a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java index 742aeef06..193bfd73b 100644 --- a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java +++ b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java @@ -16,7 +16,7 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; @@ -278,7 +278,7 @@ private Level getLevel( @Nonnull Optional id ) throws LuaException ResourceLocation dimensionId = ResourceLocation.tryParse( id.get() ); if( dimensionId == null ) throw new LuaException( "Invalid dimension name" ); - Level level = currentLevel.getServer().getLevel( ResourceKey.create( Registry.DIMENSION_REGISTRY, dimensionId ) ); + Level level = currentLevel.getServer().getLevel( ResourceKey.create( Registries.DIMENSION, dimensionId ) ); if( level == null ) throw new LuaException( "Unknown dimension" ); return level; diff --git a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerConvertRecipe.java b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerConvertRecipe.java index 81f1bcf60..948f84be4 100644 --- a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerConvertRecipe.java +++ b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerConvertRecipe.java @@ -10,6 +10,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.level.Level; @@ -25,7 +26,7 @@ public abstract class ComputerConvertRecipe extends ShapedRecipe public ComputerConvertRecipe( ResourceLocation identifier, String group, int width, int height, NonNullList ingredients, ItemStack result ) { - super( identifier, group, width, height, ingredients, result ); + super( identifier, group, CraftingBookCategory.REDSTONE, width, height, ingredients, result ); this.group = group; } diff --git a/src/main/java/dan200/computercraft/shared/integration/ModMenuIntegration.java b/src/main/java/dan200/computercraft/shared/integration/ModMenuIntegration.java index 6db40ecbd..f35c542f7 100644 --- a/src/main/java/dan200/computercraft/shared/integration/ModMenuIntegration.java +++ b/src/main/java/dan200/computercraft/shared/integration/ModMenuIntegration.java @@ -21,10 +21,8 @@ import net.minecraft.client.gui.screens.OptionsSubScreen; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; -import net.minecraft.util.FormattedCharSequence; import java.util.Arrays; -import java.util.List; // A poor mod menu integration just for testing the monitor rendering changes we've been making :) @@ -57,9 +55,9 @@ protected void init() this.addWidget( this.list ); - this.addRenderableWidget( new Button( this.width / 2 - 100, this.height - 27, 200, 20, CommonComponents.GUI_DONE, button -> { + this.addRenderableWidget( Button.builder( CommonComponents.GUI_DONE, button -> { this.minecraft.setScreen( this.lastScreen ); - } ) ); + } ).width( this.width / 2 - 100 ).pos( 200, 20 ).build() ); } @Override @@ -77,8 +75,8 @@ public void render( PoseStack poseStack, int i, int j, float f ) this.list.render( poseStack, i, j, f ); drawCenteredString( poseStack, this.font, this.title, this.width / 2, 20, 16777215 ); super.render( poseStack, i, j, f ); - List list = tooltipAt( this.list, i, j ); - this.renderTooltip( poseStack, list, i, j ); + //List list = tooltipAt( this.list, i, j ); + //this.renderTooltip( poseStack, list, i, j ); } }; }; diff --git a/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java b/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java index 42b41927d..cd77a1558 100644 --- a/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java +++ b/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java @@ -13,10 +13,8 @@ import dan200.computercraft.shared.common.IColouredItem; import dan200.computercraft.shared.util.Colour; import net.minecraft.ChatFormatting; -import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -45,16 +43,6 @@ public static ItemStack createFromIDAndColour( int id, String label, int colour return stack; } - @Override - public void fillItemCategory( @Nonnull CreativeModeTab tabs, @Nonnull NonNullList list ) - { - if( !allowedIn( tabs ) ) return; - for( int colour = 0; colour < 16; colour++ ) - { - list.add( createFromIDAndColour( -1, null, Colour.VALUES[colour].getHex() ) ); - } - } - @Override public void appendHoverText( @Nonnull ItemStack stack, @Nullable Level world, @Nonnull List list, TooltipFlag options ) { diff --git a/src/main/java/dan200/computercraft/shared/media/items/ItemTreasureDisk.java b/src/main/java/dan200/computercraft/shared/media/items/ItemTreasureDisk.java index a27ea4643..58c6a12fb 100644 --- a/src/main/java/dan200/computercraft/shared/media/items/ItemTreasureDisk.java +++ b/src/main/java/dan200/computercraft/shared/media/items/ItemTreasureDisk.java @@ -11,10 +11,8 @@ import dan200.computercraft.core.filesystem.SubMount; import dan200.computercraft.shared.Registry; import dan200.computercraft.shared.util.Colour; -import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -36,11 +34,6 @@ public ItemTreasureDisk( Properties settings ) super( settings ); } - @Override - public void fillItemCategory( @Nonnull CreativeModeTab group, @Nonnull NonNullList stacks ) - { - } - @Override public void appendHoverText( @Nonnull ItemStack stack, @Nullable Level world, @Nonnull List list, @Nonnull TooltipFlag tooltipOptions ) { diff --git a/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java b/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java index 1f6526644..acbb297d2 100644 --- a/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java +++ b/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java @@ -15,10 +15,7 @@ import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.CustomRecipe; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.SimpleRecipeSerializer; +import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; @@ -28,9 +25,9 @@ public class DiskRecipe extends CustomRecipe private final Ingredient paper = Ingredient.of( Items.PAPER ); private final Ingredient redstone = Ingredient.of( ConventionalItemTags.REDSTONE_DUSTS ); - public DiskRecipe( ResourceLocation id ) + public DiskRecipe( ResourceLocation id, CraftingBookCategory category ) { - super( id ); + super( id, category ); } @Override @@ -107,5 +104,5 @@ public RecipeSerializer getSerializer() return SERIALIZER; } - public static final SimpleRecipeSerializer SERIALIZER = new SimpleRecipeSerializer<>( DiskRecipe::new ); + public static final SimpleCraftingRecipeSerializer SERIALIZER = new SimpleCraftingRecipeSerializer<>( DiskRecipe::new ); } diff --git a/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java b/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java index add9e3f3f..574bf54d4 100644 --- a/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java +++ b/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java @@ -10,10 +10,7 @@ import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.CustomRecipe; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.SimpleRecipeSerializer; +import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; @@ -24,9 +21,9 @@ public final class PrintoutRecipe extends CustomRecipe private final Ingredient leather = Ingredient.of( Items.LEATHER ); private final Ingredient string = Ingredient.of( Items.STRING ); - private PrintoutRecipe( ResourceLocation id ) + private PrintoutRecipe( ResourceLocation id, CraftingBookCategory category ) { - super( id ); + super( id, category ); } @Override @@ -160,5 +157,5 @@ public RecipeSerializer getSerializer() return SERIALIZER; } - public static final SimpleRecipeSerializer SERIALIZER = new SimpleRecipeSerializer<>( PrintoutRecipe::new ); + public static final SimpleCraftingRecipeSerializer SERIALIZER = new SimpleCraftingRecipeSerializer( PrintoutRecipe::new ); } diff --git a/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java index a7ea410bd..7091d8b5d 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java @@ -11,7 +11,7 @@ import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvent; @@ -51,7 +51,7 @@ public PlayRecordClientMessage( FriendlyByteBuf buf ) if( buf.readBoolean() ) { name = buf.readUtf( Short.MAX_VALUE ); - soundEvent = Registry.SOUND_EVENT.get( buf.readResourceLocation() ); + soundEvent = BuiltInRegistries.SOUND_EVENT.get( buf.readResourceLocation() ); } else { diff --git a/src/main/java/dan200/computercraft/shared/network/container/ContainerData.java b/src/main/java/dan200/computercraft/shared/network/container/ContainerData.java index a529cc89c..3cc271c7a 100644 --- a/src/main/java/dan200/computercraft/shared/network/container/ContainerData.java +++ b/src/main/java/dan200/computercraft/shared/network/container/ContainerData.java @@ -7,6 +7,7 @@ import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.MenuProvider; @@ -45,7 +46,7 @@ static MenuType to ResourceLocation identifier, Function reader, Factory factory ) { - return Registry.register( Registry.MENU, identifier, new ExtendedScreenHandlerType<>( ( id, playerInventory, packetByteBuf ) -> + return Registry.register( BuiltInRegistries.MENU, identifier, new ExtendedScreenHandlerType<>( ( id, playerInventory, packetByteBuf ) -> factory.create( id, playerInventory, reader.apply( packetByteBuf ) ) ) ); } @@ -54,7 +55,7 @@ static MenuType to ResourceLocation identifier, MenuType type, Function reader, FixedFactory factory ) { - return Registry.register( Registry.MENU, identifier, new ExtendedScreenHandlerType<>( ( id, playerInventory, packetByteBuf ) -> + return Registry.register( BuiltInRegistries.MENU, identifier, new ExtendedScreenHandlerType<>( ( id, playerInventory, packetByteBuf ) -> factory.create( type, id, playerInventory, reader.apply( packetByteBuf ) ) ) ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheral.java index 8a630f9f2..f94264395 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheral.java @@ -12,7 +12,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IDynamicPeripheral; import dan200.computercraft.api.peripheral.IPeripheral; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.entity.BlockEntity; @@ -30,7 +30,7 @@ class GenericPeripheral implements IDynamicPeripheral GenericPeripheral( BlockEntity tile, String name, Set additionalTypes, List methods ) { - ResourceLocation type = Registry.BLOCK_ENTITY_TYPE.getKey( tile.getType() ); + ResourceLocation type = BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey( tile.getType() ); this.tile = tile; this.type = name != null ? name : (type != null ? type.toString() : "unknown"); this.additionalTypes = additionalTypes; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/DataHelpers.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/DataHelpers.java index bb0a51c59..b883af23b 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/DataHelpers.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/DataHelpers.java @@ -6,7 +6,7 @@ package dan200.computercraft.shared.peripheral.generic.data; import net.minecraft.core.Holder; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; @@ -38,21 +38,21 @@ public static Map getTags( @Nonnull Stream> tags @Nullable public static String getId( @Nonnull Block block ) { - ResourceLocation id = Registry.BLOCK.getKey( block ); + ResourceLocation id = BuiltInRegistries.BLOCK.getKey( block ); return id == null ? null : id.toString(); } @Nullable public static String getId( @Nonnull Item item ) { - ResourceLocation id = Registry.ITEM.getKey( item ); + ResourceLocation id = BuiltInRegistries.ITEM.getKey( item ); return id == null ? null : id.toString(); } @Nullable public static String getId( @Nonnull Enchantment enchantment ) { - ResourceLocation id = Registry.ENCHANTMENT.getKey( enchantment ); + ResourceLocation id = BuiltInRegistries.ENCHANTMENT.getKey( enchantment ); return id == null ? null : id.toString(); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/ItemBlockCable.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/ItemBlockCable.java index e3431ef7c..068f2d422 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/ItemBlockCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/ItemBlockCable.java @@ -9,12 +9,11 @@ import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.NonNullList; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; @@ -59,19 +58,13 @@ boolean placeAtCorrected( Level world, BlockPos pos, BlockState state ) return placeAt( world, pos, correctConnections( world, pos, state ), null ); } - @Override - public void fillItemCategory( @Nonnull CreativeModeTab group, @Nonnull NonNullList list ) - { - if( allowedIn( group ) ) list.add( new ItemStack( this ) ); - } - @Nonnull @Override public String getDescriptionId() { if( translationKey == null ) { - translationKey = Util.makeDescriptionId( "block", net.minecraft.core.Registry.ITEM.getKey( this ) ); + translationKey = Util.makeDescriptionId( "block", BuiltInRegistries.ITEM.getKey( this ) ); } return translationKey; } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java index 2f81e2a82..ccee56e70 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java @@ -20,9 +20,11 @@ import dan200.computercraft.shared.util.PauseAwareTimer; import net.minecraft.ResourceLocationException; import net.minecraft.core.BlockPos; -import net.minecraft.network.protocol.game.ClientboundCustomSoundPacket; +import net.minecraft.core.Holder; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; +import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; @@ -84,7 +86,7 @@ public void update() lastPlayTime = clock; server.getPlayerList().broadcast( null, pos.x, pos.y, pos.z, sound.volume * 16, level.dimension(), - new ClientboundCustomSoundPacket( sound.location, SoundSource.RECORDS, pos, sound.volume, sound.pitch, 0 ) + new ClientboundSoundPacket( Holder.direct( SoundEvent.createFixedRangeEvent( sound.location, 16 ) ), SoundSource.RECORDS, pos.x, pos.y, pos.z, sound.volume, sound.pitch, 0 ) ); } pendingNotes.clear(); @@ -236,7 +238,7 @@ public final boolean playNote( ILuaContext context, String instrumentA, Optional synchronized( pendingNotes ) { if( pendingNotes.size() >= ComputerCraft.maxNotesPerTick ) return false; - pendingNotes.add( new PendingSound( instrument.getSoundEvent().getLocation(), volume, (float) Math.pow( 2.0, (pitch - 12.0) / 12.0 ) ) ); + pendingNotes.add( new PendingSound( instrument.getSoundEvent().value().getLocation(), volume, (float) Math.pow( 2.0, (pitch - 12.0) / 12.0 ) ) ); } return true; } diff --git a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java index 89a3327a4..06017a770 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java +++ b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java @@ -23,7 +23,6 @@ import dan200.computercraft.shared.pocket.core.PocketServerComputer; import dan200.computercraft.shared.pocket.inventory.PocketComputerMenuProvider; import net.minecraft.ChatFormatting; -import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.Container; @@ -33,7 +32,6 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -71,14 +69,6 @@ public ItemStack create( int id, String label, int colour, IPocketUpgrade upgrad return result; } - @Override - public void fillItemCategory( @Nonnull CreativeModeTab group, @Nonnull NonNullList stacks ) - { - if( !allowedIn( group ) ) return; - stacks.add( create( -1, null, -1, null ) ); - PocketUpgrades.getVanillaUpgrades().map( x -> create( -1, null, -1, x ) ).forEach( stacks::add ); - } - private boolean tick( @Nonnull ItemStack stack, @Nonnull Level world, @Nonnull Entity entity, @Nonnull PocketServerComputer computer ) { IPocketUpgrade upgrade = getUpgrade( stack ); diff --git a/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java b/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java index 5ed614e10..48efe77e7 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java +++ b/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java @@ -13,18 +13,19 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.CustomRecipe; import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.SimpleRecipeSerializer; +import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; public final class PocketComputerUpgradeRecipe extends CustomRecipe { - private PocketComputerUpgradeRecipe( ResourceLocation identifier ) + private PocketComputerUpgradeRecipe( ResourceLocation identifier, CraftingBookCategory category ) { - super( identifier ); + super( identifier, category ); } @Override @@ -113,5 +114,5 @@ public RecipeSerializer getSerializer() return SERIALIZER; } - public static final SimpleRecipeSerializer SERIALIZER = new SimpleRecipeSerializer<>( PocketComputerUpgradeRecipe::new ); + public static final SimpleCraftingRecipeSerializer SERIALIZER = new SimpleCraftingRecipeSerializer<>( PocketComputerUpgradeRecipe::new ); } diff --git a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java index 4255b5148..2b0e117a1 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java @@ -42,6 +42,7 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.packs.PackType; @@ -168,6 +169,6 @@ public static void registerLoot() private static void registerCondition( String name, LootItemConditionType serializer ) { - Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, name ), serializer ); + Registry.register( BuiltInRegistries.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, name ), serializer ); } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtle.java index 5801dc2f3..215a1d810 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtle.java @@ -12,13 +12,11 @@ import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.items.ItemComputerBase; import dan200.computercraft.shared.turtle.blocks.BlockTurtle; -import net.minecraft.core.NonNullList; import net.minecraft.core.cauldron.CauldronInteraction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResult; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.LayeredCauldronBlock; @@ -56,19 +54,6 @@ public ItemStack create( int id, String label, int colour, ITurtleUpgrade leftUp return stack; } - @Override - public void fillItemCategory( @Nonnull CreativeModeTab group, @Nonnull NonNullList list ) - { - if( !allowedIn( group ) ) return; - - ComputerFamily family = getFamily(); - - list.add( create( -1, null, -1, null, null, 0, null ) ); - TurtleUpgrades.getVanillaUpgrades() - .map( x -> create( -1, null, -1, null, x, 0, null ) ) - .forEach( list::add ); - } - @Nonnull @Override public Component getName( @Nonnull ItemStack stack ) diff --git a/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java b/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java index 3f5d11c1c..0452c9763 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java +++ b/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java @@ -14,18 +14,19 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.CustomRecipe; import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.SimpleRecipeSerializer; +import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; public final class TurtleUpgradeRecipe extends CustomRecipe { - private TurtleUpgradeRecipe( ResourceLocation id ) + private TurtleUpgradeRecipe( ResourceLocation id, CraftingBookCategory category ) { - super( id ); + super( id, category ); } @Override @@ -174,5 +175,5 @@ public RecipeSerializer getSerializer() return SERIALIZER; } - public static final SimpleRecipeSerializer SERIALIZER = new SimpleRecipeSerializer<>( TurtleUpgradeRecipe::new ); + public static final SimpleCraftingRecipeSerializer SERIALIZER = new SimpleCraftingRecipeSerializer<>( TurtleUpgradeRecipe::new ); } diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleCraftingTable.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleCraftingTable.java index afcdf97b7..274bd4e46 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleCraftingTable.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleCraftingTable.java @@ -24,8 +24,8 @@ public class TurtleCraftingTable extends AbstractTurtleUpgrade @Environment( EnvType.CLIENT ) private static class Models { - private static final ModelResourceLocation leftModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_left", "inventory" ); - private static final ModelResourceLocation rightModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_right", "inventory" ); + private static final ModelResourceLocation leftModel = new ModelResourceLocation( "computercraft", "turtle_crafting_table_left", "inventory" ); + private static final ModelResourceLocation rightModel = new ModelResourceLocation( "computercraft", "turtle_crafting_table_right", "inventory" ); } public TurtleCraftingTable( ResourceLocation id, ItemStack stack ) diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java index e98e335c4..6946bc609 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java @@ -65,20 +65,20 @@ public boolean equals( IPeripheral other ) private class Models { private final ModelResourceLocation leftOffModel = advanced ? - new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_left", "inventory" ) : - new ModelResourceLocation( "computercraft:turtle_modem_normal_off_left", "inventory" ); + new ModelResourceLocation( "computercraft", "turtle_modem_advanced_off_left", "inventory" ) : + new ModelResourceLocation( "computercraft", "turtle_modem_normal_off_left", "inventory" ); private final ModelResourceLocation rightOffModel = advanced ? - new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_right", "inventory" ) : - new ModelResourceLocation( "computercraft:turtle_modem_normal_off_right", "inventory" ); + new ModelResourceLocation( "computercraft", "turtle_modem_advanced_off_right", "inventory" ) : + new ModelResourceLocation( "computercraft", "turtle_modem_normal_off_right", "inventory" ); private final ModelResourceLocation leftOnModel = advanced ? - new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_left", "inventory" ) : - new ModelResourceLocation( "computercraft:turtle_modem_normal_on_left", "inventory" ); + new ModelResourceLocation( "computercraft", "turtle_modem_advanced_on_left", "inventory" ) : + new ModelResourceLocation( "computercraft", "turtle_modem_normal_on_left", "inventory" ); private final ModelResourceLocation rightOnModel = advanced ? - new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_right", "inventory" ) : - new ModelResourceLocation( "computercraft:turtle_modem_normal_on_right", "inventory" ); + new ModelResourceLocation( "computercraft", "turtle_modem_advanced_on_right", "inventory" ) : + new ModelResourceLocation( "computercraft", "turtle_modem_normal_on_right", "inventory" ); } private final boolean advanced; diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java index ccd33ca88..579cc12d2 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java @@ -27,8 +27,8 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade @Environment( EnvType.CLIENT ) private static class Models { - private static ModelResourceLocation leftModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_left", "inventory" ); - private static ModelResourceLocation rightModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_right", "inventory" ); + private static ModelResourceLocation leftModel = new ModelResourceLocation( "computercraft", "turtle_speaker_upgrade_left", "inventory" ); + private static ModelResourceLocation rightModel = new ModelResourceLocation( "computercraft", "turtle_speaker_upgrade_right", "inventory" ); } private static class Peripheral extends UpgradeSpeakerPeripheral diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java index df049d5b1..bfb14abe0 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java @@ -5,13 +5,11 @@ */ package dan200.computercraft.shared.turtle.upgrades; -import com.mojang.math.Matrix4f; import com.mojang.math.Transformation; import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.ComputerCraftTags; import dan200.computercraft.api.client.TransformedModel; import dan200.computercraft.api.turtle.*; -import dan200.computercraft.fabric.mixininterface.IMatrix4f; import dan200.computercraft.shared.TurtlePermissions; import dan200.computercraft.shared.turtle.core.TurtleBrain; import dan200.computercraft.shared.turtle.core.TurtlePlaceCommand; @@ -46,6 +44,7 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.Vec3; import org.apache.commons.lang3.tuple.Pair; +import org.joml.Matrix4f; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -95,7 +94,8 @@ public boolean isItemSuitable( @Nonnull ItemStack stack ) @Environment( EnvType.CLIENT ) public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side ) { - return TransformedModel.of( getCraftingItem(), side == TurtleSide.LEFT ? Transforms.leftTransform : Transforms.rightTransform ); + // Not sure why it is required. Most likely bug somewhere else bug I'm bad at rendering. ~Patbox + return TransformedModel.of( getCraftingItem(), side == TurtleSide.LEFT ? (turtle == null ? Transforms.leftTransformGui : Transforms.leftTransform) : (turtle == null ? Transforms.rightTransformGui : Transforms.rightTransform) ); } @Nonnull @@ -281,18 +281,25 @@ private static void stopConsuming( BlockEntity tile, ITurtleAccess turtle ) private static class Transforms { - static final Transformation leftTransform = getMatrixFor( -0.40625f ); - static final Transformation rightTransform = getMatrixFor( 0.40625f ); + static final Transformation leftTransformGui = getMatrixFor( -0.40625f, false ); + static final Transformation rightTransformGui = getMatrixFor( 0.40625f, false ); + static final Transformation leftTransform = getMatrixFor( -0.40625f, true ); + static final Transformation rightTransform = getMatrixFor( 0.40625f, true ); - private static Transformation getMatrixFor( float offset ) + private static Transformation getMatrixFor( float offset, boolean inWorld ) { Matrix4f matrix = new Matrix4f(); - ((IMatrix4f) (Object) matrix).setFloatArray( new float[] { + + float[] floats = new float[] { 0.0f, 0.0f, -1.0f, 1.0f + offset, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, - } ); + }; + + if ( inWorld ) matrix.setTransposed( floats ); + else matrix.set( floats ); + return new Transformation( matrix ); } } diff --git a/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java b/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java index 8eeab96bd..095f833b6 100644 --- a/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java +++ b/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java @@ -12,6 +12,7 @@ import net.minecraft.util.GsonHelper; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.ShapedRecipe; @@ -25,7 +26,7 @@ public final class ImpostorRecipe extends ShapedRecipe private ImpostorRecipe( @Nonnull ResourceLocation id, @Nonnull String group, int width, int height, NonNullList ingredients, @Nonnull ItemStack result ) { - super( id, group, width, height, ingredients, result ); + super( id, group, CraftingBookCategory.MISC, width, height, ingredients, result ); this.group = group; } diff --git a/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java b/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java index 23fe10481..56678ee49 100644 --- a/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java +++ b/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java @@ -14,10 +14,7 @@ import net.minecraft.util.GsonHelper; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.ShapedRecipe; -import net.minecraft.world.item.crafting.ShapelessRecipe; +import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; import javax.annotation.Nonnull; @@ -28,7 +25,7 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe private ImpostorShapelessRecipe( @Nonnull ResourceLocation id, @Nonnull String group, @Nonnull ItemStack result, NonNullList ingredients ) { - super( id, group, result, ingredients ); + super( id, group, CraftingBookCategory.REDSTONE, result, ingredients ); this.group = group; } diff --git a/src/main/resources/computercraft.mixins.json b/src/main/resources/computercraft.mixins.json index 8ecc5dd7d..c73bcdc98 100644 --- a/src/main/resources/computercraft.mixins.json +++ b/src/main/resources/computercraft.mixins.json @@ -10,7 +10,6 @@ "MixinChunkMap", "MixinEntity", "MixinItemEntity", - "MixinMatrix4f", "MixinServerLevel", "MixinServerPlayerGameMode" ], diff --git a/src/test/java/dan200/computercraft/core/filesystem/ResourceMountTest.java b/src/test/java/dan200/computercraft/core/filesystem/ResourceMountTest.java index daf93b599..26493db11 100644 --- a/src/test/java/dan200/computercraft/core/filesystem/ResourceMountTest.java +++ b/src/test/java/dan200/computercraft/core/filesystem/ResourceMountTest.java @@ -7,15 +7,15 @@ import dan200.computercraft.api.filesystem.IMount; import net.minecraft.Util; -import net.minecraft.server.packs.FolderPackResources; import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.PathPackResources; import net.minecraft.server.packs.resources.ReloadableResourceManager; import net.minecraft.util.Unit; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -34,7 +34,7 @@ public void before() ReloadableResourceManager manager = new ReloadableResourceManager( PackType.SERVER_DATA ); CompletableFuture done = new CompletableFuture<>(); manager.createReload( Util.backgroundExecutor(), Util.backgroundExecutor(), done, List.of( - new FolderPackResources( new File( "src/main/resources" ) ) + new PathPackResources( "computercraft_test", Paths.get( "src/main/resources" ), false ) ) ); mount = ResourceMount.get( "computercraft", "lua/rom", manager );