mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 05:33:00 +00:00 
			
		
		
		
	attempt to use mojmap
currently does not compile
This commit is contained in:
		| @@ -29,9 +29,9 @@ repositories { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| loom { | //loom { | ||||||
|     accessWidenerPath = file("src/main/resources/cc.accesswidener") | //    accessWidenerPath = file("src/main/resources/cc.accesswidener") | ||||||
| } | //} | ||||||
|  |  | ||||||
| configurations { | configurations { | ||||||
|     implementation.extendsFrom shade |     implementation.extendsFrom shade | ||||||
| @@ -41,7 +41,8 @@ dependencies { | |||||||
|     checkstyle 'com.puppycrawl.tools:checkstyle:8.45.1' |     checkstyle 'com.puppycrawl.tools:checkstyle:8.45.1' | ||||||
|  |  | ||||||
|     minecraft "com.mojang:minecraft:${mc_version}" |     minecraft "com.mojang:minecraft:${mc_version}" | ||||||
|     mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}:v2" |     //mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}:v2" | ||||||
|  |     mappings(minecraft.officialMojangMappings()) | ||||||
|     modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" |     modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" | ||||||
|     modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}" |     modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ mod_version=1.97.2 | |||||||
|  |  | ||||||
| # Minecraft properties | # Minecraft properties | ||||||
| mc_version=1.17.1 | mc_version=1.17.1 | ||||||
| mappings_version=61 | #mappings_version=61 | ||||||
|  |  | ||||||
| # Dependencies | # Dependencies | ||||||
| cloth_config_version=5.0.34 | cloth_config_version=5.0.34 | ||||||
|   | |||||||
| @@ -31,10 +31,10 @@ import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; | |||||||
| import net.fabricmc.fabric.api.resource.ResourceManagerHelper; | import net.fabricmc.fabric.api.resource.ResourceManagerHelper; | ||||||
| import net.fabricmc.fabric.api.resource.ResourcePackActivationType; | import net.fabricmc.fabric.api.resource.ResourcePackActivationType; | ||||||
| import net.fabricmc.loader.api.FabricLoader; | import net.fabricmc.loader.api.FabricLoader; | ||||||
| import net.minecraft.item.ItemGroup; | import net.minecraft.core.Registry; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.world.item.CreativeModeTab; | ||||||
| import net.minecraft.util.registry.Registry; | import net.minecraft.world.item.ItemStack; | ||||||
| import org.apache.logging.log4j.LogManager; | import org.apache.logging.log4j.LogManager; | ||||||
| import org.apache.logging.log4j.Logger; | import org.apache.logging.log4j.Logger; | ||||||
|  |  | ||||||
| @@ -111,30 +111,30 @@ public final class ComputerCraft implements ModInitializer | |||||||
|     // Logging |     // Logging | ||||||
|     public static final Logger log = LogManager.getLogger( MOD_ID ); |     public static final Logger log = LogManager.getLogger( MOD_ID ); | ||||||
|  |  | ||||||
|     public static ItemGroup MAIN_GROUP = FabricItemGroupBuilder.build( new Identifier( MOD_ID, "main" ), () -> new ItemStack( ModBlocks.COMPUTER_NORMAL ) ); |     public static CreativeModeTab MAIN_GROUP = FabricItemGroupBuilder.build( new ResourceLocation( MOD_ID, "main" ), () -> new ItemStack( ModBlocks.COMPUTER_NORMAL ) ); | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onInitialize() |     public void onInitialize() | ||||||
|     { |     { | ||||||
|         ComputerCraftProxyCommon.init(); |         ComputerCraftProxyCommon.init(); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, new Identifier( ComputerCraft.MOD_ID, "colour" ), ColourableRecipe.SERIALIZER ); |         Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "colour" ), ColourableRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, new Identifier( ComputerCraft.MOD_ID, "computer_upgrade" ), ComputerUpgradeRecipe.SERIALIZER ); |         Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "computer_upgrade" ), ComputerUpgradeRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, |         Registry.register( Registry.RECIPE_SERIALIZER, | ||||||
|             new Identifier( ComputerCraft.MOD_ID, "pocket_computer_upgrade" ), |             new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer_upgrade" ), | ||||||
|             PocketComputerUpgradeRecipe.SERIALIZER ); |             PocketComputerUpgradeRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, new Identifier( ComputerCraft.MOD_ID, "disk" ), DiskRecipe.SERIALIZER ); |         Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "disk" ), DiskRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, new Identifier( ComputerCraft.MOD_ID, "printout" ), PrintoutRecipe.SERIALIZER ); |         Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "printout" ), PrintoutRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, new Identifier( ComputerCraft.MOD_ID, "turtle" ), TurtleRecipe.SERIALIZER ); |         Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), TurtleRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, new Identifier( ComputerCraft.MOD_ID, "turtle_upgrade" ), TurtleUpgradeRecipe.SERIALIZER ); |         Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "turtle_upgrade" ), TurtleUpgradeRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, new Identifier( ComputerCraft.MOD_ID, "impostor_shaped" ), ImpostorRecipe.SERIALIZER ); |         Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shaped" ), ImpostorRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.RECIPE_SERIALIZER, new Identifier( ComputerCraft.MOD_ID, "impostor_shapeless" ), ImpostorShapelessRecipe.SERIALIZER ); |         Registry.register( Registry.RECIPE_SERIALIZER, new ResourceLocation( ComputerCraft.MOD_ID, "impostor_shapeless" ), ImpostorShapelessRecipe.SERIALIZER ); | ||||||
|         Registry.register( Registry.LOOT_CONDITION_TYPE, new Identifier( ComputerCraft.MOD_ID, "block_named" ), BlockNamedEntityLootCondition.TYPE ); |         Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "block_named" ), BlockNamedEntityLootCondition.TYPE ); | ||||||
|         Registry.register( Registry.LOOT_CONDITION_TYPE, new Identifier( ComputerCraft.MOD_ID, "player_creative" ), PlayerCreativeLootCondition.TYPE ); |         Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "player_creative" ), PlayerCreativeLootCondition.TYPE ); | ||||||
|         Registry.register( Registry.LOOT_CONDITION_TYPE, new Identifier( ComputerCraft.MOD_ID, "has_id" ), HasComputerIdLootCondition.TYPE ); |         Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, "has_id" ), HasComputerIdLootCondition.TYPE ); | ||||||
|         init(); |         init(); | ||||||
|         FabricLoader.getInstance().getModContainer( MOD_ID ).ifPresent( modContainer -> { |         FabricLoader.getInstance().getModContainer( MOD_ID ).ifPresent( modContainer -> { | ||||||
|             ResourceManagerHelper.registerBuiltinResourcePack( new Identifier( MOD_ID, "classic" ), modContainer, ResourcePackActivationType.NORMAL ); |             ResourceManagerHelper.registerBuiltinResourcePack( new ResourceLocation( MOD_ID, "classic" ), modContainer, ResourcePackActivationType.NORMAL ); | ||||||
|             ResourceManagerHelper.registerBuiltinResourcePack( new Identifier( MOD_ID, "overhaul" ), modContainer, ResourcePackActivationType.NORMAL ); |             ResourceManagerHelper.registerBuiltinResourcePack( new ResourceLocation( MOD_ID, "overhaul" ), modContainer, ResourcePackActivationType.NORMAL ); | ||||||
|         } ); |         } ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -32,15 +32,14 @@ import dan200.computercraft.shared.util.IDAssigner; | |||||||
| import dan200.computercraft.shared.wired.WiredNode; | import dan200.computercraft.shared.wired.WiredNode; | ||||||
| import me.shedaniel.cloth.api.utils.v1.GameInstanceUtils; | import me.shedaniel.cloth.api.utils.v1.GameInstanceUtils; | ||||||
| import net.fabricmc.loader.api.FabricLoader; | import net.fabricmc.loader.api.FabricLoader; | ||||||
| import net.minecraft.block.entity.BlockEntity; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.resource.ReloadableResourceManager; | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraft.server.MinecraftServer; | import net.minecraft.server.MinecraftServer; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.server.packs.resources.ReloadableResourceManager; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.world.level.BlockGetter; | ||||||
| import net.minecraft.util.math.Direction; | import net.minecraft.world.level.Level; | ||||||
| import net.minecraft.world.BlockView; | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
| import java.io.File; | import java.io.File; | ||||||
| @@ -65,7 +64,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI | |||||||
|             ReloadableResourceManager manager = (ReloadableResourceManager) ((MinecraftServerAccess) server).getServerResourceManager().getResourceManager(); |             ReloadableResourceManager manager = (ReloadableResourceManager) ((MinecraftServerAccess) server).getServerResourceManager().getResourceManager(); | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 return manager.getResource( new Identifier( domain, subPath ) ) |                 return manager.getResource( new ResourceLocation( domain, subPath ) ) | ||||||
|                     .getInputStream(); |                     .getInputStream(); | ||||||
|             } |             } | ||||||
|             catch( IOException ignored ) |             catch( IOException ignored ) | ||||||
| @@ -93,13 +92,13 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath ) |     public int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath ) | ||||||
|     { |     { | ||||||
|         return IDAssigner.getNextId( parentSubPath ); |         return IDAssigner.getNextId( parentSubPath ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity ) |     public IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String subPath, long capacity ) | ||||||
|     { |     { | ||||||
|         try |         try | ||||||
|         { |         { | ||||||
| @@ -143,7 +142,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side ) |     public int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ) | ||||||
|     { |     { | ||||||
|         return BundledRedstone.getDefaultOutput( world, pos, side ); |         return BundledRedstone.getDefaultOutput( world, pos, side ); | ||||||
|     } |     } | ||||||
| @@ -188,7 +187,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI | |||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|     @Override |     @Override | ||||||
|     public IWiredElement getWiredElementAt( @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction side ) |     public IWiredElement getWiredElementAt( @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side ) | ||||||
|     { |     { | ||||||
|         BlockEntity tile = world.getBlockEntity( pos ); |         BlockEntity tile = world.getBlockEntity( pos ); | ||||||
|         if( tile instanceof TileCable ) |         if( tile instanceof TileCable ) | ||||||
|   | |||||||
| @@ -21,13 +21,12 @@ import dan200.computercraft.api.peripheral.IPeripheralProvider; | |||||||
| import dan200.computercraft.api.pocket.IPocketUpgrade; | import dan200.computercraft.api.pocket.IPocketUpgrade; | ||||||
| import dan200.computercraft.api.redstone.IBundledRedstoneProvider; | import dan200.computercraft.api.redstone.IBundledRedstoneProvider; | ||||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
| import net.minecraft.world.BlockView; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.world.level.BlockGetter; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * The static entry point to the ComputerCraft API. |  * The static entry point to the ComputerCraft API. | ||||||
| @@ -81,9 +80,9 @@ public final class ComputerCraftAPI | |||||||
|      * @return The numerical value of the name of the new folder, or -1 if the folder could not be created for some reason. |      * @return The numerical value of the name of the new folder, or -1 if the folder could not be created for some reason. | ||||||
|      * |      * | ||||||
|      * eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now available for writing. |      * eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now available for writing. | ||||||
|      * @see #createSaveDirMount(World, String, long) |      * @see #createSaveDirMount(Level, String, long) | ||||||
|      */ |      */ | ||||||
|     public static int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath ) |     public static int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath ) | ||||||
|     { |     { | ||||||
|         return getInstance().createUniqueNumberedSaveDir( world, parentSubPath ); |         return getInstance().createUniqueNumberedSaveDir( world, parentSubPath ); | ||||||
|     } |     } | ||||||
| @@ -100,14 +99,14 @@ public final class ComputerCraftAPI | |||||||
|      * @param capacity The amount of data that can be stored in the directory before it fills up, in bytes. |      * @param capacity The amount of data that can be stored in the directory before it fills up, in bytes. | ||||||
|      * @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable() to mount this on a |      * @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable() to mount this on a | ||||||
|      * Computers' file system. |      * Computers' file system. | ||||||
|      * @see #createUniqueNumberedSaveDir(World, String) |      * @see #createUniqueNumberedSaveDir(Level, String) | ||||||
|      * @see IComputerAccess#mount(String, IMount) |      * @see IComputerAccess#mount(String, IMount) | ||||||
|      * @see IComputerAccess#mountWritable(String, IWritableMount) |      * @see IComputerAccess#mountWritable(String, IWritableMount) | ||||||
|      * @see IMount |      * @see IMount | ||||||
|      * @see IWritableMount |      * @see IWritableMount | ||||||
|      */ |      */ | ||||||
|     @Nullable |     @Nullable | ||||||
|     public static IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity ) |     public static IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String subPath, long capacity ) | ||||||
|     { |     { | ||||||
|         return getInstance().createSaveDirMount( world, subPath, capacity ); |         return getInstance().createSaveDirMount( world, subPath, capacity ); | ||||||
|     } |     } | ||||||
| @@ -192,7 +191,7 @@ public final class ComputerCraftAPI | |||||||
|      * capable of emitting bundled redstone at the location, -1 will be returned. |      * capable of emitting bundled redstone at the location, -1 will be returned. | ||||||
|      * @see IBundledRedstoneProvider |      * @see IBundledRedstoneProvider | ||||||
|      */ |      */ | ||||||
|     public static int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side ) |     public static int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ) | ||||||
|     { |     { | ||||||
|         return getInstance().getBundledRedstoneOutput( world, pos, side ); |         return getInstance().getBundledRedstoneOutput( world, pos, side ); | ||||||
|     } |     } | ||||||
| @@ -251,7 +250,7 @@ public final class ComputerCraftAPI | |||||||
|      * @see IWiredElement#getNode() |      * @see IWiredElement#getNode() | ||||||
|      */ |      */ | ||||||
|     @Nullable |     @Nullable | ||||||
|     public static IWiredElement getWiredElementAt( @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction side ) |     public static IWiredElement getWiredElementAt( @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side ) | ||||||
|     { |     { | ||||||
|         return getInstance().getWiredElementAt( world, pos, side ); |         return getInstance().getWiredElementAt( world, pos, side ); | ||||||
|     } |     } | ||||||
| @@ -261,10 +260,10 @@ public final class ComputerCraftAPI | |||||||
|         @Nonnull |         @Nonnull | ||||||
|         String getInstalledVersion(); |         String getInstalledVersion(); | ||||||
|  |  | ||||||
|         int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath ); |         int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath ); | ||||||
|  |  | ||||||
|         @Nullable |         @Nullable | ||||||
|         IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity ); |         IWritableMount createSaveDirMount( @Nonnull Level world, @Nonnull String subPath, long capacity ); | ||||||
|  |  | ||||||
|         @Nullable |         @Nullable | ||||||
|         IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath ); |         IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath ); | ||||||
| @@ -277,7 +276,7 @@ public final class ComputerCraftAPI | |||||||
|  |  | ||||||
|         void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider ); |         void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider provider ); | ||||||
|  |  | ||||||
|         int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side ); |         int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ); | ||||||
|  |  | ||||||
|         void registerMediaProvider( @Nonnull IMediaProvider provider ); |         void registerMediaProvider( @Nonnull IMediaProvider provider ); | ||||||
|  |  | ||||||
| @@ -292,6 +291,6 @@ public final class ComputerCraftAPI | |||||||
|         IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element ); |         IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element ); | ||||||
|  |  | ||||||
|         @Nullable |         @Nullable | ||||||
|         IWiredElement getWiredElementAt( @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction side ); |         IWiredElement getWiredElementAt( @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,11 +7,10 @@ package dan200.computercraft.api; | |||||||
|  |  | ||||||
| import dan200.computercraft.api.pocket.IPocketUpgrade; | import dan200.computercraft.api.pocket.IPocketUpgrade; | ||||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.nbt.NbtCompound; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.nbt.CompoundTag; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Common functionality between {@link ITurtleUpgrade} and {@link IPocketUpgrade}. |  * Common functionality between {@link ITurtleUpgrade} and {@link IPocketUpgrade}. | ||||||
| @@ -28,7 +27,7 @@ public interface IUpgradeBase | |||||||
|      * @return The unique ID for this upgrade. |      * @return The unique ID for this upgrade. | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     Identifier getUpgradeID(); |     ResourceLocation getUpgradeID(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Return an unlocalised string to describe this type of computer in item names. |      * Return an unlocalised string to describe this type of computer in item names. | ||||||
| @@ -76,8 +75,8 @@ public interface IUpgradeBase | |||||||
|  |  | ||||||
|         // A more expanded form of ItemStack.areShareTagsEqual, but allowing an empty tag to be equal to a |         // A more expanded form of ItemStack.areShareTagsEqual, but allowing an empty tag to be equal to a | ||||||
|         // null one. |         // null one. | ||||||
|         NbtCompound shareTag = stack.getNbt(); |         CompoundTag shareTag = stack.getTag(); | ||||||
|         NbtCompound craftingShareTag = crafting.getNbt(); |         CompoundTag craftingShareTag = crafting.getTag(); | ||||||
|         if( shareTag == craftingShareTag ) return true; |         if( shareTag == craftingShareTag ) return true; | ||||||
|         if( shareTag == null ) return craftingShareTag.isEmpty(); |         if( shareTag == null ) return craftingShareTag.isEmpty(); | ||||||
|         if( craftingShareTag == null ) return shareTag.isEmpty(); |         if( craftingShareTag == null ) return shareTag.isEmpty(); | ||||||
|   | |||||||
| @@ -8,16 +8,15 @@ package dan200.computercraft.api.client; | |||||||
|  |  | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.render.model.BakedModel; | import net.minecraft.client.resources.model.BakedModel; | ||||||
| import net.minecraft.client.render.model.BakedModelManager; | import net.minecraft.client.resources.model.ModelManager; | ||||||
| import net.minecraft.client.util.ModelIdentifier; | import net.minecraft.client.resources.model.ModelResourceLocation; | ||||||
| import net.minecraft.util.math.AffineTransformation; | import net.minecraft.world.item.ItemStack; | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.util.math.Vec3f; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.math.Transformation; | ||||||
|  | import com.mojang.math.Vector3f; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -27,9 +26,9 @@ import java.util.Objects; | |||||||
| public final class TransformedModel | public final class TransformedModel | ||||||
| { | { | ||||||
|     private final BakedModel model; |     private final BakedModel model; | ||||||
|     private final AffineTransformation matrix; |     private final Transformation matrix; | ||||||
|  |  | ||||||
|     public TransformedModel( @Nonnull BakedModel model, @Nonnull AffineTransformation matrix ) |     public TransformedModel( @Nonnull BakedModel model, @Nonnull Transformation matrix ) | ||||||
|     { |     { | ||||||
|         this.model = Objects.requireNonNull( model ); |         this.model = Objects.requireNonNull( model ); | ||||||
|         this.matrix = Objects.requireNonNull( matrix ); |         this.matrix = Objects.requireNonNull( matrix ); | ||||||
| @@ -38,22 +37,22 @@ public final class TransformedModel | |||||||
|     public TransformedModel( @Nonnull BakedModel model ) |     public TransformedModel( @Nonnull BakedModel model ) | ||||||
|     { |     { | ||||||
|         this.model = Objects.requireNonNull( model ); |         this.model = Objects.requireNonNull( model ); | ||||||
|         matrix = AffineTransformation.identity(); |         matrix = Transformation.identity(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static TransformedModel of( @Nonnull ModelIdentifier location ) |     public static TransformedModel of( @Nonnull ModelResourceLocation location ) | ||||||
|     { |     { | ||||||
|         BakedModelManager modelManager = MinecraftClient.getInstance() |         ModelManager modelManager = Minecraft.getInstance() | ||||||
|             .getBakedModelManager(); |             .getModelManager(); | ||||||
|         return new TransformedModel( modelManager.getModel( location ) ); |         return new TransformedModel( modelManager.getModel( location ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static TransformedModel of( @Nonnull ItemStack item, @Nonnull AffineTransformation transform ) |     public static TransformedModel of( @Nonnull ItemStack item, @Nonnull Transformation transform ) | ||||||
|     { |     { | ||||||
|         BakedModel model = MinecraftClient.getInstance() |         BakedModel model = Minecraft.getInstance() | ||||||
|             .getItemRenderer() |             .getItemRenderer() | ||||||
|             .getModels() |             .getItemModelShaper() | ||||||
|             .getModel( item ); |             .getItemModel( item ); | ||||||
|         return new TransformedModel( model, transform ); |         return new TransformedModel( model, transform ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -64,23 +63,23 @@ public final class TransformedModel | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     public AffineTransformation getMatrix() |     public Transformation getMatrix() | ||||||
|     { |     { | ||||||
|         return matrix; |         return matrix; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void push( MatrixStack matrixStack ) |     public void push( PoseStack matrixStack ) | ||||||
|     { |     { | ||||||
|         matrixStack.push(); |         matrixStack.pushPose(); | ||||||
|  |  | ||||||
|         Vec3f translation = matrix.getTranslation(); |         Vector3f translation = matrix.getTranslation(); | ||||||
|         matrixStack.translate( translation.getX(), translation.getY(), translation.getZ() ); |         matrixStack.translate( translation.x(), translation.y(), translation.z() ); | ||||||
|  |  | ||||||
|         matrixStack.multiply( matrix.getRotation2() ); |         matrixStack.mulPose( matrix.getLeftRotation() ); | ||||||
|  |  | ||||||
|         Vec3f scale = matrix.getScale(); |         Vector3f scale = matrix.getScale(); | ||||||
|         matrixStack.scale( scale.getX(), scale.getY(), scale.getZ() ); |         matrixStack.scale( scale.x(), scale.y(), scale.z() ); | ||||||
|  |  | ||||||
|         matrixStack.multiply( matrix.getRotation1() ); |         matrixStack.mulPose( matrix.getRightRotation() ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -8,9 +8,8 @@ package dan200.computercraft.api.filesystem; | |||||||
|  |  | ||||||
| import dan200.computercraft.api.ComputerCraftAPI; | import dan200.computercraft.api.ComputerCraftAPI; | ||||||
| import dan200.computercraft.api.peripheral.IComputerAccess; | import dan200.computercraft.api.peripheral.IComputerAccess; | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.nio.channels.ReadableByteChannel; | import java.nio.channels.ReadableByteChannel; | ||||||
| import java.nio.file.attribute.BasicFileAttributes; | import java.nio.file.attribute.BasicFileAttributes; | ||||||
| @@ -19,10 +18,10 @@ import java.util.List; | |||||||
| /** | /** | ||||||
|  * Represents a read only part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, IMount)}. |  * Represents a read only part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, IMount)}. | ||||||
|  * |  * | ||||||
|  * Ready made implementations of this interface can be created using {@link ComputerCraftAPI#createSaveDirMount(World, String, long)} or {@link |  * Ready made implementations of this interface can be created using {@link ComputerCraftAPI#createSaveDirMount(Level, String, long)} or {@link | ||||||
|  * ComputerCraftAPI#createResourceMount(String, String)}, or you're free to implement it yourselves! |  * ComputerCraftAPI#createResourceMount(String, String)}, or you're free to implement it yourselves! | ||||||
|  * |  * | ||||||
|  * @see ComputerCraftAPI#createSaveDirMount(World, String, long) |  * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) | ||||||
|  * @see ComputerCraftAPI#createResourceMount(String, String) |  * @see ComputerCraftAPI#createResourceMount(String, String) | ||||||
|  * @see IComputerAccess#mount(String, IMount) |  * @see IComputerAccess#mount(String, IMount) | ||||||
|  * @see IWritableMount |  * @see IWritableMount | ||||||
|   | |||||||
| @@ -8,9 +8,8 @@ package dan200.computercraft.api.filesystem; | |||||||
|  |  | ||||||
| import dan200.computercraft.api.ComputerCraftAPI; | import dan200.computercraft.api.ComputerCraftAPI; | ||||||
| import dan200.computercraft.api.peripheral.IComputerAccess; | import dan200.computercraft.api.peripheral.IComputerAccess; | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||||
| import java.nio.channels.WritableByteChannel; | import java.nio.channels.WritableByteChannel; | ||||||
| @@ -20,10 +19,10 @@ import java.util.OptionalLong; | |||||||
|  * Represents a part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, IMount)} or {@link |  * Represents a part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, IMount)} or {@link | ||||||
|  * IComputerAccess#mountWritable(String, IWritableMount)}, that can also be written to. |  * IComputerAccess#mountWritable(String, IWritableMount)}, that can also be written to. | ||||||
|  * |  * | ||||||
|  * Ready made implementations of this interface can be created using {@link ComputerCraftAPI#createSaveDirMount(World, String, long)}, or you're free to |  * Ready made implementations of this interface can be created using {@link ComputerCraftAPI#createSaveDirMount(Level, String, long)}, or you're free to | ||||||
|  * implement it yourselves! |  * implement it yourselves! | ||||||
|  * |  * | ||||||
|  * @see ComputerCraftAPI#createSaveDirMount(World, String, long) |  * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) | ||||||
|  * @see IComputerAccess#mount(String, IMount) |  * @see IComputerAccess#mount(String, IMount) | ||||||
|  * @see IComputerAccess#mountWritable(String, IWritableMount) |  * @see IComputerAccess#mountWritable(String, IWritableMount) | ||||||
|  * @see IMount |  * @see IMount | ||||||
|   | |||||||
| @@ -9,9 +9,8 @@ import dan200.computercraft.api.ComputerCraftAPI; | |||||||
| import dan200.computercraft.api.peripheral.IPeripheral; | import dan200.computercraft.api.peripheral.IPeripheral; | ||||||
| import dan200.computercraft.api.peripheral.IPeripheralProvider; | import dan200.computercraft.api.peripheral.IPeripheralProvider; | ||||||
| import dan200.computercraft.core.asm.LuaMethod; | import dan200.computercraft.core.asm.LuaMethod; | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * A generic source of {@link LuaMethod} functions. |  * A generic source of {@link LuaMethod} functions. | ||||||
| @@ -54,5 +53,5 @@ public interface GenericSource | |||||||
|      * @return This source's identifier. |      * @return This source's identifier. | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     Identifier id(); |     ResourceLocation id(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,13 +7,12 @@ | |||||||
| package dan200.computercraft.api.media; | package dan200.computercraft.api.media; | ||||||
|  |  | ||||||
| import dan200.computercraft.api.filesystem.IMount; | import dan200.computercraft.api.filesystem.IMount; | ||||||
| import net.minecraft.item.Item; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.sound.SoundEvent; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.sounds.SoundEvent; | ||||||
|  | import net.minecraft.world.item.Item; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Represents an item that can be placed in a disk drive and used by a Computer. |  * Represents an item that can be placed in a disk drive and used by a Computer. | ||||||
| @@ -77,11 +76,11 @@ public interface IMedia | |||||||
|      * dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable() |      * dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable() | ||||||
|      * @see IMount |      * @see IMount | ||||||
|      * @see dan200.computercraft.api.filesystem.IWritableMount |      * @see dan200.computercraft.api.filesystem.IWritableMount | ||||||
|      * @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long) |      * @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(Level, String, long) | ||||||
|      * @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(String, String) |      * @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(String, String) | ||||||
|      */ |      */ | ||||||
|     @Nullable |     @Nullable | ||||||
|     default IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ) |     default IMount createDataMount( @Nonnull ItemStack stack, @Nonnull Level world ) | ||||||
|     { |     { | ||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -6,10 +6,9 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.api.media; | package dan200.computercraft.api.media; | ||||||
|  |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * This interface is used to provide {@link IMedia} implementations for {@link ItemStack}. |  * This interface is used to provide {@link IMedia} implementations for {@link ItemStack}. | ||||||
|   | |||||||
| @@ -6,10 +6,9 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.api.network; | package dan200.computercraft.api.network; | ||||||
|  |  | ||||||
| import net.minecraft.util.math.Vec3d; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.phys.Vec3; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * An object on an {@link IPacketNetwork}, capable of receiving packets. |  * An object on an {@link IPacketNetwork}, capable of receiving packets. | ||||||
| @@ -22,7 +21,7 @@ public interface IPacketReceiver | |||||||
|      * @return The receivers's world. |      * @return The receivers's world. | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     World getWorld(); |     Level getWorld(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Get the position in the world at which this receiver exists. |      * Get the position in the world at which this receiver exists. | ||||||
| @@ -30,7 +29,7 @@ public interface IPacketReceiver | |||||||
|      * @return The receiver's position. |      * @return The receiver's position. | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     Vec3d getPosition(); |     Vec3 getPosition(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Get the maximum distance this receiver can send and receive messages. |      * Get the maximum distance this receiver can send and receive messages. | ||||||
|   | |||||||
| @@ -6,10 +6,9 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.api.network; | package dan200.computercraft.api.network; | ||||||
|  |  | ||||||
| import net.minecraft.util.math.Vec3d; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.phys.Vec3; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * An object on a {@link IPacketNetwork}, capable of sending packets. |  * An object on a {@link IPacketNetwork}, capable of sending packets. | ||||||
| @@ -22,7 +21,7 @@ public interface IPacketSender | |||||||
|      * @return The sender's world. |      * @return The sender's world. | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     World getWorld(); |     Level getWorld(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Get the position in the world at which this sender exists. |      * Get the position in the world at which this sender exists. | ||||||
| @@ -30,7 +29,7 @@ public interface IPacketSender | |||||||
|      * @return The sender's position. |      * @return The sender's position. | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     Vec3d getPosition(); |     Vec3 getPosition(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Get some sort of identification string for this sender. This does not strictly need to be unique, but you should be able to extract some identifiable |      * Get some sort of identification string for this sender. This does not strictly need to be unique, but you should be able to extract some identifiable | ||||||
|   | |||||||
| @@ -13,10 +13,9 @@ import dan200.computercraft.api.lua.ILuaCallback; | |||||||
| import dan200.computercraft.api.lua.ILuaContext; | import dan200.computercraft.api.lua.ILuaContext; | ||||||
| import dan200.computercraft.api.lua.ILuaTask; | import dan200.computercraft.api.lua.ILuaTask; | ||||||
| import dan200.computercraft.api.lua.MethodResult; | import dan200.computercraft.api.lua.MethodResult; | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -33,7 +32,7 @@ public interface IComputerAccess | |||||||
|      * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a file in the desired location. |      * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a file in the desired location. | ||||||
|      * Store this value if you wish to unmount the mount later. |      * Store this value if you wish to unmount the mount later. | ||||||
|      * @throws NotAttachedException If the peripheral has been detached. |      * @throws NotAttachedException If the peripheral has been detached. | ||||||
|      * @see ComputerCraftAPI#createSaveDirMount(World, String, long) |      * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) | ||||||
|      * @see ComputerCraftAPI#createResourceMount(String, String) |      * @see ComputerCraftAPI#createResourceMount(String, String) | ||||||
|      * @see #mount(String, IMount, String) |      * @see #mount(String, IMount, String) | ||||||
|      * @see #mountWritable(String, IWritableMount) |      * @see #mountWritable(String, IWritableMount) | ||||||
| @@ -55,7 +54,7 @@ public interface IComputerAccess | |||||||
|      * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a file in the desired location. |      * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a file in the desired location. | ||||||
|      * Store this value if you wish to unmount the mount later. |      * Store this value if you wish to unmount the mount later. | ||||||
|      * @throws NotAttachedException If the peripheral has been detached. |      * @throws NotAttachedException If the peripheral has been detached. | ||||||
|      * @see ComputerCraftAPI#createSaveDirMount(World, String, long) |      * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) | ||||||
|      * @see ComputerCraftAPI#createResourceMount(String, String) |      * @see ComputerCraftAPI#createResourceMount(String, String) | ||||||
|      * @see #mount(String, IMount) |      * @see #mount(String, IMount) | ||||||
|      * @see #mountWritable(String, IWritableMount) |      * @see #mountWritable(String, IWritableMount) | ||||||
| @@ -84,7 +83,7 @@ public interface IComputerAccess | |||||||
|      * @return The location on the computer's file system where you the mount mounted, or null if there was already a file in the desired location. Store |      * @return The location on the computer's file system where you the mount mounted, or null if there was already a file in the desired location. Store | ||||||
|      * this value if you wish to unmount the mount later. |      * this value if you wish to unmount the mount later. | ||||||
|      * @throws NotAttachedException If the peripheral has been detached. |      * @throws NotAttachedException If the peripheral has been detached. | ||||||
|      * @see ComputerCraftAPI#createSaveDirMount(World, String, long) |      * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) | ||||||
|      * @see ComputerCraftAPI#createResourceMount(String, String) |      * @see ComputerCraftAPI#createResourceMount(String, String) | ||||||
|      * @see #mount(String, IMount) |      * @see #mount(String, IMount) | ||||||
|      * @see #unmount(String) |      * @see #unmount(String) | ||||||
| @@ -105,7 +104,7 @@ public interface IComputerAccess | |||||||
|      * @return The location on the computer's file system where you the mount mounted, or null if there was already a file in the desired location. Store |      * @return The location on the computer's file system where you the mount mounted, or null if there was already a file in the desired location. Store | ||||||
|      * this value if you wish to unmount the mount later. |      * this value if you wish to unmount the mount later. | ||||||
|      * @throws NotAttachedException If the peripheral has been detached. |      * @throws NotAttachedException If the peripheral has been detached. | ||||||
|      * @see ComputerCraftAPI#createSaveDirMount(World, String, long) |      * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) | ||||||
|      * @see ComputerCraftAPI#createResourceMount(String, String) |      * @see ComputerCraftAPI#createResourceMount(String, String) | ||||||
|      * @see #mount(String, IMount) |      * @see #mount(String, IMount) | ||||||
|      * @see #unmount(String) |      * @see #unmount(String) | ||||||
|   | |||||||
| @@ -6,12 +6,11 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.api.peripheral; | package dan200.computercraft.api.peripheral; | ||||||
|  |  | ||||||
| import net.minecraft.block.entity.BlockEntity; |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
| import java.util.Optional; | import java.util.Optional; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -34,5 +33,5 @@ public interface IPeripheralProvider | |||||||
|      * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider) |      * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider) | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side ); |     IPeripheral getPeripheral( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,15 +5,14 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.api.peripheral; | package dan200.computercraft.api.peripheral; | ||||||
|  |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * A {@link net.minecraft.block.entity.BlockEntity} which may act as a peripheral. |  * A {@link net.minecraft.world.level.block.entity.BlockEntity} which may act as a peripheral. | ||||||
|  * |  * | ||||||
|  * If you need more complex capabilities (such as handling TEs not belonging to your mod), you should use {@link IPeripheralProvider}. |  * If you need more complex capabilities (such as handling TEs not belonging to your mod), you should use {@link IPeripheralProvider}. | ||||||
|  */ |  */ | ||||||
| @@ -24,7 +23,7 @@ public interface IPeripheralTile | |||||||
|      * |      * | ||||||
|      * @param side The side to get the peripheral from. |      * @param side The side to get the peripheral from. | ||||||
|      * @return A peripheral, or {@code null} if there is not a peripheral here. |      * @return A peripheral, or {@code null} if there is not a peripheral here. | ||||||
|      * @see IPeripheralProvider#getPeripheral(World, BlockPos, Direction) |      * @see IPeripheralProvider#getPeripheral(Level, BlockPos, Direction) | ||||||
|      */ |      */ | ||||||
|     @Nullable |     @Nullable | ||||||
|     IPeripheral getPeripheral( @Nonnull Direction side ); |     IPeripheral getPeripheral( @Nonnull Direction side ); | ||||||
|   | |||||||
| @@ -7,13 +7,12 @@ | |||||||
| package dan200.computercraft.api.pocket; | package dan200.computercraft.api.pocket; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.util.NonNullSupplier; | import dan200.computercraft.shared.util.NonNullSupplier; | ||||||
| import net.minecraft.item.Item; |  | ||||||
| import net.minecraft.item.ItemConvertible; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
| import net.minecraft.util.Util; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.Util; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.world.item.Item; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  | import net.minecraft.world.level.ItemLike; | ||||||
| import java.util.function.Supplier; | import java.util.function.Supplier; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -23,55 +22,55 @@ import java.util.function.Supplier; | |||||||
|  */ |  */ | ||||||
| public abstract class AbstractPocketUpgrade implements IPocketUpgrade | public abstract class AbstractPocketUpgrade implements IPocketUpgrade | ||||||
| { | { | ||||||
|     private final Identifier id; |     private final ResourceLocation id; | ||||||
|     private final String adjective; |     private final String adjective; | ||||||
|     private final NonNullSupplier<ItemStack> stack; |     private final NonNullSupplier<ItemStack> stack; | ||||||
|  |  | ||||||
|     protected AbstractPocketUpgrade( Identifier id, String adjective, NonNullSupplier<ItemStack> stack ) |     protected AbstractPocketUpgrade( ResourceLocation id, String adjective, NonNullSupplier<ItemStack> stack ) | ||||||
|     { |     { | ||||||
|         this.id = id; |         this.id = id; | ||||||
|         this.adjective = adjective; |         this.adjective = adjective; | ||||||
|         this.stack = stack; |         this.stack = stack; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractPocketUpgrade( Identifier id, NonNullSupplier<ItemStack> item ) |     protected AbstractPocketUpgrade( ResourceLocation id, NonNullSupplier<ItemStack> item ) | ||||||
|     { |     { | ||||||
|         this( id, Util.createTranslationKey( "upgrade", id ) + ".adjective", item ); |         this( id, Util.makeDescriptionId( "upgrade", id ) + ".adjective", item ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractPocketUpgrade( Identifier id, String adjective, ItemStack stack ) |     protected AbstractPocketUpgrade( ResourceLocation id, String adjective, ItemStack stack ) | ||||||
|     { |     { | ||||||
|         this( id, adjective, () -> stack ); |         this( id, adjective, () -> stack ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractPocketUpgrade( Identifier id, ItemStack stack ) |     protected AbstractPocketUpgrade( ResourceLocation id, ItemStack stack ) | ||||||
|     { |     { | ||||||
|         this( id, () -> stack ); |         this( id, () -> stack ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractPocketUpgrade( Identifier id, String adjective, ItemConvertible item ) |     protected AbstractPocketUpgrade( ResourceLocation id, String adjective, ItemLike item ) | ||||||
|     { |     { | ||||||
|         this( id, adjective, new CachedStack( () -> item ) ); |         this( id, adjective, new CachedStack( () -> item ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractPocketUpgrade( Identifier id, ItemConvertible item ) |     protected AbstractPocketUpgrade( ResourceLocation id, ItemLike item ) | ||||||
|     { |     { | ||||||
|         this( id, new CachedStack( () -> item ) ); |         this( id, new CachedStack( () -> item ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractPocketUpgrade( Identifier id, String adjective, Supplier<? extends ItemConvertible> item ) |     protected AbstractPocketUpgrade( ResourceLocation id, String adjective, Supplier<? extends ItemLike> item ) | ||||||
|     { |     { | ||||||
|         this( id, adjective, new CachedStack( item ) ); |         this( id, adjective, new CachedStack( item ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractPocketUpgrade( Identifier id, Supplier<? extends ItemConvertible> item ) |     protected AbstractPocketUpgrade( ResourceLocation id, Supplier<? extends ItemLike> item ) | ||||||
|     { |     { | ||||||
|         this( id, new CachedStack( item ) ); |         this( id, new CachedStack( item ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public final Identifier getUpgradeID() |     public final ResourceLocation getUpgradeID() | ||||||
|     { |     { | ||||||
|         return id; |         return id; | ||||||
|     } |     } | ||||||
| @@ -97,11 +96,11 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade | |||||||
|      */ |      */ | ||||||
|     private static final class CachedStack implements NonNullSupplier<ItemStack> |     private static final class CachedStack implements NonNullSupplier<ItemStack> | ||||||
|     { |     { | ||||||
|         private final Supplier<? extends ItemConvertible> provider; |         private final Supplier<? extends ItemLike> provider; | ||||||
|         private Item item; |         private Item item; | ||||||
|         private ItemStack stack; |         private ItemStack stack; | ||||||
|  |  | ||||||
|         CachedStack( Supplier<? extends ItemConvertible> provider ) |         CachedStack( Supplier<? extends ItemLike> provider ) | ||||||
|         { |         { | ||||||
|             this.provider = provider; |             this.provider = provider; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -7,12 +7,11 @@ | |||||||
| package dan200.computercraft.api.pocket; | package dan200.computercraft.api.pocket; | ||||||
|  |  | ||||||
| import dan200.computercraft.api.peripheral.IPeripheral; | import dan200.computercraft.api.peripheral.IPeripheral; | ||||||
| import net.minecraft.entity.Entity; |  | ||||||
| import net.minecraft.nbt.NbtCompound; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.nbt.CompoundTag; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.world.entity.Entity; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -73,7 +72,7 @@ public interface IPocketAccess | |||||||
|      * @see #updateUpgradeNBTData() |      * @see #updateUpgradeNBTData() | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     NbtCompound getUpgradeNBTData(); |     CompoundTag getUpgradeNBTData(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Mark the upgrade-specific NBT as dirty. |      * Mark the upgrade-specific NBT as dirty. | ||||||
| @@ -93,5 +92,5 @@ public interface IPocketAccess | |||||||
|      * @return A collection of all upgrade names. |      * @return A collection of all upgrade names. | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     Map<Identifier, IPeripheral> getUpgrades(); |     Map<ResourceLocation, IPeripheral> getUpgrades(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -9,10 +9,9 @@ package dan200.computercraft.api.pocket; | |||||||
| import dan200.computercraft.api.ComputerCraftAPI; | import dan200.computercraft.api.ComputerCraftAPI; | ||||||
| import dan200.computercraft.api.IUpgradeBase; | import dan200.computercraft.api.IUpgradeBase; | ||||||
| import dan200.computercraft.api.peripheral.IPeripheral; | import dan200.computercraft.api.peripheral.IPeripheral; | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Additional peripherals for pocket computers. |  * Additional peripherals for pocket computers. | ||||||
| @@ -55,7 +54,7 @@ public interface IPocketUpgrade extends IUpgradeBase | |||||||
|      * requiring the player to be sneaking - otherwise they will be unable to access the GUI. |      * requiring the player to be sneaking - otherwise they will be unable to access the GUI. | ||||||
|      * @see #createPeripheral(IPocketAccess) |      * @see #createPeripheral(IPocketAccess) | ||||||
|      */ |      */ | ||||||
|     default boolean onRightClick( @Nonnull World world, @Nonnull IPocketAccess access, @Nullable IPeripheral peripheral ) |     default boolean onRightClick( @Nonnull Level world, @Nonnull IPocketAccess access, @Nullable IPeripheral peripheral ) | ||||||
|     { |     { | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -6,11 +6,10 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.api.redstone; | package dan200.computercraft.api.redstone; | ||||||
|  |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * This interface is used to provide bundled redstone output for blocks. |  * This interface is used to provide bundled redstone output for blocks. | ||||||
| @@ -29,5 +28,5 @@ public interface IBundledRedstoneProvider | |||||||
|      * @return A number in the range 0-65535 to indicate this block is providing output, or -1 if you do not wish to handle this block. |      * @return A number in the range 0-65535 to indicate this block is providing output, or -1 if you do not wish to handle this block. | ||||||
|      * @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider) |      * @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider) | ||||||
|      */ |      */ | ||||||
|     int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side ); |     int getBundledRedstoneOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,13 +7,12 @@ | |||||||
| package dan200.computercraft.api.turtle; | package dan200.computercraft.api.turtle; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.util.NonNullSupplier; | import dan200.computercraft.shared.util.NonNullSupplier; | ||||||
| import net.minecraft.item.Item; |  | ||||||
| import net.minecraft.item.ItemConvertible; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
| import net.minecraft.util.Util; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.Util; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.world.item.Item; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  | import net.minecraft.world.level.ItemLike; | ||||||
| import java.util.function.Supplier; | import java.util.function.Supplier; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -23,12 +22,12 @@ import java.util.function.Supplier; | |||||||
|  */ |  */ | ||||||
| public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade | public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade | ||||||
| { | { | ||||||
|     private final Identifier id; |     private final ResourceLocation id; | ||||||
|     private final TurtleUpgradeType type; |     private final TurtleUpgradeType type; | ||||||
|     private final String adjective; |     private final String adjective; | ||||||
|     private final NonNullSupplier<ItemStack> stack; |     private final NonNullSupplier<ItemStack> stack; | ||||||
|  |  | ||||||
|     protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, NonNullSupplier<ItemStack> stack ) |     protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, NonNullSupplier<ItemStack> stack ) | ||||||
|     { |     { | ||||||
|         this.id = id; |         this.id = id; | ||||||
|         this.type = type; |         this.type = type; | ||||||
| @@ -36,44 +35,44 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade | |||||||
|         this.stack = stack; |         this.stack = stack; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, NonNullSupplier<ItemStack> stack ) |     protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, NonNullSupplier<ItemStack> stack ) | ||||||
|     { |     { | ||||||
|         this( id, type, Util.createTranslationKey( "upgrade", id ) + ".adjective", stack ); |         this( id, type, Util.makeDescriptionId( "upgrade", id ) + ".adjective", stack ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, ItemStack stack ) |     protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, ItemStack stack ) | ||||||
|     { |     { | ||||||
|         this( id, type, adjective, () -> stack ); |         this( id, type, adjective, () -> stack ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, ItemStack stack ) |     protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, ItemStack stack ) | ||||||
|     { |     { | ||||||
|         this( id, type, () -> stack ); |         this( id, type, () -> stack ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, ItemConvertible item ) |     protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, ItemLike item ) | ||||||
|     { |     { | ||||||
|         this( id, type, adjective, new CachedStack( () -> item ) ); |         this( id, type, adjective, new CachedStack( () -> item ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, ItemConvertible item ) |     protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, ItemLike item ) | ||||||
|     { |     { | ||||||
|         this( id, type, new CachedStack( () -> item ) ); |         this( id, type, new CachedStack( () -> item ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, Supplier<? extends ItemConvertible> item ) |     protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, Supplier<? extends ItemLike> item ) | ||||||
|     { |     { | ||||||
|         this( id, type, adjective, new CachedStack( item ) ); |         this( id, type, adjective, new CachedStack( item ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, Supplier<? extends ItemConvertible> item ) |     protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, Supplier<? extends ItemLike> item ) | ||||||
|     { |     { | ||||||
|         this( id, type, new CachedStack( item ) ); |         this( id, type, new CachedStack( item ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public final Identifier getUpgradeID() |     public final ResourceLocation getUpgradeID() | ||||||
|     { |     { | ||||||
|         return id; |         return id; | ||||||
|     } |     } | ||||||
| @@ -106,11 +105,11 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade | |||||||
|      */ |      */ | ||||||
|     private static final class CachedStack implements NonNullSupplier<ItemStack> |     private static final class CachedStack implements NonNullSupplier<ItemStack> | ||||||
|     { |     { | ||||||
|         private final Supplier<? extends ItemConvertible> provider; |         private final Supplier<? extends ItemLike> provider; | ||||||
|         private Item item; |         private Item item; | ||||||
|         private ItemStack stack; |         private ItemStack stack; | ||||||
|  |  | ||||||
|         CachedStack( Supplier<? extends ItemConvertible> provider ) |         CachedStack( Supplier<? extends ItemLike> provider ) | ||||||
|         { |         { | ||||||
|             this.provider = provider; |             this.provider = provider; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -9,31 +9,33 @@ import com.mojang.authlib.GameProfile; | |||||||
| import io.netty.channel.ChannelHandlerContext; | import io.netty.channel.ChannelHandlerContext; | ||||||
| import io.netty.util.concurrent.Future; | import io.netty.util.concurrent.Future; | ||||||
| import io.netty.util.concurrent.GenericFutureListener; | import io.netty.util.concurrent.GenericFutureListener; | ||||||
| import net.minecraft.block.entity.CommandBlockBlockEntity; | import net.minecraft.commands.arguments.EntityAnchorArgument; | ||||||
| import net.minecraft.block.entity.SignBlockEntity; |  | ||||||
| import net.minecraft.command.argument.EntityAnchorArgumentType; |  | ||||||
| import net.minecraft.entity.Entity; |  | ||||||
| import net.minecraft.entity.damage.DamageSource; |  | ||||||
| import net.minecraft.entity.effect.StatusEffectInstance; |  | ||||||
| import net.minecraft.entity.passive.HorseBaseEntity; |  | ||||||
| import net.minecraft.inventory.Inventory; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.network.*; | import net.minecraft.network.*; | ||||||
| import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket; | import net.minecraft.network.chat.ChatType; | ||||||
| import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket; | import net.minecraft.network.chat.Component; | ||||||
| import net.minecraft.recipe.Recipe; | import net.minecraft.network.protocol.Packet; | ||||||
| import net.minecraft.screen.NamedScreenHandlerFactory; | import net.minecraft.network.protocol.PacketFlow; | ||||||
| import net.minecraft.server.network.ServerPlayNetworkHandler; | import net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket; | ||||||
| import net.minecraft.server.network.ServerPlayerEntity; | import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; | ||||||
| import net.minecraft.server.world.ServerWorld; | import net.minecraft.server.level.ServerLevel; | ||||||
| import net.minecraft.sound.SoundCategory; | import net.minecraft.server.level.ServerPlayer; | ||||||
| import net.minecraft.sound.SoundEvent; | import net.minecraft.server.network.ServerGamePacketListenerImpl; | ||||||
| import net.minecraft.text.Text; | import net.minecraft.sounds.SoundEvent; | ||||||
| import net.minecraft.util.Hand; | import net.minecraft.sounds.SoundSource; | ||||||
| import net.minecraft.util.math.ChunkPos; | import net.minecraft.world.Container; | ||||||
| import net.minecraft.util.math.Vec3d; | import net.minecraft.world.InteractionHand; | ||||||
| import net.minecraft.village.TradeOfferList; | import net.minecraft.world.MenuProvider; | ||||||
|  | import net.minecraft.world.damagesource.DamageSource; | ||||||
|  | import net.minecraft.world.effect.MobEffectInstance; | ||||||
|  | import net.minecraft.world.entity.Entity; | ||||||
|  | import net.minecraft.world.entity.animal.horse.AbstractHorse; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  | import net.minecraft.world.item.crafting.Recipe; | ||||||
|  | import net.minecraft.world.item.trading.MerchantOffers; | ||||||
|  | import net.minecraft.world.level.ChunkPos; | ||||||
|  | import net.minecraft.world.level.block.entity.CommandBlockEntity; | ||||||
|  | import net.minecraft.world.level.block.entity.SignBlockEntity; | ||||||
|  | import net.minecraft.world.phys.Vec3; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
| import javax.crypto.Cipher; | import javax.crypto.Cipher; | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| @@ -41,26 +43,26 @@ import java.util.OptionalInt; | |||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * A wrapper for {@link ServerPlayerEntity} which denotes a "fake" player. |  * A wrapper for {@link ServerPlayer} which denotes a "fake" player. | ||||||
|  * |  * | ||||||
|  * Please note that this does not implement any of the traditional fake player behaviour. It simply exists to prevent me passing in normal players. |  * Please note that this does not implement any of the traditional fake player behaviour. It simply exists to prevent me passing in normal players. | ||||||
|  */ |  */ | ||||||
| public class FakePlayer extends ServerPlayerEntity | public class FakePlayer extends ServerPlayer | ||||||
| { | { | ||||||
|     public FakePlayer( ServerWorld world, GameProfile gameProfile ) |     public FakePlayer( ServerLevel world, GameProfile gameProfile ) | ||||||
|     { |     { | ||||||
|         super( world.getServer(), world, gameProfile ); |         super( world.getServer(), world, gameProfile ); | ||||||
|         networkHandler = new FakeNetHandler( this ); |         connection = new FakeNetHandler( this ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // region Direct networkHandler access |     // region Direct networkHandler access | ||||||
|     @Override |     @Override | ||||||
|     public void enterCombat() |     public void onEnterCombat() | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void endCombat() |     public void onLeaveCombat() | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -70,23 +72,23 @@ public class FakePlayer extends ServerPlayerEntity | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void playerTick() |     public void doTick() | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onDeath( DamageSource damage ) |     public void die( DamageSource damage ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Entity moveToWorld( ServerWorld destination ) |     public Entity changeDimension( ServerLevel destination ) | ||||||
|     { |     { | ||||||
|         return this; |         return this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void wakeUp( boolean bl, boolean updateSleepingPlayers ) |     public void stopSleepInBed( boolean bl, boolean updateSleepingPlayers ) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|     } |     } | ||||||
| @@ -103,33 +105,33 @@ public class FakePlayer extends ServerPlayerEntity | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void openEditSignScreen( SignBlockEntity tile ) |     public void openTextEdit( SignBlockEntity tile ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public OptionalInt openHandledScreen( @Nullable NamedScreenHandlerFactory container ) |     public OptionalInt openMenu( @Nullable MenuProvider container ) | ||||||
|     { |     { | ||||||
|         return OptionalInt.empty(); |         return OptionalInt.empty(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void sendTradeOffers( int id, TradeOfferList list, int level, int experience, boolean levelled, boolean refreshable ) |     public void sendMerchantOffers( int id, MerchantOffers list, int level, int experience, boolean levelled, boolean refreshable ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void openHorseInventory( HorseBaseEntity horse, Inventory inventory ) |     public void openHorseInventory( AbstractHorse horse, Container inventory ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void useBook( ItemStack stack, Hand hand ) |     public void openItemGui( ItemStack stack, InteractionHand hand ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void openCommandBlockScreen( CommandBlockBlockEntity block ) |     public void openCommandBlock( CommandBlockEntity block ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -149,7 +151,7 @@ public class FakePlayer extends ServerPlayerEntity | |||||||
|     //    } |     //    } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void closeHandledScreen() |     public void closeContainer() | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -159,55 +161,55 @@ public class FakePlayer extends ServerPlayerEntity | |||||||
|     //    } |     //    } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public int unlockRecipes( Collection<Recipe<?>> recipes ) |     public int awardRecipes( Collection<Recipe<?>> recipes ) | ||||||
|     { |     { | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Indirect |     // Indirect | ||||||
|     @Override |     @Override | ||||||
|     public int lockRecipes( Collection<Recipe<?>> recipes ) |     public int resetRecipes( Collection<Recipe<?>> recipes ) | ||||||
|     { |     { | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void sendMessage( Text textComponent, boolean status ) |     public void displayClientMessage( Component textComponent, boolean status ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void consumeItem() |     protected void completeUsingItem() | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void lookAt( EntityAnchorArgumentType.EntityAnchor anchor, Vec3d vec3d ) |     public void lookAt( EntityAnchorArgument.Anchor anchor, Vec3 vec3d ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void lookAtEntity( EntityAnchorArgumentType.EntityAnchor self, Entity entity, EntityAnchorArgumentType.EntityAnchor target ) |     public void lookAt( EntityAnchorArgument.Anchor self, Entity entity, EntityAnchorArgument.Anchor target ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onStatusEffectApplied( StatusEffectInstance statusEffectInstance, @Nullable Entity source ) |     protected void onEffectAdded( MobEffectInstance statusEffectInstance, @Nullable Entity source ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onStatusEffectUpgraded( StatusEffectInstance statusEffectInstance, boolean particles, @Nullable Entity source ) |     protected void onEffectUpdated( MobEffectInstance statusEffectInstance, boolean particles, @Nullable Entity source ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onStatusEffectRemoved( StatusEffectInstance statusEffectInstance ) |     protected void onEffectRemoved( MobEffectInstance statusEffectInstance ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void requestTeleport( double x, double y, double z ) |     public void teleportTo( double x, double y, double z ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -217,13 +219,13 @@ public class FakePlayer extends ServerPlayerEntity | |||||||
|     //    } |     //    } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void sendMessage( Text message, MessageType type, UUID senderUuid ) |     public void sendMessage( Component message, ChatType type, UUID senderUuid ) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public String getIp() |     public String getIpAddress() | ||||||
|     { |     { | ||||||
|         return "[Fake Player]"; |         return "[Fake Player]"; | ||||||
|     } |     } | ||||||
| @@ -239,63 +241,63 @@ public class FakePlayer extends ServerPlayerEntity | |||||||
|     //    } |     //    } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void setCameraEntity( Entity entity ) |     public void setCamera( Entity entity ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void teleport( ServerWorld serverWorld, double x, double y, double z, float pitch, float yaw ) |     public void teleportTo( ServerLevel serverWorld, double x, double y, double z, float pitch, float yaw ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void sendInitialChunkPackets( ChunkPos chunkPos, Packet<?> packet, Packet<?> packet2 ) |     public void trackChunk( ChunkPos chunkPos, Packet<?> packet, Packet<?> packet2 ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void sendUnloadChunkPacket( ChunkPos chunkPos ) |     public void untrackChunk( ChunkPos chunkPos ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void playSound( SoundEvent soundEvent, SoundCategory soundCategory, float volume, float pitch ) |     public void playNotifySound( SoundEvent soundEvent, SoundSource soundCategory, float volume, float pitch ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static class FakeNetHandler extends ServerPlayNetworkHandler |     private static class FakeNetHandler extends ServerGamePacketListenerImpl | ||||||
|     { |     { | ||||||
|         FakeNetHandler( ServerPlayerEntity player ) |         FakeNetHandler( ServerPlayer player ) | ||||||
|         { |         { | ||||||
|             super( player.server, new FakeConnection(), player ); |             super( player.server, new FakeConnection(), player ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void disconnect( Text message ) |         public void disconnect( Component message ) | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void onVehicleMove( VehicleMoveC2SPacket move ) |         public void handleMoveVehicle( ServerboundMoveVehiclePacket move ) | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void onRequestCommandCompletions( RequestCommandCompletionsC2SPacket packet ) |         public void handleCustomCommandSuggestions( ServerboundCommandSuggestionPacket packet ) | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void sendPacket( Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> listener ) |         public void send( Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> listener ) | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static class FakeConnection extends ClientConnection |     private static class FakeConnection extends Connection | ||||||
|     { |     { | ||||||
|         FakeConnection() |         FakeConnection() | ||||||
|         { |         { | ||||||
|             super( NetworkSide.CLIENTBOUND ); |             super( PacketFlow.CLIENTBOUND ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
| @@ -304,7 +306,7 @@ public class FakePlayer extends ServerPlayerEntity | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void setState( NetworkState state ) |         public void setProtocol( ConnectionProtocol state ) | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -329,18 +331,18 @@ public class FakePlayer extends ServerPlayerEntity | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void disconnect( Text message ) |         public void disconnect( Component message ) | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void setupEncryption( Cipher cipher, Cipher cipher2 ) |         public void setEncryptionKey( Cipher cipher, Cipher cipher2 ) | ||||||
|         { |         { | ||||||
|             super.setupEncryption( cipher, cipher2 ); |             super.setEncryptionKey( cipher, cipher2 ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void disableAutoRead() |         public void setReadOnly() | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -11,15 +11,14 @@ import dan200.computercraft.api.lua.ILuaCallback; | |||||||
| import dan200.computercraft.api.lua.MethodResult; | import dan200.computercraft.api.lua.MethodResult; | ||||||
| import dan200.computercraft.api.peripheral.IPeripheral; | import dan200.computercraft.api.peripheral.IPeripheral; | ||||||
| import dan200.computercraft.shared.util.ItemStorage; | import dan200.computercraft.shared.util.ItemStorage; | ||||||
| import net.minecraft.inventory.Inventory; |  | ||||||
| import net.minecraft.nbt.NbtCompound; |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
| import net.minecraft.util.math.Vec3d; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.nbt.CompoundTag; | ||||||
|  | import net.minecraft.world.Container; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.phys.Vec3; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * The interface passed to turtle by turtles, providing methods that they can call. |  * The interface passed to turtle by turtles, providing methods that they can call. | ||||||
| @@ -34,7 +33,7 @@ public interface ITurtleAccess | |||||||
|      * @return the world in which the turtle resides. |      * @return the world in which the turtle resides. | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     World getWorld(); |     Level getWorld(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Returns a vector containing the integer co-ordinates at which the turtle resides. |      * Returns a vector containing the integer co-ordinates at which the turtle resides. | ||||||
| @@ -55,7 +54,7 @@ public interface ITurtleAccess | |||||||
|      * @return Whether the movement was successful. It may fail if the block was not loaded or the block placement was cancelled. |      * @return Whether the movement was successful. It may fail if the block was not loaded or the block placement was cancelled. | ||||||
|      * @throws UnsupportedOperationException When attempting to teleport on the client side. |      * @throws UnsupportedOperationException When attempting to teleport on the client side. | ||||||
|      */ |      */ | ||||||
|     boolean teleportTo( @Nonnull World world, @Nonnull BlockPos pos ); |     boolean teleportTo( @Nonnull Level world, @Nonnull BlockPos pos ); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Returns a vector containing the floating point co-ordinates at which the turtle is rendered. This will shift when the turtle is moving. |      * Returns a vector containing the floating point co-ordinates at which the turtle is rendered. This will shift when the turtle is moving. | ||||||
| @@ -65,7 +64,7 @@ public interface ITurtleAccess | |||||||
|      * @see #getVisualYaw(float) |      * @see #getVisualYaw(float) | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     Vec3d getVisualPosition( float f ); |     Vec3 getVisualPosition( float f ); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Returns the yaw the turtle is facing when it is rendered. |      * Returns the yaw the turtle is facing when it is rendered. | ||||||
| @@ -255,7 +254,7 @@ public interface ITurtleAccess | |||||||
|      * @see #updateUpgradeNBTData(TurtleSide) |      * @see #updateUpgradeNBTData(TurtleSide) | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     NbtCompound getUpgradeNBTData( @Nullable TurtleSide side ); |     CompoundTag getUpgradeNBTData( @Nullable TurtleSide side ); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Mark the upgrade-specific data as dirty on a specific side. This is required for the data to be synced to the client and persisted. |      * Mark the upgrade-specific data as dirty on a specific side. This is required for the data to be synced to the client and persisted. | ||||||
| @@ -278,5 +277,5 @@ public interface ITurtleAccess | |||||||
|      * @return This turtle's inventory |      * @return This turtle's inventory | ||||||
|      */ |      */ | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     Inventory getInventory(); |     Container getInventory(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -12,8 +12,7 @@ import dan200.computercraft.api.client.TransformedModel; | |||||||
| import dan200.computercraft.api.peripheral.IPeripheral; | import dan200.computercraft.api.peripheral.IPeripheral; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.util.math.Direction; | import net.minecraft.core.Direction; | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,9 +10,8 @@ import dan200.computercraft.api.turtle.FakePlayer; | |||||||
| import dan200.computercraft.api.turtle.ITurtleAccess; | import dan200.computercraft.api.turtle.ITurtleAccess; | ||||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||||
| import dan200.computercraft.api.turtle.TurtleSide; | import dan200.computercraft.api.turtle.TurtleSide; | ||||||
| import net.minecraft.entity.Entity; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.world.entity.Entity; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
| @@ -11,12 +11,11 @@ import dan200.computercraft.api.turtle.FakePlayer; | |||||||
| import dan200.computercraft.api.turtle.ITurtleAccess; | import dan200.computercraft.api.turtle.ITurtleAccess; | ||||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||||
| import dan200.computercraft.api.turtle.TurtleSide; | import dan200.computercraft.api.turtle.TurtleSide; | ||||||
| import net.minecraft.block.BlockState; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.level.block.state.BlockState; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
| @@ -31,10 +30,10 @@ import java.util.Objects; | |||||||
|  */ |  */ | ||||||
| public abstract class TurtleBlockEvent extends TurtlePlayerEvent | public abstract class TurtleBlockEvent extends TurtlePlayerEvent | ||||||
| { | { | ||||||
|     private final World world; |     private final Level world; | ||||||
|     private final BlockPos pos; |     private final BlockPos pos; | ||||||
|  |  | ||||||
|     protected TurtleBlockEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction action, @Nonnull FakePlayer player, @Nonnull World world, |     protected TurtleBlockEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction action, @Nonnull FakePlayer player, @Nonnull Level world, | ||||||
|                                 @Nonnull BlockPos pos ) |                                 @Nonnull BlockPos pos ) | ||||||
|     { |     { | ||||||
|         super( turtle, action, player ); |         super( turtle, action, player ); | ||||||
| @@ -50,7 +49,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | |||||||
|      * |      * | ||||||
|      * @return The world the turtle is interacting in. |      * @return The world the turtle is interacting in. | ||||||
|      */ |      */ | ||||||
|     public World getWorld() |     public Level getWorld() | ||||||
|     { |     { | ||||||
|         return world; |         return world; | ||||||
|     } |     } | ||||||
| @@ -76,7 +75,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | |||||||
|         private final ITurtleUpgrade upgrade; |         private final ITurtleUpgrade upgrade; | ||||||
|         private final TurtleSide side; |         private final TurtleSide side; | ||||||
|  |  | ||||||
|         public Dig( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState block, |         public Dig( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState block, | ||||||
|                     @Nonnull ITurtleUpgrade upgrade, @Nonnull TurtleSide side ) |                     @Nonnull ITurtleUpgrade upgrade, @Nonnull TurtleSide side ) | ||||||
|         { |         { | ||||||
|             super( turtle, TurtleAction.DIG, player, world, pos ); |             super( turtle, TurtleAction.DIG, player, world, pos ); | ||||||
| @@ -130,7 +129,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | |||||||
|      */ |      */ | ||||||
|     public static class Move extends TurtleBlockEvent |     public static class Move extends TurtleBlockEvent | ||||||
|     { |     { | ||||||
|         public Move( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos ) |         public Move( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull Level world, @Nonnull BlockPos pos ) | ||||||
|         { |         { | ||||||
|             super( turtle, TurtleAction.MOVE, player, world, pos ); |             super( turtle, TurtleAction.MOVE, player, world, pos ); | ||||||
|         } |         } | ||||||
| @@ -145,7 +144,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | |||||||
|     { |     { | ||||||
|         private final ItemStack stack; |         private final ItemStack stack; | ||||||
|  |  | ||||||
|         public Place( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull ItemStack stack ) |         public Place( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull ItemStack stack ) | ||||||
|         { |         { | ||||||
|             super( turtle, TurtleAction.PLACE, player, world, pos ); |             super( turtle, TurtleAction.PLACE, player, world, pos ); | ||||||
|  |  | ||||||
| @@ -177,7 +176,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | |||||||
|         private final BlockState state; |         private final BlockState state; | ||||||
|         private final Map<String, Object> data; |         private final Map<String, Object> data; | ||||||
|  |  | ||||||
|         public Inspect( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, |         public Inspect( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState state, | ||||||
|                         @Nonnull Map<String, Object> data ) |                         @Nonnull Map<String, Object> data ) | ||||||
|         { |         { | ||||||
|             super( turtle, TurtleAction.INSPECT, player, world, pos ); |             super( turtle, TurtleAction.INSPECT, player, world, pos ); | ||||||
|   | |||||||
| @@ -8,9 +8,8 @@ package dan200.computercraft.api.turtle.event; | |||||||
|  |  | ||||||
| import dan200.computercraft.api.lua.MethodResult; | import dan200.computercraft.api.lua.MethodResult; | ||||||
| import dan200.computercraft.api.turtle.ITurtleAccess; | import dan200.computercraft.api.turtle.ITurtleAccess; | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,13 +8,12 @@ package dan200.computercraft.api.turtle.event; | |||||||
|  |  | ||||||
| import dan200.computercraft.api.turtle.FakePlayer; | import dan200.computercraft.api.turtle.FakePlayer; | ||||||
| import dan200.computercraft.api.turtle.ITurtleAccess; | import dan200.computercraft.api.turtle.ITurtleAccess; | ||||||
| import net.minecraft.inventory.Inventory; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.world.Container; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -22,10 +21,10 @@ import java.util.Objects; | |||||||
|  */ |  */ | ||||||
| public abstract class TurtleInventoryEvent extends TurtleBlockEvent | public abstract class TurtleInventoryEvent extends TurtleBlockEvent | ||||||
| { | { | ||||||
|     private final Inventory handler; |     private final Container handler; | ||||||
|  |  | ||||||
|     protected TurtleInventoryEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction action, @Nonnull FakePlayer player, @Nonnull World world, |     protected TurtleInventoryEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction action, @Nonnull FakePlayer player, @Nonnull Level world, | ||||||
|                                     @Nonnull BlockPos pos, @Nullable Inventory handler ) |                                     @Nonnull BlockPos pos, @Nullable Container handler ) | ||||||
|     { |     { | ||||||
|         super( turtle, action, player, world, pos ); |         super( turtle, action, player, world, pos ); | ||||||
|         this.handler = handler; |         this.handler = handler; | ||||||
| @@ -37,7 +36,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent | |||||||
|      * @return The inventory being interacted with, {@code null} if the item will be dropped to/sucked from the world. |      * @return The inventory being interacted with, {@code null} if the item will be dropped to/sucked from the world. | ||||||
|      */ |      */ | ||||||
|     @Nullable |     @Nullable | ||||||
|     public Inventory getItemHandler() |     public Container getItemHandler() | ||||||
|     { |     { | ||||||
|         return handler; |         return handler; | ||||||
|     } |     } | ||||||
| @@ -49,7 +48,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent | |||||||
|      */ |      */ | ||||||
|     public static class Suck extends TurtleInventoryEvent |     public static class Suck extends TurtleInventoryEvent | ||||||
|     { |     { | ||||||
|         public Suck( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable Inventory handler ) |         public Suck( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull Level world, @Nonnull BlockPos pos, @Nullable Container handler ) | ||||||
|         { |         { | ||||||
|             super( turtle, TurtleAction.SUCK, player, world, pos, handler ); |             super( turtle, TurtleAction.SUCK, player, world, pos, handler ); | ||||||
|         } |         } | ||||||
| @@ -64,7 +63,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent | |||||||
|     { |     { | ||||||
|         private final ItemStack stack; |         private final ItemStack stack; | ||||||
|  |  | ||||||
|         public Drop( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable Inventory handler, |         public Drop( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull Level world, @Nonnull BlockPos pos, @Nullable Container handler, | ||||||
|                      @Nonnull ItemStack stack ) |                      @Nonnull ItemStack stack ) | ||||||
|         { |         { | ||||||
|             super( turtle, TurtleAction.DROP, player, world, pos, handler ); |             super( turtle, TurtleAction.DROP, player, world, pos, handler ); | ||||||
|   | |||||||
| @@ -7,10 +7,9 @@ | |||||||
| package dan200.computercraft.api.turtle.event; | package dan200.computercraft.api.turtle.event; | ||||||
|  |  | ||||||
| import dan200.computercraft.api.turtle.ITurtleAccess; | import dan200.computercraft.api.turtle.ITurtleAccess; | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
| @@ -15,16 +15,15 @@ import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | |||||||
| import dan200.computercraft.shared.util.Colour; | import dan200.computercraft.shared.util.Colour; | ||||||
| import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; | import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; | ||||||
| import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; | import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.render.model.BakedModel; | import net.minecraft.client.renderer.texture.TextureAtlas; | ||||||
| import net.minecraft.client.render.model.ModelLoader; | import net.minecraft.client.resources.model.BakedModel; | ||||||
| import net.minecraft.client.render.model.ModelRotation; | import net.minecraft.client.resources.model.BlockModelRotation; | ||||||
| import net.minecraft.client.render.model.UnbakedModel; | import net.minecraft.client.resources.model.ModelBakery; | ||||||
| import net.minecraft.client.texture.SpriteAtlasTexture; | import net.minecraft.client.resources.model.ModelResourceLocation; | ||||||
| import net.minecraft.client.util.ModelIdentifier; | import net.minecraft.client.resources.model.UnbakedModel; | ||||||
| import net.minecraft.resource.ResourceManager; | import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.server.packs.resources.ResourceManager; | ||||||
|  |  | ||||||
| import java.util.HashSet; | import java.util.HashSet; | ||||||
| import java.util.function.Consumer; | import java.util.function.Consumer; | ||||||
|  |  | ||||||
| @@ -68,20 +67,20 @@ public final class ClientRegistry | |||||||
|  |  | ||||||
|     private ClientRegistry() {} |     private ClientRegistry() {} | ||||||
|  |  | ||||||
|     public static void onTextureStitchEvent( SpriteAtlasTexture atlasTexture, ClientSpriteRegistryCallback.Registry registry ) |     public static void onTextureStitchEvent( TextureAtlas atlasTexture, ClientSpriteRegistryCallback.Registry registry ) | ||||||
|     { |     { | ||||||
|         for( String extra : EXTRA_TEXTURES ) |         for( String extra : EXTRA_TEXTURES ) | ||||||
|         { |         { | ||||||
|             registry.register( new Identifier( ComputerCraft.MOD_ID, extra ) ); |             registry.register( new ResourceLocation( ComputerCraft.MOD_ID, extra ) ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @SuppressWarnings( "NewExpressionSideOnly" ) |     @SuppressWarnings( "NewExpressionSideOnly" ) | ||||||
|     public static void onModelBakeEvent( ResourceManager manager, Consumer<Identifier> out ) |     public static void onModelBakeEvent( ResourceManager manager, Consumer<ResourceLocation> out ) | ||||||
|     { |     { | ||||||
|         for( String model : EXTRA_MODELS ) |         for( String model : EXTRA_MODELS ) | ||||||
|         { |         { | ||||||
|             out.accept( new ModelIdentifier( new Identifier( ComputerCraft.MOD_ID, model ), "inventory" ) ); |             out.accept( new ModelResourceLocation( new ResourceLocation( ComputerCraft.MOD_ID, model ), "inventory" ) ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -114,14 +113,14 @@ public final class ClientRegistry | |||||||
|             ComputerCraftRegistry.ModBlocks.TURTLE_ADVANCED ); |             ComputerCraftRegistry.ModBlocks.TURTLE_ADVANCED ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static BakedModel bake( ModelLoader loader, UnbakedModel model, Identifier identifier ) |     private static BakedModel bake( ModelBakery loader, UnbakedModel model, ResourceLocation identifier ) | ||||||
|     { |     { | ||||||
|         model.getTextureDependencies( loader::getOrLoadModel, new HashSet<>() ); |         model.getMaterials( loader::getModel, new HashSet<>() ); | ||||||
|         return model.bake( loader, |         return model.bake( loader, | ||||||
|             spriteIdentifier -> MinecraftClient.getInstance() |             spriteIdentifier -> Minecraft.getInstance() | ||||||
|                 .getSpriteAtlas( spriteIdentifier.getAtlasId() ) |                 .getTextureAtlas( spriteIdentifier.atlasLocation() ) | ||||||
|                 .apply( spriteIdentifier.getTextureId() ), |                 .apply( spriteIdentifier.texture() ), | ||||||
|             ModelRotation.X0_Y0, |             BlockModelRotation.X0_Y0, | ||||||
|             identifier ); |             identifier ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -11,15 +11,15 @@ import dan200.computercraft.shared.command.text.ChatHelpers; | |||||||
| import dan200.computercraft.shared.command.text.TableBuilder; | import dan200.computercraft.shared.command.text.TableBuilder; | ||||||
| import dan200.computercraft.shared.command.text.TableFormatter; | import dan200.computercraft.shared.command.text.TableFormatter; | ||||||
| import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; | import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; | ||||||
| import net.minecraft.client.MinecraftClient; |  | ||||||
| import net.minecraft.client.font.TextRenderer; |  | ||||||
| import net.minecraft.client.gui.hud.ChatHud; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.util.Formatting; |  | ||||||
| import net.minecraft.util.math.MathHelper; |  | ||||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.ChatFormatting; | ||||||
|  | import net.minecraft.client.Minecraft; | ||||||
|  | import net.minecraft.client.gui.Font; | ||||||
|  | import net.minecraft.client.gui.components.ChatComponent; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.util.Mth; | ||||||
|  |  | ||||||
| public class ClientTableFormatter implements TableFormatter | public class ClientTableFormatter implements TableFormatter | ||||||
| { | { | ||||||
| @@ -29,7 +29,7 @@ public class ClientTableFormatter implements TableFormatter | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     @Nullable |     @Nullable | ||||||
|     public Text getPadding( Text component, int width ) |     public Component getPadding( Component component, int width ) | ||||||
|     { |     { | ||||||
|         int extraWidth = width - getWidth( component ); |         int extraWidth = width - getWidth( component ); | ||||||
|         if( extraWidth <= 0 ) |         if( extraWidth <= 0 ) | ||||||
| @@ -37,18 +37,18 @@ public class ClientTableFormatter implements TableFormatter | |||||||
|             return null; |             return null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         TextRenderer renderer = renderer(); |         Font renderer = renderer(); | ||||||
|  |  | ||||||
|         float spaceWidth = renderer.getWidth( " " ); |         float spaceWidth = renderer.width( " " ); | ||||||
|         int spaces = MathHelper.floor( extraWidth / spaceWidth ); |         int spaces = Mth.floor( extraWidth / spaceWidth ); | ||||||
|         int extra = extraWidth - (int) (spaces * spaceWidth); |         int extra = extraWidth - (int) (spaces * spaceWidth); | ||||||
|  |  | ||||||
|         return ChatHelpers.coloured( StringUtils.repeat( ' ', spaces ) + StringUtils.repeat( (char) 712, extra ), Formatting.GRAY ); |         return ChatHelpers.coloured( StringUtils.repeat( ' ', spaces ) + StringUtils.repeat( (char) 712, extra ), ChatFormatting.GRAY ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static TextRenderer renderer() |     private static Font renderer() | ||||||
|     { |     { | ||||||
|         return MinecraftClient.getInstance().textRenderer; |         return Minecraft.getInstance().font; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -58,16 +58,16 @@ public class ClientTableFormatter implements TableFormatter | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public int getWidth( Text component ) |     public int getWidth( Component component ) | ||||||
|     { |     { | ||||||
|         return renderer().getWidth( component ); |         return renderer().width( component ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void writeLine( int id, Text component ) |     public void writeLine( int id, Component component ) | ||||||
|     { |     { | ||||||
|         MinecraftClient mc = MinecraftClient.getInstance(); |         Minecraft mc = Minecraft.getInstance(); | ||||||
|         ChatHud chat = mc.inGameHud.getChatHud(); |         ChatComponent chat = mc.gui.getChat(); | ||||||
|  |  | ||||||
|         // TODO: Trim the text if it goes over the allowed length |         // TODO: Trim the text if it goes over the allowed length | ||||||
|         // int maxWidth = MathHelper.floor( chat.getChatWidth() / chat.getScale() ); |         // int maxWidth = MathHelper.floor( chat.getChatWidth() / chat.getScale() ); | ||||||
| @@ -79,7 +79,7 @@ public class ClientTableFormatter implements TableFormatter | |||||||
|     @Override |     @Override | ||||||
|     public int display( TableBuilder table ) |     public int display( TableBuilder table ) | ||||||
|     { |     { | ||||||
|         ChatHud chat = MinecraftClient.getInstance().inGameHud.getChatHud(); |         ChatComponent chat = Minecraft.getInstance().gui.getChat(); | ||||||
|  |  | ||||||
|         int lastHeight = lastHeights.get( table.getId() ); |         int lastHeight = lastHeights.get( table.getId() ); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,25 +5,24 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client; | package dan200.computercraft.client; | ||||||
|  |  | ||||||
| import net.minecraft.client.MinecraftClient; |  | ||||||
| import net.minecraft.client.sound.AbstractSoundInstance; |  | ||||||
| import net.minecraft.client.sound.SoundInstance; |  | ||||||
| import net.minecraft.client.sound.TickableSoundInstance; |  | ||||||
| import net.minecraft.sound.SoundCategory; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
| import net.minecraft.util.math.Vec3d; |  | ||||||
|  |  | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  | import net.minecraft.client.Minecraft; | ||||||
|  | import net.minecraft.client.resources.sounds.AbstractSoundInstance; | ||||||
|  | import net.minecraft.client.resources.sounds.SoundInstance; | ||||||
|  | import net.minecraft.client.resources.sounds.TickableSoundInstance; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.sounds.SoundSource; | ||||||
|  | import net.minecraft.world.phys.Vec3; | ||||||
|  |  | ||||||
| public class SoundManager | public class SoundManager | ||||||
| { | { | ||||||
|     private static final Map<UUID, MoveableSound> sounds = new HashMap<>(); |     private static final Map<UUID, MoveableSound> sounds = new HashMap<>(); | ||||||
|  |  | ||||||
|     public static void playSound( UUID source, Vec3d position, Identifier event, float volume, float pitch ) |     public static void playSound( UUID source, Vec3 position, ResourceLocation event, float volume, float pitch ) | ||||||
|     { |     { | ||||||
|         var soundManager = MinecraftClient.getInstance().getSoundManager(); |         var soundManager = Minecraft.getInstance().getSoundManager(); | ||||||
|  |  | ||||||
|         MoveableSound oldSound = sounds.get( source ); |         MoveableSound oldSound = sounds.get( source ); | ||||||
|         if( oldSound != null ) soundManager.stop( oldSound ); |         if( oldSound != null ) soundManager.stop( oldSound ); | ||||||
| @@ -38,10 +37,10 @@ public class SoundManager | |||||||
|         SoundInstance sound = sounds.remove( source ); |         SoundInstance sound = sounds.remove( source ); | ||||||
|         if( sound == null ) return; |         if( sound == null ) return; | ||||||
|  |  | ||||||
|         MinecraftClient.getInstance().getSoundManager().stop( sound ); |         Minecraft.getInstance().getSoundManager().stop( sound ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void moveSound( UUID source, Vec3d position ) |     public static void moveSound( UUID source, Vec3 position ) | ||||||
|     { |     { | ||||||
|         MoveableSound sound = sounds.get( source ); |         MoveableSound sound = sounds.get( source ); | ||||||
|         if( sound != null ) sound.setPosition( position ); |         if( sound != null ) sound.setPosition( position ); | ||||||
| @@ -54,24 +53,24 @@ public class SoundManager | |||||||
|  |  | ||||||
|     private static class MoveableSound extends AbstractSoundInstance implements TickableSoundInstance |     private static class MoveableSound extends AbstractSoundInstance implements TickableSoundInstance | ||||||
|     { |     { | ||||||
|         protected MoveableSound( Identifier sound, Vec3d position, float volume, float pitch ) |         protected MoveableSound( ResourceLocation sound, Vec3 position, float volume, float pitch ) | ||||||
|         { |         { | ||||||
|             super( sound, SoundCategory.RECORDS ); |             super( sound, SoundSource.RECORDS ); | ||||||
|             setPosition( position ); |             setPosition( position ); | ||||||
|             this.volume = volume; |             this.volume = volume; | ||||||
|             this.pitch = pitch; |             this.pitch = pitch; | ||||||
|             attenuationType = SoundInstance.AttenuationType.LINEAR; |             attenuation = SoundInstance.Attenuation.LINEAR; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         void setPosition( Vec3d position ) |         void setPosition( Vec3 position ) | ||||||
|         { |         { | ||||||
|             x = (float) position.getX(); |             x = (float) position.x(); | ||||||
|             y = (float) position.getY(); |             y = (float) position.y(); | ||||||
|             z = (float) position.getZ(); |             z = (float) position.z(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public boolean isDone() |         public boolean isStopped() | ||||||
|         { |         { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client.gui; | package dan200.computercraft.client.gui; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.client.gui.widgets.ComputerSidebar; | import dan200.computercraft.client.gui.widgets.ComputerSidebar; | ||||||
| import dan200.computercraft.client.gui.widgets.WidgetTerminal; | import dan200.computercraft.client.gui.widgets.WidgetTerminal; | ||||||
| @@ -16,14 +17,13 @@ import dan200.computercraft.shared.computer.upload.UploadResult; | |||||||
| import dan200.computercraft.shared.network.NetworkHandler; | import dan200.computercraft.shared.network.NetworkHandler; | ||||||
| import dan200.computercraft.shared.network.server.ContinueUploadMessage; | import dan200.computercraft.shared.network.server.ContinueUploadMessage; | ||||||
| import dan200.computercraft.shared.network.server.UploadFileMessage; | import dan200.computercraft.shared.network.server.UploadFileMessage; | ||||||
| import net.minecraft.client.gui.screen.ingame.HandledScreen; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.player.PlayerInventory; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.text.TranslatableText; |  | ||||||
| import org.lwjgl.glfw.GLFW; | import org.lwjgl.glfw.GLFW; | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.network.chat.TranslatableComponent; | ||||||
|  | import net.minecraft.world.entity.player.Inventory; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.nio.ByteBuffer; | import java.nio.ByteBuffer; | ||||||
| import java.nio.channels.SeekableByteChannel; | import java.nio.channels.SeekableByteChannel; | ||||||
| @@ -34,12 +34,12 @@ import java.util.Arrays; | |||||||
| import java.util.Collections; | import java.util.Collections; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public abstract class ComputerScreenBase<T extends ContainerComputerBase> extends HandledScreen<T> | public abstract class ComputerScreenBase<T extends ContainerComputerBase> extends AbstractContainerScreen<T> | ||||||
| { | { | ||||||
|  |  | ||||||
|     private static final Text OK = new TranslatableText( "gui.ok" ); |     private static final Component OK = new TranslatableComponent( "gui.ok" ); | ||||||
|     private static final Text CANCEL = new TranslatableText( "gui.cancel" ); |     private static final Component CANCEL = new TranslatableComponent( "gui.cancel" ); | ||||||
|     private static final Text OVERWRITE = new TranslatableText( "gui.computercraft.upload.overwrite_button" ); |     private static final Component OVERWRITE = new TranslatableComponent( "gui.computercraft.upload.overwrite_button" ); | ||||||
|  |  | ||||||
|     protected WidgetTerminal terminal; |     protected WidgetTerminal terminal; | ||||||
|     protected final ClientComputer computer; |     protected final ClientComputer computer; | ||||||
| @@ -47,7 +47,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|  |  | ||||||
|     protected final int sidebarYOffset; |     protected final int sidebarYOffset; | ||||||
|  |  | ||||||
|     public ComputerScreenBase( T container, PlayerInventory player, Text title, int sidebarYOffset ) |     public ComputerScreenBase( T container, Inventory player, Component title, int sidebarYOffset ) | ||||||
|     { |     { | ||||||
|         super( container, player, title ); |         super( container, player, title ); | ||||||
|         computer = (ClientComputer) container.getComputer(); |         computer = (ClientComputer) container.getComputer(); | ||||||
| @@ -61,10 +61,10 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|     protected final void init() |     protected final void init() | ||||||
|     { |     { | ||||||
|         super.init(); |         super.init(); | ||||||
|         client.keyboard.setRepeatEvents( true ); |         minecraft.keyboardHandler.setSendRepeatsToGui( true ); | ||||||
|  |  | ||||||
|         terminal = addDrawableChild( createTerminal() ); |         terminal = addRenderableWidget( createTerminal() ); | ||||||
|         ComputerSidebar.addButtons( this, computer, this::addDrawableChild, x, y + sidebarYOffset ); |         ComputerSidebar.addButtons( this, computer, this::addRenderableWidget, leftPos, topPos + sidebarYOffset ); | ||||||
|         setFocused( terminal ); |         setFocused( terminal ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -72,13 +72,13 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|     public final void removed() |     public final void removed() | ||||||
|     { |     { | ||||||
|         super.removed(); |         super.removed(); | ||||||
|         client.keyboard.setRepeatEvents( false ); |         minecraft.keyboardHandler.setSendRepeatsToGui( false ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public final void handledScreenTick() |     public final void containerTick() | ||||||
|     { |     { | ||||||
|         super.handledScreenTick(); |         super.containerTick(); | ||||||
|         terminal.update(); |         terminal.update(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -95,11 +95,11 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public final void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) |     public final void render( @Nonnull PoseStack stack, int mouseX, int mouseY, float partialTicks ) | ||||||
|     { |     { | ||||||
|         renderBackground( stack ); |         renderBackground( stack ); | ||||||
|         super.render( stack, mouseX, mouseY, partialTicks ); |         super.render( stack, mouseX, mouseY, partialTicks ); | ||||||
|         drawMouseoverTooltip( stack, mouseX, mouseY ); |         renderTooltip( stack, mouseX, mouseY ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -109,13 +109,13 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void drawForeground( @Nonnull MatrixStack transform, int mouseX, int mouseY ) |     protected void renderLabels( @Nonnull PoseStack transform, int mouseX, int mouseY ) | ||||||
|     { |     { | ||||||
|         // Skip rendering labels. |         // Skip rendering labels. | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void filesDragged( @Nonnull List<Path> files ) |     public void onFilesDrop( @Nonnull List<Path> files ) | ||||||
|     { |     { | ||||||
|         if( files.isEmpty() ) return; |         if( files.isEmpty() ) return; | ||||||
|  |  | ||||||
| @@ -145,7 +145,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|                 String name = file.getFileName().toString(); |                 String name = file.getFileName().toString(); | ||||||
|                 if( name.length() > UploadFileMessage.MAX_FILE_NAME ) |                 if( name.length() > UploadFileMessage.MAX_FILE_NAME ) | ||||||
|                 { |                 { | ||||||
|                     alert( UploadResult.FAILED_TITLE, new TranslatableText( "gui.computercraft.upload.failed.name_too_long" ) ); |                     alert( UploadResult.FAILED_TITLE, new TranslatableComponent( "gui.computercraft.upload.failed.name_too_long" ) ); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -156,7 +156,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|                 byte[] digest = FileUpload.getDigest( buffer ); |                 byte[] digest = FileUpload.getDigest( buffer ); | ||||||
|                 if( digest == null ) |                 if( digest == null ) | ||||||
|                 { |                 { | ||||||
|                     alert( UploadResult.FAILED_TITLE, new TranslatableText( "gui.computercraft.upload.failed.corrupted" ) ); |                     alert( UploadResult.FAILED_TITLE, new TranslatableComponent( "gui.computercraft.upload.failed.corrupted" ) ); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -166,13 +166,13 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|             catch( IOException e ) |             catch( IOException e ) | ||||||
|             { |             { | ||||||
|                 ComputerCraft.log.error( "Failed uploading files", e ); |                 ComputerCraft.log.error( "Failed uploading files", e ); | ||||||
|                 alert( UploadResult.FAILED_TITLE, new TranslatableText( "gui.computercraft.upload.failed.generic", "Cannot compute checksum" ) ); |                 alert( UploadResult.FAILED_TITLE, new TranslatableComponent( "gui.computercraft.upload.failed.generic", "Cannot compute checksum" ) ); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if( toUpload.size() > UploadFileMessage.MAX_FILES ) |         if( toUpload.size() > UploadFileMessage.MAX_FILES ) | ||||||
|         { |         { | ||||||
|             alert( UploadResult.FAILED_TITLE, new TranslatableText( "gui.computercraft.upload.failed.too_many_files" ) ); |             alert( UploadResult.FAILED_TITLE, new TranslatableComponent( "gui.computercraft.upload.failed.too_many_files" ) ); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -182,7 +182,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void uploadResult( UploadResult result, Text message ) |     public void uploadResult( UploadResult result, Component message ) | ||||||
|     { |     { | ||||||
|         switch( result ) |         switch( result ) | ||||||
|         { |         { | ||||||
| @@ -194,7 +194,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|                 break; |                 break; | ||||||
|             case CONFIRM_OVERWRITE: |             case CONFIRM_OVERWRITE: | ||||||
|                 OptionScreen.show( |                 OptionScreen.show( | ||||||
|                     client, UploadResult.UPLOAD_OVERWRITE, message, |                     minecraft, UploadResult.UPLOAD_OVERWRITE, message, | ||||||
|                     Arrays.asList( |                     Arrays.asList( | ||||||
|                         OptionScreen.newButton( CANCEL, b -> cancelUpload() ), |                         OptionScreen.newButton( CANCEL, b -> cancelUpload() ), | ||||||
|                         OptionScreen.newButton( OVERWRITE, b -> continueUpload() ) |                         OptionScreen.newButton( OVERWRITE, b -> continueUpload() ) | ||||||
| @@ -207,21 +207,21 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | |||||||
|  |  | ||||||
|     private void continueUpload() |     private void continueUpload() | ||||||
|     { |     { | ||||||
|         if( client.currentScreen instanceof OptionScreen ) ((OptionScreen) client.currentScreen).disable(); |         if( minecraft.screen instanceof OptionScreen ) ((OptionScreen) minecraft.screen).disable(); | ||||||
|         NetworkHandler.sendToServer( new ContinueUploadMessage( computer.getInstanceID(), true ) ); |         NetworkHandler.sendToServer( new ContinueUploadMessage( computer.getInstanceID(), true ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void cancelUpload() |     private void cancelUpload() | ||||||
|     { |     { | ||||||
|         client.setScreen( this ); |         minecraft.setScreen( this ); | ||||||
|         NetworkHandler.sendToServer( new ContinueUploadMessage( computer.getInstanceID(), false ) ); |         NetworkHandler.sendToServer( new ContinueUploadMessage( computer.getInstanceID(), false ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void alert( Text title, Text message ) |     private void alert( Component title, Component message ) | ||||||
|     { |     { | ||||||
|         OptionScreen.show( client, title, message, |         OptionScreen.show( minecraft, title, message, | ||||||
|             Collections.singletonList( OptionScreen.newButton( OK, b -> client.setScreen( this ) ) ), |             Collections.singletonList( OptionScreen.newButton( OK, b -> minecraft.setScreen( this ) ) ), | ||||||
|             () -> client.setScreen( this ) |             () -> minecraft.setScreen( this ) | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,18 +12,18 @@ import dan200.computercraft.core.terminal.Terminal; | |||||||
| import dan200.computercraft.core.terminal.TextBuffer; | import dan200.computercraft.core.terminal.TextBuffer; | ||||||
| import dan200.computercraft.shared.util.Colour; | import dan200.computercraft.shared.util.Colour; | ||||||
| import dan200.computercraft.shared.util.Palette; | import dan200.computercraft.shared.util.Palette; | ||||||
| import net.minecraft.client.MinecraftClient; |  | ||||||
| import net.minecraft.client.render.VertexConsumer; |  | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
| import net.minecraft.util.math.AffineTransformation; |  | ||||||
| import net.minecraft.util.math.Matrix4f; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.client.Minecraft; | ||||||
|  | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  |  | ||||||
| import static dan200.computercraft.client.render.RenderTypes.FULL_BRIGHT_LIGHTMAP; | import static dan200.computercraft.client.render.RenderTypes.FULL_BRIGHT_LIGHTMAP; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.VertexConsumer; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
|  | import com.mojang.math.Transformation; | ||||||
|  |  | ||||||
| public final class FixedWidthFontRenderer | public final class FixedWidthFontRenderer | ||||||
| { | { | ||||||
|     public static final int FONT_HEIGHT = 9; |     public static final int FONT_HEIGHT = 9; | ||||||
| @@ -31,9 +31,9 @@ public final class FixedWidthFontRenderer | |||||||
|     public static final float WIDTH = 256.0f; |     public static final float WIDTH = 256.0f; | ||||||
|     public static final float BACKGROUND_START = (WIDTH - 6.0f) / WIDTH; |     public static final float BACKGROUND_START = (WIDTH - 6.0f) / WIDTH; | ||||||
|     public static final float BACKGROUND_END = (WIDTH - 4.0f) / WIDTH; |     public static final float BACKGROUND_END = (WIDTH - 4.0f) / WIDTH; | ||||||
|     private static final Matrix4f IDENTITY = AffineTransformation.identity() |     private static final Matrix4f IDENTITY = Transformation.identity() | ||||||
|         .getMatrix(); |         .getMatrix(); | ||||||
|     public static final Identifier FONT = new Identifier( "computercraft", "textures/gui/term_font.png" ); |     public static final ResourceLocation FONT = new ResourceLocation( "computercraft", "textures/gui/term_font.png" ); | ||||||
|  |  | ||||||
|  |  | ||||||
|     private FixedWidthFontRenderer() |     private FixedWidthFontRenderer() | ||||||
| @@ -157,34 +157,34 @@ public final class FixedWidthFontRenderer | |||||||
|  |  | ||||||
|         buffer.vertex( transform, x, y, 0f ) |         buffer.vertex( transform, x, y, 0f ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( xStart / WIDTH, yStart / WIDTH ) |             .uv( xStart / WIDTH, yStart / WIDTH ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x, y + FONT_HEIGHT, 0f ) |         buffer.vertex( transform, x, y + FONT_HEIGHT, 0f ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ) |             .uv( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x + FONT_WIDTH, y, 0f ) |         buffer.vertex( transform, x + FONT_WIDTH, y, 0f ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ) |             .uv( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x + FONT_WIDTH, y, 0f ) |         buffer.vertex( transform, x + FONT_WIDTH, y, 0f ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ) |             .uv( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x, y + FONT_HEIGHT, 0f ) |         buffer.vertex( transform, x, y + FONT_HEIGHT, 0f ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ) |             .uv( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x + FONT_WIDTH, y + FONT_HEIGHT, 0f ) |         buffer.vertex( transform, x + FONT_WIDTH, y + FONT_HEIGHT, 0f ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( (xStart + FONT_WIDTH) / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ) |             .uv( (xStart + FONT_WIDTH) / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void drawQuad( Matrix4f transform, VertexConsumer buffer, float x, float y, float width, float height, Palette palette, |     private static void drawQuad( Matrix4f transform, VertexConsumer buffer, float x, float y, float width, float height, Palette palette, | ||||||
| @@ -210,28 +210,28 @@ public final class FixedWidthFontRenderer | |||||||
|     { |     { | ||||||
|         buffer.vertex( transform, x, y, 0 ) |         buffer.vertex( transform, x, y, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( BACKGROUND_START, BACKGROUND_START ) |             .uv( BACKGROUND_START, BACKGROUND_START ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x, y + height, 0 ) |         buffer.vertex( transform, x, y + height, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( BACKGROUND_START, BACKGROUND_END ) |             .uv( BACKGROUND_START, BACKGROUND_END ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x + width, y, 0 ) |         buffer.vertex( transform, x + width, y, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( BACKGROUND_END, BACKGROUND_START ) |             .uv( BACKGROUND_END, BACKGROUND_START ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x + width, y, 0 ) |         buffer.vertex( transform, x + width, y, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( BACKGROUND_END, BACKGROUND_START ) |             .uv( BACKGROUND_END, BACKGROUND_START ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x, y + height, 0 ) |         buffer.vertex( transform, x, y + height, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( BACKGROUND_START, BACKGROUND_END ) |             .uv( BACKGROUND_START, BACKGROUND_END ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x + width, y + height, 0 ) |         buffer.vertex( transform, x + width, y + height, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( BACKGROUND_END, BACKGROUND_END ) |             .uv( BACKGROUND_END, BACKGROUND_END ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void drawTerminalWithoutCursor( @Nonnull Matrix4f transform, @Nonnull VertexConsumer buffer, float x, float y, |     public static void drawTerminalWithoutCursor( @Nonnull Matrix4f transform, @Nonnull VertexConsumer buffer, float x, float y, | ||||||
| @@ -319,12 +319,12 @@ public final class FixedWidthFontRenderer | |||||||
|     public static void drawTerminal( @Nonnull Matrix4f transform, float x, float y, @Nonnull Terminal terminal, boolean greyscale, float topMarginSize, |     public static void drawTerminal( @Nonnull Matrix4f transform, float x, float y, @Nonnull Terminal terminal, boolean greyscale, float topMarginSize, | ||||||
|                                      float bottomMarginSize, float leftMarginSize, float rightMarginSize ) |                                      float bottomMarginSize, float leftMarginSize, float rightMarginSize ) | ||||||
|     { |     { | ||||||
|         VertexConsumerProvider.Immediate renderer = MinecraftClient.getInstance() |         MultiBufferSource.BufferSource renderer = Minecraft.getInstance() | ||||||
|             .getBufferBuilders() |             .renderBuffers() | ||||||
|             .getEntityVertexConsumers(); |             .bufferSource(); | ||||||
|         VertexConsumer buffer = renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH ); |         VertexConsumer buffer = renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH ); | ||||||
|         drawTerminal( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize ); |         drawTerminal( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize ); | ||||||
|         renderer.draw(); |         renderer.endBatch(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void drawTerminal( float x, float y, @Nonnull Terminal terminal, boolean greyscale, float topMarginSize, float bottomMarginSize, |     public static void drawTerminal( float x, float y, @Nonnull Terminal terminal, boolean greyscale, float topMarginSize, float bottomMarginSize, | ||||||
| @@ -341,21 +341,21 @@ public final class FixedWidthFontRenderer | |||||||
|  |  | ||||||
|     public static void drawEmptyTerminal( @Nonnull Matrix4f transform, float x, float y, float width, float height ) |     public static void drawEmptyTerminal( @Nonnull Matrix4f transform, float x, float y, float width, float height ) | ||||||
|     { |     { | ||||||
|         VertexConsumerProvider.Immediate renderer = MinecraftClient.getInstance() |         MultiBufferSource.BufferSource renderer = Minecraft.getInstance() | ||||||
|             .getBufferBuilders() |             .renderBuffers() | ||||||
|             .getEntityVertexConsumers(); |             .bufferSource(); | ||||||
|         drawEmptyTerminal( transform, renderer, x, y, width, height ); |         drawEmptyTerminal( transform, renderer, x, y, width, height ); | ||||||
|         renderer.draw(); |         renderer.endBatch(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void drawEmptyTerminal( @Nonnull Matrix4f transform, @Nonnull VertexConsumerProvider renderer, float x, float y, float width, |     public static void drawEmptyTerminal( @Nonnull Matrix4f transform, @Nonnull MultiBufferSource renderer, float x, float y, float width, | ||||||
|                                           float height ) |                                           float height ) | ||||||
|     { |     { | ||||||
|         Colour colour = Colour.BLACK; |         Colour colour = Colour.BLACK; | ||||||
|         drawQuad( transform, renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() ); |         drawQuad( transform, renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void drawBlocker( @Nonnull Matrix4f transform, @Nonnull VertexConsumerProvider renderer, float x, float y, float width, float height ) |     public static void drawBlocker( @Nonnull Matrix4f transform, @Nonnull MultiBufferSource renderer, float x, float y, float width, float height ) | ||||||
|     { |     { | ||||||
|         Colour colour = Colour.BLACK; |         Colour colour = Colour.BLACK; | ||||||
|         drawQuad( transform, renderer.getBuffer( RenderTypes.TERMINAL_BLOCKER ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() ); |         drawQuad( transform, renderer.getBuffer( RenderTypes.TERMINAL_BLOCKER ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() ); | ||||||
|   | |||||||
| @@ -13,41 +13,41 @@ import dan200.computercraft.client.render.ComputerBorderRenderer; | |||||||
| import dan200.computercraft.client.render.RenderTypes; | import dan200.computercraft.client.render.RenderTypes; | ||||||
| import dan200.computercraft.shared.computer.inventory.ContainerComputerBase; | import dan200.computercraft.shared.computer.inventory.ContainerComputerBase; | ||||||
| import dan200.computercraft.shared.computer.inventory.ContainerViewComputer; | import dan200.computercraft.shared.computer.inventory.ContainerViewComputer; | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.player.PlayerInventory; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.world.entity.player.Inventory; | ||||||
|  |  | ||||||
| import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER; | import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER; | ||||||
| import static dan200.computercraft.client.render.ComputerBorderRenderer.getTexture; | import static dan200.computercraft.client.render.ComputerBorderRenderer.getTexture; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  |  | ||||||
| public final class GuiComputer<T extends ContainerComputerBase> extends ComputerScreenBase<T> | public final class GuiComputer<T extends ContainerComputerBase> extends ComputerScreenBase<T> | ||||||
| { | { | ||||||
|     private final int termWidth; |     private final int termWidth; | ||||||
|     private final int termHeight; |     private final int termHeight; | ||||||
|  |  | ||||||
|     private GuiComputer( T container, PlayerInventory player, Text title, int termWidth, int termHeight ) |     private GuiComputer( T container, Inventory player, Component title, int termWidth, int termHeight ) | ||||||
|     { |     { | ||||||
|         super( container, player, title, BORDER ); |         super( container, player, title, BORDER ); | ||||||
|         this.termWidth = termWidth; |         this.termWidth = termWidth; | ||||||
|         this.termHeight = termHeight; |         this.termHeight = termHeight; | ||||||
|  |  | ||||||
|         backgroundWidth = WidgetTerminal.getWidth( termWidth ) + BORDER * 2 + ComputerSidebar.WIDTH; |         imageWidth = WidgetTerminal.getWidth( termWidth ) + BORDER * 2 + ComputerSidebar.WIDTH; | ||||||
|         backgroundHeight = WidgetTerminal.getHeight( termHeight ) + BORDER * 2; |         imageHeight = WidgetTerminal.getHeight( termHeight ) + BORDER * 2; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static GuiComputer<ContainerComputerBase> create( ContainerComputerBase container, PlayerInventory inventory, Text component ) |     public static GuiComputer<ContainerComputerBase> create( ContainerComputerBase container, Inventory inventory, Component component ) | ||||||
|     { |     { | ||||||
|         return new GuiComputer<>( container, inventory, component, ComputerCraft.computerTermWidth, ComputerCraft.computerTermHeight ); |         return new GuiComputer<>( container, inventory, component, ComputerCraft.computerTermWidth, ComputerCraft.computerTermHeight ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static GuiComputer<ContainerComputerBase> createPocket( ContainerComputerBase container, PlayerInventory inventory, Text component ) |     public static GuiComputer<ContainerComputerBase> createPocket( ContainerComputerBase container, Inventory inventory, Component component ) | ||||||
|     { |     { | ||||||
|         return new GuiComputer<>( container, inventory, component, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight ); |         return new GuiComputer<>( container, inventory, component, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static GuiComputer<ContainerViewComputer> createView( ContainerViewComputer container, PlayerInventory inventory, Text component ) |     public static GuiComputer<ContainerViewComputer> createView( ContainerViewComputer container, Inventory inventory, Component component ) | ||||||
|     { |     { | ||||||
|         return new GuiComputer<>( container, inventory, component, container.getWidth(), container.getHeight() ); |         return new GuiComputer<>( container, inventory, component, container.getWidth(), container.getHeight() ); | ||||||
|     } |     } | ||||||
| @@ -56,15 +56,15 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Computer | |||||||
|     protected WidgetTerminal createTerminal() |     protected WidgetTerminal createTerminal() | ||||||
|     { |     { | ||||||
|         return new WidgetTerminal( computer, |         return new WidgetTerminal( computer, | ||||||
|             x + ComputerSidebar.WIDTH + BORDER, y + BORDER, termWidth, termHeight |             leftPos + ComputerSidebar.WIDTH + BORDER, topPos + BORDER, termWidth, termHeight | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|     @Override |     @Override | ||||||
|     public void drawBackground( @Nonnull MatrixStack stack, float partialTicks, int mouseX, int mouseY ) |     public void renderBg( @Nonnull PoseStack stack, float partialTicks, int mouseX, int mouseY ) | ||||||
|     { |     { | ||||||
|         ComputerBorderRenderer.render( |         ComputerBorderRenderer.render( | ||||||
|             getTexture( family ), terminal.x, terminal.y, getZOffset(), |             getTexture( family ), terminal.x, terminal.y, getBlitOffset(), | ||||||
|             RenderTypes.FULL_BRIGHT_LIGHTMAP, terminal.getWidth(), terminal.getHeight() ); |             RenderTypes.FULL_BRIGHT_LIGHTMAP, terminal.getWidth(), terminal.getHeight() ); | ||||||
|         ComputerSidebar.renderBackground( stack, x, y + sidebarYOffset ); |         ComputerSidebar.renderBackground( stack, leftPos, topPos + sidebarYOffset ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,39 +7,38 @@ | |||||||
| package dan200.computercraft.client.gui; | package dan200.computercraft.client.gui; | ||||||
|  |  | ||||||
| import com.mojang.blaze3d.systems.RenderSystem; | import com.mojang.blaze3d.systems.RenderSystem; | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive; | import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive; | ||||||
| import net.minecraft.client.gui.screen.ingame.HandledScreen; |  | ||||||
| import net.minecraft.client.render.GameRenderer; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.player.PlayerInventory; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||||||
|  | import net.minecraft.client.renderer.GameRenderer; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.world.entity.player.Inventory; | ||||||
|  |  | ||||||
| public class GuiDiskDrive extends HandledScreen<ContainerDiskDrive> | public class GuiDiskDrive extends AbstractContainerScreen<ContainerDiskDrive> | ||||||
| { | { | ||||||
|     private static final Identifier BACKGROUND = new Identifier( "computercraft", "textures/gui/disk_drive.png" ); |     private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/disk_drive.png" ); | ||||||
|  |  | ||||||
|     public GuiDiskDrive( ContainerDiskDrive container, PlayerInventory player, Text title ) |     public GuiDiskDrive( ContainerDiskDrive container, Inventory player, Component title ) | ||||||
|     { |     { | ||||||
|         super( container, player, title ); |         super( container, player, title ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render( @Nonnull MatrixStack transform, int mouseX, int mouseY, float partialTicks ) |     public void render( @Nonnull PoseStack transform, int mouseX, int mouseY, float partialTicks ) | ||||||
|     { |     { | ||||||
|         renderBackground( transform ); |         renderBackground( transform ); | ||||||
|         super.render( transform, mouseX, mouseY, partialTicks ); |         super.render( transform, mouseX, mouseY, partialTicks ); | ||||||
|         drawMouseoverTooltip( transform, mouseX, mouseY ); |         renderTooltip( transform, mouseX, mouseY ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) |     protected void renderBg( @Nonnull PoseStack transform, float partialTicks, int mouseX, int mouseY ) | ||||||
|     { |     { | ||||||
|         RenderSystem.setShader( GameRenderer::getPositionTexShader ); |         RenderSystem.setShader( GameRenderer::getPositionTexShader ); | ||||||
|         RenderSystem.setShaderColor( 1.0F, 1.0F, 1.0F, 1.0F ); |         RenderSystem.setShaderColor( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||||
|         RenderSystem.setShaderTexture( 0, BACKGROUND ); |         RenderSystem.setShaderTexture( 0, BACKGROUND ); | ||||||
|         drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight ); |         blit( transform, leftPos, topPos, 0, 0, imageWidth, imageHeight ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,42 +7,41 @@ | |||||||
| package dan200.computercraft.client.gui; | package dan200.computercraft.client.gui; | ||||||
|  |  | ||||||
| import com.mojang.blaze3d.systems.RenderSystem; | import com.mojang.blaze3d.systems.RenderSystem; | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.shared.peripheral.printer.ContainerPrinter; | import dan200.computercraft.shared.peripheral.printer.ContainerPrinter; | ||||||
| import net.minecraft.client.gui.screen.ingame.HandledScreen; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.player.PlayerInventory; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.world.entity.player.Inventory; | ||||||
|  |  | ||||||
| public class GuiPrinter extends HandledScreen<ContainerPrinter> | public class GuiPrinter extends AbstractContainerScreen<ContainerPrinter> | ||||||
| { | { | ||||||
|     private static final Identifier BACKGROUND = new Identifier( "computercraft", "textures/gui/printer.png" ); |     private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/printer.png" ); | ||||||
|  |  | ||||||
|     public GuiPrinter( ContainerPrinter container, PlayerInventory player, Text title ) |     public GuiPrinter( ContainerPrinter container, Inventory player, Component title ) | ||||||
|     { |     { | ||||||
|         super( container, player, title ); |         super( container, player, title ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) |     public void render( @Nonnull PoseStack stack, int mouseX, int mouseY, float partialTicks ) | ||||||
|     { |     { | ||||||
|         renderBackground( stack ); |         renderBackground( stack ); | ||||||
|         super.render( stack, mouseX, mouseY, partialTicks ); |         super.render( stack, mouseX, mouseY, partialTicks ); | ||||||
|         drawMouseoverTooltip( stack, mouseX, mouseY ); |         renderTooltip( stack, mouseX, mouseY ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) |     protected void renderBg( @Nonnull PoseStack transform, float partialTicks, int mouseX, int mouseY ) | ||||||
|     { |     { | ||||||
|         RenderSystem.setShaderColor( 1.0F, 1.0F, 1.0F, 1.0F ); |         RenderSystem.setShaderColor( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||||
|         RenderSystem.setShaderTexture( 0, BACKGROUND ); |         RenderSystem.setShaderTexture( 0, BACKGROUND ); | ||||||
|         drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight ); |         blit( transform, leftPos, topPos, 0, 0, imageWidth, imageHeight ); | ||||||
|  |  | ||||||
|         if( getScreenHandler().isPrinting() ) |         if( getMenu().isPrinting() ) | ||||||
|         { |         { | ||||||
|             drawTexture( transform, x + 34, y + 21, 176, 0, 25, 45 ); |             blit( transform, leftPos + 34, topPos + 21, 176, 0, 25, 45 ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,24 +7,24 @@ | |||||||
| package dan200.computercraft.client.gui; | package dan200.computercraft.client.gui; | ||||||
|  |  | ||||||
| import com.mojang.blaze3d.systems.RenderSystem; | import com.mojang.blaze3d.systems.RenderSystem; | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
| import dan200.computercraft.core.terminal.TextBuffer; | import dan200.computercraft.core.terminal.TextBuffer; | ||||||
| import dan200.computercraft.shared.common.ContainerHeldItem; | import dan200.computercraft.shared.common.ContainerHeldItem; | ||||||
| import dan200.computercraft.shared.media.items.ItemPrintout; | import dan200.computercraft.shared.media.items.ItemPrintout; | ||||||
| import net.minecraft.client.MinecraftClient; |  | ||||||
| import net.minecraft.client.gui.screen.ingame.HandledScreen; |  | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.player.PlayerInventory; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.util.math.Matrix4f; |  | ||||||
| import org.lwjgl.glfw.GLFW; | import org.lwjgl.glfw.GLFW; | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.Minecraft; | ||||||
|  | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||||||
|  | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.world.entity.player.Inventory; | ||||||
|  |  | ||||||
| import static dan200.computercraft.client.render.PrintoutRenderer.*; | import static dan200.computercraft.client.render.PrintoutRenderer.*; | ||||||
| import static dan200.computercraft.client.render.RenderTypes.FULL_BRIGHT_LIGHTMAP; | import static dan200.computercraft.client.render.RenderTypes.FULL_BRIGHT_LIGHTMAP; | ||||||
|  |  | ||||||
| public class GuiPrintout extends HandledScreen<ContainerHeldItem> | public class GuiPrintout extends AbstractContainerScreen<ContainerHeldItem> | ||||||
| { | { | ||||||
|     private final boolean book; |     private final boolean book; | ||||||
|     private final int pages; |     private final int pages; | ||||||
| @@ -32,11 +32,11 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem> | |||||||
|     private final TextBuffer[] colours; |     private final TextBuffer[] colours; | ||||||
|     private int page; |     private int page; | ||||||
|  |  | ||||||
|     public GuiPrintout( ContainerHeldItem container, PlayerInventory player, Text title ) |     public GuiPrintout( ContainerHeldItem container, Inventory player, Component title ) | ||||||
|     { |     { | ||||||
|         super( container, player, title ); |         super( container, player, title ); | ||||||
|  |  | ||||||
|         backgroundHeight = Y_SIZE; |         imageHeight = Y_SIZE; | ||||||
|  |  | ||||||
|         String[] text = ItemPrintout.getText( container.getStack() ); |         String[] text = ItemPrintout.getText( container.getStack() ); | ||||||
|         this.text = new TextBuffer[text.length]; |         this.text = new TextBuffer[text.length]; | ||||||
| @@ -89,37 +89,37 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem> | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) |     public void render( @Nonnull PoseStack stack, int mouseX, int mouseY, float partialTicks ) | ||||||
|     { |     { | ||||||
|         // We must take the background further back in order to not overlap with our printed pages. |         // We must take the background further back in order to not overlap with our printed pages. | ||||||
|         setZOffset( getZOffset() - 1 ); |         setBlitOffset( getBlitOffset() - 1 ); | ||||||
|         renderBackground( stack ); |         renderBackground( stack ); | ||||||
|         setZOffset( getZOffset() + 1 ); |         setBlitOffset( getBlitOffset() + 1 ); | ||||||
|  |  | ||||||
|         super.render( stack, mouseX, mouseY, partialTicks ); |         super.render( stack, mouseX, mouseY, partialTicks ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void drawForeground( @Nonnull MatrixStack transform, int mouseX, int mouseY ) |     protected void renderLabels( @Nonnull PoseStack transform, int mouseX, int mouseY ) | ||||||
|     { |     { | ||||||
|         // Skip rendering labels. |         // Skip rendering labels. | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) |     protected void renderBg( @Nonnull PoseStack transform, float partialTicks, int mouseX, int mouseY ) | ||||||
|     { |     { | ||||||
|         // Draw the printout |         // Draw the printout | ||||||
|         RenderSystem.setShaderColor( 1.0f, 1.0f, 1.0f, 1.0f ); |         RenderSystem.setShaderColor( 1.0f, 1.0f, 1.0f, 1.0f ); | ||||||
|         RenderSystem.enableDepthTest(); |         RenderSystem.enableDepthTest(); | ||||||
|  |  | ||||||
|         VertexConsumerProvider.Immediate renderer = MinecraftClient.getInstance() |         MultiBufferSource.BufferSource renderer = Minecraft.getInstance() | ||||||
|             .getBufferBuilders() |             .renderBuffers() | ||||||
|             .getEntityVertexConsumers(); |             .bufferSource(); | ||||||
|         Matrix4f matrix = transform.peek() |         Matrix4f matrix = transform.last() | ||||||
|             .getModel(); |             .pose(); | ||||||
|         drawBorder( matrix, renderer, x, y, getZOffset(), page, pages, book, FULL_BRIGHT_LIGHTMAP ); |         drawBorder( matrix, renderer, leftPos, topPos, getBlitOffset(), page, pages, book, FULL_BRIGHT_LIGHTMAP ); | ||||||
|         drawText( matrix, renderer, x + X_TEXT_MARGIN, y + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours ); |         drawText( matrix, renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours ); | ||||||
|         renderer.draw(); |         renderer.endBatch(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -7,38 +7,37 @@ | |||||||
| package dan200.computercraft.client.gui; | package dan200.computercraft.client.gui; | ||||||
|  |  | ||||||
| import com.mojang.blaze3d.systems.RenderSystem; | import com.mojang.blaze3d.systems.RenderSystem; | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.client.gui.widgets.ComputerSidebar; | import dan200.computercraft.client.gui.widgets.ComputerSidebar; | ||||||
| import dan200.computercraft.client.gui.widgets.WidgetTerminal; | import dan200.computercraft.client.gui.widgets.WidgetTerminal; | ||||||
| import dan200.computercraft.client.render.ComputerBorderRenderer; | import dan200.computercraft.client.render.ComputerBorderRenderer; | ||||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||||
| import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; | import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.player.PlayerInventory; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.world.entity.player.Inventory; | ||||||
|  |  | ||||||
| import static dan200.computercraft.shared.turtle.inventory.ContainerTurtle.BORDER; | import static dan200.computercraft.shared.turtle.inventory.ContainerTurtle.BORDER; | ||||||
|  |  | ||||||
| public class GuiTurtle extends ComputerScreenBase<ContainerTurtle> | public class GuiTurtle extends ComputerScreenBase<ContainerTurtle> | ||||||
| { | { | ||||||
|     private static final Identifier BACKGROUND_NORMAL = new Identifier( "computercraft", "textures/gui/turtle_normal.png" ); |     private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( "computercraft", "textures/gui/turtle_normal.png" ); | ||||||
|     private static final Identifier BACKGROUND_ADVANCED = new Identifier( "computercraft", "textures/gui/turtle_advanced.png" ); |     private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( "computercraft", "textures/gui/turtle_advanced.png" ); | ||||||
|  |  | ||||||
|     private static final int TEX_WIDTH = 254; |     private static final int TEX_WIDTH = 254; | ||||||
|     private static final int TEX_HEIGHT = 217; |     private static final int TEX_HEIGHT = 217; | ||||||
|  |  | ||||||
|     private final ComputerFamily family; |     private final ComputerFamily family; | ||||||
|  |  | ||||||
|     public GuiTurtle( ContainerTurtle container, PlayerInventory player, Text title ) |     public GuiTurtle( ContainerTurtle container, Inventory player, Component title ) | ||||||
|     { |     { | ||||||
|         super( container, player, title, BORDER ); |         super( container, player, title, BORDER ); | ||||||
|  |  | ||||||
|         family = container.getFamily(); |         family = container.getFamily(); | ||||||
|         backgroundWidth = TEX_WIDTH + ComputerSidebar.WIDTH; |         imageWidth = TEX_WIDTH + ComputerSidebar.WIDTH; | ||||||
|         backgroundHeight = TEX_HEIGHT; |         imageHeight = TEX_HEIGHT; | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -46,25 +45,25 @@ public class GuiTurtle extends ComputerScreenBase<ContainerTurtle> | |||||||
|     protected WidgetTerminal createTerminal() |     protected WidgetTerminal createTerminal() | ||||||
|     { |     { | ||||||
|         return new WidgetTerminal( |         return new WidgetTerminal( | ||||||
|             computer, x + BORDER + ComputerSidebar.WIDTH, y + BORDER, |             computer, leftPos + BORDER + ComputerSidebar.WIDTH, topPos + BORDER, | ||||||
|             ComputerCraft.turtleTermWidth, ComputerCraft.turtleTermHeight |             ComputerCraft.turtleTermWidth, ComputerCraft.turtleTermHeight | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) |     public void renderBg( @Nonnull PoseStack transform, float partialTicks, int mouseX, int mouseY ) | ||||||
|     { |     { | ||||||
|         boolean advanced = family == ComputerFamily.ADVANCED; |         boolean advanced = family == ComputerFamily.ADVANCED; | ||||||
|         RenderSystem.setShaderTexture( 0, advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL ); |         RenderSystem.setShaderTexture( 0, advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL ); | ||||||
|         drawTexture( transform, x + ComputerSidebar.WIDTH, y, 0, 0, TEX_WIDTH, TEX_HEIGHT ); |         blit( transform, leftPos + ComputerSidebar.WIDTH, topPos, 0, 0, TEX_WIDTH, TEX_HEIGHT ); | ||||||
|  |  | ||||||
|         // Draw selection slot |         // Draw selection slot | ||||||
|         int slot = getScreenHandler().getSelectedSlot(); |         int slot = getMenu().getSelectedSlot(); | ||||||
|         if( slot >= 0 ) |         if( slot >= 0 ) | ||||||
|         { |         { | ||||||
|             int slotX = slot % 4; |             int slotX = slot % 4; | ||||||
|             int slotY = slot / 4; |             int slotY = slot / 4; | ||||||
|             drawTexture( transform, x + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, y + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, |             blit( transform, leftPos + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, topPos + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, | ||||||
|                 0, |                 0, | ||||||
|                 217, |                 217, | ||||||
|                 24, |                 24, | ||||||
| @@ -72,6 +71,6 @@ public class GuiTurtle extends ComputerScreenBase<ContainerTurtle> | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         RenderSystem.setShaderTexture( 0, advanced ? ComputerBorderRenderer.BACKGROUND_ADVANCED : ComputerBorderRenderer.BACKGROUND_NORMAL ); |         RenderSystem.setShaderTexture( 0, advanced ? ComputerBorderRenderer.BACKGROUND_ADVANCED : ComputerBorderRenderer.BACKGROUND_NORMAL ); | ||||||
|         ComputerSidebar.renderBackground( transform, x, y + sidebarYOffset ); |         ComputerSidebar.renderBackground( transform, leftPos, topPos + sidebarYOffset ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,29 +5,29 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client.gui; | package dan200.computercraft.client.gui; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.client.gui.widgets.WidgetTerminal; | import dan200.computercraft.client.gui.widgets.WidgetTerminal; | ||||||
| import dan200.computercraft.shared.computer.core.ClientComputer; | import dan200.computercraft.shared.computer.core.ClientComputer; | ||||||
| import dan200.computercraft.shared.computer.inventory.ContainerComputerBase; | import dan200.computercraft.shared.computer.inventory.ContainerComputerBase; | ||||||
| import net.minecraft.client.font.TextRenderer; |  | ||||||
| import net.minecraft.client.gui.screen.Screen; |  | ||||||
| import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.player.PlayerInventory; |  | ||||||
| import net.minecraft.text.OrderedText; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.text.TranslatableText; |  | ||||||
| import org.lwjgl.glfw.GLFW; | import org.lwjgl.glfw.GLFW; | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.gui.Font; | ||||||
|  | import net.minecraft.client.gui.screens.Screen; | ||||||
|  | import net.minecraft.client.gui.screens.inventory.MenuAccess; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.network.chat.TranslatableComponent; | ||||||
|  | import net.minecraft.util.FormattedCharSequence; | ||||||
|  | import net.minecraft.world.entity.player.Inventory; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class NoTermComputerScreen<T extends ContainerComputerBase> extends Screen implements ScreenHandlerProvider<T> | public class NoTermComputerScreen<T extends ContainerComputerBase> extends Screen implements MenuAccess<T> | ||||||
| { | { | ||||||
|     private final T menu; |     private final T menu; | ||||||
|     private WidgetTerminal terminal; |     private WidgetTerminal terminal; | ||||||
|  |  | ||||||
|     public NoTermComputerScreen( T menu, PlayerInventory player, Text title ) |     public NoTermComputerScreen( T menu, Inventory player, Component title ) | ||||||
|     { |     { | ||||||
|         super( title ); |         super( title ); | ||||||
|         this.menu = menu; |         this.menu = menu; | ||||||
| @@ -35,7 +35,7 @@ public class NoTermComputerScreen<T extends ContainerComputerBase> extends Scree | |||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public T getScreenHandler() |     public T getMenu() | ||||||
|     { |     { | ||||||
|         return menu; |         return menu; | ||||||
|     } |     } | ||||||
| @@ -44,12 +44,12 @@ public class NoTermComputerScreen<T extends ContainerComputerBase> extends Scree | |||||||
|     protected void init() |     protected void init() | ||||||
|     { |     { | ||||||
|         this.passEvents = true; |         this.passEvents = true; | ||||||
|         client.mouse.lockCursor(); |         minecraft.mouseHandler.grabMouse(); | ||||||
|         client.currentScreen = this; |         minecraft.screen = this; | ||||||
|         super.init(); |         super.init(); | ||||||
|         client.keyboard.setRepeatEvents( true ); |         minecraft.keyboardHandler.setSendRepeatsToGui( true ); | ||||||
|  |  | ||||||
|         terminal = addSelectableChild( new WidgetTerminal( (ClientComputer) menu.getComputer(), 0, 0, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight ) ); |         terminal = addWidget( new WidgetTerminal( (ClientComputer) menu.getComputer(), 0, 0, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight ) ); | ||||||
|         terminal.visible = false; |         terminal.visible = false; | ||||||
|         terminal.active = false; |         terminal.active = false; | ||||||
|         setFocused( terminal ); |         setFocused( terminal ); | ||||||
| @@ -59,7 +59,7 @@ public class NoTermComputerScreen<T extends ContainerComputerBase> extends Scree | |||||||
|     public final void removed() |     public final void removed() | ||||||
|     { |     { | ||||||
|         super.removed(); |         super.removed(); | ||||||
|         client.keyboard.setRepeatEvents( false ); |         minecraft.keyboardHandler.setSendRepeatsToGui( false ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -72,14 +72,14 @@ public class NoTermComputerScreen<T extends ContainerComputerBase> extends Scree | |||||||
|     @Override |     @Override | ||||||
|     public boolean mouseScrolled( double pMouseX, double pMouseY, double pDelta ) |     public boolean mouseScrolled( double pMouseX, double pMouseY, double pDelta ) | ||||||
|     { |     { | ||||||
|         client.player.getInventory().scrollInHotbar( pDelta ); |         minecraft.player.getInventory().swapPaint( pDelta ); | ||||||
|         return super.mouseScrolled( pMouseX, pMouseY, pDelta ); |         return super.mouseScrolled( pMouseX, pMouseY, pDelta ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onClose() |     public void onClose() | ||||||
|     { |     { | ||||||
|         client.player.closeHandledScreen(); |         minecraft.player.closeContainer(); | ||||||
|         super.onClose(); |         super.onClose(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -102,16 +102,16 @@ public class NoTermComputerScreen<T extends ContainerComputerBase> extends Scree | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render( MatrixStack transform, int mouseX, int mouseY, float partialTicks ) |     public void render( PoseStack transform, int mouseX, int mouseY, float partialTicks ) | ||||||
|     { |     { | ||||||
|         super.render( transform, mouseX, mouseY, partialTicks ); |         super.render( transform, mouseX, mouseY, partialTicks ); | ||||||
|  |  | ||||||
|         TextRenderer font = client.textRenderer; |         Font font = minecraft.font; | ||||||
|         List<OrderedText> lines = font.wrapLines( new TranslatableText( "gui.computercraft.pocket_computer_overlay" ), (int) (width * 0.8) ); |         List<FormattedCharSequence> lines = font.split( new TranslatableComponent( "gui.computercraft.pocket_computer_overlay" ), (int) (width * 0.8) ); | ||||||
|         float y = 10.0f; |         float y = 10.0f; | ||||||
|         for( OrderedText line : lines ) |         for( FormattedCharSequence line : lines ) | ||||||
|         { |         { | ||||||
|             font.drawWithShadow( transform, line, (float) ((width / 2) - (client.textRenderer.getWidth( line ) / 2)), y, 0xFFFFFF ); |             font.drawShadow( transform, line, (float) ((width / 2) - (minecraft.font.width( line ) / 2)), y, 0xFFFFFF ); | ||||||
|             y += 9.0f; |             y += 9.0f; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -6,21 +6,20 @@ | |||||||
| package dan200.computercraft.client.gui; | package dan200.computercraft.client.gui; | ||||||
|  |  | ||||||
| import com.mojang.blaze3d.systems.RenderSystem; | import com.mojang.blaze3d.systems.RenderSystem; | ||||||
| import net.minecraft.client.MinecraftClient; | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import net.minecraft.client.font.MultilineText; |  | ||||||
| import net.minecraft.client.gui.screen.Screen; |  | ||||||
| import net.minecraft.client.gui.widget.ButtonWidget; |  | ||||||
| import net.minecraft.client.gui.widget.ClickableWidget; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.Minecraft; | ||||||
|  | import net.minecraft.client.gui.components.AbstractWidget; | ||||||
|  | import net.minecraft.client.gui.components.Button; | ||||||
|  | import net.minecraft.client.gui.components.MultiLineLabel; | ||||||
|  | import net.minecraft.client.gui.screens.Screen; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public final class OptionScreen extends Screen | public final class OptionScreen extends Screen | ||||||
| { | { | ||||||
|     private static final Identifier BACKGROUND = new Identifier( "computercraft", "textures/gui/blank_screen.png" ); |     private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/blank_screen.png" ); | ||||||
|  |  | ||||||
|     public static final int BUTTON_WIDTH = 100; |     public static final int BUTTON_WIDTH = 100; | ||||||
|     public static final int BUTTON_HEIGHT = 20; |     public static final int BUTTON_HEIGHT = 20; | ||||||
| @@ -33,14 +32,14 @@ public final class OptionScreen extends Screen | |||||||
|     private int innerWidth; |     private int innerWidth; | ||||||
|     private int innerHeight; |     private int innerHeight; | ||||||
|  |  | ||||||
|     private MultilineText messageRenderer; |     private MultiLineLabel messageRenderer; | ||||||
|     private final Text message; |     private final Component message; | ||||||
|     private final List<ClickableWidget> buttons; |     private final List<AbstractWidget> buttons; | ||||||
|     private final Runnable exit; |     private final Runnable exit; | ||||||
|  |  | ||||||
|     private final Screen originalScreen; |     private final Screen originalScreen; | ||||||
|  |  | ||||||
|     private OptionScreen( Text title, Text message, List<ClickableWidget> buttons, Runnable exit, Screen originalScreen ) |     private OptionScreen( Component title, Component message, List<AbstractWidget> buttons, Runnable exit, Screen originalScreen ) | ||||||
|     { |     { | ||||||
|         super( title ); |         super( title ); | ||||||
|         this.message = message; |         this.message = message; | ||||||
| @@ -49,9 +48,9 @@ public final class OptionScreen extends Screen | |||||||
|         this.originalScreen = originalScreen; |         this.originalScreen = originalScreen; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void show( MinecraftClient client, Text title, Text message, List<ClickableWidget> buttons, Runnable exit ) |     public static void show( Minecraft client, Component title, Component message, List<AbstractWidget> buttons, Runnable exit ) | ||||||
|     { |     { | ||||||
|         client.setScreen( new OptionScreen( title, message, buttons, exit, unwrap( client.currentScreen ) ) ); |         client.setScreen( new OptionScreen( title, message, buttons, exit, unwrap( client.screen ) ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static Screen unwrap( Screen screen ) |     public static Screen unwrap( Screen screen ) | ||||||
| @@ -67,40 +66,40 @@ public final class OptionScreen extends Screen | |||||||
|         int buttonWidth = BUTTON_WIDTH * buttons.size() + PADDING * (buttons.size() - 1); |         int buttonWidth = BUTTON_WIDTH * buttons.size() + PADDING * (buttons.size() - 1); | ||||||
|         int innerWidth = this.innerWidth = Math.max( 256, buttonWidth + PADDING * 2 ); |         int innerWidth = this.innerWidth = Math.max( 256, buttonWidth + PADDING * 2 ); | ||||||
|  |  | ||||||
|         messageRenderer = MultilineText.create( textRenderer, message, innerWidth - PADDING * 2 ); |         messageRenderer = MultiLineLabel.create( font, message, innerWidth - PADDING * 2 ); | ||||||
|  |  | ||||||
|         int textHeight = messageRenderer.count() * FONT_HEIGHT + PADDING * 2; |         int textHeight = messageRenderer.getLineCount() * FONT_HEIGHT + PADDING * 2; | ||||||
|         innerHeight = textHeight + (buttons.isEmpty() ? 0 : buttons.get( 0 ).getHeight()) + PADDING; |         innerHeight = textHeight + (buttons.isEmpty() ? 0 : buttons.get( 0 ).getHeight()) + PADDING; | ||||||
|  |  | ||||||
|         x = (width - innerWidth) / 2; |         x = (width - innerWidth) / 2; | ||||||
|         y = (height - innerHeight) / 2; |         y = (height - innerHeight) / 2; | ||||||
|  |  | ||||||
|         int x = (width - buttonWidth) / 2; |         int x = (width - buttonWidth) / 2; | ||||||
|         for( ClickableWidget button : buttons ) |         for( AbstractWidget button : buttons ) | ||||||
|         { |         { | ||||||
|             button.x = x; |             button.x = x; | ||||||
|             button.y = y + textHeight; |             button.y = y + textHeight; | ||||||
|             addDrawableChild( button ); |             addRenderableWidget( button ); | ||||||
|  |  | ||||||
|             x += BUTTON_WIDTH + PADDING; |             x += BUTTON_WIDTH + PADDING; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render( @Nonnull MatrixStack transform, int mouseX, int mouseY, float partialTicks ) |     public void render( @Nonnull PoseStack transform, int mouseX, int mouseY, float partialTicks ) | ||||||
|     { |     { | ||||||
|         renderBackground( transform ); |         renderBackground( transform ); | ||||||
|  |  | ||||||
|         // Render the actual texture. |         // Render the actual texture. | ||||||
|         RenderSystem.setShaderTexture( 0, BACKGROUND ); |         RenderSystem.setShaderTexture( 0, BACKGROUND ); | ||||||
|         drawTexture( transform, x, y, 0, 0, innerWidth, PADDING ); |         blit( transform, x, y, 0, 0, innerWidth, PADDING ); | ||||||
|         drawTexture( transform, |         blit( transform, | ||||||
|             x, y + PADDING, 0, PADDING, innerWidth, innerHeight - PADDING * 2, |             x, y + PADDING, 0, PADDING, innerWidth, innerHeight - PADDING * 2, | ||||||
|             innerWidth, PADDING |             innerWidth, PADDING | ||||||
|         ); |         ); | ||||||
|         drawTexture( transform, x, y + innerHeight - PADDING, 0, 256 - PADDING, innerWidth, PADDING ); |         blit( transform, x, y + innerHeight - PADDING, 0, 256 - PADDING, innerWidth, PADDING ); | ||||||
|  |  | ||||||
|         messageRenderer.draw( transform, x + PADDING, y + PADDING, FONT_HEIGHT, 0x404040 ); |         messageRenderer.renderLeftAlignedNoShadow( transform, x + PADDING, y + PADDING, FONT_HEIGHT, 0x404040 ); | ||||||
|         super.render( transform, mouseX, mouseY, partialTicks ); |         super.render( transform, mouseX, mouseY, partialTicks ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -110,14 +109,14 @@ public final class OptionScreen extends Screen | |||||||
|         exit.run(); |         exit.run(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static ClickableWidget newButton( Text component, ButtonWidget.PressAction clicked ) |     public static AbstractWidget newButton( Component component, Button.OnPress clicked ) | ||||||
|     { |     { | ||||||
|         return new ButtonWidget( 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, component, clicked ); |         return new Button( 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, component, clicked ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void disable() |     public void disable() | ||||||
|     { |     { | ||||||
|         for( ClickableWidget widget : buttons ) widget.active = false; |         for( AbstractWidget widget : buttons ) widget.active = false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|   | |||||||
| @@ -5,26 +5,25 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client.gui.widgets; | package dan200.computercraft.client.gui.widgets; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.client.render.ComputerBorderRenderer; | import dan200.computercraft.client.render.ComputerBorderRenderer; | ||||||
| import dan200.computercraft.shared.command.text.ChatHelpers; | import dan200.computercraft.shared.command.text.ChatHelpers; | ||||||
| import dan200.computercraft.shared.computer.core.ClientComputer; | import dan200.computercraft.shared.computer.core.ClientComputer; | ||||||
| import net.minecraft.client.gui.screen.Screen; |  | ||||||
| import net.minecraft.client.gui.widget.ClickableWidget; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.text.TranslatableText; |  | ||||||
| import net.minecraft.util.Formatting; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| import java.util.function.Consumer; | import java.util.function.Consumer; | ||||||
|  | import net.minecraft.ChatFormatting; | ||||||
|  | import net.minecraft.client.gui.components.AbstractWidget; | ||||||
|  | import net.minecraft.client.gui.screens.Screen; | ||||||
|  | import net.minecraft.network.chat.TranslatableComponent; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Registers buttons to interact with a computer. |  * Registers buttons to interact with a computer. | ||||||
|  */ |  */ | ||||||
| public final class ComputerSidebar | public final class ComputerSidebar | ||||||
| { | { | ||||||
|     private static final Identifier TEXTURE = new Identifier( ComputerCraft.MOD_ID, "textures/gui/buttons.png" ); |     private static final ResourceLocation TEXTURE = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/buttons.png" ); | ||||||
|  |  | ||||||
|     private static final int TEX_SIZE = 64; |     private static final int TEX_SIZE = 64; | ||||||
|  |  | ||||||
| @@ -45,7 +44,7 @@ public final class ComputerSidebar | |||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void addButtons( Screen screen, ClientComputer computer, Consumer<ClickableWidget> add, int x, int y ) |     public static void addButtons( Screen screen, ClientComputer computer, Consumer<AbstractWidget> add, int x, int y ) | ||||||
|     { |     { | ||||||
|         x += CORNERS_BORDER + 1; |         x += CORNERS_BORDER + 1; | ||||||
|         y += CORNERS_BORDER + ICON_MARGIN; |         y += CORNERS_BORDER + ICON_MARGIN; | ||||||
| @@ -54,11 +53,11 @@ public final class ComputerSidebar | |||||||
|             screen, x, y, ICON_WIDTH, ICON_HEIGHT, () -> computer.isOn() ? 15 : 1, 1, ICON_TEX_Y_DIFF, |             screen, x, y, ICON_WIDTH, ICON_HEIGHT, () -> computer.isOn() ? 15 : 1, 1, ICON_TEX_Y_DIFF, | ||||||
|             TEXTURE, TEX_SIZE, TEX_SIZE, b -> toggleComputer( computer ), |             TEXTURE, TEX_SIZE, TEX_SIZE, b -> toggleComputer( computer ), | ||||||
|             () -> computer.isOn() ? Arrays.asList( |             () -> computer.isOn() ? Arrays.asList( | ||||||
|                 new TranslatableText( "gui.computercraft.tooltip.turn_off" ), |                 new TranslatableComponent( "gui.computercraft.tooltip.turn_off" ), | ||||||
|                 ChatHelpers.coloured( new TranslatableText( "gui.computercraft.tooltip.turn_off.key" ), Formatting.GRAY ) |                 ChatHelpers.coloured( new TranslatableComponent( "gui.computercraft.tooltip.turn_off.key" ), ChatFormatting.GRAY ) | ||||||
|             ) : Arrays.asList( |             ) : Arrays.asList( | ||||||
|                 new TranslatableText( "gui.computercraft.tooltip.turn_on" ), |                 new TranslatableComponent( "gui.computercraft.tooltip.turn_on" ), | ||||||
|                 ChatHelpers.coloured( new TranslatableText( "gui.computercraft.tooltip.turn_off.key" ), Formatting.GRAY ) |                 ChatHelpers.coloured( new TranslatableComponent( "gui.computercraft.tooltip.turn_off.key" ), ChatFormatting.GRAY ) | ||||||
|             ) |             ) | ||||||
|         ) ); |         ) ); | ||||||
|  |  | ||||||
| @@ -68,26 +67,26 @@ public final class ComputerSidebar | |||||||
|             screen, x, y, ICON_WIDTH, ICON_HEIGHT, 29, 1, ICON_TEX_Y_DIFF, |             screen, x, y, ICON_WIDTH, ICON_HEIGHT, 29, 1, ICON_TEX_Y_DIFF, | ||||||
|             TEXTURE, TEX_SIZE, TEX_SIZE, b -> computer.queueEvent( "terminate" ), |             TEXTURE, TEX_SIZE, TEX_SIZE, b -> computer.queueEvent( "terminate" ), | ||||||
|             Arrays.asList( |             Arrays.asList( | ||||||
|                 new TranslatableText( "gui.computercraft.tooltip.terminate" ), |                 new TranslatableComponent( "gui.computercraft.tooltip.terminate" ), | ||||||
|                 ChatHelpers.coloured( new TranslatableText( "gui.computercraft.tooltip.terminate.key" ), Formatting.GRAY ) |                 ChatHelpers.coloured( new TranslatableComponent( "gui.computercraft.tooltip.terminate.key" ), ChatFormatting.GRAY ) | ||||||
|             ) |             ) | ||||||
|         ) ); |         ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void renderBackground( MatrixStack transform, int x, int y ) |     public static void renderBackground( PoseStack transform, int x, int y ) | ||||||
|     { |     { | ||||||
|         Screen.drawTexture( transform, |         Screen.blit( transform, | ||||||
|             x, y, 0, 102, WIDTH, FULL_BORDER, |             x, y, 0, 102, WIDTH, FULL_BORDER, | ||||||
|             ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE |             ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         Screen.drawTexture( transform, |         Screen.blit( transform, | ||||||
|             x, y + FULL_BORDER, WIDTH, HEIGHT - FULL_BORDER * 2, |             x, y + FULL_BORDER, WIDTH, HEIGHT - FULL_BORDER * 2, | ||||||
|             0, 107, WIDTH, 4, |             0, 107, WIDTH, 4, | ||||||
|             ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE |             ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         Screen.drawTexture( transform, |         Screen.blit( transform, | ||||||
|             x, y + HEIGHT - FULL_BORDER, 0, 111, WIDTH, FULL_BORDER, |             x, y + HEIGHT - FULL_BORDER, 0, 111, WIDTH, FULL_BORDER, | ||||||
|             ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE |             ComputerBorderRenderer.TEX_SIZE, ComputerBorderRenderer.TEX_SIZE | ||||||
|         ); |         ); | ||||||
|   | |||||||
| @@ -6,37 +6,36 @@ | |||||||
| package dan200.computercraft.client.gui.widgets; | package dan200.computercraft.client.gui.widgets; | ||||||
|  |  | ||||||
| import com.mojang.blaze3d.systems.RenderSystem; | import com.mojang.blaze3d.systems.RenderSystem; | ||||||
| import net.minecraft.client.gui.screen.Screen; | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import net.minecraft.client.gui.widget.ButtonWidget; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.text.LiteralText; |  | ||||||
| import net.minecraft.text.Text; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.gui.components.Button; | ||||||
|  | import net.minecraft.client.gui.screens.Screen; | ||||||
|  | import net.minecraft.network.chat.Component; | ||||||
|  | import net.minecraft.network.chat.TextComponent; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.function.IntSupplier; | import java.util.function.IntSupplier; | ||||||
| import java.util.function.Supplier; | import java.util.function.Supplier; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Version of {@link net.minecraft.client.gui.widget.TexturedButtonWidget} which allows changing some properties |  * Version of {@link net.minecraft.client.gui.components.ImageButton} which allows changing some properties | ||||||
|  * dynamically. |  * dynamically. | ||||||
|  */ |  */ | ||||||
| public class DynamicImageButton extends ButtonWidget | public class DynamicImageButton extends Button | ||||||
| { | { | ||||||
|     private final Screen screen; |     private final Screen screen; | ||||||
|     private final Identifier texture; |     private final ResourceLocation texture; | ||||||
|     private final IntSupplier xTexStart; |     private final IntSupplier xTexStart; | ||||||
|     private final int yTexStart; |     private final int yTexStart; | ||||||
|     private final int yDiffTex; |     private final int yDiffTex; | ||||||
|     private final int textureWidth; |     private final int textureWidth; | ||||||
|     private final int textureHeight; |     private final int textureHeight; | ||||||
|     private final Supplier<List<Text>> tooltip; |     private final Supplier<List<Component>> tooltip; | ||||||
|  |  | ||||||
|     public DynamicImageButton( |     public DynamicImageButton( | ||||||
|         Screen screen, int x, int y, int width, int height, int xTexStart, int yTexStart, int yDiffTex, |         Screen screen, int x, int y, int width, int height, int xTexStart, int yTexStart, int yDiffTex, | ||||||
|         Identifier texture, int textureWidth, int textureHeight, |         ResourceLocation texture, int textureWidth, int textureHeight, | ||||||
|         PressAction onPress, List<Text> tooltip |         OnPress onPress, List<Component> tooltip | ||||||
|     ) |     ) | ||||||
|     { |     { | ||||||
|         this( |         this( | ||||||
| @@ -49,11 +48,11 @@ public class DynamicImageButton extends ButtonWidget | |||||||
|  |  | ||||||
|     public DynamicImageButton( |     public DynamicImageButton( | ||||||
|         Screen screen, int x, int y, int width, int height, IntSupplier xTexStart, int yTexStart, int yDiffTex, |         Screen screen, int x, int y, int width, int height, IntSupplier xTexStart, int yTexStart, int yDiffTex, | ||||||
|         Identifier texture, int textureWidth, int textureHeight, |         ResourceLocation texture, int textureWidth, int textureHeight, | ||||||
|         PressAction onPress, Supplier<List<Text>> tooltip |         OnPress onPress, Supplier<List<Component>> tooltip | ||||||
|     ) |     ) | ||||||
|     { |     { | ||||||
|         super( x, y, width, height, LiteralText.EMPTY, onPress ); |         super( x, y, width, height, TextComponent.EMPTY, onPress ); | ||||||
|         this.screen = screen; |         this.screen = screen; | ||||||
|         this.textureWidth = textureWidth; |         this.textureWidth = textureWidth; | ||||||
|         this.textureHeight = textureHeight; |         this.textureHeight = textureHeight; | ||||||
| @@ -65,7 +64,7 @@ public class DynamicImageButton extends ButtonWidget | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void renderButton( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) |     public void renderButton( @Nonnull PoseStack stack, int mouseX, int mouseY, float partialTicks ) | ||||||
|     { |     { | ||||||
|         RenderSystem.setShaderTexture( 0, texture ); |         RenderSystem.setShaderTexture( 0, texture ); | ||||||
|         RenderSystem.disableDepthTest(); |         RenderSystem.disableDepthTest(); | ||||||
| @@ -73,7 +72,7 @@ public class DynamicImageButton extends ButtonWidget | |||||||
|         int yTex = yTexStart; |         int yTex = yTexStart; | ||||||
|         if( isHovered() ) yTex += yDiffTex; |         if( isHovered() ) yTex += yDiffTex; | ||||||
|  |  | ||||||
|         drawTexture( stack, x, y, xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight ); |         blit( stack, x, y, xTexStart.getAsInt(), yTex, width, height, textureWidth, textureHeight ); | ||||||
|         RenderSystem.enableDepthTest(); |         RenderSystem.enableDepthTest(); | ||||||
|  |  | ||||||
|         if( isHovered() ) renderToolTip( stack, mouseX, mouseY ); |         if( isHovered() ) renderToolTip( stack, mouseX, mouseY ); | ||||||
| @@ -81,20 +80,20 @@ public class DynamicImageButton extends ButtonWidget | |||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public Text getMessage() |     public Component getMessage() | ||||||
|     { |     { | ||||||
|         List<Text> tooltip = this.tooltip.get(); |         List<Component> tooltip = this.tooltip.get(); | ||||||
|         return tooltip.isEmpty() ? LiteralText.EMPTY : tooltip.get( 0 ); |         return tooltip.isEmpty() ? TextComponent.EMPTY : tooltip.get( 0 ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // @Override |     // @Override | ||||||
|     public void renderToolTip( @Nonnull MatrixStack stack, int mouseX, int mouseY ) |     public void renderToolTip( @Nonnull PoseStack stack, int mouseX, int mouseY ) | ||||||
|     { |     { | ||||||
|         List<Text> tooltip = this.tooltip.get(); |         List<Component> tooltip = this.tooltip.get(); | ||||||
|  |  | ||||||
|         if( !tooltip.isEmpty() ) |         if( !tooltip.isEmpty() ) | ||||||
|         { |         { | ||||||
|             screen.renderTooltip( stack, tooltip, mouseX, mouseY ); |             screen.renderComponentTooltip( stack, tooltip, mouseX, mouseY ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -10,12 +10,10 @@ import dan200.computercraft.client.gui.FixedWidthFontRenderer; | |||||||
| import dan200.computercraft.core.terminal.Terminal; | import dan200.computercraft.core.terminal.Terminal; | ||||||
| import dan200.computercraft.shared.computer.core.ClientComputer; | import dan200.computercraft.shared.computer.core.ClientComputer; | ||||||
| import net.minecraft.SharedConstants; | import net.minecraft.SharedConstants; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; | import net.minecraft.client.gui.components.AbstractWidget; | ||||||
| import net.minecraft.client.gui.widget.ClickableWidget; | import net.minecraft.client.gui.narration.NarrationElementOutput; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.network.chat.TextComponent; | ||||||
| import net.minecraft.text.LiteralText; |  | ||||||
| import net.minecraft.util.math.Matrix4f; |  | ||||||
| import org.lwjgl.glfw.GLFW; | import org.lwjgl.glfw.GLFW; | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| @@ -25,7 +23,10 @@ import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT | |||||||
| import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; | import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; | ||||||
| import static dan200.computercraft.client.render.ComputerBorderRenderer.MARGIN; | import static dan200.computercraft.client.render.ComputerBorderRenderer.MARGIN; | ||||||
|  |  | ||||||
| public class WidgetTerminal extends ClickableWidget | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
|  |  | ||||||
|  | public class WidgetTerminal extends AbstractWidget | ||||||
| { | { | ||||||
|     private static final float TERMINATE_TIME = 0.5f; |     private static final float TERMINATE_TIME = 0.5f; | ||||||
|  |  | ||||||
| @@ -49,7 +50,7 @@ public class WidgetTerminal extends ClickableWidget | |||||||
|  |  | ||||||
|     public WidgetTerminal( @Nonnull ClientComputer computer, int x, int y, int termWidth, int termHeight ) |     public WidgetTerminal( @Nonnull ClientComputer computer, int x, int y, int termWidth, int termHeight ) | ||||||
|     { |     { | ||||||
|         super( x, y, termWidth * FONT_WIDTH + MARGIN * 2, termHeight * FONT_HEIGHT + MARGIN * 2, LiteralText.EMPTY ); |         super( x, y, termWidth * FONT_WIDTH + MARGIN * 2, termHeight * FONT_HEIGHT + MARGIN * 2, TextComponent.EMPTY ); | ||||||
|  |  | ||||||
|         this.computer = computer; |         this.computer = computer; | ||||||
|  |  | ||||||
| @@ -207,7 +208,7 @@ public class WidgetTerminal extends ClickableWidget | |||||||
|  |  | ||||||
|                 case GLFW.GLFW_KEY_V: |                 case GLFW.GLFW_KEY_V: | ||||||
|                     // Ctrl+V for paste |                     // Ctrl+V for paste | ||||||
|                     String clipboard = MinecraftClient.getInstance().keyboard.getClipboard(); |                     String clipboard = Minecraft.getInstance().keyboardHandler.getClipboard(); | ||||||
|                     if( clipboard != null ) |                     if( clipboard != null ) | ||||||
|                     { |                     { | ||||||
|                         // Clip to the first occurrence of \r or \n |                         // Clip to the first occurrence of \r or \n | ||||||
| @@ -227,7 +228,7 @@ public class WidgetTerminal extends ClickableWidget | |||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                         // Filter the string |                         // Filter the string | ||||||
|                         clipboard = SharedConstants.stripInvalidChars( clipboard ); |                         clipboard = SharedConstants.filterText( clipboard ); | ||||||
|                         if( !clipboard.isEmpty() ) |                         if( !clipboard.isEmpty() ) | ||||||
|                         { |                         { | ||||||
|                             // Clip to 512 characters and queue the event |                             // Clip to 512 characters and queue the event | ||||||
| @@ -346,10 +347,10 @@ public class WidgetTerminal extends ClickableWidget | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render( @Nonnull MatrixStack transform, int mouseX, int mouseY, float partialTicks ) |     public void render( @Nonnull PoseStack transform, int mouseX, int mouseY, float partialTicks ) | ||||||
|     { |     { | ||||||
|         if( !visible ) return; |         if( !visible ) return; | ||||||
|         Matrix4f matrix = transform.peek().getModel(); |         Matrix4f matrix = transform.last().pose(); | ||||||
|         Terminal terminal = computer.getTerminal(); |         Terminal terminal = computer.getTerminal(); | ||||||
|         if( terminal != null ) |         if( terminal != null ) | ||||||
|         { |         { | ||||||
| @@ -362,7 +363,7 @@ public class WidgetTerminal extends ClickableWidget | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void appendNarrations( NarrationMessageBuilder builder ) |     public void updateNarration( NarrationElementOutput builder ) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -39,12 +39,11 @@ import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; | |||||||
| import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; | import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; | ||||||
| import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; | import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; | ||||||
| import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry; | import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry; | ||||||
| import net.minecraft.client.item.UnclampedModelPredicateProvider; | import net.minecraft.client.renderer.RenderType; | ||||||
| import net.minecraft.client.render.RenderLayer; | import net.minecraft.client.renderer.item.ClampedItemPropertyFunction; | ||||||
| import net.minecraft.item.Item; | import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraft.screen.PlayerScreenHandler; | import net.minecraft.world.inventory.InventoryMenu; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.world.item.Item; | ||||||
|  |  | ||||||
| import java.util.function.Supplier; | import java.util.function.Supplier; | ||||||
|  |  | ||||||
| @Environment( EnvType.CLIENT ) | @Environment( EnvType.CLIENT ) | ||||||
| @@ -73,11 +72,11 @@ public final class ComputerCraftProxyClient implements ClientModInitializer | |||||||
|         registerContainers(); |         registerContainers(); | ||||||
|  |  | ||||||
|         // While turtles themselves are not transparent, their upgrades may be. |         // While turtles themselves are not transparent, their upgrades may be. | ||||||
|         BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.TURTLE_NORMAL, RenderLayer.getTranslucent() ); |         BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.TURTLE_NORMAL, RenderType.translucent() ); | ||||||
|         BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.TURTLE_ADVANCED, RenderLayer.getTranslucent() ); |         BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.TURTLE_ADVANCED, RenderType.translucent() ); | ||||||
|         // Monitors' textures have transparent fronts and so count as cutouts. |         // Monitors' textures have transparent fronts and so count as cutouts. | ||||||
|         BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.MONITOR_NORMAL, RenderLayer.getCutout() ); |         BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.MONITOR_NORMAL, RenderType.cutout() ); | ||||||
|         BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.MONITOR_ADVANCED, RenderLayer.getCutout() ); |         BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.MONITOR_ADVANCED, RenderType.cutout() ); | ||||||
|  |  | ||||||
|         // Setup TESRs |         // Setup TESRs | ||||||
|         BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.MONITOR_NORMAL, TileEntityMonitorRenderer::new ); |         BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.MONITOR_NORMAL, TileEntityMonitorRenderer::new ); | ||||||
| @@ -85,7 +84,7 @@ public final class ComputerCraftProxyClient implements ClientModInitializer | |||||||
|         BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.TURTLE_NORMAL, TileEntityTurtleRenderer::new ); |         BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.TURTLE_NORMAL, TileEntityTurtleRenderer::new ); | ||||||
|         BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.TURTLE_ADVANCED, TileEntityTurtleRenderer::new ); |         BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.TURTLE_ADVANCED, TileEntityTurtleRenderer::new ); | ||||||
|  |  | ||||||
|         ClientSpriteRegistryCallback.event( PlayerScreenHandler.BLOCK_ATLAS_TEXTURE ) |         ClientSpriteRegistryCallback.event( InventoryMenu.BLOCK_ATLAS ) | ||||||
|             .register( ClientRegistry::onTextureStitchEvent ); |             .register( ClientRegistry::onTextureStitchEvent ); | ||||||
|         ModelLoadingRegistry.INSTANCE.registerModelProvider( ClientRegistry::onModelBakeEvent ); |         ModelLoadingRegistry.INSTANCE.registerModelProvider( ClientRegistry::onModelBakeEvent ); | ||||||
|         ModelLoadingRegistry.INSTANCE.registerResourceProvider( loader -> ( name, context ) -> TurtleModelLoader.INSTANCE.accepts( name ) ? |         ModelLoadingRegistry.INSTANCE.registerResourceProvider( loader -> ( name, context ) -> TurtleModelLoader.INSTANCE.accepts( name ) ? | ||||||
| @@ -127,9 +126,9 @@ public final class ComputerCraftProxyClient implements ClientModInitializer | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @SafeVarargs |     @SafeVarargs | ||||||
|     private static void registerItemProperty( String name, UnclampedModelPredicateProvider getter, Supplier<? extends Item>... items ) |     private static void registerItemProperty( String name, ClampedItemPropertyFunction getter, Supplier<? extends Item>... items ) | ||||||
|     { |     { | ||||||
|         Identifier id = new Identifier( ComputerCraft.MOD_ID, name ); |         ResourceLocation id = new ResourceLocation( ComputerCraft.MOD_ID, name ); | ||||||
|         for( Supplier<? extends Item> item : items ) |         for( Supplier<? extends Item> item : items ) | ||||||
|         { |         { | ||||||
|             FabricModelPredicateProviderRegistry.register( item.get(), id, getter ); |             FabricModelPredicateProviderRegistry.register( item.get(), id, getter ); | ||||||
|   | |||||||
| @@ -6,21 +6,26 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
|  | 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.ComputerCraftRegistry; | import dan200.computercraft.shared.ComputerCraftRegistry; | ||||||
| import dan200.computercraft.shared.peripheral.modem.wired.BlockCable; | import dan200.computercraft.shared.peripheral.modem.wired.BlockCable; | ||||||
| import dan200.computercraft.shared.peripheral.modem.wired.CableShapes; | import dan200.computercraft.shared.peripheral.modem.wired.CableShapes; | ||||||
| import dan200.computercraft.shared.util.WorldUtil; | import dan200.computercraft.shared.util.WorldUtil; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.block.BlockState; | import net.minecraft.client.Camera; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.render.Camera; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.client.render.VertexConsumer; | import net.minecraft.util.Mth; | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.Entity; |  | ||||||
| import net.minecraft.util.hit.HitResult; |  | ||||||
| import net.minecraft.util.math.*; | import net.minecraft.util.math.*; | ||||||
| import net.minecraft.util.shape.VoxelShape; | import net.minecraft.world.entity.Entity; | ||||||
|  | import net.minecraft.world.level.block.state.BlockState; | ||||||
|  | import net.minecraft.world.phys.HitResult; | ||||||
|  | import net.minecraft.world.phys.Vec3; | ||||||
|  | import net.minecraft.world.phys.shapes.VoxelShape; | ||||||
|  |  | ||||||
| @Environment( EnvType.CLIENT ) | @Environment( EnvType.CLIENT ) | ||||||
| public final class CableHighlightRenderer | public final class CableHighlightRenderer | ||||||
| @@ -29,21 +34,21 @@ public final class CableHighlightRenderer | |||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean drawHighlight( MatrixStack stack, VertexConsumer consumer, Entity entity, double d, double e, double f, BlockPos pos, |     public static boolean drawHighlight( PoseStack stack, VertexConsumer consumer, Entity entity, double d, double e, double f, BlockPos pos, | ||||||
|                                          BlockState state ) |                                          BlockState state ) | ||||||
|     { |     { | ||||||
|         Camera info = MinecraftClient.getInstance().gameRenderer.getCamera(); |         Camera info = Minecraft.getInstance().gameRenderer.getMainCamera(); | ||||||
|  |  | ||||||
|         // We only care about instances with both cable and modem. |         // We only care about instances with both cable and modem. | ||||||
|         if( state.getBlock() != ComputerCraftRegistry.ModBlocks.CABLE || state.get( BlockCable.MODEM ) |         if( state.getBlock() != ComputerCraftRegistry.ModBlocks.CABLE || state.getValue( BlockCable.MODEM ) | ||||||
|             .getFacing() == null || !state.get( BlockCable.CABLE ) ) |             .getFacing() == null || !state.getValue( BlockCable.CABLE ) ) | ||||||
|         { |         { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         HitResult hitResult = MinecraftClient.getInstance().crosshairTarget; |         HitResult hitResult = Minecraft.getInstance().hitResult; | ||||||
|  |  | ||||||
|         Vec3d hitPos = hitResult != null ? hitResult.getPos() : new Vec3d( d, e, f ); |         Vec3 hitPos = hitResult != null ? hitResult.getLocation() : new Vec3( d, e, f ); | ||||||
|  |  | ||||||
|         VoxelShape shape = WorldUtil.isVecInside( CableShapes.getModemShape( state ), |         VoxelShape shape = WorldUtil.isVecInside( CableShapes.getModemShape( state ), | ||||||
|             hitPos.subtract( pos.getX(), |             hitPos.subtract( pos.getX(), | ||||||
| @@ -51,19 +56,19 @@ public final class CableHighlightRenderer | |||||||
|                 pos.getZ() ) ) ? CableShapes.getModemShape( state ) : CableShapes.getCableShape( |                 pos.getZ() ) ) ? CableShapes.getModemShape( state ) : CableShapes.getCableShape( | ||||||
|             state ); |             state ); | ||||||
|  |  | ||||||
|         Vec3d cameraPos = info.getPos(); |         Vec3 cameraPos = info.getPosition(); | ||||||
|  |  | ||||||
|         double xOffset = pos.getX() - cameraPos.getX(); |         double xOffset = pos.getX() - cameraPos.x(); | ||||||
|         double yOffset = pos.getY() - cameraPos.getY(); |         double yOffset = pos.getY() - cameraPos.y(); | ||||||
|         double zOffset = pos.getZ() - cameraPos.getZ(); |         double zOffset = pos.getZ() - cameraPos.z(); | ||||||
|         Matrix4f matrix4f = stack.peek() |         Matrix4f matrix4f = stack.last() | ||||||
|             .getModel(); |             .pose(); | ||||||
|         Matrix3f normal = stack.peek().getNormal(); |         Matrix3f normal = stack.last().normal(); | ||||||
|         shape.forEachEdge( ( x1, y1, z1, x2, y2, z2 ) -> { |         shape.forAllEdges( ( x1, y1, z1, x2, y2, z2 ) -> { | ||||||
|             float xDelta = (float) (x2 - x1); |             float xDelta = (float) (x2 - x1); | ||||||
|             float yDelta = (float) (y2 - y1); |             float yDelta = (float) (y2 - y1); | ||||||
|             float zDelta = (float) (z2 - z1); |             float zDelta = (float) (z2 - z1); | ||||||
|             float len = MathHelper.sqrt( xDelta * xDelta + yDelta * yDelta + zDelta * zDelta ); |             float len = Mth.sqrt( xDelta * xDelta + yDelta * yDelta + zDelta * zDelta ); | ||||||
|             xDelta = xDelta / len; |             xDelta = xDelta / len; | ||||||
|             yDelta = yDelta / len; |             yDelta = yDelta / len; | ||||||
|             zDelta = zDelta / len; |             zDelta = zDelta / len; | ||||||
| @@ -71,11 +76,11 @@ public final class CableHighlightRenderer | |||||||
|             consumer.vertex( matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset) ) |             consumer.vertex( matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset) ) | ||||||
|                 .color( 0, 0, 0, 0.4f ) |                 .color( 0, 0, 0, 0.4f ) | ||||||
|                 .normal( normal, xDelta, yDelta, zDelta ) |                 .normal( normal, xDelta, yDelta, zDelta ) | ||||||
|                 .next(); |                 .endVertex(); | ||||||
|             consumer.vertex( matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset) ) |             consumer.vertex( matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset) ) | ||||||
|                 .color( 0, 0, 0, 0.4f ) |                 .color( 0, 0, 0, 0.4f ) | ||||||
|                 .normal( normal, xDelta, yDelta, zDelta ) |                 .normal( normal, xDelta, yDelta, zDelta ) | ||||||
|                 .next(); |                 .endVertex(); | ||||||
|         } ); |         } ); | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|   | |||||||
| @@ -5,23 +5,22 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.Tesselator; | ||||||
|  | import com.mojang.blaze3d.vertex.VertexConsumer; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||||
| import net.minecraft.client.render.RenderLayer; |  | ||||||
| import net.minecraft.client.render.Tessellator; |  | ||||||
| import net.minecraft.client.render.VertexConsumer; |  | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
| import net.minecraft.util.math.Matrix4f; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
|  | import net.minecraft.client.renderer.RenderType; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  |  | ||||||
| public class ComputerBorderRenderer | public class ComputerBorderRenderer | ||||||
| { | { | ||||||
|     public static final Identifier BACKGROUND_NORMAL = new Identifier( ComputerCraft.MOD_ID, "textures/gui/corners_normal.png" ); |     public static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_normal.png" ); | ||||||
|     public static final Identifier BACKGROUND_ADVANCED = new Identifier( ComputerCraft.MOD_ID, "textures/gui/corners_advanced.png" ); |     public static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_advanced.png" ); | ||||||
|     public static final Identifier BACKGROUND_COMMAND = new Identifier( ComputerCraft.MOD_ID, "textures/gui/corners_command.png" ); |     public static final ResourceLocation BACKGROUND_COMMAND = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_command.png" ); | ||||||
|     public static final Identifier BACKGROUND_COLOUR = new Identifier( ComputerCraft.MOD_ID, "textures/gui/corners_colour.png" ); |     public static final ResourceLocation BACKGROUND_COLOUR = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_colour.png" ); | ||||||
|     /** |     /** | ||||||
|      * The margin between the terminal and its border. |      * The margin between the terminal and its border. | ||||||
|      */ |      */ | ||||||
| @@ -45,7 +44,7 @@ public class ComputerBorderRenderer | |||||||
|  |  | ||||||
|     static |     static | ||||||
|     { |     { | ||||||
|         IDENTITY.loadIdentity(); |         IDENTITY.setIdentity(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private final Matrix4f transform; |     private final Matrix4f transform; | ||||||
| @@ -68,7 +67,7 @@ public class ComputerBorderRenderer | |||||||
|  |  | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     public static Identifier getTexture( @Nonnull ComputerFamily family ) |     public static ResourceLocation getTexture( @Nonnull ComputerFamily family ) | ||||||
|     { |     { | ||||||
|         switch( family ) |         switch( family ) | ||||||
|         { |         { | ||||||
| @@ -82,11 +81,11 @@ public class ComputerBorderRenderer | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void render( Identifier location, int x, int y, int z, int light, int width, int height ) |     public static void render( ResourceLocation location, int x, int y, int z, int light, int width, int height ) | ||||||
|     { |     { | ||||||
|         VertexConsumerProvider.Immediate source = VertexConsumerProvider.immediate( Tessellator.getInstance().getBuffer() ); |         MultiBufferSource.BufferSource source = MultiBufferSource.immediate( Tesselator.getInstance().getBuilder() ); | ||||||
|         render( IDENTITY, source.getBuffer( RenderLayer.getText( location ) ), x, y, z, light, width, height, false, 1, 1, 1 ); |         render( IDENTITY, source.getBuffer( RenderType.text( location ) ), x, y, z, light, width, height, false, 1, 1, 1 ); | ||||||
|         source.draw(); |         source.endBatch(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -144,23 +143,23 @@ public class ComputerBorderRenderer | |||||||
|     { |     { | ||||||
|         builder.vertex( transform, x, y + height, z ) |         builder.vertex( transform, x, y + height, z ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) |             .uv( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         builder.vertex( transform, x + width, y + height, z ) |         builder.vertex( transform, x + width, y + height, z ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) |             .uv( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         builder.vertex( transform, x + width, y, z ) |         builder.vertex( transform, x + width, y, z ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE ) |             .uv( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         builder.vertex( transform, x, y, z ) |         builder.vertex( transform, x, y, z ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .texture( u * TEX_SCALE, v * TEX_SCALE ) |             .uv( u * TEX_SCALE, v * TEX_SCALE ) | ||||||
|             .light( light ) |             .uv2( light ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,32 +6,32 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.math.Vector3f; | ||||||
| import dan200.computercraft.fabric.mixin.HeldItemRendererAccess; | import dan200.computercraft.fabric.mixin.HeldItemRendererAccess; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; | import net.minecraft.client.renderer.ItemInHandRenderer; | ||||||
| import net.minecraft.client.render.item.HeldItemRenderer; | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.util.Mth; | ||||||
| import net.minecraft.entity.player.PlayerEntity; | import net.minecraft.world.InteractionHand; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.world.entity.HumanoidArm; | ||||||
| import net.minecraft.util.Arm; | import net.minecraft.world.entity.player.Player; | ||||||
| import net.minecraft.util.Hand; | import net.minecraft.world.item.ItemStack; | ||||||
| import net.minecraft.util.math.MathHelper; |  | ||||||
| import net.minecraft.util.math.Vec3f; |  | ||||||
|  |  | ||||||
| @Environment( EnvType.CLIENT ) | @Environment( EnvType.CLIENT ) | ||||||
| public abstract class ItemMapLikeRenderer | public abstract class ItemMapLikeRenderer | ||||||
| { | { | ||||||
|     public void renderItemFirstPerson( |     public void renderItemFirstPerson( | ||||||
|         MatrixStack transform, VertexConsumerProvider render, int lightTexture, Hand hand, float pitch, float equipProgress, |         PoseStack transform, MultiBufferSource render, int lightTexture, InteractionHand hand, float pitch, float equipProgress, | ||||||
|         float swingProgress, ItemStack stack |         float swingProgress, ItemStack stack | ||||||
|     ) |     ) | ||||||
|     { |     { | ||||||
|         PlayerEntity player = MinecraftClient.getInstance().player; |         Player player = Minecraft.getInstance().player; | ||||||
|  |  | ||||||
|         transform.push(); |         transform.pushPose(); | ||||||
|         if( hand == Hand.MAIN_HAND && player.getOffHandStack().isEmpty() ) |         if( hand == InteractionHand.MAIN_HAND && player.getOffhandItem().isEmpty() ) | ||||||
|         { |         { | ||||||
|             renderItemFirstPersonCenter( transform, render, lightTexture, pitch, equipProgress, swingProgress, stack ); |             renderItemFirstPersonCenter( transform, render, lightTexture, pitch, equipProgress, swingProgress, stack ); | ||||||
|         } |         } | ||||||
| @@ -40,12 +40,12 @@ public abstract class ItemMapLikeRenderer | |||||||
|             renderItemFirstPersonSide( transform, |             renderItemFirstPersonSide( transform, | ||||||
|                 render, |                 render, | ||||||
|                 lightTexture, |                 lightTexture, | ||||||
|                 hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(), |                 hand == InteractionHand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(), | ||||||
|                 equipProgress, |                 equipProgress, | ||||||
|                 swingProgress, |                 swingProgress, | ||||||
|                 stack ); |                 stack ); | ||||||
|         } |         } | ||||||
|         transform.pop(); |         transform.popPose(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -59,34 +59,34 @@ public abstract class ItemMapLikeRenderer | |||||||
|      * @param swingProgress The swing progress of this item |      * @param swingProgress The swing progress of this item | ||||||
|      * @param stack         The stack to render |      * @param stack         The stack to render | ||||||
|      */ |      */ | ||||||
|     private void renderItemFirstPersonCenter( MatrixStack transform, VertexConsumerProvider render, int combinedLight, float pitch, float equipProgress, |     private void renderItemFirstPersonCenter( PoseStack transform, MultiBufferSource render, int combinedLight, float pitch, float equipProgress, | ||||||
|                                               float swingProgress, ItemStack stack ) |                                               float swingProgress, ItemStack stack ) | ||||||
|     { |     { | ||||||
|         MinecraftClient minecraft = MinecraftClient.getInstance(); |         Minecraft minecraft = Minecraft.getInstance(); | ||||||
|         HeldItemRenderer renderer = minecraft.getHeldItemRenderer(); |         ItemInHandRenderer renderer = minecraft.getItemInHandRenderer(); | ||||||
|  |  | ||||||
|         // Setup the appropriate transformations. This is just copied from the |         // Setup the appropriate transformations. This is just copied from the | ||||||
|         // corresponding method in ItemRenderer. |         // corresponding method in ItemRenderer. | ||||||
|         float swingRt = MathHelper.sqrt( swingProgress ); |         float swingRt = Mth.sqrt( swingProgress ); | ||||||
|         float tX = -0.2f * MathHelper.sin( swingProgress * (float) Math.PI ); |         float tX = -0.2f * Mth.sin( swingProgress * (float) Math.PI ); | ||||||
|         float tZ = -0.4f * MathHelper.sin( swingRt * (float) Math.PI ); |         float tZ = -0.4f * Mth.sin( swingRt * (float) Math.PI ); | ||||||
|         transform.translate( 0, -tX / 2, tZ ); |         transform.translate( 0, -tX / 2, tZ ); | ||||||
|  |  | ||||||
|         HeldItemRendererAccess access = (HeldItemRendererAccess) renderer; |         HeldItemRendererAccess access = (HeldItemRendererAccess) renderer; | ||||||
|         float pitchAngle = access.callGetMapAngle( pitch ); |         float pitchAngle = access.callGetMapAngle( pitch ); | ||||||
|         transform.translate( 0, 0.04F + equipProgress * -1.2f + pitchAngle * -0.5f, -0.72f ); |         transform.translate( 0, 0.04F + equipProgress * -1.2f + pitchAngle * -0.5f, -0.72f ); | ||||||
|         transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( pitchAngle * -85.0f ) ); |         transform.mulPose( Vector3f.XP.rotationDegrees( pitchAngle * -85.0f ) ); | ||||||
|         if( !minecraft.player.isInvisible() ) |         if( !minecraft.player.isInvisible() ) | ||||||
|         { |         { | ||||||
|             transform.push(); |             transform.pushPose(); | ||||||
|             transform.multiply( Vec3f.POSITIVE_Y.getDegreesQuaternion( 90.0F ) ); |             transform.mulPose( Vector3f.YP.rotationDegrees( 90.0F ) ); | ||||||
|             access.callRenderArm( transform, render, combinedLight, Arm.RIGHT ); |             access.callRenderArm( transform, render, combinedLight, HumanoidArm.RIGHT ); | ||||||
|             access.callRenderArm( transform, render, combinedLight, Arm.LEFT ); |             access.callRenderArm( transform, render, combinedLight, HumanoidArm.LEFT ); | ||||||
|             transform.pop(); |             transform.popPose(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         float rX = MathHelper.sin( swingRt * (float) Math.PI ); |         float rX = Mth.sin( swingRt * (float) Math.PI ); | ||||||
|         transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( rX * 20.0F ) ); |         transform.mulPose( Vector3f.XP.rotationDegrees( rX * 20.0F ) ); | ||||||
|         transform.scale( 2.0F, 2.0F, 2.0F ); |         transform.scale( 2.0F, 2.0F, 2.0F ); | ||||||
|  |  | ||||||
|         renderItem( transform, render, stack, combinedLight ); |         renderItem( transform, render, stack, combinedLight ); | ||||||
| @@ -103,39 +103,39 @@ public abstract class ItemMapLikeRenderer | |||||||
|      * @param swingProgress The swing progress of this item |      * @param swingProgress The swing progress of this item | ||||||
|      * @param stack         The stack to render |      * @param stack         The stack to render | ||||||
|      */ |      */ | ||||||
|     private void renderItemFirstPersonSide( MatrixStack transform, VertexConsumerProvider render, int combinedLight, Arm side, float equipProgress, |     private void renderItemFirstPersonSide( PoseStack transform, MultiBufferSource render, int combinedLight, HumanoidArm side, float equipProgress, | ||||||
|                                             float swingProgress, ItemStack stack ) |                                             float swingProgress, ItemStack stack ) | ||||||
|     { |     { | ||||||
|         MinecraftClient minecraft = MinecraftClient.getInstance(); |         Minecraft minecraft = Minecraft.getInstance(); | ||||||
|         float offset = side == Arm.RIGHT ? 1f : -1f; |         float offset = side == HumanoidArm.RIGHT ? 1f : -1f; | ||||||
|         transform.translate( offset * 0.125f, -0.125f, 0f ); |         transform.translate( offset * 0.125f, -0.125f, 0f ); | ||||||
|  |  | ||||||
|         // If the player is not invisible then render a single arm |         // If the player is not invisible then render a single arm | ||||||
|         if( !minecraft.player.isInvisible() ) |         if( !minecraft.player.isInvisible() ) | ||||||
|         { |         { | ||||||
|             transform.push(); |             transform.pushPose(); | ||||||
|             transform.multiply( Vec3f.POSITIVE_Z.getDegreesQuaternion( offset * 10f ) ); |             transform.mulPose( Vector3f.ZP.rotationDegrees( offset * 10f ) ); | ||||||
|             ((HeldItemRendererAccess) minecraft.getHeldItemRenderer()) |             ((HeldItemRendererAccess) minecraft.getItemInHandRenderer()) | ||||||
|                 .callRenderArmHoldingItem( transform, render, combinedLight, equipProgress, swingProgress, side ); |                 .callRenderArmHoldingItem( transform, render, combinedLight, equipProgress, swingProgress, side ); | ||||||
|             transform.pop(); |             transform.popPose(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Setup the appropriate transformations. This is just copied from the |         // Setup the appropriate transformations. This is just copied from the | ||||||
|         // corresponding method in ItemRenderer. |         // corresponding method in ItemRenderer. | ||||||
|         transform.push(); |         transform.pushPose(); | ||||||
|         transform.translate( offset * 0.51f, -0.08f + equipProgress * -1.2f, -0.75f ); |         transform.translate( offset * 0.51f, -0.08f + equipProgress * -1.2f, -0.75f ); | ||||||
|         float f1 = MathHelper.sqrt( swingProgress ); |         float f1 = Mth.sqrt( swingProgress ); | ||||||
|         float f2 = MathHelper.sin( f1 * (float) Math.PI ); |         float f2 = Mth.sin( f1 * (float) Math.PI ); | ||||||
|         float f3 = -0.5f * f2; |         float f3 = -0.5f * f2; | ||||||
|         float f4 = 0.4f * MathHelper.sin( f1 * ((float) Math.PI * 2f) ); |         float f4 = 0.4f * Mth.sin( f1 * ((float) Math.PI * 2f) ); | ||||||
|         float f5 = -0.3f * MathHelper.sin( swingProgress * (float) Math.PI ); |         float f5 = -0.3f * Mth.sin( swingProgress * (float) Math.PI ); | ||||||
|         transform.translate( offset * f3, f4 - 0.3f * f2, f5 ); |         transform.translate( offset * f3, f4 - 0.3f * f2, f5 ); | ||||||
|         transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( f2 * -45f ) ); |         transform.mulPose( Vector3f.XP.rotationDegrees( f2 * -45f ) ); | ||||||
|         transform.multiply( Vec3f.POSITIVE_Y.getDegreesQuaternion( offset * f2 * -30f ) ); |         transform.mulPose( Vector3f.YP.rotationDegrees( offset * f2 * -30f ) ); | ||||||
|  |  | ||||||
|         renderItem( transform, render, stack, combinedLight ); |         renderItem( transform, render, stack, combinedLight ); | ||||||
|  |  | ||||||
|         transform.pop(); |         transform.popPose(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -146,5 +146,5 @@ public abstract class ItemMapLikeRenderer | |||||||
|      * @param stack     The stack to render |      * @param stack     The stack to render | ||||||
|      * @param light     TODO rebase |      * @param light     TODO rebase | ||||||
|      */ |      */ | ||||||
|     protected abstract void renderItem( MatrixStack transform, VertexConsumerProvider render, ItemStack stack, int light ); |     protected abstract void renderItem( PoseStack transform, MultiBufferSource render, ItemStack stack, int light ); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,6 +7,13 @@ | |||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
| import com.mojang.blaze3d.systems.RenderSystem; | import com.mojang.blaze3d.systems.RenderSystem; | ||||||
|  | import com.mojang.blaze3d.vertex.BufferBuilder; | ||||||
|  | import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.blaze3d.vertex.Tesselator; | ||||||
|  | import com.mojang.blaze3d.vertex.VertexFormat; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
|  | import com.mojang.math.Vector3f; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.client.gui.FixedWidthFontRenderer; | import dan200.computercraft.client.gui.FixedWidthFontRenderer; | ||||||
| import dan200.computercraft.core.terminal.Terminal; | import dan200.computercraft.core.terminal.Terminal; | ||||||
| @@ -14,13 +21,12 @@ import dan200.computercraft.shared.computer.core.ClientComputer; | |||||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||||
| import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | ||||||
| import dan200.computercraft.shared.util.Colour; | import dan200.computercraft.shared.util.Colour; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.render.*; | import net.minecraft.client.render.*; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.client.renderer.RenderType; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraft.util.math.Matrix4f; | import net.minecraft.world.item.ItemStack; | ||||||
| import net.minecraft.util.math.Vec3f; |  | ||||||
|  |  | ||||||
| import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; | import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; | ||||||
| import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; | import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; | ||||||
| @@ -38,7 +44,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void renderItem( MatrixStack transform, VertexConsumerProvider render, ItemStack stack, int light ) |     protected void renderItem( PoseStack transform, MultiBufferSource render, ItemStack stack, int light ) | ||||||
|     { |     { | ||||||
|         ClientComputer computer = ItemPocketComputer.createClientComputer( stack ); |         ClientComputer computer = ItemPocketComputer.createClientComputer( stack ); | ||||||
|         Terminal terminal = computer == null ? null : computer.getTerminal(); |         Terminal terminal = computer == null ? null : computer.getTerminal(); | ||||||
| @@ -60,9 +66,9 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer | |||||||
|  |  | ||||||
|         // Setup various transformations. Note that these are partially adapted from the corresponding method |         // Setup various transformations. Note that these are partially adapted from the corresponding method | ||||||
|         // in ItemRenderer |         // in ItemRenderer | ||||||
|         transform.push(); |         transform.pushPose(); | ||||||
|         transform.multiply( Vec3f.POSITIVE_Y.getDegreesQuaternion( 180f ) ); |         transform.mulPose( Vector3f.YP.rotationDegrees( 180f ) ); | ||||||
|         transform.multiply( Vec3f.POSITIVE_Z.getDegreesQuaternion( 180f ) ); |         transform.mulPose( Vector3f.ZP.rotationDegrees( 180f ) ); | ||||||
|         transform.scale( 0.5f, 0.5f, 0.5f ); |         transform.scale( 0.5f, 0.5f, 0.5f ); | ||||||
|  |  | ||||||
|         float scale = 0.75f / Math.max( width + BORDER * 2, height + BORDER * 2 + LIGHT_HEIGHT ); |         float scale = 0.75f / Math.max( width + BORDER * 2, height + BORDER * 2 + LIGHT_HEIGHT ); | ||||||
| @@ -74,8 +80,8 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer | |||||||
|         ComputerFamily family = item.getFamily(); |         ComputerFamily family = item.getFamily(); | ||||||
|         int frameColour = item.getColour( stack ); |         int frameColour = item.getColour( stack ); | ||||||
|  |  | ||||||
|         Matrix4f matrix = transform.peek() |         Matrix4f matrix = transform.last() | ||||||
|             .getModel(); |             .pose(); | ||||||
|         renderFrame( matrix, render, family, frameColour, light, width, height ); |         renderFrame( matrix, render, family, frameColour, light, width, height ); | ||||||
|  |  | ||||||
|         // Render the light |         // Render the light | ||||||
| @@ -92,7 +98,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer | |||||||
|                 matrix, render.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ), |                 matrix, render.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ), | ||||||
|                 MARGIN, MARGIN, terminal, !computer.isColour(), MARGIN, MARGIN, MARGIN, MARGIN |                 MARGIN, MARGIN, terminal, !computer.isColour(), MARGIN, MARGIN, MARGIN, MARGIN | ||||||
|             ); |             ); | ||||||
|             FixedWidthFontRenderer.drawBlocker( transform.peek().getModel(), render, 0, 0, width, height ); |             FixedWidthFontRenderer.drawBlocker( transform.last().pose(), render, 0, 0, width, height ); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
| @@ -100,23 +106,23 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer | |||||||
|             FixedWidthFontRenderer.drawEmptyTerminal( matrix, 0, 0, width, height ); |             FixedWidthFontRenderer.drawEmptyTerminal( matrix, 0, 0, width, height ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         transform.pop(); |         transform.popPose(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void renderFrame( Matrix4f transform, VertexConsumerProvider render, ComputerFamily family, int colour, int light, int width, int height ) |     private static void renderFrame( Matrix4f transform, MultiBufferSource render, ComputerFamily family, int colour, int light, int width, int height ) | ||||||
|     { |     { | ||||||
|         RenderSystem.enableBlend(); |         RenderSystem.enableBlend(); | ||||||
|         MinecraftClient.getInstance() |         Minecraft.getInstance() | ||||||
|             .getTextureManager() |             .getTextureManager() | ||||||
|             .bindTexture( colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family ) ); |             .bindForSetup( colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family ) ); | ||||||
|  |  | ||||||
|         Identifier texture = colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family ); |         ResourceLocation texture = colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family ); | ||||||
|  |  | ||||||
|         float r = ((colour >>> 16) & 0xFF) / 255.0f; |         float r = ((colour >>> 16) & 0xFF) / 255.0f; | ||||||
|         float g = ((colour >>> 8) & 0xFF) / 255.0f; |         float g = ((colour >>> 8) & 0xFF) / 255.0f; | ||||||
|         float b = (colour & 0xFF) / 255.0f; |         float b = (colour & 0xFF) / 255.0f; | ||||||
|  |  | ||||||
|         ComputerBorderRenderer.render( transform, render.getBuffer( RenderLayer.getText( texture ) ), 0, 0, 0, light, width, height, true, r, g, b ); |         ComputerBorderRenderer.render( transform, render.getBuffer( RenderType.text( texture ) ), 0, 0, 0, light, width, height, true, r, g, b ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void renderLight( Matrix4f transform, int colour, int width, int height ) |     private static void renderLight( Matrix4f transform, int colour, int width, int height ) | ||||||
| @@ -127,23 +133,23 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer | |||||||
|         float g = ((colour >>> 8) & 0xFF) / 255.0f; |         float g = ((colour >>> 8) & 0xFF) / 255.0f; | ||||||
|         float b = (colour & 0xFF) / 255.0f; |         float b = (colour & 0xFF) / 255.0f; | ||||||
|  |  | ||||||
|         Tessellator tessellator = Tessellator.getInstance(); |         Tesselator tessellator = Tesselator.getInstance(); | ||||||
|         BufferBuilder buffer = tessellator.getBuffer(); |         BufferBuilder buffer = tessellator.getBuilder(); | ||||||
|         buffer.begin( VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR ); |         buffer.begin( VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR ); | ||||||
|         buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ) |         buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, width, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ) |         buffer.vertex( transform, width, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, width, height + BORDER / 2.0f, 0 ) |         buffer.vertex( transform, width, height + BORDER / 2.0f, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + BORDER / 2.0f, 0 ) |         buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + BORDER / 2.0f, 0 ) | ||||||
|             .color( r, g, b, 1.0f ) |             .color( r, g, b, 1.0f ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|  |  | ||||||
|         tessellator.draw(); |         tessellator.end(); | ||||||
|         RenderSystem.enableTexture(); |         RenderSystem.enableTexture(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,11 +7,8 @@ | |||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.media.items.ItemPrintout; | import dan200.computercraft.shared.media.items.ItemPrintout; | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.world.item.ItemStack; | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.util.math.Matrix4f; |  | ||||||
| import net.minecraft.util.math.Vec3f; |  | ||||||
|  |  | ||||||
| import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; | import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; | ||||||
| import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; | import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; | ||||||
| @@ -19,6 +16,10 @@ import static dan200.computercraft.client.render.PrintoutRenderer.*; | |||||||
| import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE; | import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE; | ||||||
| import static dan200.computercraft.shared.media.items.ItemPrintout.LINE_MAX_LENGTH; | import static dan200.computercraft.shared.media.items.ItemPrintout.LINE_MAX_LENGTH; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
|  | import com.mojang.math.Vector3f; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Emulates map and item-frame rendering for printouts. |  * Emulates map and item-frame rendering for printouts. | ||||||
|  */ |  */ | ||||||
| @@ -31,16 +32,16 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void renderItem( MatrixStack transform, VertexConsumerProvider render, ItemStack stack, int light ) |     protected void renderItem( PoseStack transform, MultiBufferSource render, ItemStack stack, int light ) | ||||||
|     { |     { | ||||||
|         transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( 180f ) ); |         transform.mulPose( Vector3f.XP.rotationDegrees( 180f ) ); | ||||||
|         transform.scale( 0.42f, 0.42f, -0.42f ); |         transform.scale( 0.42f, 0.42f, -0.42f ); | ||||||
|         transform.translate( -0.5f, -0.48f, 0.0f ); |         transform.translate( -0.5f, -0.48f, 0.0f ); | ||||||
|  |  | ||||||
|         drawPrintout( transform, render, stack, light ); |         drawPrintout( transform, render, stack, light ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void drawPrintout( MatrixStack transform, VertexConsumerProvider render, ItemStack stack, int light ) |     private static void drawPrintout( PoseStack transform, MultiBufferSource render, ItemStack stack, int light ) | ||||||
|     { |     { | ||||||
|         int pages = ItemPrintout.getPageCount( stack ); |         int pages = ItemPrintout.getPageCount( stack ); | ||||||
|         boolean book = ((ItemPrintout) stack.getItem()).getType() == ItemPrintout.Type.BOOK; |         boolean book = ((ItemPrintout) stack.getItem()).getType() == ItemPrintout.Type.BOOK; | ||||||
| @@ -70,13 +71,13 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer | |||||||
|         transform.scale( scale, scale, scale ); |         transform.scale( scale, scale, scale ); | ||||||
|         transform.translate( (max - width) / 2.0, (max - height) / 2.0, 0.0 ); |         transform.translate( (max - width) / 2.0, (max - height) / 2.0, 0.0 ); | ||||||
|  |  | ||||||
|         Matrix4f matrix = transform.peek() |         Matrix4f matrix = transform.last() | ||||||
|             .getModel(); |             .pose(); | ||||||
|         drawBorder( matrix, render, 0, 0, -0.01f, 0, pages, book, light ); |         drawBorder( matrix, render, 0, 0, -0.01f, 0, pages, book, light ); | ||||||
|         drawText( matrix, render, X_TEXT_MARGIN, Y_TEXT_MARGIN, 0, light, ItemPrintout.getText( stack ), ItemPrintout.getColours( stack ) ); |         drawText( matrix, render, X_TEXT_MARGIN, Y_TEXT_MARGIN, 0, light, ItemPrintout.getText( stack ), ItemPrintout.getColours( stack ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public boolean renderInFrame( MatrixStack matrixStack, VertexConsumerProvider consumerProvider, ItemStack stack, int light ) |     public boolean renderInFrame( PoseStack matrixStack, MultiBufferSource consumerProvider, ItemStack stack, int light ) | ||||||
|     { |     { | ||||||
|         if( !(stack.getItem() instanceof ItemPrintout) ) |         if( !(stack.getItem() instanceof ItemPrintout) ) | ||||||
|         { |         { | ||||||
| @@ -85,7 +86,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer | |||||||
|  |  | ||||||
|         // Move a little bit forward to ensure we're not clipping with the frame |         // Move a little bit forward to ensure we're not clipping with the frame | ||||||
|         matrixStack.translate( 0.0f, 0.0f, -0.001f ); |         matrixStack.translate( 0.0f, 0.0f, -0.001f ); | ||||||
|         matrixStack.multiply( Vec3f.POSITIVE_Z.getDegreesQuaternion( 180f ) ); |         matrixStack.mulPose( Vector3f.ZP.rotationDegrees( 180f ) ); | ||||||
|         matrixStack.scale( 0.95f, 0.95f, -0.95f ); |         matrixStack.scale( 0.95f, 0.95f, -0.95f ); | ||||||
|         matrixStack.translate( -0.5f, -0.5f, 0.0f ); |         matrixStack.translate( -0.5f, -0.5f, 0.0f ); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,13 +7,12 @@ package dan200.computercraft.client.render; | |||||||
|  |  | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.client.render.VertexFormat; | import net.minecraft.client.renderer.block.model.BakedQuad; | ||||||
| import net.minecraft.client.render.VertexFormatElement; | import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||||||
| import net.minecraft.client.render.VertexFormats; | import com.mojang.blaze3d.vertex.VertexFormat; | ||||||
| import net.minecraft.client.render.model.BakedQuad; | import com.mojang.blaze3d.vertex.VertexFormatElement; | ||||||
| import net.minecraft.util.math.Matrix4f; | import com.mojang.math.Matrix4f; | ||||||
| import net.minecraft.util.math.Vector4f; | import com.mojang.math.Vector4f; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -27,7 +26,7 @@ public final class ModelTransformer | |||||||
|     static |     static | ||||||
|     { |     { | ||||||
|         identity = new Matrix4f(); |         identity = new Matrix4f(); | ||||||
|         identity.loadIdentity(); |         identity.setIdentity(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private ModelTransformer() |     private ModelTransformer() | ||||||
| @@ -36,7 +35,7 @@ public final class ModelTransformer | |||||||
|  |  | ||||||
|     public static void transformQuadsTo( List<BakedQuad> output, List<BakedQuad> input, Matrix4f transform ) |     public static void transformQuadsTo( List<BakedQuad> output, List<BakedQuad> input, Matrix4f transform ) | ||||||
|     { |     { | ||||||
|         transformQuadsTo( VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, output, input, transform ); |         transformQuadsTo( DefaultVertexFormat.BLOCK, output, input, transform ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void transformQuadsTo( VertexFormat format, List<BakedQuad> output, List<BakedQuad> input, Matrix4f transform ) |     public static void transformQuadsTo( VertexFormat format, List<BakedQuad> output, List<BakedQuad> input, Matrix4f transform ) | ||||||
| @@ -56,8 +55,8 @@ public final class ModelTransformer | |||||||
|  |  | ||||||
|     private static BakedQuad doTransformQuad( VertexFormat format, BakedQuad quad, Matrix4f transform ) |     private static BakedQuad doTransformQuad( VertexFormat format, BakedQuad quad, Matrix4f transform ) | ||||||
|     { |     { | ||||||
|         int[] vertexData = quad.getVertexData().clone(); |         int[] vertexData = quad.getVertices().clone(); | ||||||
|         BakedQuad copy = new BakedQuad( vertexData, -1, quad.getFace(), quad.getSprite(), true ); |         BakedQuad copy = new BakedQuad( vertexData, -1, quad.getDirection(), quad.getSprite(), true ); | ||||||
|  |  | ||||||
|         int offsetBytes = 0; |         int offsetBytes = 0; | ||||||
|         for( int v = 0; v < 4; ++v ) |         for( int v = 0; v < 4; ++v ) | ||||||
| @@ -65,7 +64,7 @@ public final class ModelTransformer | |||||||
|             for( VertexFormatElement element : format.getElements() ) // For each vertex element |             for( VertexFormatElement element : format.getElements() ) // For each vertex element | ||||||
|             { |             { | ||||||
|                 int start = offsetBytes / Integer.BYTES; |                 int start = offsetBytes / Integer.BYTES; | ||||||
|                 if( element.getType() == VertexFormatElement.Type.POSITION && element.getDataType() == VertexFormatElement.DataType.FLOAT ) // When we find a position element |                 if( element.getUsage() == VertexFormatElement.Usage.POSITION && element.getType() == VertexFormatElement.Type.FLOAT ) // When we find a position element | ||||||
|                 { |                 { | ||||||
|                     Vector4f pos = new Vector4f( Float.intBitsToFloat( vertexData[start] ), |                     Vector4f pos = new Vector4f( Float.intBitsToFloat( vertexData[start] ), | ||||||
|                         Float.intBitsToFloat( vertexData[start + 1] ), |                         Float.intBitsToFloat( vertexData[start + 1] ), | ||||||
| @@ -76,11 +75,11 @@ public final class ModelTransformer | |||||||
|                     pos.transform( transform ); |                     pos.transform( transform ); | ||||||
|  |  | ||||||
|                     // Insert the position |                     // Insert the position | ||||||
|                     vertexData[start] = Float.floatToRawIntBits( pos.getX() ); |                     vertexData[start] = Float.floatToRawIntBits( pos.x() ); | ||||||
|                     vertexData[start + 1] = Float.floatToRawIntBits( pos.getY() ); |                     vertexData[start + 1] = Float.floatToRawIntBits( pos.y() ); | ||||||
|                     vertexData[start + 2] = Float.floatToRawIntBits( pos.getZ() ); |                     vertexData[start + 2] = Float.floatToRawIntBits( pos.z() ); | ||||||
|                 } |                 } | ||||||
|                 offsetBytes += element.getByteLength(); |                 offsetBytes += element.getByteSize(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return copy; |         return copy; | ||||||
|   | |||||||
| @@ -9,17 +9,22 @@ package dan200.computercraft.client.render; | |||||||
| import dan200.computercraft.shared.peripheral.monitor.TileMonitor; | import dan200.computercraft.shared.peripheral.monitor.TileMonitor; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.block.BlockState; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.block.entity.BlockEntity; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.core.Direction; | ||||||
| import net.minecraft.client.render.VertexConsumer; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.entity.Entity; |  | ||||||
| import net.minecraft.util.math.*; | import net.minecraft.util.math.*; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.entity.Entity; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
|  | import net.minecraft.world.level.block.state.BlockState; | ||||||
|  | import net.minecraft.world.phys.Vec3; | ||||||
| import java.util.EnumSet; | import java.util.EnumSet; | ||||||
| import static net.minecraft.util.math.Direction.*; | import static net.minecraft.core.Direction.*; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.blaze3d.vertex.VertexConsumer; | ||||||
|  | import com.mojang.math.Matrix3f; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Overrides monitor highlighting to only render the outline of the <em>whole</em> monitor, rather than the current block. This means you do not get an |  * Overrides monitor highlighting to only render the outline of the <em>whole</em> monitor, rather than the current block. This means you do not get an | ||||||
| @@ -32,15 +37,15 @@ public final class MonitorHighlightRenderer | |||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean drawHighlight( MatrixStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos pos, BlockState blockState ) |     public static boolean drawHighlight( PoseStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos pos, BlockState blockState ) | ||||||
|     { |     { | ||||||
|         // Preserve normal behaviour when crouching. |         // Preserve normal behaviour when crouching. | ||||||
|         if( entity.isInSneakingPose() ) |         if( entity.isCrouching() ) | ||||||
|         { |         { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         World world = entity.getEntityWorld(); |         Level world = entity.getCommandSenderWorld(); | ||||||
|  |  | ||||||
|         BlockEntity tile = world.getBlockEntity( pos ); |         BlockEntity tile = world.getBlockEntity( pos ); | ||||||
|         if( !(tile instanceof TileMonitor monitor) ) |         if( !(tile instanceof TileMonitor monitor) ) | ||||||
| @@ -71,15 +76,15 @@ public final class MonitorHighlightRenderer | |||||||
|             faces.remove( monitor.getDown() ); |             faces.remove( monitor.getDown() ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Vec3d cameraPos = MinecraftClient.getInstance().gameRenderer.getCamera() |         Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera() | ||||||
|             .getPos(); |             .getPosition(); | ||||||
|         matrixStack.push(); |         matrixStack.pushPose(); | ||||||
|         matrixStack.translate( pos.getX() - cameraPos.getX(), pos.getY() - cameraPos.getY(), pos.getZ() - cameraPos.getZ() ); |         matrixStack.translate( pos.getX() - cameraPos.x(), pos.getY() - cameraPos.y(), pos.getZ() - cameraPos.z() ); | ||||||
|  |  | ||||||
|         // I wish I could think of a better way to do this |         // I wish I could think of a better way to do this | ||||||
|         Matrix4f transform = matrixStack.peek() |         Matrix4f transform = matrixStack.last() | ||||||
|             .getModel(); |             .pose(); | ||||||
|         Matrix3f normal = matrixStack.peek().getNormal(); |         Matrix3f normal = matrixStack.last().normal(); | ||||||
|         if( faces.contains( NORTH ) || faces.contains( WEST ) ) |         if( faces.contains( NORTH ) || faces.contains( WEST ) ) | ||||||
|         { |         { | ||||||
|             line( vertexConsumer, transform, normal, 0, 0, 0, UP ); |             line( vertexConsumer, transform, normal, 0, 0, 0, UP ); | ||||||
| @@ -129,7 +134,7 @@ public final class MonitorHighlightRenderer | |||||||
|             line( vertexConsumer, transform, normal, 1, 1, 0, SOUTH ); |             line( vertexConsumer, transform, normal, 1, 1, 0, SOUTH ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         matrixStack.pop(); |         matrixStack.popPose(); | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| @@ -138,11 +143,11 @@ public final class MonitorHighlightRenderer | |||||||
|     { |     { | ||||||
|         buffer.vertex( transform, x, y, z ) |         buffer.vertex( transform, x, y, z ) | ||||||
|             .color( 0, 0, 0, 0.4f ) |             .color( 0, 0, 0, 0.4f ) | ||||||
|             .normal( normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ() ) |             .normal( normal, direction.getStepX(), direction.getStepY(), direction.getStepZ() ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|         buffer.vertex( transform, x + direction.getOffsetX(), y + direction.getOffsetY(), z + direction.getOffsetZ() ) |         buffer.vertex( transform, x + direction.getStepX(), y + direction.getStepY(), z + direction.getStepZ() ) | ||||||
|             .color( 0, 0, 0, 0.4f ) |             .color( 0, 0, 0, 0.4f ) | ||||||
|             .normal( normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ() ) |             .normal( normal, direction.getStepX(), direction.getStepY(), direction.getStepZ() ) | ||||||
|             .next(); |             .endVertex(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,40 +5,40 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.shaders.Uniform; | ||||||
|  | import com.mojang.blaze3d.vertex.VertexFormat; | ||||||
| import dan200.computercraft.client.gui.FixedWidthFontRenderer; | import dan200.computercraft.client.gui.FixedWidthFontRenderer; | ||||||
| import dan200.computercraft.shared.util.Palette; | import dan200.computercraft.shared.util.Palette; | ||||||
| import net.minecraft.client.gl.GlUniform; |  | ||||||
| import net.minecraft.client.render.Shader; |  | ||||||
| import net.minecraft.client.render.VertexFormat; |  | ||||||
| import net.minecraft.resource.ResourceFactory; |  | ||||||
| import org.apache.logging.log4j.LogManager; | import org.apache.logging.log4j.LogManager; | ||||||
| import org.apache.logging.log4j.Logger; | import org.apache.logging.log4j.Logger; | ||||||
| import org.lwjgl.opengl.GL13; | import org.lwjgl.opengl.GL13; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.client.renderer.ShaderInstance; | ||||||
|  | import net.minecraft.server.packs.resources.ResourceProvider; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.nio.FloatBuffer; | import java.nio.FloatBuffer; | ||||||
|  |  | ||||||
| public class MonitorTextureBufferShader extends Shader | public class MonitorTextureBufferShader extends ShaderInstance | ||||||
| { | { | ||||||
|     static final int TEXTURE_INDEX = GL13.GL_TEXTURE3; |     static final int TEXTURE_INDEX = GL13.GL_TEXTURE3; | ||||||
|  |  | ||||||
|     private static final Logger LOGGER = LogManager.getLogger(); |     private static final Logger LOGGER = LogManager.getLogger(); | ||||||
|  |  | ||||||
|     private final GlUniform palette; |     private final Uniform palette; | ||||||
|     private final GlUniform width; |     private final Uniform width; | ||||||
|     private final GlUniform height; |     private final Uniform height; | ||||||
|  |  | ||||||
|     public MonitorTextureBufferShader( ResourceFactory factory, String name, VertexFormat format ) throws IOException |     public MonitorTextureBufferShader( ResourceProvider factory, String name, VertexFormat format ) throws IOException | ||||||
|     { |     { | ||||||
|         super( factory, name, format ); |         super( factory, name, format ); | ||||||
|  |  | ||||||
|         width = getUniformChecked( "Width" ); |         width = getUniformChecked( "Width" ); | ||||||
|         height = getUniformChecked( "Height" ); |         height = getUniformChecked( "Height" ); | ||||||
|         palette = new GlUniform( "Palette", GlUniform.field_32044 /* UT_FLOAT3 */, 16 * 3, this ); |         palette = new Uniform( "Palette", Uniform.UT_FLOAT3 /* UT_FLOAT3 */, 16 * 3, this ); | ||||||
|         updateUniformLocation( palette ); |         updateUniformLocation( palette ); | ||||||
|  |  | ||||||
|         GlUniform tbo = getUniformChecked( "Tbo" ); |         Uniform tbo = getUniformChecked( "Tbo" ); | ||||||
|         if( tbo != null ) tbo.set( TEXTURE_INDEX - GL13.GL_TEXTURE0 ); |         if( tbo != null ) tbo.set( TEXTURE_INDEX - GL13.GL_TEXTURE0 ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -53,7 +53,7 @@ public class MonitorTextureBufferShader extends Shader | |||||||
|     { |     { | ||||||
|         if( this.palette == null ) return; |         if( this.palette == null ) return; | ||||||
|  |  | ||||||
|         FloatBuffer paletteBuffer = this.palette.getFloatData(); |         FloatBuffer paletteBuffer = this.palette.getFloatBuffer(); | ||||||
|         paletteBuffer.rewind(); |         paletteBuffer.rewind(); | ||||||
|         for( int i = 0; i < 16; i++ ) |         for( int i = 0; i < 16; i++ ) | ||||||
|         { |         { | ||||||
| @@ -71,9 +71,9 @@ public class MonitorTextureBufferShader extends Shader | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void bind() |     public void apply() | ||||||
|     { |     { | ||||||
|         super.bind(); |         super.apply(); | ||||||
|         palette.upload(); |         palette.upload(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -84,23 +84,23 @@ public class MonitorTextureBufferShader extends Shader | |||||||
|         super.close(); |         super.close(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void updateUniformLocation( GlUniform uniform ) |     private void updateUniformLocation( Uniform uniform ) | ||||||
|     { |     { | ||||||
|         int id = GlUniform.getUniformLocation( getProgramRef(), uniform.getName() ); |         int id = Uniform.glGetUniformLocation( getId(), uniform.getName() ); | ||||||
|         if( id == -1 ) |         if( id == -1 ) | ||||||
|         { |         { | ||||||
|             LOGGER.warn( "Shader {} could not find uniform named {} in the specified shader program.", getName(), uniform.getName() ); |             LOGGER.warn( "Shader {} could not find uniform named {} in the specified shader program.", getName(), uniform.getName() ); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             uniform.setLoc( id ); |             uniform.setLocation( id ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|     private GlUniform getUniformChecked( String name ) |     private Uniform getUniformChecked( String name ) | ||||||
|     { |     { | ||||||
|         GlUniform uniform = getUniform( name ); |         Uniform uniform = getUniform( name ); | ||||||
|         if( uniform == null ) |         if( uniform == null ) | ||||||
|         { |         { | ||||||
|             LOGGER.warn( "Monitor shader {} should have uniform {}, but it was not present.", getName(), name ); |             LOGGER.warn( "Monitor shader {} should have uniform {}, but it was not present.", getName(), name ); | ||||||
|   | |||||||
| @@ -9,13 +9,14 @@ package dan200.computercraft.client.render; | |||||||
| import dan200.computercraft.client.gui.FixedWidthFontRenderer; | import dan200.computercraft.client.gui.FixedWidthFontRenderer; | ||||||
| import dan200.computercraft.core.terminal.TextBuffer; | import dan200.computercraft.core.terminal.TextBuffer; | ||||||
| import dan200.computercraft.shared.util.Palette; | import dan200.computercraft.shared.util.Palette; | ||||||
| import net.minecraft.client.render.VertexConsumer; | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; |  | ||||||
| import net.minecraft.util.math.Matrix4f; |  | ||||||
|  |  | ||||||
| import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; | import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; | ||||||
| import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE; | import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.VertexConsumer; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
|  |  | ||||||
| public final class PrintoutRenderer | public final class PrintoutRenderer | ||||||
| { | { | ||||||
|     /** |     /** | ||||||
| @@ -48,7 +49,7 @@ public final class PrintoutRenderer | |||||||
|  |  | ||||||
|     private PrintoutRenderer() {} |     private PrintoutRenderer() {} | ||||||
|  |  | ||||||
|     public static void drawText( Matrix4f transform, VertexConsumerProvider renderer, int x, int y, int start, int light, TextBuffer[] text, TextBuffer[] colours ) |     public static void drawText( Matrix4f transform, MultiBufferSource renderer, int x, int y, int start, int light, TextBuffer[] text, TextBuffer[] colours ) | ||||||
|     { |     { | ||||||
|         VertexConsumer buffer = renderer.getBuffer( RenderTypes.PRINTOUT_TEXT ); |         VertexConsumer buffer = renderer.getBuffer( RenderTypes.PRINTOUT_TEXT ); | ||||||
|         for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ ) |         for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ ) | ||||||
| @@ -68,7 +69,7 @@ public final class PrintoutRenderer | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void drawText( Matrix4f transform, VertexConsumerProvider renderer, int x, int y, int start, int light, String[] text, String[] colours ) |     public static void drawText( Matrix4f transform, MultiBufferSource renderer, int x, int y, int start, int light, String[] text, String[] colours ) | ||||||
|     { |     { | ||||||
|         VertexConsumer buffer = renderer.getBuffer( RenderTypes.PRINTOUT_TEXT ); |         VertexConsumer buffer = renderer.getBuffer( RenderTypes.PRINTOUT_TEXT ); | ||||||
|         for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ ) |         for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ ) | ||||||
| @@ -88,7 +89,7 @@ public final class PrintoutRenderer | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void drawBorder( Matrix4f transform, VertexConsumerProvider renderer, float x, float y, float z, int page, int pages, boolean isBook, int light ) |     public static void drawBorder( Matrix4f transform, MultiBufferSource renderer, float x, float y, float z, int page, int pages, boolean isBook, int light ) | ||||||
|     { |     { | ||||||
|         int leftPages = page; |         int leftPages = page; | ||||||
|         int rightPages = pages - page - 1; |         int rightPages = pages - page - 1; | ||||||
| @@ -173,6 +174,6 @@ public final class PrintoutRenderer | |||||||
|  |  | ||||||
|     private static void vertex( VertexConsumer buffer, Matrix4f matrix, float x, float y, float z, float u, float v, int light ) |     private static void vertex( VertexConsumer buffer, Matrix4f matrix, float x, float y, float z, float u, float v, int light ) | ||||||
|     { |     { | ||||||
|         buffer.vertex( matrix, x, y, z ).color( 255, 255, 255, 255 ).texture( u, v ).light( light ).next(); |         buffer.vertex( matrix, x, y, z ).color( 255, 255, 255, 255 ).uv( u, v ).uv2( light ).endVertex(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,10 +5,14 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||||||
|  | import com.mojang.blaze3d.vertex.VertexFormat; | ||||||
| import dan200.computercraft.client.gui.FixedWidthFontRenderer; | import dan200.computercraft.client.gui.FixedWidthFontRenderer; | ||||||
| import net.minecraft.client.render.*; | import net.minecraft.client.render.*; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.client.renderer.RenderStateShard; | ||||||
|  | import net.minecraft.client.renderer.RenderType; | ||||||
|  | import net.minecraft.client.renderer.ShaderInstance; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
| @@ -21,17 +25,17 @@ public class RenderTypes | |||||||
|     public static MonitorTextureBufferShader monitorTboShader; |     public static MonitorTextureBufferShader monitorTboShader; | ||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|     public static Shader terminalShader; |     public static ShaderInstance terminalShader; | ||||||
|  |  | ||||||
|     public static final RenderLayer TERMINAL_WITHOUT_DEPTH = Types.TERMINAL_WITHOUT_DEPTH; |     public static final RenderType TERMINAL_WITHOUT_DEPTH = Types.TERMINAL_WITHOUT_DEPTH; | ||||||
|     public static final RenderLayer MONITOR_TBO = Types.MONITOR_TBO; |     public static final RenderType MONITOR_TBO = Types.MONITOR_TBO; | ||||||
|     public static final RenderLayer TERMINAL_BLOCKER = Types.BLOCKER; |     public static final RenderType TERMINAL_BLOCKER = Types.BLOCKER; | ||||||
|     public static final RenderLayer TERMINAL_WITH_DEPTH = Types.TERMINAL_WITH_DEPTH; |     public static final RenderType TERMINAL_WITH_DEPTH = Types.TERMINAL_WITH_DEPTH; | ||||||
|     public static final RenderLayer PRINTOUT_TEXT = Types.PRINTOUT_TEXT; |     public static final RenderType PRINTOUT_TEXT = Types.PRINTOUT_TEXT; | ||||||
|  |  | ||||||
|     public static final RenderLayer PRINTOUT_BACKGROUND = RenderLayer.getText( new Identifier( "computercraft", "textures/gui/printout.png" ) ); |     public static final RenderType PRINTOUT_BACKGROUND = RenderType.text( new ResourceLocation( "computercraft", "textures/gui/printout.png" ) ); | ||||||
|  |  | ||||||
|     public static final RenderLayer POSITION_COLOR = Types.POSITION_COLOR; |     public static final RenderType POSITION_COLOR = Types.POSITION_COLOR; | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     static MonitorTextureBufferShader getMonitorTextureBufferShader() |     static MonitorTextureBufferShader getMonitorTextureBufferShader() | ||||||
| @@ -41,72 +45,72 @@ public class RenderTypes | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     static Shader getTerminalShader() |     static ShaderInstance getTerminalShader() | ||||||
|     { |     { | ||||||
|         if( terminalShader == null ) throw new NullPointerException( "MonitorTboShader has not been registered" ); |         if( terminalShader == null ) throw new NullPointerException( "MonitorTboShader has not been registered" ); | ||||||
|         return terminalShader; |         return terminalShader; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static final class Types extends RenderPhase |     private static final class Types extends RenderStateShard | ||||||
|     { |     { | ||||||
|         private static final VertexFormat.DrawMode GL_MODE = VertexFormat.DrawMode.TRIANGLES; |         private static final VertexFormat.Mode GL_MODE = VertexFormat.Mode.TRIANGLES; | ||||||
|         private static final VertexFormat FORMAT = VertexFormats.POSITION_COLOR_TEXTURE; |         private static final VertexFormat FORMAT = DefaultVertexFormat.POSITION_COLOR_TEX; | ||||||
|         private static final Shader TERM_SHADER = new Shader( RenderTypes::getTerminalShader ); |         private static final ShaderStateShard TERM_SHADER = new ShaderStateShard( RenderTypes::getTerminalShader ); | ||||||
|  |  | ||||||
|         private static final RenderPhase.Texture TERM_FONT_TEXTURE = new RenderPhase.Texture( |         private static final RenderStateShard.TextureStateShard TERM_FONT_TEXTURE = new RenderStateShard.TextureStateShard( | ||||||
|             FixedWidthFontRenderer.FONT, |             FixedWidthFontRenderer.FONT, | ||||||
|             false, false // blur, minimap |             false, false // blur, minimap | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         public static final RenderLayer MONITOR_TBO = RenderLayer.of( "monitor_tbo", VertexFormats.POSITION_TEXTURE, VertexFormat.DrawMode.TRIANGLE_STRIP, 128, false, false, // useDelegate, needsSorting |         public static final RenderType MONITOR_TBO = RenderType.create( "monitor_tbo", DefaultVertexFormat.POSITION_TEX, VertexFormat.Mode.TRIANGLE_STRIP, 128, false, false, // useDelegate, needsSorting | ||||||
|             RenderLayer.MultiPhaseParameters.builder() |             RenderType.CompositeState.builder() | ||||||
|                 .texture( TERM_FONT_TEXTURE ) // blur, minimap |                 .setTextureState( TERM_FONT_TEXTURE ) // blur, minimap | ||||||
|                 .shader( new RenderPhase.Shader( RenderTypes::getMonitorTextureBufferShader ) ) |                 .setShaderState( new RenderStateShard.ShaderStateShard( RenderTypes::getMonitorTextureBufferShader ) ) | ||||||
|                 .writeMaskState( RenderLayer.ALL_MASK ) |                 .setWriteMaskState( RenderType.COLOR_DEPTH_WRITE ) | ||||||
|                 .build( false ) ); |                 .createCompositeState( false ) ); | ||||||
|  |  | ||||||
|         static final RenderLayer TERMINAL_WITHOUT_DEPTH = RenderLayer.of( |         static final RenderType TERMINAL_WITHOUT_DEPTH = RenderType.create( | ||||||
|             "terminal_without_depth", FORMAT, GL_MODE, 1024, |             "terminal_without_depth", FORMAT, GL_MODE, 1024, | ||||||
|             false, false, // useDelegate, needsSorting |             false, false, // useDelegate, needsSorting | ||||||
|             RenderLayer.MultiPhaseParameters.builder() |             RenderType.CompositeState.builder() | ||||||
|                 .texture( TERM_FONT_TEXTURE ) |                 .setTextureState( TERM_FONT_TEXTURE ) | ||||||
|                 .shader( TERM_SHADER ) |                 .setShaderState( TERM_SHADER ) | ||||||
|                 .writeMaskState( COLOR_MASK ) |                 .setWriteMaskState( COLOR_WRITE ) | ||||||
|                 .build( false ) |                 .createCompositeState( false ) | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         static final RenderLayer BLOCKER = RenderLayer.of( "terminal_blocker", FORMAT, GL_MODE, 256, false, false, // useDelegate, needsSorting |         static final RenderType BLOCKER = RenderType.create( "terminal_blocker", FORMAT, GL_MODE, 256, false, false, // useDelegate, needsSorting | ||||||
|             RenderLayer.MultiPhaseParameters.builder() |             RenderType.CompositeState.builder() | ||||||
|                 .texture( TERM_FONT_TEXTURE ) |                 .setTextureState( TERM_FONT_TEXTURE ) | ||||||
|                 .shader( TERM_SHADER ) |                 .setShaderState( TERM_SHADER ) | ||||||
|                 .writeMaskState( DEPTH_MASK ) |                 .setWriteMaskState( DEPTH_WRITE ) | ||||||
|                 .build( false ) ); |                 .createCompositeState( false ) ); | ||||||
|  |  | ||||||
|         static final RenderLayer TERMINAL_WITH_DEPTH = RenderLayer.of( |         static final RenderType TERMINAL_WITH_DEPTH = RenderType.create( | ||||||
|             "terminal_with_depth", FORMAT, GL_MODE, 1024, |             "terminal_with_depth", FORMAT, GL_MODE, 1024, | ||||||
|             false, false, // useDelegate, needsSorting |             false, false, // useDelegate, needsSorting | ||||||
|             RenderLayer.MultiPhaseParameters.builder() |             RenderType.CompositeState.builder() | ||||||
|                 .texture( TERM_FONT_TEXTURE ) |                 .setTextureState( TERM_FONT_TEXTURE ) | ||||||
|                 .shader( TERM_SHADER ) |                 .setShaderState( TERM_SHADER ) | ||||||
|                 .build( false ) |                 .createCompositeState( false ) | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         static final RenderLayer PRINTOUT_TEXT = RenderLayer.of( |         static final RenderType PRINTOUT_TEXT = RenderType.create( | ||||||
|             "printout_text", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT, GL_MODE, 1024, |             "printout_text", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, GL_MODE, 1024, | ||||||
|             false, false, // useDelegate, needsSorting |             false, false, // useDelegate, needsSorting | ||||||
|             RenderLayer.MultiPhaseParameters.builder() |             RenderType.CompositeState.builder() | ||||||
|                 .texture( TERM_FONT_TEXTURE ) |                 .setTextureState( TERM_FONT_TEXTURE ) | ||||||
|                 .shader( RenderPhase.TEXT_SHADER ) |                 .setShaderState( RenderStateShard.RENDERTYPE_TEXT_SHADER ) | ||||||
|                 .lightmap( RenderPhase.ENABLE_LIGHTMAP ) |                 .setLightmapState( RenderStateShard.LIGHTMAP ) | ||||||
|                 .build( false ) |                 .createCompositeState( false ) | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         static final RenderLayer POSITION_COLOR = RenderLayer.of( |         static final RenderType POSITION_COLOR = RenderType.create( | ||||||
|             "position_color", VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.QUADS, 128, |             "position_color", DefaultVertexFormat.POSITION_COLOR, VertexFormat.Mode.QUADS, 128, | ||||||
|             false, false, // useDelegate, needsSorting |             false, false, // useDelegate, needsSorting | ||||||
|             RenderLayer.MultiPhaseParameters.builder() |             RenderType.CompositeState.builder() | ||||||
|                 .shader( COLOR_SHADER ) |                 .setShaderState( POSITION_COLOR_SHADER ) | ||||||
|                 .build( false ) |                 .createCompositeState( false ) | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         private Types( String name, Runnable setup, Runnable destroy ) |         private Types( String name, Runnable setup, Runnable destroy ) | ||||||
|   | |||||||
| @@ -8,6 +8,14 @@ package dan200.computercraft.client.render; | |||||||
|  |  | ||||||
| import com.mojang.blaze3d.platform.GlStateManager; | import com.mojang.blaze3d.platform.GlStateManager; | ||||||
| import com.mojang.blaze3d.systems.RenderSystem; | import com.mojang.blaze3d.systems.RenderSystem; | ||||||
|  | import com.mojang.blaze3d.vertex.BufferBuilder; | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.blaze3d.vertex.Tesselator; | ||||||
|  | import com.mojang.blaze3d.vertex.VertexBuffer; | ||||||
|  | import com.mojang.blaze3d.vertex.VertexConsumer; | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
|  | import com.mojang.math.Transformation; | ||||||
|  | import com.mojang.math.Vector3f; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.client.FrameInfo; | import dan200.computercraft.client.FrameInfo; | ||||||
| import dan200.computercraft.client.gui.FixedWidthFontRenderer; | import dan200.computercraft.client.gui.FixedWidthFontRenderer; | ||||||
| @@ -18,11 +26,13 @@ import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer; | |||||||
| import dan200.computercraft.shared.peripheral.monitor.TileMonitor; | import dan200.computercraft.shared.peripheral.monitor.TileMonitor; | ||||||
| import dan200.computercraft.shared.util.Colour; | import dan200.computercraft.shared.util.Colour; | ||||||
| import dan200.computercraft.shared.util.DirectionUtil; | import dan200.computercraft.shared.util.DirectionUtil; | ||||||
| import net.minecraft.client.gl.VertexBuffer; |  | ||||||
| import net.minecraft.client.render.*; | import net.minecraft.client.render.*; | ||||||
| import net.minecraft.client.render.block.entity.BlockEntityRenderer; | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
| import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; | import net.minecraft.client.renderer.RenderType; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||||||
|  | import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
| import net.minecraft.util.math.*; | import net.minecraft.util.math.*; | ||||||
| import org.lwjgl.opengl.GL11; | import org.lwjgl.opengl.GL11; | ||||||
| import org.lwjgl.opengl.GL20; | import org.lwjgl.opengl.GL20; | ||||||
| @@ -32,7 +42,7 @@ import javax.annotation.Nonnull; | |||||||
| import java.nio.ByteBuffer; | import java.nio.ByteBuffer; | ||||||
|  |  | ||||||
| import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*; | import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*; | ||||||
| import static net.minecraft.client.util.GlAllocationUtils.allocateByteBuffer; | import static com.mojang.blaze3d.platform.MemoryTracker.create; | ||||||
|  |  | ||||||
| public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonitor> | public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonitor> | ||||||
| { | { | ||||||
| @@ -40,16 +50,16 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|      * {@link TileMonitor#RENDER_MARGIN}, but a tiny bit of additional padding to ensure that there is no space between the monitor frame and contents. |      * {@link TileMonitor#RENDER_MARGIN}, but a tiny bit of additional padding to ensure that there is no space between the monitor frame and contents. | ||||||
|      */ |      */ | ||||||
|     private static final float MARGIN = (float) (TileMonitor.RENDER_MARGIN * 1.1); |     private static final float MARGIN = (float) (TileMonitor.RENDER_MARGIN * 1.1); | ||||||
|     private static final Matrix4f IDENTITY = AffineTransformation.identity() |     private static final Matrix4f IDENTITY = Transformation.identity() | ||||||
|         .getMatrix(); |         .getMatrix(); | ||||||
|     private static ByteBuffer tboContents; |     private static ByteBuffer tboContents; | ||||||
|  |  | ||||||
|     public TileEntityMonitorRenderer( BlockEntityRendererFactory.Context context ) |     public TileEntityMonitorRenderer( BlockEntityRendererProvider.Context context ) | ||||||
|     { |     { | ||||||
|         // super( context ); |         // super( context ); | ||||||
|     } |     } | ||||||
|     @Override |     @Override | ||||||
|     public void render( @Nonnull TileMonitor monitor, float partialTicks, @Nonnull MatrixStack transform, @Nonnull VertexConsumerProvider renderer, |     public void render( @Nonnull TileMonitor monitor, float partialTicks, @Nonnull PoseStack transform, @Nonnull MultiBufferSource renderer, | ||||||
|                         int lightmapCoord, int overlayLight ) |                         int lightmapCoord, int overlayLight ) | ||||||
|     { |     { | ||||||
|         // Render from the origin monitor |         // Render from the origin monitor | ||||||
| @@ -57,7 +67,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|  |  | ||||||
|         if( originTerminal == null ) return; |         if( originTerminal == null ) return; | ||||||
|         TileMonitor origin = originTerminal.getOrigin(); |         TileMonitor origin = originTerminal.getOrigin(); | ||||||
|         BlockPos monitorPos = monitor.getPos(); |         BlockPos monitorPos = monitor.getBlockPos(); | ||||||
|  |  | ||||||
|         // Ensure each monitor terminal is rendered only once. We allow rendering a specific tile |         // Ensure each monitor terminal is rendered only once. We allow rendering a specific tile | ||||||
|         // multiple times in a single frame to ensure compatibility with shaders which may run a |         // multiple times in a single frame to ensure compatibility with shaders which may run a | ||||||
| @@ -71,22 +81,22 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|         originTerminal.lastRenderFrame = renderFrame; |         originTerminal.lastRenderFrame = renderFrame; | ||||||
|         originTerminal.lastRenderPos = monitorPos; |         originTerminal.lastRenderPos = monitorPos; | ||||||
|  |  | ||||||
|         BlockPos originPos = origin.getPos(); |         BlockPos originPos = origin.getBlockPos(); | ||||||
|  |  | ||||||
|         // Determine orientation |         // Determine orientation | ||||||
|         Direction dir = origin.getDirection(); |         Direction dir = origin.getDirection(); | ||||||
|         Direction front = origin.getFront(); |         Direction front = origin.getFront(); | ||||||
|         float yaw = dir.asRotation(); |         float yaw = dir.toYRot(); | ||||||
|         float pitch = DirectionUtil.toPitchAngle( front ); |         float pitch = DirectionUtil.toPitchAngle( front ); | ||||||
|  |  | ||||||
|         // Setup initial transform |         // Setup initial transform | ||||||
|         transform.push(); |         transform.pushPose(); | ||||||
|         transform.translate( originPos.getX() - monitorPos.getX() + 0.5, |         transform.translate( originPos.getX() - monitorPos.getX() + 0.5, | ||||||
|             originPos.getY() - monitorPos.getY() + 0.5, |             originPos.getY() - monitorPos.getY() + 0.5, | ||||||
|             originPos.getZ() - monitorPos.getZ() + 0.5 ); |             originPos.getZ() - monitorPos.getZ() + 0.5 ); | ||||||
|  |  | ||||||
|         transform.multiply( Vec3f.NEGATIVE_Y.getDegreesQuaternion( yaw ) ); |         transform.mulPose( Vector3f.YN.rotationDegrees( yaw ) ); | ||||||
|         transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( pitch ) ); |         transform.mulPose( Vector3f.XP.rotationDegrees( pitch ) ); | ||||||
|         transform.translate( -0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN, |         transform.translate( -0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN, | ||||||
|             origin.getHeight() - 0.5 - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN) + 0, |             origin.getHeight() - 0.5 - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN) + 0, | ||||||
|             0.50 ); |             0.50 ); | ||||||
| @@ -102,10 +112,10 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|             int pixelWidth = width * FONT_WIDTH, pixelHeight = height * FONT_HEIGHT; |             int pixelWidth = width * FONT_WIDTH, pixelHeight = height * FONT_HEIGHT; | ||||||
|             double xScale = xSize / pixelWidth; |             double xScale = xSize / pixelWidth; | ||||||
|             double yScale = ySize / pixelHeight; |             double yScale = ySize / pixelHeight; | ||||||
|             transform.push(); |             transform.pushPose(); | ||||||
|             transform.scale( (float) xScale, (float) -yScale, 1.0f ); |             transform.scale( (float) xScale, (float) -yScale, 1.0f ); | ||||||
|  |  | ||||||
|             Matrix4f matrix = transform.peek().getModel(); |             Matrix4f matrix = transform.last().pose(); | ||||||
|  |  | ||||||
|             renderTerminal( renderer, matrix, originTerminal, (float) (MARGIN / xScale), (float) (MARGIN / yScale) ); |             renderTerminal( renderer, matrix, originTerminal, (float) (MARGIN / xScale), (float) (MARGIN / yScale) ); | ||||||
|  |  | ||||||
| @@ -113,21 +123,21 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|             // reasonable. |             // reasonable. | ||||||
|             FixedWidthFontRenderer.drawCursor( matrix, renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ), 0, 0, terminal, !originTerminal.isColour() ); |             FixedWidthFontRenderer.drawCursor( matrix, renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ), 0, 0, terminal, !originTerminal.isColour() ); | ||||||
|  |  | ||||||
|             transform.pop(); |             transform.popPose(); | ||||||
|  |  | ||||||
|             // Draw the background blocker |             // Draw the background blocker | ||||||
|             FixedWidthFontRenderer.drawBlocker( |             FixedWidthFontRenderer.drawBlocker( | ||||||
|                 transform.peek().getModel(), renderer, |                 transform.last().pose(), renderer, | ||||||
|                 -MARGIN, MARGIN, |                 -MARGIN, MARGIN, | ||||||
|                 (float) (xSize + 2 * MARGIN), (float) -(ySize + MARGIN * 2) |                 (float) (xSize + 2 * MARGIN), (float) -(ySize + MARGIN * 2) | ||||||
|             ); |             ); | ||||||
|  |  | ||||||
|             renderer.getBuffer( RenderLayer.getSolid() ); |             renderer.getBuffer( RenderType.solid() ); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             FixedWidthFontRenderer.drawEmptyTerminal( transform.peek() |             FixedWidthFontRenderer.drawEmptyTerminal( transform.last() | ||||||
|                     .getModel(), |                     .pose(), | ||||||
|                 renderer, |                 renderer, | ||||||
|                 -MARGIN, |                 -MARGIN, | ||||||
|                 MARGIN, |                 MARGIN, | ||||||
| @@ -135,10 +145,10 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|                 (float) -(ySize + MARGIN * 2) ); |                 (float) -(ySize + MARGIN * 2) ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         transform.pop(); |         transform.popPose(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void renderTerminal( VertexConsumerProvider renderer, Matrix4f matrix, ClientMonitor monitor, float xMargin, float yMargin ) |     private static void renderTerminal( MultiBufferSource renderer, Matrix4f matrix, ClientMonitor monitor, float xMargin, float yMargin ) | ||||||
|     { |     { | ||||||
|         Terminal terminal = monitor.getTerminal(); |         Terminal terminal = monitor.getTerminal(); | ||||||
|  |  | ||||||
| @@ -162,7 +172,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|                     int size = width * height * 3; |                     int size = width * height * 3; | ||||||
|                     if( tboContents == null || tboContents.capacity() < size ) |                     if( tboContents == null || tboContents.capacity() < size ) | ||||||
|                     { |                     { | ||||||
|                         tboContents = allocateByteBuffer( size ); |                         tboContents = create( size ); | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     ByteBuffer monitorBuffer = tboContents; |                     ByteBuffer monitorBuffer = tboContents; | ||||||
| @@ -207,9 +217,9 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|                 VertexBuffer vbo = monitor.buffer; |                 VertexBuffer vbo = monitor.buffer; | ||||||
|                 if( redraw ) |                 if( redraw ) | ||||||
|                 { |                 { | ||||||
|                     Tessellator tessellator = Tessellator.getInstance(); |                     Tesselator tessellator = Tesselator.getInstance(); | ||||||
|                     BufferBuilder builder = tessellator.getBuffer(); |                     BufferBuilder builder = tessellator.getBuilder(); | ||||||
|                     builder.begin( RenderTypes.TERMINAL_WITHOUT_DEPTH.getDrawMode(), RenderTypes.TERMINAL_WITHOUT_DEPTH.getVertexFormat() ); |                     builder.begin( RenderTypes.TERMINAL_WITHOUT_DEPTH.mode(), RenderTypes.TERMINAL_WITHOUT_DEPTH.format() ); | ||||||
|                     FixedWidthFontRenderer.drawTerminalWithoutCursor( IDENTITY, |                     FixedWidthFontRenderer.drawTerminalWithoutCursor( IDENTITY, | ||||||
|                         builder, |                         builder, | ||||||
|                         0, |                         0, | ||||||
| @@ -227,8 +237,8 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|  |  | ||||||
|                 renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ); |                 renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ); | ||||||
|  |  | ||||||
|                 RenderTypes.TERMINAL_WITHOUT_DEPTH.startDrawing(); |                 RenderTypes.TERMINAL_WITHOUT_DEPTH.setupRenderState(); | ||||||
|                 vbo.setShader( matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader() ); |                 vbo.drawWithShader( matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader() ); | ||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -236,11 +246,11 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito | |||||||
|     private static void tboVertex( VertexConsumer builder, Matrix4f matrix, float x, float y ) |     private static void tboVertex( VertexConsumer builder, Matrix4f matrix, float x, float y ) | ||||||
|     { |     { | ||||||
|         // We encode position in the UV, as that's not transformed by the matrix. |         // We encode position in the UV, as that's not transformed by the matrix. | ||||||
|         builder.vertex( matrix, x, y, 0 ).texture( x, y ).next(); |         builder.vertex( matrix, x, y, 0 ).uv( x, y ).endVertex(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public int getRenderDistance() |     public int getViewDistance() | ||||||
|     { |     { | ||||||
|         return ComputerCraft.monitorDistance; |         return ComputerCraft.monitorDistance; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -5,6 +5,10 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
|  | 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.api.client.TransformedModel; | import dan200.computercraft.api.client.TransformedModel; | ||||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||||
| import dan200.computercraft.api.turtle.TurtleSide; | import dan200.computercraft.api.turtle.TurtleSide; | ||||||
| @@ -13,48 +17,43 @@ import dan200.computercraft.shared.turtle.blocks.TileTurtle; | |||||||
| import dan200.computercraft.shared.util.DirectionUtil; | import dan200.computercraft.shared.util.DirectionUtil; | ||||||
| import dan200.computercraft.shared.util.Holiday; | import dan200.computercraft.shared.util.Holiday; | ||||||
| import dan200.computercraft.shared.util.HolidayUtil; | import dan200.computercraft.shared.util.HolidayUtil; | ||||||
| import net.minecraft.client.MinecraftClient; |  | ||||||
| import net.minecraft.client.font.TextRenderer; |  | ||||||
| import net.minecraft.client.render.TexturedRenderLayers; |  | ||||||
| import net.minecraft.client.render.VertexConsumer; |  | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; |  | ||||||
| import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; |  | ||||||
| import net.minecraft.client.render.block.entity.BlockEntityRenderer; |  | ||||||
| import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; |  | ||||||
| import net.minecraft.client.render.model.BakedModel; |  | ||||||
| import net.minecraft.client.render.model.BakedModelManager; |  | ||||||
| import net.minecraft.client.render.model.BakedQuad; |  | ||||||
| import net.minecraft.client.util.ModelIdentifier; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
| import net.minecraft.util.hit.BlockHitResult; |  | ||||||
| import net.minecraft.util.hit.HitResult; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
| import net.minecraft.util.math.Matrix4f; |  | ||||||
| import net.minecraft.util.math.Vec3d; |  | ||||||
| import net.minecraft.util.math.Vec3f; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.Minecraft; | ||||||
|  | import net.minecraft.client.gui.Font; | ||||||
|  | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
|  | import net.minecraft.client.renderer.Sheets; | ||||||
|  | import net.minecraft.client.renderer.block.model.BakedQuad; | ||||||
|  | import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; | ||||||
|  | import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||||||
|  | import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||||||
|  | import net.minecraft.client.resources.model.BakedModel; | ||||||
|  | import net.minecraft.client.resources.model.ModelManager; | ||||||
|  | import net.minecraft.client.resources.model.ModelResourceLocation; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.world.phys.BlockHitResult; | ||||||
|  | import net.minecraft.world.phys.HitResult; | ||||||
|  | import net.minecraft.world.phys.Vec3; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Random; | import java.util.Random; | ||||||
|  |  | ||||||
| public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> | public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> | ||||||
| { | { | ||||||
|     private static final ModelIdentifier NORMAL_TURTLE_MODEL = new ModelIdentifier( "computercraft:turtle_normal", "inventory" ); |     private static final ModelResourceLocation NORMAL_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_normal", "inventory" ); | ||||||
|     private static final ModelIdentifier ADVANCED_TURTLE_MODEL = new ModelIdentifier( "computercraft:turtle_advanced", "inventory" ); |     private static final ModelResourceLocation ADVANCED_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_advanced", "inventory" ); | ||||||
|     private static final ModelIdentifier COLOUR_TURTLE_MODEL = new ModelIdentifier( "computercraft:turtle_colour", "inventory" ); |     private static final ModelResourceLocation COLOUR_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_colour", "inventory" ); | ||||||
|     private static final ModelIdentifier ELF_OVERLAY_MODEL = new ModelIdentifier( "computercraft:turtle_elf_overlay", "inventory" ); |     private static final ModelResourceLocation ELF_OVERLAY_MODEL = new ModelResourceLocation( "computercraft:turtle_elf_overlay", "inventory" ); | ||||||
|  |  | ||||||
|     private final Random random = new Random( 0 ); |     private final Random random = new Random( 0 ); | ||||||
|  |  | ||||||
|     BlockEntityRenderDispatcher renderer; |     BlockEntityRenderDispatcher renderer; | ||||||
|  |  | ||||||
|     public TileEntityTurtleRenderer( BlockEntityRendererFactory.Context context ) |     public TileEntityTurtleRenderer( BlockEntityRendererProvider.Context context ) | ||||||
|     { |     { | ||||||
|         renderer = context.getRenderDispatcher(); |         renderer = context.getBlockEntityRenderDispatcher(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static ModelIdentifier getTurtleModel( ComputerFamily family, boolean coloured ) |     public static ModelResourceLocation getTurtleModel( ComputerFamily family, boolean coloured ) | ||||||
|     { |     { | ||||||
|         switch( family ) |         switch( family ) | ||||||
|         { |         { | ||||||
| @@ -66,11 +65,11 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static ModelIdentifier getTurtleOverlayModel( Identifier overlay, boolean christmas ) |     public static ModelResourceLocation getTurtleOverlayModel( ResourceLocation overlay, boolean christmas ) | ||||||
|     { |     { | ||||||
|         if( overlay != null ) |         if( overlay != null ) | ||||||
|         { |         { | ||||||
|             return new ModelIdentifier( overlay, "inventory" ); |             return new ModelResourceLocation( overlay, "inventory" ); | ||||||
|         } |         } | ||||||
|         if( christmas ) |         if( christmas ) | ||||||
|         { |         { | ||||||
| @@ -80,44 +79,44 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render( @Nonnull TileTurtle turtle, float partialTicks, @Nonnull MatrixStack transform, @Nonnull VertexConsumerProvider buffers, |     public void render( @Nonnull TileTurtle turtle, float partialTicks, @Nonnull PoseStack transform, @Nonnull MultiBufferSource buffers, | ||||||
|                         int lightmapCoord, int overlayLight ) |                         int lightmapCoord, int overlayLight ) | ||||||
|     { |     { | ||||||
|         // Render the label |         // Render the label | ||||||
|         String label = turtle.createProxy() |         String label = turtle.createProxy() | ||||||
|             .getLabel(); |             .getLabel(); | ||||||
|         HitResult hit = renderer.crosshairTarget; |         HitResult hit = renderer.cameraHitResult; | ||||||
|         if( label != null && hit.getType() == HitResult.Type.BLOCK && turtle.getPos() |         if( label != null && hit.getType() == HitResult.Type.BLOCK && turtle.getBlockPos() | ||||||
|             .equals( ((BlockHitResult) hit).getBlockPos() ) ) |             .equals( ((BlockHitResult) hit).getBlockPos() ) ) | ||||||
|         { |         { | ||||||
|             MinecraftClient mc = MinecraftClient.getInstance(); |             Minecraft mc = Minecraft.getInstance(); | ||||||
|             TextRenderer font = mc.textRenderer; |             Font font = mc.font; | ||||||
|  |  | ||||||
|             transform.push(); |             transform.pushPose(); | ||||||
|             transform.translate( 0.5, 1.2, 0.5 ); |             transform.translate( 0.5, 1.2, 0.5 ); | ||||||
|             transform.multiply( mc.getEntityRenderDispatcher() |             transform.mulPose( mc.getEntityRenderDispatcher() | ||||||
|                 .getRotation() ); |                 .cameraOrientation() ); | ||||||
|             transform.scale( -0.025f, -0.025f, 0.025f ); |             transform.scale( -0.025f, -0.025f, 0.025f ); | ||||||
|  |  | ||||||
|             Matrix4f matrix = transform.peek() |             Matrix4f matrix = transform.last() | ||||||
|                 .getModel(); |                 .pose(); | ||||||
|             int opacity = (int) (mc.options.getTextBackgroundOpacity( 0.25f ) * 255) << 24; |             int opacity = (int) (mc.options.getBackgroundOpacity( 0.25f ) * 255) << 24; | ||||||
|             float width = -font.getWidth( label ) / 2.0f; |             float width = -font.width( label ) / 2.0f; | ||||||
|             font.draw( label, width, (float) 0, 0x20ffffff, false, matrix, buffers, true, opacity, lightmapCoord ); |             font.drawInBatch( label, width, (float) 0, 0x20ffffff, false, matrix, buffers, true, opacity, lightmapCoord ); | ||||||
|             font.draw( label, width, (float) 0, 0xffffffff, false, matrix, buffers, false, 0, lightmapCoord ); |             font.drawInBatch( label, width, (float) 0, 0xffffffff, false, matrix, buffers, false, 0, lightmapCoord ); | ||||||
|  |  | ||||||
|             transform.pop(); |             transform.popPose(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         transform.push(); |         transform.pushPose(); | ||||||
|  |  | ||||||
|         // Setup the transform. |         // Setup the transform. | ||||||
|         Vec3d offset = turtle.getRenderOffset( partialTicks ); |         Vec3 offset = turtle.getRenderOffset( partialTicks ); | ||||||
|         float yaw = turtle.getRenderYaw( partialTicks ); |         float yaw = turtle.getRenderYaw( partialTicks ); | ||||||
|         transform.translate( offset.x, offset.y, offset.z ); |         transform.translate( offset.x, offset.y, offset.z ); | ||||||
|  |  | ||||||
|         transform.translate( 0.5f, 0.5f, 0.5f ); |         transform.translate( 0.5f, 0.5f, 0.5f ); | ||||||
|         transform.multiply( Vec3f.POSITIVE_Y.getDegreesQuaternion( 180.0f - yaw ) ); |         transform.mulPose( Vector3f.YP.rotationDegrees( 180.0f - yaw ) ); | ||||||
|         if( label != null && (label.equals( "Dinnerbone" ) || label.equals( "Grumm" )) ) |         if( label != null && (label.equals( "Dinnerbone" ) || label.equals( "Grumm" )) ) | ||||||
|         { |         { | ||||||
|             // Flip the model |             // Flip the model | ||||||
| @@ -128,13 +127,13 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> | |||||||
|         // Render the turtle |         // Render the turtle | ||||||
|         int colour = turtle.getColour(); |         int colour = turtle.getColour(); | ||||||
|         ComputerFamily family = turtle.getFamily(); |         ComputerFamily family = turtle.getFamily(); | ||||||
|         Identifier overlay = turtle.getOverlay(); |         ResourceLocation overlay = turtle.getOverlay(); | ||||||
|  |  | ||||||
|         VertexConsumer buffer = buffers.getBuffer( TexturedRenderLayers.getEntityTranslucentCull() ); |         VertexConsumer buffer = buffers.getBuffer( Sheets.translucentCullBlockSheet() ); | ||||||
|         renderModel( transform, buffer, lightmapCoord, overlayLight, getTurtleModel( family, colour != -1 ), colour == -1 ? null : new int[] { colour } ); |         renderModel( transform, buffer, lightmapCoord, overlayLight, getTurtleModel( family, colour != -1 ), colour == -1 ? null : new int[] { colour } ); | ||||||
|  |  | ||||||
|         // Render the overlay |         // Render the overlay | ||||||
|         ModelIdentifier overlayModel = getTurtleOverlayModel( overlay, HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS ); |         ModelResourceLocation overlayModel = getTurtleOverlayModel( overlay, HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS ); | ||||||
|         if( overlayModel != null ) |         if( overlayModel != null ) | ||||||
|         { |         { | ||||||
|             renderModel( transform, buffer, lightmapCoord, overlayLight, overlayModel, null ); |             renderModel( transform, buffer, lightmapCoord, overlayLight, overlayModel, null ); | ||||||
| @@ -144,10 +143,10 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> | |||||||
|         renderUpgrade( transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.LEFT, partialTicks ); |         renderUpgrade( transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.LEFT, partialTicks ); | ||||||
|         renderUpgrade( transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.RIGHT, partialTicks ); |         renderUpgrade( transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.RIGHT, partialTicks ); | ||||||
|  |  | ||||||
|         transform.pop(); |         transform.popPose(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void renderUpgrade( @Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, TileTurtle turtle, |     private void renderUpgrade( @Nonnull PoseStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, TileTurtle turtle, | ||||||
|                                       TurtleSide side, float f ) |                                       TurtleSide side, float f ) | ||||||
|     { |     { | ||||||
|         ITurtleUpgrade upgrade = turtle.getUpgrade( side ); |         ITurtleUpgrade upgrade = turtle.getUpgrade( side ); | ||||||
| @@ -155,32 +154,32 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> | |||||||
|         { |         { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         transform.push(); |         transform.pushPose(); | ||||||
|  |  | ||||||
|         float toolAngle = turtle.getToolRenderAngle( side, f ); |         float toolAngle = turtle.getToolRenderAngle( side, f ); | ||||||
|         transform.translate( 0.0f, 0.5f, 0.5f ); |         transform.translate( 0.0f, 0.5f, 0.5f ); | ||||||
|         transform.multiply( Vec3f.NEGATIVE_X.getDegreesQuaternion( toolAngle ) ); |         transform.mulPose( Vector3f.XN.rotationDegrees( toolAngle ) ); | ||||||
|         transform.translate( 0.0f, -0.5f, -0.5f ); |         transform.translate( 0.0f, -0.5f, -0.5f ); | ||||||
|  |  | ||||||
|         TransformedModel model = upgrade.getModel( turtle.getAccess(), side ); |         TransformedModel model = upgrade.getModel( turtle.getAccess(), side ); | ||||||
|         model.push( transform ); |         model.push( transform ); | ||||||
|         renderModel( transform, renderer, lightmapCoord, overlayLight, model.getModel(), null ); |         renderModel( transform, renderer, lightmapCoord, overlayLight, model.getModel(), null ); | ||||||
|         transform.pop(); |         transform.popPose(); | ||||||
|  |  | ||||||
|         transform.pop(); |         transform.popPose(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void renderModel( @Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, |     private void renderModel( @Nonnull PoseStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, | ||||||
|                                     ModelIdentifier modelLocation, int[] tints ) |                                     ModelResourceLocation modelLocation, int[] tints ) | ||||||
|     { |     { | ||||||
|         BakedModelManager modelManager = MinecraftClient.getInstance() |         ModelManager modelManager = Minecraft.getInstance() | ||||||
|             .getItemRenderer() |             .getItemRenderer() | ||||||
|             .getModels() |             .getItemModelShaper() | ||||||
|             .getModelManager(); |             .getModelManager(); | ||||||
|         renderModel( transform, renderer, lightmapCoord, overlayLight, modelManager.getModel( modelLocation ), tints ); |         renderModel( transform, renderer, lightmapCoord, overlayLight, modelManager.getModel( modelLocation ), tints ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void renderModel( @Nonnull MatrixStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, BakedModel model, |     private void renderModel( @Nonnull PoseStack transform, @Nonnull VertexConsumer renderer, int lightmapCoord, int overlayLight, BakedModel model, | ||||||
|                                     int[] tints ) |                                     int[] tints ) | ||||||
|     { |     { | ||||||
|         random.setSeed( 0 ); |         random.setSeed( 0 ); | ||||||
| @@ -191,27 +190,27 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle> | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void renderQuads( @Nonnull MatrixStack transform, @Nonnull VertexConsumer buffer, int lightmapCoord, int overlayLight, |     private static void renderQuads( @Nonnull PoseStack transform, @Nonnull VertexConsumer buffer, int lightmapCoord, int overlayLight, | ||||||
|                                      List<BakedQuad> quads, int[] tints ) |                                      List<BakedQuad> quads, int[] tints ) | ||||||
|     { |     { | ||||||
|         MatrixStack.Entry matrix = transform.peek(); |         PoseStack.Pose matrix = transform.last(); | ||||||
|  |  | ||||||
|         for( BakedQuad bakedquad : quads ) |         for( BakedQuad bakedquad : quads ) | ||||||
|         { |         { | ||||||
|             int tint = -1; |             int tint = -1; | ||||||
|             if( tints != null && bakedquad.hasColor() ) |             if( tints != null && bakedquad.isTinted() ) | ||||||
|             { |             { | ||||||
|                 int idx = bakedquad.getColorIndex(); |                 int idx = bakedquad.getTintIndex(); | ||||||
|                 if( idx >= 0 && idx < tints.length ) |                 if( idx >= 0 && idx < tints.length ) | ||||||
|                 { |                 { | ||||||
|                     tint = tints[bakedquad.getColorIndex()]; |                     tint = tints[bakedquad.getTintIndex()]; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             float f = (float) (tint >> 16 & 255) / 255.0F; |             float f = (float) (tint >> 16 & 255) / 255.0F; | ||||||
|             float f1 = (float) (tint >> 8 & 255) / 255.0F; |             float f1 = (float) (tint >> 8 & 255) / 255.0F; | ||||||
|             float f2 = (float) (tint & 255) / 255.0F; |             float f2 = (float) (tint & 255) / 255.0F; | ||||||
|             buffer.quad( matrix, |             buffer.putBulkData( matrix, | ||||||
|                 bakedquad, |                 bakedquad, | ||||||
|                 new float[] { 1.0F, 1.0F, 1.0F, 1.0F }, |                 new float[] { 1.0F, 1.0F, 1.0F, 1.0F }, | ||||||
|                 f, |                 f, | ||||||
|   | |||||||
| @@ -10,14 +10,13 @@ import com.mojang.datafixers.util.Pair; | |||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.client.render.model.BakedModel; | import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||||||
| import net.minecraft.client.render.model.ModelBakeSettings; | import net.minecraft.client.resources.model.BakedModel; | ||||||
| import net.minecraft.client.render.model.ModelLoader; | import net.minecraft.client.resources.model.Material; | ||||||
| import net.minecraft.client.render.model.UnbakedModel; | import net.minecraft.client.resources.model.ModelBakery; | ||||||
| import net.minecraft.client.texture.Sprite; | import net.minecraft.client.resources.model.ModelState; | ||||||
| import net.minecraft.client.util.SpriteIdentifier; | import net.minecraft.client.resources.model.UnbakedModel; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.resources.ResourceLocation; | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| @@ -29,15 +28,15 @@ import java.util.stream.Collectors; | |||||||
| public final class TurtleModelLoader | public final class TurtleModelLoader | ||||||
| { | { | ||||||
|     public static final TurtleModelLoader INSTANCE = new TurtleModelLoader(); |     public static final TurtleModelLoader INSTANCE = new TurtleModelLoader(); | ||||||
|     private static final Identifier NORMAL_TURTLE_MODEL = new Identifier( ComputerCraft.MOD_ID, "block/turtle_normal" ); |     private static final ResourceLocation NORMAL_TURTLE_MODEL = new ResourceLocation( ComputerCraft.MOD_ID, "block/turtle_normal" ); | ||||||
|     private static final Identifier ADVANCED_TURTLE_MODEL = new Identifier( ComputerCraft.MOD_ID, "block/turtle_advanced" ); |     private static final ResourceLocation ADVANCED_TURTLE_MODEL = new ResourceLocation( ComputerCraft.MOD_ID, "block/turtle_advanced" ); | ||||||
|     private static final Identifier COLOUR_TURTLE_MODEL = new Identifier( ComputerCraft.MOD_ID, "block/turtle_colour" ); |     private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation( ComputerCraft.MOD_ID, "block/turtle_colour" ); | ||||||
|  |  | ||||||
|     private TurtleModelLoader() |     private TurtleModelLoader() | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public boolean accepts( @Nonnull Identifier name ) |     public boolean accepts( @Nonnull ResourceLocation name ) | ||||||
|     { |     { | ||||||
|         return name.getNamespace() |         return name.getNamespace() | ||||||
|             .equals( ComputerCraft.MOD_ID ) && (name.getPath() |             .equals( ComputerCraft.MOD_ID ) && (name.getPath() | ||||||
| @@ -46,7 +45,7 @@ public final class TurtleModelLoader | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     public UnbakedModel loadModel( @Nonnull Identifier name ) |     public UnbakedModel loadModel( @Nonnull ResourceLocation name ) | ||||||
|     { |     { | ||||||
|         if( name.getNamespace() |         if( name.getNamespace() | ||||||
|             .equals( ComputerCraft.MOD_ID ) ) |             .equals( ComputerCraft.MOD_ID ) ) | ||||||
| @@ -65,39 +64,39 @@ public final class TurtleModelLoader | |||||||
|  |  | ||||||
|     private static final class TurtleModel implements UnbakedModel |     private static final class TurtleModel implements UnbakedModel | ||||||
|     { |     { | ||||||
|         private final Identifier family; |         private final ResourceLocation family; | ||||||
|  |  | ||||||
|         private TurtleModel( Identifier family ) |         private TurtleModel( ResourceLocation family ) | ||||||
|         { |         { | ||||||
|             this.family = family; |             this.family = family; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public Collection<SpriteIdentifier> getTextureDependencies( Function<Identifier, UnbakedModel> modelGetter, |         public Collection<Material> getMaterials( Function<ResourceLocation, UnbakedModel> modelGetter, | ||||||
|                                                                     Set<Pair<String, String>> missingTextureErrors ) |                                                                     Set<Pair<String, String>> missingTextureErrors ) | ||||||
|         { |         { | ||||||
|             return getModelDependencies() |             return getDependencies() | ||||||
|                 .stream() |                 .stream() | ||||||
|                 .flatMap( x -> modelGetter.apply( x ) |                 .flatMap( x -> modelGetter.apply( x ) | ||||||
|                     .getTextureDependencies( modelGetter, missingTextureErrors ) |                     .getMaterials( modelGetter, missingTextureErrors ) | ||||||
|                     .stream() ) |                     .stream() ) | ||||||
|                 .collect( Collectors.toSet() ); |                 .collect( Collectors.toSet() ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Nonnull |         @Nonnull | ||||||
|         @Override |         @Override | ||||||
|         public Collection<Identifier> getModelDependencies() |         public Collection<ResourceLocation> getDependencies() | ||||||
|         { |         { | ||||||
|             return Arrays.asList( family, COLOUR_TURTLE_MODEL ); |             return Arrays.asList( family, COLOUR_TURTLE_MODEL ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public BakedModel bake( @Nonnull ModelLoader loader, @Nonnull Function<SpriteIdentifier, Sprite> spriteGetter, @Nonnull ModelBakeSettings state, |         public BakedModel bake( @Nonnull ModelBakery loader, @Nonnull Function<Material, TextureAtlasSprite> spriteGetter, @Nonnull ModelState state, | ||||||
|                                 Identifier modelId ) |                                 ResourceLocation modelId ) | ||||||
|         { |         { | ||||||
|             return new TurtleSmartItemModel( loader.getOrLoadModel( family ) |             return new TurtleSmartItemModel( loader.getModel( family ) | ||||||
|                 .bake( loader, spriteGetter, state, modelId ), |                 .bake( loader, spriteGetter, state, modelId ), | ||||||
|                 loader.getOrLoadModel( COLOUR_TURTLE_MODEL ) |                 loader.getModel( COLOUR_TURTLE_MODEL ) | ||||||
|                     .bake( loader, spriteGetter, state, modelId ) ); |                     .bake( loader, spriteGetter, state, modelId ) ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -6,18 +6,17 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
|  | import com.mojang.math.Transformation; | ||||||
| import dan200.computercraft.api.client.TransformedModel; | import dan200.computercraft.api.client.TransformedModel; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.block.BlockState; | import net.minecraft.client.renderer.block.model.BakedQuad; | ||||||
| import net.minecraft.client.render.model.BakedModel; | import net.minecraft.client.renderer.block.model.ItemOverrides; | ||||||
| import net.minecraft.client.render.model.BakedQuad; | import net.minecraft.client.renderer.block.model.ItemTransforms; | ||||||
| import net.minecraft.client.render.model.json.ModelOverrideList; | import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||||||
| import net.minecraft.client.render.model.json.ModelTransformation; | import net.minecraft.client.resources.model.BakedModel; | ||||||
| import net.minecraft.client.texture.Sprite; | import net.minecraft.core.Direction; | ||||||
| import net.minecraft.util.math.AffineTransformation; | import net.minecraft.world.level.block.state.BlockState; | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.util.*; | import java.util.*; | ||||||
|  |  | ||||||
| @@ -26,13 +25,13 @@ public class TurtleMultiModel implements BakedModel | |||||||
| { | { | ||||||
|     private final BakedModel baseModel; |     private final BakedModel baseModel; | ||||||
|     private final BakedModel overlayModel; |     private final BakedModel overlayModel; | ||||||
|     private final AffineTransformation generalTransform; |     private final Transformation generalTransform; | ||||||
|     private final TransformedModel leftUpgradeModel; |     private final TransformedModel leftUpgradeModel; | ||||||
|     private final TransformedModel rightUpgradeModel; |     private final TransformedModel rightUpgradeModel; | ||||||
|     private List<BakedQuad> generalQuads = null; |     private List<BakedQuad> generalQuads = null; | ||||||
|     private final Map<Direction, List<BakedQuad>> faceQuads = new EnumMap<>( Direction.class ); |     private final Map<Direction, List<BakedQuad>> faceQuads = new EnumMap<>( Direction.class ); | ||||||
|  |  | ||||||
|     public TurtleMultiModel( BakedModel baseModel, BakedModel overlayModel, AffineTransformation generalTransform, TransformedModel leftUpgradeModel, |     public TurtleMultiModel( BakedModel baseModel, BakedModel overlayModel, Transformation generalTransform, TransformedModel leftUpgradeModel, | ||||||
|                              TransformedModel rightUpgradeModel ) |                              TransformedModel rightUpgradeModel ) | ||||||
|     { |     { | ||||||
|         // Get the models |         // Get the models | ||||||
| @@ -77,14 +76,14 @@ public class TurtleMultiModel implements BakedModel | |||||||
|         } |         } | ||||||
|         if( leftUpgradeModel != null ) |         if( leftUpgradeModel != null ) | ||||||
|         { |         { | ||||||
|             AffineTransformation upgradeTransform = generalTransform.multiply( leftUpgradeModel.getMatrix() ); |             Transformation upgradeTransform = generalTransform.compose( leftUpgradeModel.getMatrix() ); | ||||||
|             ModelTransformer.transformQuadsTo( quads, leftUpgradeModel.getModel() |             ModelTransformer.transformQuadsTo( quads, leftUpgradeModel.getModel() | ||||||
|                     .getQuads( state, side, rand ), |                     .getQuads( state, side, rand ), | ||||||
|                 upgradeTransform.getMatrix() ); |                 upgradeTransform.getMatrix() ); | ||||||
|         } |         } | ||||||
|         if( rightUpgradeModel != null ) |         if( rightUpgradeModel != null ) | ||||||
|         { |         { | ||||||
|             AffineTransformation upgradeTransform = generalTransform.multiply( rightUpgradeModel.getMatrix() ); |             Transformation upgradeTransform = generalTransform.compose( rightUpgradeModel.getMatrix() ); | ||||||
|             ModelTransformer.transformQuadsTo( quads, rightUpgradeModel.getModel() |             ModelTransformer.transformQuadsTo( quads, rightUpgradeModel.getModel() | ||||||
|                     .getQuads( state, side, rand ), |                     .getQuads( state, side, rand ), | ||||||
|                 upgradeTransform.getMatrix() ); |                 upgradeTransform.getMatrix() ); | ||||||
| @@ -100,43 +99,43 @@ public class TurtleMultiModel implements BakedModel | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasDepth() |     public boolean isGui3d() | ||||||
|     { |     { | ||||||
|         return baseModel.hasDepth(); |         return baseModel.isGui3d(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean isSideLit() |     public boolean usesBlockLight() | ||||||
|     { |     { | ||||||
|         return baseModel.isSideLit(); |         return baseModel.usesBlockLight(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean isBuiltin() |     public boolean isCustomRenderer() | ||||||
|     { |     { | ||||||
|         return baseModel.isBuiltin(); |         return baseModel.isCustomRenderer(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public Sprite getParticleSprite() |     public TextureAtlasSprite getParticleIcon() | ||||||
|     { |     { | ||||||
|         return baseModel.getParticleSprite(); |         return baseModel.getParticleIcon(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public ModelTransformation getTransformation() |     public ItemTransforms getTransforms() | ||||||
|     { |     { | ||||||
|         return baseModel.getTransformation(); |         return baseModel.getTransforms(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public ModelOverrideList getOverrides() |     public ItemOverrides getOverrides() | ||||||
|     { |     { | ||||||
|         return ModelOverrideList.EMPTY; |         return ItemOverrides.EMPTY; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,31 +5,30 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.shared.turtle.core.TurtlePlayer; | import dan200.computercraft.shared.turtle.core.TurtlePlayer; | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; |  | ||||||
| import net.minecraft.client.render.entity.EntityRenderer; |  | ||||||
| import net.minecraft.client.render.entity.EntityRendererFactory; |  | ||||||
| import net.minecraft.client.util.math.MatrixStack; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
|  | import net.minecraft.client.renderer.entity.EntityRenderer; | ||||||
|  | import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  |  | ||||||
| public class TurtlePlayerRenderer extends EntityRenderer<TurtlePlayer> | public class TurtlePlayerRenderer extends EntityRenderer<TurtlePlayer> | ||||||
| { //FIXME Make sure this isn't an issue. Context was EntityRenderDispatcher. | { //FIXME Make sure this isn't an issue. Context was EntityRenderDispatcher. | ||||||
|     public TurtlePlayerRenderer( EntityRendererFactory.Context context ) |     public TurtlePlayerRenderer( EntityRendererProvider.Context context ) | ||||||
|     { |     { | ||||||
|         super( context ); |         super( context ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void render( @Nonnull TurtlePlayer entityIn, float entityYaw, float partialTicks, @Nonnull MatrixStack transform, |     public void render( @Nonnull TurtlePlayer entityIn, float entityYaw, float partialTicks, @Nonnull PoseStack transform, | ||||||
|                         @Nonnull VertexConsumerProvider buffer, int packedLightIn ) |                         @Nonnull MultiBufferSource buffer, int packedLightIn ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public Identifier getTexture( @Nonnull TurtlePlayer entity ) |     public ResourceLocation getTexture( @Nonnull TurtlePlayer entity ) | ||||||
|     { |     { | ||||||
|         return ComputerBorderRenderer.BACKGROUND_NORMAL; |         return ComputerBorderRenderer.BACKGROUND_NORMAL; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -6,6 +6,8 @@ | |||||||
| package dan200.computercraft.client.render; | package dan200.computercraft.client.render; | ||||||
|  |  | ||||||
| import com.google.common.base.Objects; | import com.google.common.base.Objects; | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.math.Transformation; | ||||||
| import dan200.computercraft.api.client.TransformedModel; | import dan200.computercraft.api.client.TransformedModel; | ||||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||||
| import dan200.computercraft.api.turtle.TurtleSide; | import dan200.computercraft.api.turtle.TurtleSide; | ||||||
| @@ -14,23 +16,20 @@ import dan200.computercraft.shared.util.Holiday; | |||||||
| import dan200.computercraft.shared.util.HolidayUtil; | import dan200.computercraft.shared.util.HolidayUtil; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.block.BlockState; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.multiplayer.ClientLevel; | ||||||
| import net.minecraft.client.render.model.BakedModel; | import net.minecraft.client.renderer.block.model.BakedQuad; | ||||||
| import net.minecraft.client.render.model.BakedModelManager; | import net.minecraft.client.renderer.block.model.ItemOverrides; | ||||||
| import net.minecraft.client.render.model.BakedQuad; | import net.minecraft.client.renderer.block.model.ItemTransforms; | ||||||
| import net.minecraft.client.render.model.json.ModelOverrideList; | import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||||||
| import net.minecraft.client.render.model.json.ModelTransformation; | import net.minecraft.client.resources.model.BakedModel; | ||||||
| import net.minecraft.client.texture.Sprite; | import net.minecraft.client.resources.model.ModelManager; | ||||||
| import net.minecraft.client.util.ModelIdentifier; | import net.minecraft.client.resources.model.ModelResourceLocation; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.core.Direction; | ||||||
| import net.minecraft.client.world.ClientWorld; | import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraft.entity.LivingEntity; | import net.minecraft.world.entity.LivingEntity; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.world.item.ItemStack; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.world.level.block.state.BlockState; | ||||||
| import net.minecraft.util.math.AffineTransformation; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
| import java.util.Collections; | import java.util.Collections; | ||||||
| @@ -41,17 +40,17 @@ import java.util.Random; | |||||||
| @Environment( EnvType.CLIENT ) | @Environment( EnvType.CLIENT ) | ||||||
| public class TurtleSmartItemModel implements BakedModel | public class TurtleSmartItemModel implements BakedModel | ||||||
| { | { | ||||||
|     private static final AffineTransformation identity, flip; |     private static final Transformation identity, flip; | ||||||
|  |  | ||||||
|     static |     static | ||||||
|     { |     { | ||||||
|         MatrixStack stack = new MatrixStack(); |         PoseStack stack = new PoseStack(); | ||||||
|         stack.scale( 0, -1, 0 ); |         stack.scale( 0, -1, 0 ); | ||||||
|         stack.translate( 0, 0, 1 ); |         stack.translate( 0, 0, 1 ); | ||||||
|  |  | ||||||
|         identity = AffineTransformation.identity(); |         identity = Transformation.identity(); | ||||||
|         flip = new AffineTransformation( stack.peek() |         flip = new Transformation( stack.last() | ||||||
|             .getModel() ); |             .pose() ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static class TurtleModelCombination |     private static class TurtleModelCombination | ||||||
| @@ -59,11 +58,11 @@ public class TurtleSmartItemModel implements BakedModel | |||||||
|         final boolean colour; |         final boolean colour; | ||||||
|         final ITurtleUpgrade leftUpgrade; |         final ITurtleUpgrade leftUpgrade; | ||||||
|         final ITurtleUpgrade rightUpgrade; |         final ITurtleUpgrade rightUpgrade; | ||||||
|         final Identifier overlay; |         final ResourceLocation overlay; | ||||||
|         final boolean christmas; |         final boolean christmas; | ||||||
|         final boolean flip; |         final boolean flip; | ||||||
|  |  | ||||||
|         TurtleModelCombination( boolean colour, ITurtleUpgrade leftUpgrade, ITurtleUpgrade rightUpgrade, Identifier overlay, boolean christmas, |         TurtleModelCombination( boolean colour, ITurtleUpgrade leftUpgrade, ITurtleUpgrade rightUpgrade, ResourceLocation overlay, boolean christmas, | ||||||
|                                 boolean flip ) |                                 boolean flip ) | ||||||
|         { |         { | ||||||
|             this.colour = colour; |             this.colour = colour; | ||||||
| @@ -109,7 +108,7 @@ public class TurtleSmartItemModel implements BakedModel | |||||||
|     private final BakedModel colourModel; |     private final BakedModel colourModel; | ||||||
|  |  | ||||||
|     private final HashMap<TurtleModelCombination, BakedModel> cachedModels = new HashMap<>(); |     private final HashMap<TurtleModelCombination, BakedModel> cachedModels = new HashMap<>(); | ||||||
|     private final ModelOverrideList overrides; |     private final ItemOverrides overrides; | ||||||
|  |  | ||||||
|     public TurtleSmartItemModel( BakedModel familyModel, BakedModel colourModel ) |     public TurtleSmartItemModel( BakedModel familyModel, BakedModel colourModel ) | ||||||
|     { |     { | ||||||
| @@ -117,17 +116,17 @@ public class TurtleSmartItemModel implements BakedModel | |||||||
|         this.colourModel = colourModel; |         this.colourModel = colourModel; | ||||||
|  |  | ||||||
|         // this actually works I think, trust me |         // this actually works I think, trust me | ||||||
|         overrides = new ModelOverrideList( null, null, null, Collections.emptyList() ) |         overrides = new ItemOverrides( null, null, null, Collections.emptyList() ) | ||||||
|         { |         { | ||||||
|             @Nonnull |             @Nonnull | ||||||
|             @Override |             @Override | ||||||
|             public BakedModel apply( BakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity, int seed ) |             public BakedModel resolve( BakedModel originalModel, ItemStack stack, @Nullable ClientLevel world, @Nullable LivingEntity entity, int seed ) | ||||||
|             { |             { | ||||||
|                 ItemTurtle turtle = (ItemTurtle) stack.getItem(); |                 ItemTurtle turtle = (ItemTurtle) stack.getItem(); | ||||||
|                 int colour = turtle.getColour( stack ); |                 int colour = turtle.getColour( stack ); | ||||||
|                 ITurtleUpgrade leftUpgrade = turtle.getUpgrade( stack, TurtleSide.LEFT ); |                 ITurtleUpgrade leftUpgrade = turtle.getUpgrade( stack, TurtleSide.LEFT ); | ||||||
|                 ITurtleUpgrade rightUpgrade = turtle.getUpgrade( stack, TurtleSide.RIGHT ); |                 ITurtleUpgrade rightUpgrade = turtle.getUpgrade( stack, TurtleSide.RIGHT ); | ||||||
|                 Identifier overlay = turtle.getOverlay( stack ); |                 ResourceLocation overlay = turtle.getOverlay( stack ); | ||||||
|                 boolean christmas = HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS; |                 boolean christmas = HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS; | ||||||
|                 String label = turtle.getLabel( stack ); |                 String label = turtle.getLabel( stack ); | ||||||
|                 boolean flip = label != null && (label.equals( "Dinnerbone" ) || label.equals( "Grumm" )); |                 boolean flip = label != null && (label.equals( "Dinnerbone" ) || label.equals( "Grumm" )); | ||||||
| @@ -145,15 +144,15 @@ public class TurtleSmartItemModel implements BakedModel | |||||||
|  |  | ||||||
|     private BakedModel buildModel( TurtleModelCombination combo ) |     private BakedModel buildModel( TurtleModelCombination combo ) | ||||||
|     { |     { | ||||||
|         MinecraftClient mc = MinecraftClient.getInstance(); |         Minecraft mc = Minecraft.getInstance(); | ||||||
|         BakedModelManager modelManager = mc.getItemRenderer() |         ModelManager modelManager = mc.getItemRenderer() | ||||||
|             .getModels() |             .getItemModelShaper() | ||||||
|             .getModelManager(); |             .getModelManager(); | ||||||
|         ModelIdentifier overlayModelLocation = TileEntityTurtleRenderer.getTurtleOverlayModel( combo.overlay, combo.christmas ); |         ModelResourceLocation overlayModelLocation = TileEntityTurtleRenderer.getTurtleOverlayModel( combo.overlay, combo.christmas ); | ||||||
|  |  | ||||||
|         BakedModel baseModel = combo.colour ? colourModel : familyModel; |         BakedModel baseModel = combo.colour ? colourModel : familyModel; | ||||||
|         BakedModel overlayModel = overlayModelLocation != null ? modelManager.getModel( overlayModelLocation ) : null; |         BakedModel overlayModel = overlayModelLocation != null ? modelManager.getModel( overlayModelLocation ) : null; | ||||||
|         AffineTransformation transform = combo.flip ? flip : identity; |         Transformation transform = combo.flip ? flip : identity; | ||||||
|         TransformedModel leftModel = combo.leftUpgrade != null ? combo.leftUpgrade.getModel( null, TurtleSide.LEFT ) : null; |         TransformedModel leftModel = combo.leftUpgrade != null ? combo.leftUpgrade.getModel( null, TurtleSide.LEFT ) : null; | ||||||
|         TransformedModel rightModel = combo.rightUpgrade != null ? combo.rightUpgrade.getModel( null, TurtleSide.RIGHT ) : null; |         TransformedModel rightModel = combo.rightUpgrade != null ? combo.rightUpgrade.getModel( null, TurtleSide.RIGHT ) : null; | ||||||
|         return new TurtleMultiModel( baseModel, overlayModel, transform, leftModel, rightModel ); |         return new TurtleMultiModel( baseModel, overlayModel, transform, leftModel, rightModel ); | ||||||
| @@ -174,33 +173,33 @@ public class TurtleSmartItemModel implements BakedModel | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasDepth() |     public boolean isGui3d() | ||||||
|     { |     { | ||||||
|         return familyModel.hasDepth(); |         return familyModel.isGui3d(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean isSideLit() |     public boolean usesBlockLight() | ||||||
|     { |     { | ||||||
|         return familyModel.isSideLit(); |         return familyModel.usesBlockLight(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean isBuiltin() |     public boolean isCustomRenderer() | ||||||
|     { |     { | ||||||
|         return familyModel.isBuiltin(); |         return familyModel.isCustomRenderer(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public Sprite getParticleSprite() |     public TextureAtlasSprite getParticleIcon() | ||||||
|     { |     { | ||||||
|         return familyModel.getParticleSprite(); |         return familyModel.getParticleIcon(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     public ModelOverrideList getOverrides() |     public ItemOverrides getOverrides() | ||||||
|     { |     { | ||||||
|         return overrides; |         return overrides; | ||||||
|     } |     } | ||||||
| @@ -208,9 +207,9 @@ public class TurtleSmartItemModel implements BakedModel | |||||||
|     @Nonnull |     @Nonnull | ||||||
|     @Override |     @Override | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public ModelTransformation getTransformation() |     public ItemTransforms getTransforms() | ||||||
|     { |     { | ||||||
|         return familyModel.getTransformation(); |         return familyModel.getTransforms(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,10 +5,9 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.core.computer; | package dan200.computercraft.core.computer; | ||||||
|  |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * A side on a computer. Unlike {@link Direction}, this is relative to the direction the computer is |  * A side on a computer. Unlike {@link Direction}, this is relative to the direction the computer is | ||||||
|   | |||||||
| @@ -9,9 +9,8 @@ import dan200.computercraft.ComputerCraft; | |||||||
| import dan200.computercraft.api.peripheral.IWorkMonitor; | import dan200.computercraft.api.peripheral.IWorkMonitor; | ||||||
| import dan200.computercraft.core.tracking.Tracking; | import dan200.computercraft.core.tracking.Tracking; | ||||||
| import dan200.computercraft.shared.turtle.core.TurtleBrain; | import dan200.computercraft.shared.turtle.core.TurtleBrain; | ||||||
| import net.minecraft.block.entity.BlockEntity; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
| import java.util.ArrayDeque; | import java.util.ArrayDeque; | ||||||
| import java.util.Queue; | import java.util.Queue; | ||||||
| import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||||
|   | |||||||
| @@ -13,15 +13,14 @@ import dan200.computercraft.ComputerCraft; | |||||||
| import dan200.computercraft.api.filesystem.IMount; | import dan200.computercraft.api.filesystem.IMount; | ||||||
| import dan200.computercraft.core.apis.handles.ArrayByteChannel; | import dan200.computercraft.core.apis.handles.ArrayByteChannel; | ||||||
| import dan200.computercraft.shared.util.IoUtil; | import dan200.computercraft.shared.util.IoUtil; | ||||||
| import net.minecraft.resource.ReloadableResourceManager; |  | ||||||
| import net.minecraft.resource.Resource; |  | ||||||
| import net.minecraft.resource.ResourceManager; |  | ||||||
| import net.minecraft.resource.SynchronousResourceReloader; |  | ||||||
| import net.minecraft.util.Identifier; |  | ||||||
| import net.minecraft.util.InvalidIdentifierException; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.ResourceLocationException; | ||||||
|  | import net.minecraft.resources.ResourceLocation; | ||||||
|  | import net.minecraft.server.packs.resources.ReloadableResourceManager; | ||||||
|  | import net.minecraft.server.packs.resources.Resource; | ||||||
|  | import net.minecraft.server.packs.resources.ResourceManager; | ||||||
|  | import net.minecraft.server.packs.resources.ResourceManagerReloadListener; | ||||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
| @@ -61,7 +60,7 @@ public final class ResourceMount implements IMount | |||||||
|     /** |     /** | ||||||
|      * Maintain a cache of currently loaded resource mounts. This cache is invalidated when currentManager changes. |      * Maintain a cache of currently loaded resource mounts. This cache is invalidated when currentManager changes. | ||||||
|      */ |      */ | ||||||
|     private static final Map<ReloadableResourceManager, Map<Identifier, ResourceMount>> MOUNT_CACHE = new WeakHashMap<>( 2 ); |     private static final Map<ReloadableResourceManager, Map<ResourceLocation, ResourceMount>> MOUNT_CACHE = new WeakHashMap<>( 2 ); | ||||||
|  |  | ||||||
|     private final String namespace; |     private final String namespace; | ||||||
|     private final String subPath; |     private final String subPath; | ||||||
| @@ -72,7 +71,7 @@ public final class ResourceMount implements IMount | |||||||
|  |  | ||||||
|     public static ResourceMount get( String namespace, String subPath, ReloadableResourceManager manager ) |     public static ResourceMount get( String namespace, String subPath, ReloadableResourceManager manager ) | ||||||
|     { |     { | ||||||
|         Map<Identifier, ResourceMount> cache; |         Map<ResourceLocation, ResourceMount> cache; | ||||||
|  |  | ||||||
|         synchronized( MOUNT_CACHE ) |         synchronized( MOUNT_CACHE ) | ||||||
|         { |         { | ||||||
| @@ -80,7 +79,7 @@ public final class ResourceMount implements IMount | |||||||
|             if( cache == null ) MOUNT_CACHE.put( manager, cache = CACHE_TEMPLATE.makeMap() ); |             if( cache == null ) MOUNT_CACHE.put( manager, cache = CACHE_TEMPLATE.makeMap() ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Identifier path = new Identifier( namespace, subPath ); |         ResourceLocation path = new ResourceLocation( namespace, subPath ); | ||||||
|         synchronized( cache ) |         synchronized( cache ) | ||||||
|         { |         { | ||||||
|             ResourceMount mount = cache.get( path ); |             ResourceMount mount = cache.get( path ); | ||||||
| @@ -104,8 +103,8 @@ public final class ResourceMount implements IMount | |||||||
|         boolean hasAny = false; |         boolean hasAny = false; | ||||||
|         String existingNamespace = null; |         String existingNamespace = null; | ||||||
|  |  | ||||||
|         FileEntry newRoot = new FileEntry( new Identifier( namespace, subPath ) ); |         FileEntry newRoot = new FileEntry( new ResourceLocation( namespace, subPath ) ); | ||||||
|         for( Identifier file : manager.findResources( subPath, s -> true ) ) |         for( ResourceLocation file : manager.listResources( subPath, s -> true ) ) | ||||||
|         { |         { | ||||||
|             existingNamespace = file.getNamespace(); |             existingNamespace = file.getNamespace(); | ||||||
|  |  | ||||||
| @@ -160,12 +159,12 @@ public final class ResourceMount implements IMount | |||||||
|             FileEntry nextEntry = lastEntry.children.get( part ); |             FileEntry nextEntry = lastEntry.children.get( part ); | ||||||
|             if( nextEntry == null ) |             if( nextEntry == null ) | ||||||
|             { |             { | ||||||
|                 Identifier childPath; |                 ResourceLocation childPath; | ||||||
|                 try |                 try | ||||||
|                 { |                 { | ||||||
|                     childPath = new Identifier( namespace, subPath + "/" + path ); |                     childPath = new ResourceLocation( namespace, subPath + "/" + path ); | ||||||
|                 } |                 } | ||||||
|                 catch( InvalidIdentifierException e ) |                 catch( ResourceLocationException e ) | ||||||
|                 { |                 { | ||||||
|                     ComputerCraft.log.warn( "Cannot create resource location for {} ({})", part, e.getMessage() ); |                     ComputerCraft.log.warn( "Cannot create resource location for {} ({})", part, e.getMessage() ); | ||||||
|                     return; |                     return; | ||||||
| @@ -271,11 +270,11 @@ public final class ResourceMount implements IMount | |||||||
|  |  | ||||||
|     private static class FileEntry |     private static class FileEntry | ||||||
|     { |     { | ||||||
|         final Identifier identifier; |         final ResourceLocation identifier; | ||||||
|         Map<String, FileEntry> children; |         Map<String, FileEntry> children; | ||||||
|         long size = -1; |         long size = -1; | ||||||
|  |  | ||||||
|         FileEntry( Identifier identifier ) |         FileEntry( ResourceLocation identifier ) | ||||||
|         { |         { | ||||||
|             this.identifier = identifier; |             this.identifier = identifier; | ||||||
|         } |         } | ||||||
| @@ -297,7 +296,7 @@ public final class ResourceMount implements IMount | |||||||
|      * While people should really be keeping a permanent reference to this, some people construct it every |      * While people should really be keeping a permanent reference to this, some people construct it every | ||||||
|      * method call, so let's make this as small as possible. |      * method call, so let's make this as small as possible. | ||||||
|      */ |      */ | ||||||
|     static class Listener implements SynchronousResourceReloader |     static class Listener implements ResourceManagerReloadListener | ||||||
|     { |     { | ||||||
|         private static final Listener INSTANCE = new Listener(); |         private static final Listener INSTANCE = new Listener(); | ||||||
|  |  | ||||||
| @@ -305,14 +304,14 @@ public final class ResourceMount implements IMount | |||||||
|         private final Set<ReloadableResourceManager> managers = Collections.newSetFromMap( new WeakHashMap<>() ); |         private final Set<ReloadableResourceManager> managers = Collections.newSetFromMap( new WeakHashMap<>() ); | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void reload( @Nonnull ResourceManager manager ) |         public void onResourceManagerReload( @Nonnull ResourceManager manager ) | ||||||
|         { |         { | ||||||
|             for( ResourceMount mount : mounts ) mount.load(); |             for( ResourceMount mount : mounts ) mount.load(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         synchronized void add( ReloadableResourceManager manager, ResourceMount mount ) |         synchronized void add( ReloadableResourceManager manager, ResourceMount mount ) | ||||||
|         { |         { | ||||||
|             if( managers.add( manager ) ) manager.registerReloader( this ); |             if( managers.add( manager ) ) manager.registerReloadListener( this ); | ||||||
|             mounts.add( mount ); |             mounts.add( mount ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -7,10 +7,9 @@ package dan200.computercraft.core.terminal; | |||||||
|  |  | ||||||
| import dan200.computercraft.shared.util.Colour; | import dan200.computercraft.shared.util.Colour; | ||||||
| import dan200.computercraft.shared.util.Palette; | import dan200.computercraft.shared.util.Palette; | ||||||
| import net.minecraft.nbt.NbtCompound; |  | ||||||
| import net.minecraft.network.PacketByteBuf; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.nbt.CompoundTag; | ||||||
|  | import net.minecraft.network.FriendlyByteBuf; | ||||||
|  |  | ||||||
| public class Terminal | public class Terminal | ||||||
| { | { | ||||||
| @@ -310,7 +309,7 @@ public class Terminal | |||||||
|         if( onChanged != null ) onChanged.run(); |         if( onChanged != null ) onChanged.run(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public synchronized void write( PacketByteBuf buffer ) |     public synchronized void write( FriendlyByteBuf buffer ) | ||||||
|     { |     { | ||||||
|         buffer.writeInt( cursorX ); |         buffer.writeInt( cursorX ); | ||||||
|         buffer.writeInt( cursorY ); |         buffer.writeInt( cursorY ); | ||||||
| @@ -336,7 +335,7 @@ public class Terminal | |||||||
|         palette.write( buffer ); |         palette.write( buffer ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public synchronized void read( PacketByteBuf buffer ) |     public synchronized void read( FriendlyByteBuf buffer ) | ||||||
|     { |     { | ||||||
|         cursorX = buffer.readInt(); |         cursorX = buffer.readInt(); | ||||||
|         cursorY = buffer.readInt(); |         cursorY = buffer.readInt(); | ||||||
| @@ -366,7 +365,7 @@ public class Terminal | |||||||
|         setChanged(); |         setChanged(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public synchronized NbtCompound writeToNBT( NbtCompound nbt ) |     public synchronized CompoundTag writeToNBT( CompoundTag nbt ) | ||||||
|     { |     { | ||||||
|         nbt.putInt( "term_cursorX", cursorX ); |         nbt.putInt( "term_cursorX", cursorX ); | ||||||
|         nbt.putInt( "term_cursorY", cursorY ); |         nbt.putInt( "term_cursorY", cursorY ); | ||||||
| @@ -384,7 +383,7 @@ public class Terminal | |||||||
|         return nbt; |         return nbt; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public synchronized void readFromNBT( NbtCompound nbt ) |     public synchronized void readFromNBT( CompoundTag nbt ) | ||||||
|     { |     { | ||||||
|         cursorX = nbt.getInt( "term_cursorX" ); |         cursorX = nbt.getInt( "term_cursorX" ); | ||||||
|         cursorY = nbt.getInt( "term_cursorY" ); |         cursorY = nbt.getInt( "term_cursorY" ); | ||||||
|   | |||||||
| @@ -5,16 +5,16 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import net.minecraft.client.gui.hud.ChatHud; | import net.minecraft.client.gui.components.ChatComponent; | ||||||
| import net.minecraft.text.Text; | import net.minecraft.network.chat.Component; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.gen.Invoker; | import org.spongepowered.asm.mixin.gen.Invoker; | ||||||
|  |  | ||||||
| @Mixin( ChatHud.class ) | @Mixin( ChatComponent.class ) | ||||||
| public interface ChatHudAccess | public interface ChatHudAccess | ||||||
| { | { | ||||||
|     @Invoker |     @Invoker | ||||||
|     void callAddMessage( Text text, int messageId ); |     void callAddMessage( Component text, int messageId ); | ||||||
|  |  | ||||||
|     @Invoker |     @Invoker | ||||||
|     void callRemoveMessage( int messageId ); |     void callRemoveMessage( int messageId ); | ||||||
|   | |||||||
| @@ -5,22 +5,22 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import net.minecraft.client.render.item.HeldItemRenderer; | import net.minecraft.client.renderer.ItemInHandRenderer; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
| import net.minecraft.util.Arm; | import net.minecraft.world.entity.HumanoidArm; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.gen.Invoker; | import org.spongepowered.asm.mixin.gen.Invoker; | ||||||
|  |  | ||||||
| @Mixin( HeldItemRenderer.class ) | @Mixin( ItemInHandRenderer.class ) | ||||||
| public interface HeldItemRendererAccess | public interface HeldItemRendererAccess | ||||||
| { | { | ||||||
|     @Invoker |     @Invoker | ||||||
|     float callGetMapAngle( float tickDelta ); |     float callGetMapAngle( float tickDelta ); | ||||||
|  |  | ||||||
|     @Invoker |     @Invoker | ||||||
|     void callRenderArm( MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, Arm arm ); |     void callRenderArm( PoseStack matrices, MultiBufferSource vertexConsumers, int light, HumanoidArm arm ); | ||||||
|  |  | ||||||
|     @Invoker |     @Invoker | ||||||
|     void callRenderArmHoldingItem( MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, float equipProgress, float swingProgress, Arm arm ); |     void callRenderArmHoldingItem( PoseStack matrices, MultiBufferSource vertexConsumers, int light, float equipProgress, float swingProgress, HumanoidArm arm ); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,8 +5,8 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import net.minecraft.resource.ServerResourceManager; |  | ||||||
| import net.minecraft.server.MinecraftServer; | import net.minecraft.server.MinecraftServer; | ||||||
|  | import net.minecraft.server.ServerResources; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.gen.Accessor; | import org.spongepowered.asm.mixin.gen.Accessor; | ||||||
|  |  | ||||||
| @@ -14,5 +14,5 @@ import org.spongepowered.asm.mixin.gen.Accessor; | |||||||
| public interface MinecraftServerAccess | public interface MinecraftServerAccess | ||||||
| { | { | ||||||
|     @Accessor |     @Accessor | ||||||
|     ServerResourceManager getServerResourceManager(); |     ServerResources getServerResourceManager(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,14 +6,12 @@ | |||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.util.DropConsumer; | import dan200.computercraft.shared.util.DropConsumer; | ||||||
| import net.minecraft.block.Block; |  | ||||||
| import net.minecraft.entity.ItemEntity; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import java.util.function.Supplier; | import java.util.function.Supplier; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.world.entity.item.ItemEntity; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.level.block.Block; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| @@ -23,7 +21,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | |||||||
| /** | /** | ||||||
|  * Captures block drops. |  * Captures block drops. | ||||||
|  * |  * | ||||||
|  * @see Block#dropStack(World, BlockPos, ItemStack) |  * @see Block#popResource(Level, BlockPos, ItemStack) | ||||||
|  */ |  */ | ||||||
| @Mixin( Block.class ) | @Mixin( Block.class ) | ||||||
| public class MixinBlock | public class MixinBlock | ||||||
| @@ -35,9 +33,9 @@ public class MixinBlock | |||||||
|         ), |         ), | ||||||
|         locals = LocalCapture.CAPTURE_FAILSOFT, |         locals = LocalCapture.CAPTURE_FAILSOFT, | ||||||
|         cancellable = true ) |         cancellable = true ) | ||||||
|     private static void dropStack( World world, Supplier<ItemEntity> itemEntitySupplier, ItemStack stack, CallbackInfo callbackInfo, ItemEntity itemEntity ) |     private static void dropStack( Level world, Supplier<ItemEntity> itemEntitySupplier, ItemStack stack, CallbackInfo callbackInfo, ItemEntity itemEntity ) | ||||||
|     { |     { | ||||||
|         if( DropConsumer.onHarvestDrops( world, itemEntity.getBlockPos(), stack ) ) |         if( DropConsumer.onHarvestDrops( world, itemEntity.blockPosition(), stack ) ) | ||||||
|         { |         { | ||||||
|             callbackInfo.cancel(); |             callbackInfo.cancel(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -6,9 +6,9 @@ | |||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.util.DropConsumer; | import dan200.computercraft.shared.util.DropConsumer; | ||||||
| import net.minecraft.entity.Entity; | import net.minecraft.world.entity.Entity; | ||||||
| import net.minecraft.entity.ItemEntity; | import net.minecraft.world.entity.item.ItemEntity; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.world.item.ItemStack; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| @@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | |||||||
| /** | /** | ||||||
|  * Captures entities. |  * Captures entities. | ||||||
|  * |  * | ||||||
|  * @see Entity#dropStack(ItemStack, float) |  * @see Entity#spawnAtLocation(ItemStack, float) | ||||||
|  */ |  */ | ||||||
| @Mixin( Entity.class ) | @Mixin( Entity.class ) | ||||||
| public class MixinEntity | public class MixinEntity | ||||||
|   | |||||||
| @@ -6,13 +6,10 @@ | |||||||
|  |  | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.shaders.Program; | ||||||
| import com.mojang.datafixers.util.Pair; | import com.mojang.datafixers.util.Pair; | ||||||
| import dan200.computercraft.client.render.MonitorTextureBufferShader; | import dan200.computercraft.client.render.MonitorTextureBufferShader; | ||||||
| import dan200.computercraft.client.render.RenderTypes; | import dan200.computercraft.client.render.RenderTypes; | ||||||
| import net.minecraft.client.gl.Program; |  | ||||||
| import net.minecraft.client.render.GameRenderer; |  | ||||||
| import net.minecraft.client.render.Shader; |  | ||||||
| import net.minecraft.resource.ResourceManager; |  | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| @@ -22,22 +19,25 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.function.Consumer; | import java.util.function.Consumer; | ||||||
|  | import net.minecraft.client.renderer.GameRenderer; | ||||||
|  | import net.minecraft.client.renderer.ShaderInstance; | ||||||
|  | import net.minecraft.server.packs.resources.ResourceManager; | ||||||
|  |  | ||||||
| @Mixin( GameRenderer.class ) | @Mixin( GameRenderer.class ) | ||||||
| public class MixinGameRenderer | public class MixinGameRenderer | ||||||
| { | { | ||||||
|     @Inject( method = "loadShaders", at = @At( value = "INVOKE_ASSIGN", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 53 ), locals = LocalCapture.CAPTURE_FAILSOFT ) |     @Inject( method = "loadShaders", at = @At( value = "INVOKE_ASSIGN", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 53 ), locals = LocalCapture.CAPTURE_FAILSOFT ) | ||||||
|     private void loadShaders( ResourceManager manager, CallbackInfo info, List<Program> list, List<Pair<Shader, Consumer<Shader>>> list2 ) throws IOException |     private void loadShaders( ResourceManager manager, CallbackInfo info, List<Program> list, List<Pair<ShaderInstance, Consumer<ShaderInstance>>> list2 ) throws IOException | ||||||
|     { |     { | ||||||
|         list2.add( Pair.of( new Shader( |         list2.add( Pair.of( new ShaderInstance( | ||||||
|             manager, |             manager, | ||||||
|             "terminal", |             "terminal", | ||||||
|             RenderTypes.TERMINAL_WITHOUT_DEPTH.getVertexFormat() |             RenderTypes.TERMINAL_WITHOUT_DEPTH.format() | ||||||
|         ), shader -> RenderTypes.terminalShader = shader ) ); |         ), shader -> RenderTypes.terminalShader = shader ) ); | ||||||
|         list2.add( Pair.of( new MonitorTextureBufferShader( |         list2.add( Pair.of( new MonitorTextureBufferShader( | ||||||
|             manager, |             manager, | ||||||
|             "monitor_tbo", |             "monitor_tbo", | ||||||
|             RenderTypes.MONITOR_TBO.getVertexFormat() |             RenderTypes.MONITOR_TBO.format() | ||||||
|         ), shader -> RenderTypes.monitorTboShader = (MonitorTextureBufferShader) shader ) ); |         ), shader -> RenderTypes.monitorTboShader = (MonitorTextureBufferShader) shader ) ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,20 +6,20 @@ | |||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import dan200.computercraft.client.gui.widgets.WidgetTerminal; | import dan200.computercraft.client.gui.widgets.WidgetTerminal; | ||||||
| import net.minecraft.client.gui.Element; | import net.minecraft.client.gui.components.events.GuiEventListener; | ||||||
| import net.minecraft.client.gui.screen.Screen; | import net.minecraft.client.gui.screens.Screen; | ||||||
| import net.minecraft.client.gui.screen.ingame.HandledScreen; | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||||||
| import net.minecraft.screen.ScreenHandler; | import net.minecraft.network.chat.Component; | ||||||
| import net.minecraft.text.Text; | import net.minecraft.world.inventory.AbstractContainerMenu; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||||||
|  |  | ||||||
| @Mixin( HandledScreen.class ) | @Mixin( AbstractContainerScreen.class ) | ||||||
| public class MixinHandledScreen<T extends ScreenHandler> extends Screen | public class MixinHandledScreen<T extends AbstractContainerMenu> extends Screen | ||||||
| { | { | ||||||
|     protected MixinHandledScreen( Text title ) |     protected MixinHandledScreen( Component title ) | ||||||
|     { |     { | ||||||
|         super( title ); |         super( title ); | ||||||
|     } |     } | ||||||
| @@ -27,7 +27,7 @@ public class MixinHandledScreen<T extends ScreenHandler> extends Screen | |||||||
|     @Inject( method = "mouseReleased", at = @At ( "HEAD" ) ) |     @Inject( method = "mouseReleased", at = @At ( "HEAD" ) ) | ||||||
|     public void mouseReleased( double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir ) |     public void mouseReleased( double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir ) | ||||||
|     { |     { | ||||||
|         for ( Element child : this.children() ) |         for ( GuiEventListener child : this.children() ) | ||||||
|         { |         { | ||||||
|             if ( child instanceof WidgetTerminal ) |             if ( child instanceof WidgetTerminal ) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -5,32 +5,32 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.client.render.ItemPocketRenderer; | import dan200.computercraft.client.render.ItemPocketRenderer; | ||||||
| import dan200.computercraft.client.render.ItemPrintoutRenderer; | import dan200.computercraft.client.render.ItemPrintoutRenderer; | ||||||
| import dan200.computercraft.shared.media.items.ItemPrintout; | import dan200.computercraft.shared.media.items.ItemPrintout; | ||||||
| import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.client.network.AbstractClientPlayerEntity; | import net.minecraft.client.player.AbstractClientPlayer; | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; | import net.minecraft.client.renderer.ItemInHandRenderer; | ||||||
| import net.minecraft.client.render.item.HeldItemRenderer; | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.world.InteractionHand; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.world.entity.HumanoidArm; | ||||||
| import net.minecraft.util.Arm; | import net.minecraft.world.item.ItemStack; | ||||||
| import net.minecraft.util.Hand; |  | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.Shadow; | import org.spongepowered.asm.mixin.Shadow; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||||
|  |  | ||||||
| @Mixin( HeldItemRenderer.class ) | @Mixin( ItemInHandRenderer.class ) | ||||||
| @Environment( EnvType.CLIENT ) | @Environment( EnvType.CLIENT ) | ||||||
| public class MixinHeldItemRenderer | public class MixinHeldItemRenderer | ||||||
| { | { | ||||||
|     @Shadow |     @Shadow | ||||||
|     private void renderArmHoldingItem( MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, float equipProgress, float swingProgress, |     private void renderArmHoldingItem( PoseStack matrices, MultiBufferSource vertexConsumers, int light, float equipProgress, float swingProgress, | ||||||
|                                        Arm arm ) |                                        HumanoidArm arm ) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -46,8 +46,8 @@ public class MixinHeldItemRenderer | |||||||
|         at = @At( "HEAD" ), |         at = @At( "HEAD" ), | ||||||
|         cancellable = true ) |         cancellable = true ) | ||||||
|     public void renderFirstPersonItem( |     public void renderFirstPersonItem( | ||||||
|         AbstractClientPlayerEntity player, float var2, float pitch, Hand hand, float swingProgress, |         AbstractClientPlayer player, float var2, float pitch, InteractionHand hand, float swingProgress, | ||||||
|         ItemStack stack, float equipProgress, MatrixStack matrixStack, VertexConsumerProvider provider, int light, |         ItemStack stack, float equipProgress, PoseStack matrixStack, MultiBufferSource provider, int light, | ||||||
|         CallbackInfo callback |         CallbackInfo callback | ||||||
|     ) |     ) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -5,22 +5,22 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
| import dan200.computercraft.client.render.ItemPrintoutRenderer; | import dan200.computercraft.client.render.ItemPrintoutRenderer; | ||||||
| import dan200.computercraft.shared.media.items.ItemPrintout; | import dan200.computercraft.shared.media.items.ItemPrintout; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.client.render.VertexConsumerProvider; | import net.minecraft.client.renderer.MultiBufferSource; | ||||||
| import net.minecraft.client.render.entity.ItemFrameEntityRenderer; | import net.minecraft.client.renderer.entity.ItemFrameRenderer; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.world.entity.EntityType; | ||||||
| import net.minecraft.entity.EntityType; | import net.minecraft.world.entity.decoration.ItemFrame; | ||||||
| import net.minecraft.entity.decoration.ItemFrameEntity; | import net.minecraft.world.item.ItemStack; | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||||
|  |  | ||||||
| @Mixin( ItemFrameEntityRenderer.class ) | @Mixin( ItemFrameRenderer.class ) | ||||||
| @Environment( EnvType.CLIENT ) | @Environment( EnvType.CLIENT ) | ||||||
| public class MixinItemFrameEntityRenderer | public class MixinItemFrameEntityRenderer | ||||||
| { | { | ||||||
| @@ -34,17 +34,17 @@ public class MixinItemFrameEntityRenderer | |||||||
|         ), |         ), | ||||||
|         cancellable = true ) |         cancellable = true ) | ||||||
|     private void renderItem( |     private void renderItem( | ||||||
|         ItemFrameEntity itemFrameEntity, float f, float g, MatrixStack matrixStack, |         ItemFrame itemFrameEntity, float f, float g, PoseStack matrixStack, | ||||||
|         VertexConsumerProvider vertexConsumerProvider, int itemFrameEntityLight, CallbackInfo info |         MultiBufferSource vertexConsumerProvider, int itemFrameEntityLight, CallbackInfo info | ||||||
|     ) |     ) | ||||||
|     { |     { | ||||||
|         ItemStack stack = itemFrameEntity.getHeldItemStack(); |         ItemStack stack = itemFrameEntity.getItem(); | ||||||
|         if( stack.getItem() instanceof ItemPrintout ) |         if( stack.getItem() instanceof ItemPrintout ) | ||||||
|         { |         { | ||||||
|             int light = itemFrameEntity.getType() == EntityType.GLOW_ITEM_FRAME ? 0xf000d2 : itemFrameEntityLight; // See getLightVal. |             int light = itemFrameEntity.getType() == EntityType.GLOW_ITEM_FRAME ? 0xf000d2 : itemFrameEntityLight; // See getLightVal. | ||||||
|             ItemPrintoutRenderer.INSTANCE.renderInFrame( matrixStack, vertexConsumerProvider, stack, light ); |             ItemPrintoutRenderer.INSTANCE.renderInFrame( matrixStack, vertexConsumerProvider, stack, light ); | ||||||
|             // TODO: need to find how to make if statement instead return, like it doing Forge |             // TODO: need to find how to make if statement instead return, like it doing Forge | ||||||
|             matrixStack.pop(); |             matrixStack.popPose(); | ||||||
|             info.cancel(); |             info.cancel(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ import com.google.common.collect.ImmutableMap; | |||||||
| import com.google.gson.JsonParseException; | import com.google.gson.JsonParseException; | ||||||
| import dan200.computercraft.shared.peripheral.generic.data.ItemData; | import dan200.computercraft.shared.peripheral.generic.data.ItemData; | ||||||
| import net.fabricmc.loader.api.FabricLoader; | import net.fabricmc.loader.api.FabricLoader; | ||||||
| import net.minecraft.util.Language; | import net.minecraft.locale.Language; | ||||||
| import org.apache.logging.log4j.Logger; | import org.apache.logging.log4j.Logger; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.Shadow; | import org.spongepowered.asm.mixin.Shadow; | ||||||
|   | |||||||
| @@ -5,8 +5,8 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
|  | import com.mojang.math.Matrix4f; | ||||||
| import dan200.computercraft.fabric.mixininterface.IMatrix4f; | import dan200.computercraft.fabric.mixininterface.IMatrix4f; | ||||||
| import net.minecraft.util.math.Matrix4f; |  | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.Shadow; | import org.spongepowered.asm.mixin.Shadow; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,15 +7,15 @@ package dan200.computercraft.fabric.mixin; | |||||||
|  |  | ||||||
| import dan200.computercraft.client.FrameInfo; | import dan200.computercraft.client.FrameInfo; | ||||||
| import dan200.computercraft.fabric.events.ClientUnloadWorldEvent; | import dan200.computercraft.fabric.events.ClientUnloadWorldEvent; | ||||||
| import net.minecraft.client.MinecraftClient; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.gui.screen.Screen; | import net.minecraft.client.gui.screens.Screen; | ||||||
| import net.minecraft.client.world.ClientWorld; | import net.minecraft.client.multiplayer.ClientLevel; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||||
|  |  | ||||||
| @Mixin( MinecraftClient.class ) | @Mixin( Minecraft.class ) | ||||||
| public abstract class MixinMinecraftClient | public abstract class MixinMinecraftClient | ||||||
| { | { | ||||||
|     @Inject( method = "render", at = @At( "HEAD" ) ) |     @Inject( method = "render", at = @At( "HEAD" ) ) | ||||||
| @@ -31,7 +31,7 @@ public abstract class MixinMinecraftClient | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Inject( method = "joinWorld", at = @At( "RETURN" ) ) |     @Inject( method = "joinWorld", at = @At( "RETURN" ) ) | ||||||
|     private void joinWorldAfter( ClientWorld world, CallbackInfo info ) |     private void joinWorldAfter( ClientLevel world, CallbackInfo info ) | ||||||
|     { |     { | ||||||
|         ClientUnloadWorldEvent.EVENT.invoker().onClientUnloadWorld(); |         ClientUnloadWorldEvent.EVENT.invoker().onClientUnloadWorld(); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ package dan200.computercraft.fabric.mixin; | |||||||
| import dan200.computercraft.shared.command.ClientCommands; | import dan200.computercraft.shared.command.ClientCommands; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.client.gui.screen.Screen; | import net.minecraft.client.gui.screens.Screen; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
|   | |||||||
| @@ -6,35 +6,35 @@ | |||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.ComputerCraftRegistry; | import dan200.computercraft.shared.ComputerCraftRegistry; | ||||||
| import net.minecraft.advancement.criterion.Criteria; | import net.minecraft.advancements.CriteriaTriggers; | ||||||
| import net.minecraft.block.BlockState; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.server.level.ServerPlayer; | ||||||
| import net.minecraft.server.network.ServerPlayerEntity; | import net.minecraft.server.level.ServerPlayerGameMode; | ||||||
| import net.minecraft.server.network.ServerPlayerInteractionManager; | import net.minecraft.world.InteractionHand; | ||||||
| import net.minecraft.util.ActionResult; | import net.minecraft.world.InteractionResult; | ||||||
| import net.minecraft.util.Hand; | import net.minecraft.world.item.ItemStack; | ||||||
| import net.minecraft.util.hit.BlockHitResult; | import net.minecraft.world.level.Level; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.world.level.block.state.BlockState; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.phys.BlockHitResult; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||||||
|  |  | ||||||
| @Mixin( ServerPlayerInteractionManager.class ) | @Mixin( ServerPlayerGameMode.class ) | ||||||
| public class MixinServerPlayerInteractionManager | public class MixinServerPlayerInteractionManager | ||||||
| { | { | ||||||
|     @Inject( at = @At( value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;copy()Lnet/minecraft/item/ItemStack;", ordinal = 0 ), method = "interactBlock(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;", cancellable = true ) |     @Inject( at = @At( value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;copy()Lnet/minecraft/item/ItemStack;", ordinal = 0 ), method = "interactBlock(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;", cancellable = true ) | ||||||
|     private void interact( ServerPlayerEntity player, World world, ItemStack stack, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir ) |     private void interact( ServerPlayer player, Level world, ItemStack stack, InteractionHand hand, BlockHitResult hitResult, CallbackInfoReturnable<InteractionResult> cir ) | ||||||
|     { |     { | ||||||
|         BlockPos pos = hitResult.getBlockPos(); |         BlockPos pos = hitResult.getBlockPos(); | ||||||
|         BlockState state = world.getBlockState( pos ); |         BlockState state = world.getBlockState( pos ); | ||||||
|         if( player.getMainHandStack().getItem() == ComputerCraftRegistry.ModItems.DISK && state.getBlock() == ComputerCraftRegistry.ModBlocks.DISK_DRIVE ) |         if( player.getMainHandItem().getItem() == ComputerCraftRegistry.ModItems.DISK && state.getBlock() == ComputerCraftRegistry.ModBlocks.DISK_DRIVE ) | ||||||
|         { |         { | ||||||
|             ActionResult actionResult = state.onUse( world, player, hand, hitResult ); |             InteractionResult actionResult = state.use( world, player, hand, hitResult ); | ||||||
|             if( actionResult.isAccepted() ) |             if( actionResult.consumesAction() ) | ||||||
|             { |             { | ||||||
|                 Criteria.ITEM_USED_ON_BLOCK.trigger( player, pos, stack ); |                 CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger( player, pos, stack ); | ||||||
|                 cir.setReturnValue( actionResult ); |                 cir.setReturnValue( actionResult ); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -6,8 +6,8 @@ | |||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.util.DropConsumer; | import dan200.computercraft.shared.util.DropConsumer; | ||||||
| import net.minecraft.entity.Entity; | import net.minecraft.server.level.ServerLevel; | ||||||
| import net.minecraft.server.world.ServerWorld; | import net.minecraft.world.entity.Entity; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| @@ -16,9 +16,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | |||||||
| /** | /** | ||||||
|  * Captures item stacks spawned into the world. |  * Captures item stacks spawned into the world. | ||||||
|  * |  * | ||||||
|  * @see ServerWorld#spawnEntity(Entity) |  * @see ServerLevel#addFreshEntity(Entity) | ||||||
|  */ |  */ | ||||||
| @Mixin( ServerWorld.class ) | @Mixin( ServerLevel.class ) | ||||||
| public class MixinServerWorld | public class MixinServerWorld | ||||||
| { | { | ||||||
|     @Inject( method = "spawnEntity", at = @At( "HEAD" ), cancellable = true ) |     @Inject( method = "spawnEntity", at = @At( "HEAD" ), cancellable = true ) | ||||||
|   | |||||||
| @@ -6,9 +6,6 @@ | |||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.common.TileGeneric; | import dan200.computercraft.shared.common.TileGeneric; | ||||||
| import net.minecraft.block.entity.BlockEntity; |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.Shadow; | import org.spongepowered.asm.mixin.Shadow; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| @@ -16,6 +13,9 @@ import org.spongepowered.asm.mixin.injection.Inject; | |||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
|  | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -23,7 +23,7 @@ import java.util.Collection; | |||||||
|  * |  * | ||||||
|  * Forge does this, this is just a bodge to get Fabric in line with that behaviour. |  * Forge does this, this is just a bodge to get Fabric in line with that behaviour. | ||||||
|  */ |  */ | ||||||
| @Mixin( World.class ) | @Mixin( Level.class ) | ||||||
| public class MixinWorld | public class MixinWorld | ||||||
| { | { | ||||||
|     @Shadow |     @Shadow | ||||||
| @@ -38,7 +38,7 @@ public class MixinWorld | |||||||
|     @Inject( method = "addBlockEntity", at = @At( "HEAD" ) ) |     @Inject( method = "addBlockEntity", at = @At( "HEAD" ) ) | ||||||
|     public void addBlockEntity( @Nullable BlockEntity entity, CallbackInfo info ) |     public void addBlockEntity( @Nullable BlockEntity entity, CallbackInfo info ) | ||||||
|     { |     { | ||||||
|         if( entity != null && !entity.isRemoved() && this.isInBuildLimit( entity.getPos() ) && iteratingTickingBlockEntities ) |         if( entity != null && !entity.isRemoved() && this.isInBuildLimit( entity.getBlockPos() ) && iteratingTickingBlockEntities ) | ||||||
|         { |         { | ||||||
|             setWorld( entity, this ); |             setWorld( entity, this ); | ||||||
|         } |         } | ||||||
| @@ -46,9 +46,9 @@ public class MixinWorld | |||||||
|  |  | ||||||
|     private static void setWorld( BlockEntity entity, Object world ) |     private static void setWorld( BlockEntity entity, Object world ) | ||||||
|     { |     { | ||||||
|         if( entity.getWorld() != world && entity instanceof TileGeneric ) |         if( entity.getLevel() != world && entity instanceof TileGeneric ) | ||||||
|         { |         { | ||||||
|             entity.setWorld( (World) world ); |             entity.setLevel( (Level) world ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,27 +5,27 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
|  | import com.mojang.blaze3d.vertex.PoseStack; | ||||||
|  | import com.mojang.blaze3d.vertex.VertexConsumer; | ||||||
| import dan200.computercraft.client.render.CableHighlightRenderer; | import dan200.computercraft.client.render.CableHighlightRenderer; | ||||||
| import dan200.computercraft.client.render.MonitorHighlightRenderer; | import dan200.computercraft.client.render.MonitorHighlightRenderer; | ||||||
| import net.fabricmc.api.EnvType; | import net.fabricmc.api.EnvType; | ||||||
| import net.fabricmc.api.Environment; | import net.fabricmc.api.Environment; | ||||||
| import net.minecraft.block.BlockState; | import net.minecraft.client.renderer.LevelRenderer; | ||||||
| import net.minecraft.client.render.VertexConsumer; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.client.render.WorldRenderer; | import net.minecraft.world.entity.Entity; | ||||||
| import net.minecraft.client.util.math.MatrixStack; | import net.minecraft.world.level.block.state.BlockState; | ||||||
| import net.minecraft.entity.Entity; |  | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.injection.At; | import org.spongepowered.asm.mixin.injection.At; | ||||||
| import org.spongepowered.asm.mixin.injection.Inject; | import org.spongepowered.asm.mixin.injection.Inject; | ||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||||
|  |  | ||||||
| @Mixin( WorldRenderer.class ) | @Mixin( LevelRenderer.class ) | ||||||
| @Environment( EnvType.CLIENT ) | @Environment( EnvType.CLIENT ) | ||||||
| public class MixinWorldRenderer | public class MixinWorldRenderer | ||||||
| { | { | ||||||
|     @Inject( method = "drawBlockOutline", cancellable = true, at = @At( "HEAD" ) ) |     @Inject( method = "drawBlockOutline", cancellable = true, at = @At( "HEAD" ) ) | ||||||
|     public void drawBlockOutline( MatrixStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos blockPos, |     public void drawBlockOutline( PoseStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos blockPos, | ||||||
|                                   BlockState blockState, CallbackInfo info ) |                                   BlockState blockState, CallbackInfo info ) | ||||||
|     { |     { | ||||||
|         if( CableHighlightRenderer.drawHighlight( matrixStack, |         if( CableHighlightRenderer.drawHighlight( matrixStack, | ||||||
|   | |||||||
| @@ -5,8 +5,8 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import net.minecraft.block.entity.SignBlockEntity; | import net.minecraft.network.chat.Component; | ||||||
| import net.minecraft.text.Text; | import net.minecraft.world.level.block.entity.SignBlockEntity; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.gen.Accessor; | import org.spongepowered.asm.mixin.gen.Accessor; | ||||||
|  |  | ||||||
| @@ -14,5 +14,5 @@ import org.spongepowered.asm.mixin.gen.Accessor; | |||||||
| public interface SignBlockEntityAccess | public interface SignBlockEntityAccess | ||||||
| { | { | ||||||
|     @Accessor |     @Accessor | ||||||
|     Text[] getTexts(); |     Component[] getTexts(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,15 +5,15 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.fabric.mixin; | package dan200.computercraft.fabric.mixin; | ||||||
|  |  | ||||||
| import net.minecraft.util.WorldSavePath; | import net.minecraft.world.level.storage.LevelResource; | ||||||
| import org.spongepowered.asm.mixin.Mixin; | import org.spongepowered.asm.mixin.Mixin; | ||||||
| import org.spongepowered.asm.mixin.gen.Invoker; | import org.spongepowered.asm.mixin.gen.Invoker; | ||||||
|  |  | ||||||
| @Mixin( WorldSavePath.class ) | @Mixin( LevelResource.class ) | ||||||
| public interface WorldSavePathAccess | public interface WorldSavePathAccess | ||||||
| { | { | ||||||
|     @Invoker( "<init>" ) |     @Invoker( "<init>" ) | ||||||
|     static WorldSavePath createWorldSavePath( String relativePath ) |     static LevelResource createWorldSavePath( String relativePath ) | ||||||
|     { |     { | ||||||
|         throw new UnsupportedOperationException(); |         throw new UnsupportedOperationException(); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,11 +9,10 @@ package dan200.computercraft.shared; | |||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.api.redstone.IBundledRedstoneProvider; | import dan200.computercraft.api.redstone.IBundledRedstoneProvider; | ||||||
| import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider; | import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider; | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
| @@ -29,20 +28,20 @@ public final class BundledRedstone | |||||||
|         if( !providers.contains( provider ) ) providers.add( provider ); |         if( !providers.contains( provider ) ) providers.add( provider ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static int getDefaultOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side ) |     public static int getDefaultOutput( @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side ) | ||||||
|     { |     { | ||||||
|         return world.isInBuildLimit( pos ) ? DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side ) : -1; |         return world.isInWorldBounds( pos ) ? DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side ) : -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static int getOutput( World world, BlockPos pos, Direction side ) |     public static int getOutput( Level world, BlockPos pos, Direction side ) | ||||||
|     { |     { | ||||||
|         int signal = getUnmaskedOutput( world, pos, side ); |         int signal = getUnmaskedOutput( world, pos, side ); | ||||||
|         return signal >= 0 ? signal : 0; |         return signal >= 0 ? signal : 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static int getUnmaskedOutput( World world, BlockPos pos, Direction side ) |     private static int getUnmaskedOutput( Level world, BlockPos pos, Direction side ) | ||||||
|     { |     { | ||||||
|         if( !world.isInBuildLimit( pos ) ) |         if( !world.isInWorldBounds( pos ) ) | ||||||
|         { |         { | ||||||
|             return -1; |             return -1; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -51,24 +51,28 @@ import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityT | |||||||
| import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; | import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; | ||||||
| import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; | import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; | ||||||
| import net.minecraft.block.*; | import net.minecraft.block.*; | ||||||
| import net.minecraft.block.entity.BlockEntity; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.block.entity.BlockEntityType; | import net.minecraft.core.Registry; | ||||||
| import net.minecraft.entity.EntityType; | import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraft.entity.SpawnGroup; | import net.minecraft.world.entity.EntityType; | ||||||
| import net.minecraft.item.BlockItem; | import net.minecraft.world.entity.MobCategory; | ||||||
| import net.minecraft.item.Item; | import net.minecraft.world.inventory.AbstractContainerMenu; | ||||||
| import net.minecraft.item.ItemGroup; | import net.minecraft.world.inventory.MenuType; | ||||||
| import net.minecraft.item.Items; | import net.minecraft.world.item.BlockItem; | ||||||
| import net.minecraft.screen.ScreenHandler; | import net.minecraft.world.item.CreativeModeTab; | ||||||
| import net.minecraft.screen.ScreenHandlerType; | import net.minecraft.world.item.Item; | ||||||
| import net.minecraft.sound.BlockSoundGroup; | import net.minecraft.world.item.Items; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.world.level.block.Block; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.world.level.block.Blocks; | ||||||
| import net.minecraft.util.registry.Registry; | import net.minecraft.world.level.block.SoundType; | ||||||
|  | import net.minecraft.world.level.block.entity.BlockEntity; | ||||||
|  | import net.minecraft.world.level.block.entity.BlockEntityType; | ||||||
|  | import net.minecraft.world.level.block.state.BlockBehaviour; | ||||||
|  | import net.minecraft.world.level.block.state.BlockState; | ||||||
|  | import net.minecraft.world.level.material.Material; | ||||||
| import java.util.function.BiFunction; | import java.util.function.BiFunction; | ||||||
|  |  | ||||||
| import static net.minecraft.util.registry.Registry.BLOCK_ENTITY_TYPE; | import static net.minecraft.core.Registry.BLOCK_ENTITY_TYPE; | ||||||
|  |  | ||||||
| public final class ComputerCraftRegistry | public final class ComputerCraftRegistry | ||||||
| { | { | ||||||
| @@ -122,10 +126,10 @@ public final class ComputerCraftRegistry | |||||||
|         { |         { | ||||||
|             //return FabricBlockSettings.copyOf(Blocks.GLASS) |             //return FabricBlockSettings.copyOf(Blocks.GLASS) | ||||||
|             //                        .strength(2); |             //                        .strength(2); | ||||||
|             return AbstractBlock.Settings.of( Material.GLASS ) |             return BlockBehaviour.Properties.of( Material.GLASS ) | ||||||
|                 .strength( 2F ) |                 .strength( 2F ) | ||||||
|                 .sounds( BlockSoundGroup.STONE ) |                 .sound( SoundType.STONE ) | ||||||
|                 .nonOpaque(); |                 .noOcclusion(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private static Block.Settings turtleProperties() |         private static Block.Settings turtleProperties() | ||||||
| @@ -144,7 +148,7 @@ public final class ComputerCraftRegistry | |||||||
|  |  | ||||||
|         public static <T extends Block> T register( String id, T value ) |         public static <T extends Block> T register( String id, T value ) | ||||||
|         { |         { | ||||||
|             return Registry.register( Registry.BLOCK, new Identifier( MOD_ID, id ), value ); |             return Registry.register( Registry.BLOCK, new ResourceLocation( MOD_ID, id ), value ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -194,7 +198,7 @@ public final class ComputerCraftRegistry | |||||||
|         { |         { | ||||||
|             BlockEntityType<T> blockEntityType = FabricBlockEntityTypeBuilder.create( factory::apply, block ).build(); |             BlockEntityType<T> blockEntityType = FabricBlockEntityTypeBuilder.create( factory::apply, block ).build(); | ||||||
|             return Registry.register( BLOCK_ENTITY_TYPE, |             return Registry.register( BLOCK_ENTITY_TYPE, | ||||||
|                 new Identifier( MOD_ID, id ), |                 new ResourceLocation( MOD_ID, id ), | ||||||
|                 blockEntityType |                 blockEntityType | ||||||
|             ); |             ); | ||||||
|         } |         } | ||||||
| @@ -202,22 +206,22 @@ public final class ComputerCraftRegistry | |||||||
|  |  | ||||||
|     public static final class ModItems |     public static final class ModItems | ||||||
|     { |     { | ||||||
|         private static final ItemGroup mainItemGroup = ComputerCraft.MAIN_GROUP; |         private static final CreativeModeTab mainItemGroup = ComputerCraft.MAIN_GROUP; | ||||||
|         public static final ItemComputer COMPUTER_NORMAL = ofBlock( ModBlocks.COMPUTER_NORMAL, ItemComputer::new ); |         public static final ItemComputer COMPUTER_NORMAL = ofBlock( ModBlocks.COMPUTER_NORMAL, ItemComputer::new ); | ||||||
|         public static final ItemComputer COMPUTER_ADVANCED = ofBlock( ModBlocks.COMPUTER_ADVANCED, ItemComputer::new ); |         public static final ItemComputer COMPUTER_ADVANCED = ofBlock( ModBlocks.COMPUTER_ADVANCED, ItemComputer::new ); | ||||||
|         public static final ItemComputer COMPUTER_COMMAND = ofBlock( ModBlocks.COMPUTER_COMMAND, ItemComputer::new ); |         public static final ItemComputer COMPUTER_COMMAND = ofBlock( ModBlocks.COMPUTER_COMMAND, ItemComputer::new ); | ||||||
|         public static final ItemPocketComputer POCKET_COMPUTER_NORMAL = register( "pocket_computer_normal", |         public static final ItemPocketComputer POCKET_COMPUTER_NORMAL = register( "pocket_computer_normal", | ||||||
|             new ItemPocketComputer( properties().maxCount( 1 ), ComputerFamily.NORMAL ) ); |             new ItemPocketComputer( properties().stacksTo( 1 ), ComputerFamily.NORMAL ) ); | ||||||
|         public static final ItemPocketComputer POCKET_COMPUTER_ADVANCED = register( "pocket_computer_advanced", |         public static final ItemPocketComputer POCKET_COMPUTER_ADVANCED = register( "pocket_computer_advanced", | ||||||
|             new ItemPocketComputer( properties().maxCount( 1 ), |             new ItemPocketComputer( properties().stacksTo( 1 ), | ||||||
|                 ComputerFamily.ADVANCED ) ); |                 ComputerFamily.ADVANCED ) ); | ||||||
|         public static final ItemTurtle TURTLE_NORMAL = ofBlock( ModBlocks.TURTLE_NORMAL, ItemTurtle::new ); |         public static final ItemTurtle TURTLE_NORMAL = ofBlock( ModBlocks.TURTLE_NORMAL, ItemTurtle::new ); | ||||||
|         public static final ItemTurtle TURTLE_ADVANCED = ofBlock( ModBlocks.TURTLE_ADVANCED, ItemTurtle::new ); |         public static final ItemTurtle TURTLE_ADVANCED = ofBlock( ModBlocks.TURTLE_ADVANCED, ItemTurtle::new ); | ||||||
|         public static final ItemDisk DISK = register( "disk", new ItemDisk( properties().maxCount( 1 ) ) ); |         public static final ItemDisk DISK = register( "disk", new ItemDisk( properties().stacksTo( 1 ) ) ); | ||||||
|         public static final ItemTreasureDisk TREASURE_DISK = register( "treasure_disk", new ItemTreasureDisk( properties().maxCount( 1 ) ) ); |         public static final ItemTreasureDisk TREASURE_DISK = register( "treasure_disk", new ItemTreasureDisk( properties().stacksTo( 1 ) ) ); | ||||||
|         public static final ItemPrintout PRINTED_PAGE = register( "printed_page", new ItemPrintout( properties().maxCount( 1 ), ItemPrintout.Type.PAGE ) ); |         public static final ItemPrintout PRINTED_PAGE = register( "printed_page", new ItemPrintout( properties().stacksTo( 1 ), ItemPrintout.Type.PAGE ) ); | ||||||
|         public static final ItemPrintout PRINTED_PAGES = register( "printed_pages", new ItemPrintout( properties().maxCount( 1 ), ItemPrintout.Type.PAGES ) ); |         public static final ItemPrintout PRINTED_PAGES = register( "printed_pages", new ItemPrintout( properties().stacksTo( 1 ), ItemPrintout.Type.PAGES ) ); | ||||||
|         public static final ItemPrintout PRINTED_BOOK = register( "printed_book", new ItemPrintout( properties().maxCount( 1 ), ItemPrintout.Type.BOOK ) ); |         public static final ItemPrintout PRINTED_BOOK = register( "printed_book", new ItemPrintout( properties().stacksTo( 1 ), ItemPrintout.Type.BOOK ) ); | ||||||
|         public static final BlockItem SPEAKER = ofBlock( ModBlocks.SPEAKER, BlockItem::new ); |         public static final BlockItem SPEAKER = ofBlock( ModBlocks.SPEAKER, BlockItem::new ); | ||||||
|         public static final BlockItem DISK_DRIVE = ofBlock( ModBlocks.DISK_DRIVE, BlockItem::new ); |         public static final BlockItem DISK_DRIVE = ofBlock( ModBlocks.DISK_DRIVE, BlockItem::new ); | ||||||
|         public static final BlockItem PRINTER = ofBlock( ModBlocks.PRINTER, BlockItem::new ); |         public static final BlockItem PRINTER = ofBlock( ModBlocks.PRINTER, BlockItem::new ); | ||||||
| @@ -229,29 +233,29 @@ public final class ComputerCraftRegistry | |||||||
|         public static final ItemBlockCable.Cable CABLE = register( "cable", new ItemBlockCable.Cable( ModBlocks.CABLE, properties() ) ); |         public static final ItemBlockCable.Cable CABLE = register( "cable", new ItemBlockCable.Cable( ModBlocks.CABLE, properties() ) ); | ||||||
|         public static final ItemBlockCable.WiredModem WIRED_MODEM = register( "wired_modem", new ItemBlockCable.WiredModem( ModBlocks.CABLE, properties() ) ); |         public static final ItemBlockCable.WiredModem WIRED_MODEM = register( "wired_modem", new ItemBlockCable.WiredModem( ModBlocks.CABLE, properties() ) ); | ||||||
|  |  | ||||||
|         private static <B extends Block, I extends Item> I ofBlock( B parent, BiFunction<B, Item.Settings, I> supplier ) |         private static <B extends Block, I extends Item> I ofBlock( B parent, BiFunction<B, Item.Properties, I> supplier ) | ||||||
|         { |         { | ||||||
|             return Registry.register( Registry.ITEM, Registry.BLOCK.getId( parent ), supplier.apply( parent, properties() ) ); |             return Registry.register( Registry.ITEM, Registry.BLOCK.getKey( parent ), supplier.apply( parent, properties() ) ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private static Item.Settings properties() |         private static Item.Properties properties() | ||||||
|         { |         { | ||||||
|             return new Item.Settings().group( mainItemGroup ); |             return new Item.Properties().tab( mainItemGroup ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private static <T extends Item> T register( String id, T item ) |         private static <T extends Item> T register( String id, T item ) | ||||||
|         { |         { | ||||||
|             return Registry.register( Registry.ITEM, new Identifier( MOD_ID, id ), item ); |             return Registry.register( Registry.ITEM, new ResourceLocation( MOD_ID, id ), item ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static class ModEntities |     public static class ModEntities | ||||||
|     { |     { | ||||||
|         public static final EntityType<TurtlePlayer> TURTLE_PLAYER = Registry.register( Registry.ENTITY_TYPE, |         public static final EntityType<TurtlePlayer> TURTLE_PLAYER = Registry.register( Registry.ENTITY_TYPE, | ||||||
|             new Identifier( MOD_ID, "turtle_player" ), |             new ResourceLocation( MOD_ID, "turtle_player" ), | ||||||
|             EntityType.Builder.<TurtlePlayer>create( SpawnGroup.MISC ).disableSaving() |             EntityType.Builder.<TurtlePlayer>createNothing( MobCategory.MISC ).noSave() | ||||||
|                 .disableSummon() |                 .noSummon() | ||||||
|                 .setDimensions( |                 .sized( | ||||||
|                     0, |                     0, | ||||||
|                     0 ) |                     0 ) | ||||||
|                 .build( |                 .build( | ||||||
| @@ -260,36 +264,36 @@ public final class ComputerCraftRegistry | |||||||
|  |  | ||||||
|     public static class ModContainers |     public static class ModContainers | ||||||
|     { |     { | ||||||
|         public static final ScreenHandlerType<ContainerComputerBase> COMPUTER = ContainerData.toType( new Identifier( MOD_ID, "computer" ), ModContainers.COMPUTER, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); |         public static final MenuType<ContainerComputerBase> COMPUTER = ContainerData.toType( new ResourceLocation( MOD_ID, "computer" ), ModContainers.COMPUTER, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); | ||||||
|         public static final ScreenHandlerType<ContainerComputerBase> POCKET_COMPUTER = ContainerData.toType( new Identifier( MOD_ID, "pocket_computer" ), ModContainers.POCKET_COMPUTER, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); |         public static final MenuType<ContainerComputerBase> POCKET_COMPUTER = ContainerData.toType( new ResourceLocation( MOD_ID, "pocket_computer" ), ModContainers.POCKET_COMPUTER, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); | ||||||
|         public static final ScreenHandlerType<ContainerComputerBase> POCKET_COMPUTER_NO_TERM = ContainerData.toType( new Identifier( MOD_ID, "pocket_computer_no_term" ), ModContainers.POCKET_COMPUTER_NO_TERM, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); |         public static final MenuType<ContainerComputerBase> POCKET_COMPUTER_NO_TERM = ContainerData.toType( new ResourceLocation( MOD_ID, "pocket_computer_no_term" ), ModContainers.POCKET_COMPUTER_NO_TERM, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); | ||||||
|         public static final ScreenHandlerType<ContainerTurtle> TURTLE = ContainerData.toType( new Identifier( MOD_ID, "turtle" ), ComputerContainerData::new, ContainerTurtle::new ); |         public static final MenuType<ContainerTurtle> TURTLE = ContainerData.toType( new ResourceLocation( MOD_ID, "turtle" ), ComputerContainerData::new, ContainerTurtle::new ); | ||||||
|         public static final ScreenHandlerType<ContainerDiskDrive> DISK_DRIVE = registerSimple( "disk_drive", ContainerDiskDrive::new ); |         public static final MenuType<ContainerDiskDrive> DISK_DRIVE = registerSimple( "disk_drive", ContainerDiskDrive::new ); | ||||||
|         public static final ScreenHandlerType<ContainerPrinter> PRINTER = registerSimple( "printer", ContainerPrinter::new ); |         public static final MenuType<ContainerPrinter> PRINTER = registerSimple( "printer", ContainerPrinter::new ); | ||||||
|         public static final ScreenHandlerType<ContainerHeldItem> PRINTOUT = ContainerData.toType( new Identifier( MOD_ID, "printout" ), HeldItemContainerData::new, ContainerHeldItem::createPrintout ); |         public static final MenuType<ContainerHeldItem> PRINTOUT = ContainerData.toType( new ResourceLocation( MOD_ID, "printout" ), HeldItemContainerData::new, ContainerHeldItem::createPrintout ); | ||||||
|         public static final ScreenHandlerType<ContainerViewComputer> VIEW_COMPUTER = ContainerData.toType( new Identifier( MOD_ID, "view_computer" ), ViewComputerContainerData::new, ContainerViewComputer::new ); |         public static final MenuType<ContainerViewComputer> VIEW_COMPUTER = ContainerData.toType( new ResourceLocation( MOD_ID, "view_computer" ), ViewComputerContainerData::new, ContainerViewComputer::new ); | ||||||
|  |  | ||||||
|         private static <T extends ScreenHandler> ScreenHandlerType<T> registerSimple( String id, |         private static <T extends AbstractContainerMenu> MenuType<T> registerSimple( String id, | ||||||
|                                                                                       ScreenHandlerRegistry.SimpleClientHandlerFactory<T> function ) |                                                                                       ScreenHandlerRegistry.SimpleClientHandlerFactory<T> function ) | ||||||
|         { |         { | ||||||
|             return ScreenHandlerRegistry.registerSimple( new Identifier( MOD_ID, id ), function ); |             return ScreenHandlerRegistry.registerSimple( new ResourceLocation( MOD_ID, id ), function ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static final class TurtleUpgrades |     public static final class TurtleUpgrades | ||||||
|     { |     { | ||||||
|         public static TurtleModem wirelessModemNormal = new TurtleModem( false, new Identifier( ComputerCraft.MOD_ID, "wireless_modem_normal" ) ); |         public static TurtleModem wirelessModemNormal = new TurtleModem( false, new ResourceLocation( ComputerCraft.MOD_ID, "wireless_modem_normal" ) ); | ||||||
|         public static TurtleModem wirelessModemAdvanced = new TurtleModem( true, new Identifier( ComputerCraft.MOD_ID, "wireless_modem_advanced" ) ); |         public static TurtleModem wirelessModemAdvanced = new TurtleModem( true, new ResourceLocation( ComputerCraft.MOD_ID, "wireless_modem_advanced" ) ); | ||||||
|         public static TurtleSpeaker speaker = new TurtleSpeaker( new Identifier( ComputerCraft.MOD_ID, "speaker" ) ); |         public static TurtleSpeaker speaker = new TurtleSpeaker( new ResourceLocation( ComputerCraft.MOD_ID, "speaker" ) ); | ||||||
|  |  | ||||||
|         public static TurtleCraftingTable craftingTable = new TurtleCraftingTable( new Identifier( "minecraft", "crafting_table" ) ); |         public static TurtleCraftingTable craftingTable = new TurtleCraftingTable( new ResourceLocation( "minecraft", "crafting_table" ) ); | ||||||
|         public static TurtleSword diamondSword = new TurtleSword( new Identifier( "minecraft", "diamond_sword" ), Items.DIAMOND_SWORD ); |         public static TurtleSword diamondSword = new TurtleSword( new ResourceLocation( "minecraft", "diamond_sword" ), Items.DIAMOND_SWORD ); | ||||||
|         public static TurtleShovel diamondShovel = new TurtleShovel( new Identifier( "minecraft", "diamond_shovel" ), Items.DIAMOND_SHOVEL ); |         public static TurtleShovel diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), Items.DIAMOND_SHOVEL ); | ||||||
|         public static TurtleTool diamondPickaxe = new TurtleTool( new Identifier( "minecraft", "diamond_pickaxe" ), Items.DIAMOND_PICKAXE ); |         public static TurtleTool diamondPickaxe = new TurtleTool( new ResourceLocation( "minecraft", "diamond_pickaxe" ), Items.DIAMOND_PICKAXE ); | ||||||
|         public static TurtleAxe diamondAxe = new TurtleAxe( new Identifier( "minecraft", "diamond_axe" ), Items.DIAMOND_AXE ); |         public static TurtleAxe diamondAxe = new TurtleAxe( new ResourceLocation( "minecraft", "diamond_axe" ), Items.DIAMOND_AXE ); | ||||||
|         public static TurtleHoe diamondHoe = new TurtleHoe( new Identifier( "minecraft", "diamond_hoe" ), Items.DIAMOND_HOE ); |         public static TurtleHoe diamondHoe = new TurtleHoe( new ResourceLocation( "minecraft", "diamond_hoe" ), Items.DIAMOND_HOE ); | ||||||
|  |  | ||||||
|         public static TurtleTool netheritePickaxe = new TurtleTool( new Identifier( "minecraft", "netherite_pickaxe" ), Items.NETHERITE_PICKAXE ); |         public static TurtleTool netheritePickaxe = new TurtleTool( new ResourceLocation( "minecraft", "netherite_pickaxe" ), Items.NETHERITE_PICKAXE ); | ||||||
|  |  | ||||||
|         public static void registerTurtleUpgrades() |         public static void registerTurtleUpgrades() | ||||||
|         { |         { | ||||||
|   | |||||||
| @@ -9,9 +9,8 @@ package dan200.computercraft.shared; | |||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.api.media.IMedia; | import dan200.computercraft.api.media.IMedia; | ||||||
| import dan200.computercraft.api.media.IMediaProvider; | import dan200.computercraft.api.media.IMediaProvider; | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
| import java.util.LinkedHashSet; | import java.util.LinkedHashSet; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
|   | |||||||
| @@ -10,12 +10,11 @@ import dan200.computercraft.ComputerCraft; | |||||||
| import dan200.computercraft.api.peripheral.IPeripheral; | import dan200.computercraft.api.peripheral.IPeripheral; | ||||||
| import dan200.computercraft.api.peripheral.IPeripheralProvider; | import dan200.computercraft.api.peripheral.IPeripheralProvider; | ||||||
| import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider; | import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider; | ||||||
| import net.minecraft.util.math.BlockPos; |  | ||||||
| import net.minecraft.util.math.Direction; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.core.BlockPos; | ||||||
|  | import net.minecraft.core.Direction; | ||||||
|  | import net.minecraft.world.level.Level; | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| import java.util.LinkedHashSet; | import java.util.LinkedHashSet; | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
| @@ -33,13 +32,13 @@ public final class Peripherals | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|     public static IPeripheral getPeripheral( World world, BlockPos pos, Direction side ) |     public static IPeripheral getPeripheral( Level world, BlockPos pos, Direction side ) | ||||||
|     { |     { | ||||||
|         return world.isInBuildLimit( pos ) && !world.isClient ? getPeripheralAt( world, pos, side ) : null; |         return world.isInWorldBounds( pos ) && !world.isClientSide ? getPeripheralAt( world, pos, side ) : null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|     private static IPeripheral getPeripheralAt( World world, BlockPos pos, Direction side ) |     private static IPeripheral getPeripheralAt( Level world, BlockPos pos, Direction side ) | ||||||
|     { |     { | ||||||
|         // Try the handlers in order: |         // Try the handlers in order: | ||||||
|         for( IPeripheralProvider peripheralProvider : providers ) |         for( IPeripheralProvider peripheralProvider : providers ) | ||||||
|   | |||||||
| @@ -9,9 +9,8 @@ import dan200.computercraft.api.pocket.IPocketUpgrade; | |||||||
| import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenCustomHashMap; | import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenCustomHashMap; | ||||||
| import net.fabricmc.loader.api.FabricLoader; | import net.fabricmc.loader.api.FabricLoader; | ||||||
| import net.fabricmc.loader.api.ModContainer; | import net.fabricmc.loader.api.ModContainer; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.Util; | ||||||
| import net.minecraft.util.Util; | import net.minecraft.world.item.ItemStack; | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
| import java.util.*; | import java.util.*; | ||||||
| @@ -19,7 +18,7 @@ import java.util.*; | |||||||
| public final class PocketUpgrades | public final class PocketUpgrades | ||||||
| { | { | ||||||
|     private static final Map<String, IPocketUpgrade> upgrades = new HashMap<>(); |     private static final Map<String, IPocketUpgrade> upgrades = new HashMap<>(); | ||||||
|     private static final Map<IPocketUpgrade, String> upgradeOwners = new Object2ObjectLinkedOpenCustomHashMap<>( Util.identityHashStrategy() ); |     private static final Map<IPocketUpgrade, String> upgradeOwners = new Object2ObjectLinkedOpenCustomHashMap<>( Util.identityStrategy() ); | ||||||
|  |  | ||||||
|     private PocketUpgrades() {} |     private PocketUpgrades() {} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,21 +5,21 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.shared; | package dan200.computercraft.shared; | ||||||
|  |  | ||||||
| import net.minecraft.entity.player.PlayerEntity; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.server.MinecraftServer; | import net.minecraft.server.MinecraftServer; | ||||||
| import net.minecraft.server.world.ServerWorld; | import net.minecraft.server.level.ServerLevel; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.world.entity.player.Player; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.level.Level; | ||||||
|  |  | ||||||
| public final class TurtlePermissions | public final class TurtlePermissions | ||||||
| { | { | ||||||
|     public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player ) |     public static boolean isBlockEnterable( Level world, BlockPos pos, Player player ) | ||||||
|     { |     { | ||||||
|         MinecraftServer server = world.getServer(); |         MinecraftServer server = world.getServer(); | ||||||
|         return server == null || world.isClient || world instanceof ServerWorld && !server.isSpawnProtected( (ServerWorld) world, pos, player ); |         return server == null || world.isClientSide || world instanceof ServerLevel && !server.isUnderSpawnProtection( (ServerLevel) world, pos, player ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean isBlockEditable( World world, BlockPos pos, PlayerEntity player ) |     public static boolean isBlockEditable( Level world, BlockPos pos, Player player ) | ||||||
|     { |     { | ||||||
|         return isBlockEnterable( world, pos, player ); |         return isBlockEnterable( world, pos, player ); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -8,10 +8,9 @@ package dan200.computercraft.shared; | |||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  | import net.minecraft.world.item.ItemStack; | ||||||
| import java.util.*; | import java.util.*; | ||||||
| import java.util.stream.Stream; | import java.util.stream.Stream; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,9 +6,8 @@ | |||||||
| package dan200.computercraft.shared.command; | package dan200.computercraft.shared.command; | ||||||
|  |  | ||||||
| import dan200.computercraft.shared.util.IDAssigner; | import dan200.computercraft.shared.util.IDAssigner; | ||||||
| import net.minecraft.util.Util; |  | ||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
|  | import net.minecraft.Util; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Basic client-side commands. |  * Basic client-side commands. | ||||||
| @@ -42,7 +41,7 @@ public final class ClientCommands | |||||||
|             File file = new File( IDAssigner.getDir(), "computer/" + id ); |             File file = new File( IDAssigner.getDir(), "computer/" + id ); | ||||||
|             if( !file.isDirectory() ) return true; |             if( !file.isDirectory() ) return true; | ||||||
|  |  | ||||||
|             Util.getOperatingSystem().open( file ); |             Util.getPlatform().openFile( file ); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|         return false; |         return false; | ||||||
|   | |||||||
| @@ -23,21 +23,20 @@ import dan200.computercraft.shared.computer.inventory.ContainerViewComputer; | |||||||
| import dan200.computercraft.shared.network.container.ViewComputerContainerData; | import dan200.computercraft.shared.network.container.ViewComputerContainerData; | ||||||
| import dan200.computercraft.shared.util.IDAssigner; | import dan200.computercraft.shared.util.IDAssigner; | ||||||
| import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory; | import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory; | ||||||
| import net.minecraft.entity.Entity; | import net.minecraft.commands.CommandSourceStack; | ||||||
| import net.minecraft.entity.player.PlayerEntity; | import net.minecraft.core.BlockPos; | ||||||
| import net.minecraft.entity.player.PlayerInventory; | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import net.minecraft.network.PacketByteBuf; | import net.minecraft.network.chat.MutableComponent; | ||||||
| import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket; | import net.minecraft.network.chat.TextComponent; | ||||||
| import net.minecraft.screen.ScreenHandler; | import net.minecraft.network.chat.TranslatableComponent; | ||||||
| import net.minecraft.server.command.ServerCommandSource; | import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket; | ||||||
| import net.minecraft.server.network.ServerPlayerEntity; | import net.minecraft.server.level.ServerLevel; | ||||||
| import net.minecraft.server.world.ServerWorld; | import net.minecraft.server.level.ServerPlayer; | ||||||
| import net.minecraft.text.LiteralText; | import net.minecraft.world.entity.Entity; | ||||||
| import net.minecraft.text.MutableText; | import net.minecraft.world.entity.player.Inventory; | ||||||
| import net.minecraft.text.TranslatableText; | import net.minecraft.world.entity.player.Player; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.world.inventory.AbstractContainerMenu; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.level.Level; | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.util.*; | import java.util.*; | ||||||
| @@ -52,7 +51,7 @@ import static dan200.computercraft.shared.command.builder.CommandBuilder.args; | |||||||
| import static dan200.computercraft.shared.command.builder.CommandBuilder.command; | import static dan200.computercraft.shared.command.builder.CommandBuilder.command; | ||||||
| import static dan200.computercraft.shared.command.builder.HelpingArgumentBuilder.choice; | import static dan200.computercraft.shared.command.builder.HelpingArgumentBuilder.choice; | ||||||
| import static dan200.computercraft.shared.command.text.ChatHelpers.*; | import static dan200.computercraft.shared.command.text.ChatHelpers.*; | ||||||
| import static net.minecraft.server.command.CommandManager.literal; | import static net.minecraft.commands.Commands.literal; | ||||||
|  |  | ||||||
| public final class CommandComputerCraft | public final class CommandComputerCraft | ||||||
| { | { | ||||||
| @@ -66,7 +65,7 @@ public final class CommandComputerCraft | |||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void register( CommandDispatcher<ServerCommandSource> dispatcher, Boolean dedicated ) |     public static void register( CommandDispatcher<CommandSourceStack> dispatcher, Boolean dedicated ) | ||||||
|     { |     { | ||||||
|         dispatcher.register( choice( "computercraft" ) |         dispatcher.register( choice( "computercraft" ) | ||||||
|             .then( literal( "dump" ) |             .then( literal( "dump" ) | ||||||
| @@ -74,17 +73,17 @@ public final class CommandComputerCraft | |||||||
|                 .executes( context -> { |                 .executes( context -> { | ||||||
|                     TableBuilder table = new TableBuilder( DUMP_LIST_ID, "Computer", "On", "Position" ); |                     TableBuilder table = new TableBuilder( DUMP_LIST_ID, "Computer", "On", "Position" ); | ||||||
|  |  | ||||||
|                     ServerCommandSource source = context.getSource(); |                     CommandSourceStack source = context.getSource(); | ||||||
|                     List<ServerComputer> computers = new ArrayList<>( ComputerCraft.serverComputerRegistry.getComputers() ); |                     List<ServerComputer> computers = new ArrayList<>( ComputerCraft.serverComputerRegistry.getComputers() ); | ||||||
|  |  | ||||||
|                     // Unless we're on a server, limit the number of rows we can send. |                     // Unless we're on a server, limit the number of rows we can send. | ||||||
|                     World world = source.getWorld(); |                     Level world = source.getLevel(); | ||||||
|                     BlockPos pos = new BlockPos( source.getPosition() ); |                     BlockPos pos = new BlockPos( source.getPosition() ); | ||||||
|  |  | ||||||
|                     computers.sort( ( a, b ) -> { |                     computers.sort( ( a, b ) -> { | ||||||
|                         if( a.getWorld() == b.getWorld() && a.getWorld() == world ) |                         if( a.getWorld() == b.getWorld() && a.getWorld() == world ) | ||||||
|                         { |                         { | ||||||
|                             return Double.compare( a.getPosition().getSquaredDistance( pos ), b.getPosition().getSquaredDistance( pos ) ); |                             return Double.compare( a.getPosition().distSqr( pos ), b.getPosition().distSqr( pos ) ); | ||||||
|                         } |                         } | ||||||
|                         else if( a.getWorld() == world ) |                         else if( a.getWorld() == world ) | ||||||
|                         { |                         { | ||||||
| @@ -148,7 +147,7 @@ public final class CommandComputerCraft | |||||||
|                         if( computer.isOn() ) shutdown++; |                         if( computer.isOn() ) shutdown++; | ||||||
|                         computer.shutdown(); |                         computer.shutdown(); | ||||||
|                     } |                     } | ||||||
|                     context.getSource().sendFeedback( translate( "commands.computercraft.shutdown.done", shutdown, computers.size() ), false ); |                     context.getSource().sendSuccess( translate( "commands.computercraft.shutdown.done", shutdown, computers.size() ), false ); | ||||||
|                     return shutdown; |                     return shutdown; | ||||||
|                 } ) ) |                 } ) ) | ||||||
|  |  | ||||||
| @@ -162,7 +161,7 @@ public final class CommandComputerCraft | |||||||
|                         if( !computer.isOn() ) on++; |                         if( !computer.isOn() ) on++; | ||||||
|                         computer.turnOn(); |                         computer.turnOn(); | ||||||
|                     } |                     } | ||||||
|                     context.getSource().sendFeedback( translate( "commands.computercraft.turn_on.done", on, computers.size() ), false ); |                     context.getSource().sendSuccess( translate( "commands.computercraft.turn_on.done", on, computers.size() ), false ); | ||||||
|                     return on; |                     return on; | ||||||
|                 } ) ) |                 } ) ) | ||||||
|  |  | ||||||
| @@ -171,25 +170,25 @@ public final class CommandComputerCraft | |||||||
|                 .arg( "computer", oneComputer() ) |                 .arg( "computer", oneComputer() ) | ||||||
|                 .executes( context -> { |                 .executes( context -> { | ||||||
|                     ServerComputer computer = getComputerArgument( context, "computer" ); |                     ServerComputer computer = getComputerArgument( context, "computer" ); | ||||||
|                     World world = computer.getWorld(); |                     Level world = computer.getWorld(); | ||||||
|                     BlockPos pos = computer.getPosition(); |                     BlockPos pos = computer.getPosition(); | ||||||
|  |  | ||||||
|                     if( world == null || pos == null ) throw TP_NOT_THERE.create(); |                     if( world == null || pos == null ) throw TP_NOT_THERE.create(); | ||||||
|  |  | ||||||
|                     Entity entity = context.getSource().getEntityOrThrow(); |                     Entity entity = context.getSource().getEntityOrException(); | ||||||
|                     if( !(entity instanceof ServerPlayerEntity) ) throw TP_NOT_PLAYER.create(); |                     if( !(entity instanceof ServerPlayer) ) throw TP_NOT_PLAYER.create(); | ||||||
|  |  | ||||||
|                     ServerPlayerEntity player = (ServerPlayerEntity) entity; |                     ServerPlayer player = (ServerPlayer) entity; | ||||||
|                     if( player.getEntityWorld() == world ) |                     if( player.getCommandSenderWorld() == world ) | ||||||
|                     { |                     { | ||||||
|                         player.networkHandler.requestTeleport( |                         player.connection.teleport( | ||||||
|                             pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0, |                             pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0, | ||||||
|                             EnumSet.noneOf( PlayerPositionLookS2CPacket.Flag.class ) |                             EnumSet.noneOf( ClientboundPlayerPositionPacket.RelativeArgument.class ) | ||||||
|                         ); |                         ); | ||||||
|                     } |                     } | ||||||
|                     else |                     else | ||||||
|                     { |                     { | ||||||
|                         player.teleport( (ServerWorld) world, |                         player.teleportTo( (ServerLevel) world, | ||||||
|                             pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0 |                             pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0 | ||||||
|                         ); |                         ); | ||||||
|                     } |                     } | ||||||
| @@ -222,28 +221,28 @@ public final class CommandComputerCraft | |||||||
|                 .requires( UserLevel.OP ) |                 .requires( UserLevel.OP ) | ||||||
|                 .arg( "computer", oneComputer() ) |                 .arg( "computer", oneComputer() ) | ||||||
|                 .executes( context -> { |                 .executes( context -> { | ||||||
|                     ServerPlayerEntity player = context.getSource().getPlayer(); |                     ServerPlayer player = context.getSource().getPlayerOrException(); | ||||||
|                     ServerComputer computer = getComputerArgument( context, "computer" ); |                     ServerComputer computer = getComputerArgument( context, "computer" ); | ||||||
|                     computer.sendTerminalState( player ); |                     computer.sendTerminalState( player ); | ||||||
|                     ViewComputerContainerData container = new ViewComputerContainerData( computer ); |                     ViewComputerContainerData container = new ViewComputerContainerData( computer ); | ||||||
|                     container.open( player, new ExtendedScreenHandlerFactory() |                     container.open( player, new ExtendedScreenHandlerFactory() | ||||||
|                     { |                     { | ||||||
|                         @Override |                         @Override | ||||||
|                         public void writeScreenOpeningData( ServerPlayerEntity player, PacketByteBuf buf ) |                         public void writeScreenOpeningData( ServerPlayer player, FriendlyByteBuf buf ) | ||||||
|                         { |                         { | ||||||
|                             container.toBytes( buf ); |                             container.toBytes( buf ); | ||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                         @Nonnull |                         @Nonnull | ||||||
|                         @Override |                         @Override | ||||||
|                         public MutableText getDisplayName() |                         public MutableComponent getDisplayName() | ||||||
|                         { |                         { | ||||||
|                             return new TranslatableText( "gui.computercraft.view_computer" ); |                             return new TranslatableComponent( "gui.computercraft.view_computer" ); | ||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                         @Nonnull |                         @Nonnull | ||||||
|                         @Override |                         @Override | ||||||
|                         public ScreenHandler createMenu( int id, @Nonnull PlayerInventory player, @Nonnull PlayerEntity entity ) |                         public AbstractContainerMenu createMenu( int id, @Nonnull Inventory player, @Nonnull Player entity ) | ||||||
|                         { |                         { | ||||||
|                             return new ContainerViewComputer( id, player, computer ); |                             return new ContainerViewComputer( id, player, computer ); | ||||||
|                         } |                         } | ||||||
| @@ -258,7 +257,7 @@ public final class CommandComputerCraft | |||||||
|                         getTimingContext( context.getSource() ).start(); |                         getTimingContext( context.getSource() ).start(); | ||||||
|  |  | ||||||
|                         String stopCommand = "/computercraft track stop"; |                         String stopCommand = "/computercraft track stop"; | ||||||
|                         context.getSource().sendFeedback( translate( "commands.computercraft.track.start.stop", |                         context.getSource().sendSuccess( translate( "commands.computercraft.track.start.stop", | ||||||
|                             link( text( stopCommand ), stopCommand, translate( "commands.computercraft.track.stop.action" ) ) ), false ); |                             link( text( stopCommand ), stopCommand, translate( "commands.computercraft.track.stop.action" ) ) ), false ); | ||||||
|                         return 1; |                         return 1; | ||||||
|                     } ) ) |                     } ) ) | ||||||
| @@ -292,9 +291,9 @@ public final class CommandComputerCraft | |||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static MutableText linkComputer( ServerCommandSource source, ServerComputer serverComputer, int computerId ) |     private static MutableComponent linkComputer( CommandSourceStack source, ServerComputer serverComputer, int computerId ) | ||||||
|     { |     { | ||||||
|         MutableText out = new LiteralText( "" ); |         MutableComponent out = new TextComponent( "" ); | ||||||
|  |  | ||||||
|         // Append the computer instance |         // Append the computer instance | ||||||
|         if( serverComputer == null ) |         if( serverComputer == null ) | ||||||
| @@ -333,14 +332,14 @@ public final class CommandComputerCraft | |||||||
|  |  | ||||||
|         if( UserLevel.OWNER.test( source ) && isPlayer( source ) ) |         if( UserLevel.OWNER.test( source ) && isPlayer( source ) ) | ||||||
|         { |         { | ||||||
|             MutableText linkPath = linkStorage( computerId ); |             MutableComponent linkPath = linkStorage( computerId ); | ||||||
|             if( linkPath != null ) out.append( " " ).append( linkPath ); |             if( linkPath != null ) out.append( " " ).append( linkPath ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return out; |         return out; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static MutableText linkPosition( ServerCommandSource context, ServerComputer computer ) |     private static MutableComponent linkPosition( CommandSourceStack context, ServerComputer computer ) | ||||||
|     { |     { | ||||||
|         if( UserLevel.OP.test( context ) ) |         if( UserLevel.OP.test( context ) ) | ||||||
|         { |         { | ||||||
| @@ -356,7 +355,7 @@ public final class CommandComputerCraft | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static MutableText linkStorage( int id ) |     private static MutableComponent linkStorage( int id ) | ||||||
|     { |     { | ||||||
|         File file = new File( IDAssigner.getDir(), "computer/" + id ); |         File file = new File( IDAssigner.getDir(), "computer/" + id ); | ||||||
|         if( !file.isDirectory() ) return null; |         if( !file.isDirectory() ) return null; | ||||||
| @@ -369,20 +368,20 @@ public final class CommandComputerCraft | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nonnull |     @Nonnull | ||||||
|     private static TrackingContext getTimingContext( ServerCommandSource source ) |     private static TrackingContext getTimingContext( CommandSourceStack source ) | ||||||
|     { |     { | ||||||
|         Entity entity = source.getEntity(); |         Entity entity = source.getEntity(); | ||||||
|         return entity instanceof PlayerEntity ? Tracking.getContext( entity.getUuid() ) : Tracking.getContext( SYSTEM_UUID ); |         return entity instanceof Player ? Tracking.getContext( entity.getUUID() ) : Tracking.getContext( SYSTEM_UUID ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static final List<TrackingField> DEFAULT_FIELDS = Arrays.asList( TrackingField.TASKS, TrackingField.TOTAL_TIME, TrackingField.AVERAGE_TIME, TrackingField.MAX_TIME ); |     private static final List<TrackingField> DEFAULT_FIELDS = Arrays.asList( TrackingField.TASKS, TrackingField.TOTAL_TIME, TrackingField.AVERAGE_TIME, TrackingField.MAX_TIME ); | ||||||
|  |  | ||||||
|     private static int displayTimings( ServerCommandSource source, TrackingField sortField, List<TrackingField> fields ) throws CommandSyntaxException |     private static int displayTimings( CommandSourceStack source, TrackingField sortField, List<TrackingField> fields ) throws CommandSyntaxException | ||||||
|     { |     { | ||||||
|         return displayTimings( source, getTimingContext( source ).getTimings(), sortField, fields ); |         return displayTimings( source, getTimingContext( source ).getTimings(), sortField, fields ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static int displayTimings( ServerCommandSource source, @Nonnull List<ComputerTracker> timings, @Nonnull TrackingField sortField, @Nonnull List<TrackingField> fields ) throws CommandSyntaxException |     private static int displayTimings( CommandSourceStack source, @Nonnull List<ComputerTracker> timings, @Nonnull TrackingField sortField, @Nonnull List<TrackingField> fields ) throws CommandSyntaxException | ||||||
|     { |     { | ||||||
|         if( timings.isEmpty() ) throw NO_TIMINGS_EXCEPTION.create(); |         if( timings.isEmpty() ) throw NO_TIMINGS_EXCEPTION.create(); | ||||||
|  |  | ||||||
| @@ -398,7 +397,7 @@ public final class CommandComputerCraft | |||||||
|  |  | ||||||
|         timings.sort( Comparator.<ComputerTracker, Long>comparing( x -> x.get( sortField ) ).reversed() ); |         timings.sort( Comparator.<ComputerTracker, Long>comparing( x -> x.get( sortField ) ).reversed() ); | ||||||
|  |  | ||||||
|         MutableText[] headers = new MutableText[1 + fields.size()]; |         MutableComponent[] headers = new MutableComponent[1 + fields.size()]; | ||||||
|         headers[0] = translate( "commands.computercraft.track.dump.computer" ); |         headers[0] = translate( "commands.computercraft.track.dump.computer" ); | ||||||
|         for( int i = 0; i < fields.size(); i++ ) headers[i + 1] = translate( fields.get( i ).translationKey() ); |         for( int i = 0; i < fields.size(); i++ ) headers[i + 1] = translate( fields.get( i ).translationKey() ); | ||||||
|         TableBuilder table = new TableBuilder( TRACK_ID, headers ); |         TableBuilder table = new TableBuilder( TRACK_ID, headers ); | ||||||
| @@ -408,9 +407,9 @@ public final class CommandComputerCraft | |||||||
|             Computer computer = entry.getComputer(); |             Computer computer = entry.getComputer(); | ||||||
|             ServerComputer serverComputer = computer == null ? null : lookup.get( computer ); |             ServerComputer serverComputer = computer == null ? null : lookup.get( computer ); | ||||||
|  |  | ||||||
|             MutableText computerComponent = linkComputer( source, serverComputer, entry.getComputerId() ); |             MutableComponent computerComponent = linkComputer( source, serverComputer, entry.getComputerId() ); | ||||||
|  |  | ||||||
|             MutableText[] row = new MutableText[1 + fields.size()]; |             MutableComponent[] row = new MutableComponent[1 + fields.size()]; | ||||||
|             row[0] = computerComponent; |             row[0] = computerComponent; | ||||||
|             for( int i = 0; i < fields.size(); i++ ) row[i + 1] = text( entry.getFormatted( fields.get( i ) ) ); |             for( int i = 0; i < fields.size(); i++ ) row[i + 1] = text( entry.getFormatted( fields.get( i ) ) ); | ||||||
|             table.row( row ); |             table.row( row ); | ||||||
|   | |||||||
| @@ -10,42 +10,41 @@ import com.mojang.brigadier.context.CommandContext; | |||||||
| import com.mojang.brigadier.suggestion.Suggestions; | import com.mojang.brigadier.suggestion.Suggestions; | ||||||
| import com.mojang.brigadier.suggestion.SuggestionsBuilder; | import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||||||
| import dan200.computercraft.api.turtle.FakePlayer; | import dan200.computercraft.api.turtle.FakePlayer; | ||||||
| import net.minecraft.command.CommandSource; |  | ||||||
| import net.minecraft.entity.Entity; |  | ||||||
| import net.minecraft.server.command.ServerCommandSource; |  | ||||||
| import net.minecraft.server.network.ServerPlayerEntity; |  | ||||||
|  |  | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| import java.util.Locale; | import java.util.Locale; | ||||||
| import java.util.concurrent.CompletableFuture; | import java.util.concurrent.CompletableFuture; | ||||||
| import java.util.function.Function; | import java.util.function.Function; | ||||||
|  | import net.minecraft.commands.CommandSourceStack; | ||||||
|  | import net.minecraft.commands.SharedSuggestionProvider; | ||||||
|  | import net.minecraft.server.level.ServerPlayer; | ||||||
|  | import net.minecraft.world.entity.Entity; | ||||||
|  |  | ||||||
| public final class CommandUtils | public final class CommandUtils | ||||||
| { | { | ||||||
|     private CommandUtils() {} |     private CommandUtils() {} | ||||||
|  |  | ||||||
|     public static boolean isPlayer( ServerCommandSource output ) |     public static boolean isPlayer( CommandSourceStack output ) | ||||||
|     { |     { | ||||||
|         Entity sender = output.getEntity(); |         Entity sender = output.getEntity(); | ||||||
|         return sender instanceof ServerPlayerEntity && !(sender instanceof FakePlayer) && ((ServerPlayerEntity) sender).networkHandler != null; |         return sender instanceof ServerPlayer && !(sender instanceof FakePlayer) && ((ServerPlayer) sender).connection != null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @SuppressWarnings( "unchecked" ) |     @SuppressWarnings( "unchecked" ) | ||||||
|     public static CompletableFuture<Suggestions> suggestOnServer( CommandContext<?> context, SuggestionsBuilder builder, |     public static CompletableFuture<Suggestions> suggestOnServer( CommandContext<?> context, SuggestionsBuilder builder, | ||||||
|                                                                   Function<CommandContext<ServerCommandSource>, CompletableFuture<Suggestions>> supplier ) |                                                                   Function<CommandContext<CommandSourceStack>, CompletableFuture<Suggestions>> supplier ) | ||||||
|     { |     { | ||||||
|         Object source = context.getSource(); |         Object source = context.getSource(); | ||||||
|         if( !(source instanceof CommandSource) ) |         if( !(source instanceof SharedSuggestionProvider) ) | ||||||
|         { |         { | ||||||
|             return Suggestions.empty(); |             return Suggestions.empty(); | ||||||
|         } |         } | ||||||
|         else if( source instanceof ServerCommandSource ) |         else if( source instanceof CommandSourceStack ) | ||||||
|         { |         { | ||||||
|             return supplier.apply( (CommandContext<ServerCommandSource>) context ); |             return supplier.apply( (CommandContext<CommandSourceStack>) context ); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             return ((CommandSource) source).getCompletions( (CommandContext<CommandSource>) context, builder ); |             return ((SharedSuggestionProvider) source).customSuggestion( (CommandContext<SharedSuggestionProvider>) context, builder ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ package dan200.computercraft.shared.command; | |||||||
| import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType; | import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType; | ||||||
| import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; | import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; | ||||||
| import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; | import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; | ||||||
| import net.minecraft.text.TranslatableText; | import net.minecraft.network.chat.TranslatableComponent; | ||||||
|  |  | ||||||
| public final class Exceptions | public final class Exceptions | ||||||
| { | { | ||||||
| @@ -25,16 +25,16 @@ public final class Exceptions | |||||||
|  |  | ||||||
|     private static SimpleCommandExceptionType translated( String key ) |     private static SimpleCommandExceptionType translated( String key ) | ||||||
|     { |     { | ||||||
|         return new SimpleCommandExceptionType( new TranslatableText( key ) ); |         return new SimpleCommandExceptionType( new TranslatableComponent( key ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static DynamicCommandExceptionType translated1( String key ) |     private static DynamicCommandExceptionType translated1( String key ) | ||||||
|     { |     { | ||||||
|         return new DynamicCommandExceptionType( x -> new TranslatableText( key, x ) ); |         return new DynamicCommandExceptionType( x -> new TranslatableComponent( key, x ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static Dynamic2CommandExceptionType translated2( String key ) |     private static Dynamic2CommandExceptionType translated2( String key ) | ||||||
|     { |     { | ||||||
|         return new Dynamic2CommandExceptionType( ( x, y ) -> new TranslatableText( key, x, y ) ); |         return new Dynamic2CommandExceptionType( ( x, y ) -> new TranslatableComponent( key, x, y ) ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,17 +5,16 @@ | |||||||
|  */ |  */ | ||||||
| package dan200.computercraft.shared.command; | package dan200.computercraft.shared.command; | ||||||
|  |  | ||||||
| import net.minecraft.entity.Entity; | import net.minecraft.commands.CommandSourceStack; | ||||||
| import net.minecraft.entity.player.PlayerEntity; |  | ||||||
| import net.minecraft.server.MinecraftServer; | import net.minecraft.server.MinecraftServer; | ||||||
| import net.minecraft.server.command.ServerCommandSource; | import net.minecraft.world.entity.Entity; | ||||||
|  | import net.minecraft.world.entity.player.Player; | ||||||
| import java.util.function.Predicate; | import java.util.function.Predicate; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * The level a user must be at in order to execute a command. |  * The level a user must be at in order to execute a command. | ||||||
|  */ |  */ | ||||||
| public enum UserLevel implements Predicate<ServerCommandSource> | public enum UserLevel implements Predicate<CommandSourceStack> | ||||||
| { | { | ||||||
|     /** |     /** | ||||||
|      * Only can be used by the owner of the server: namely the server console or the player in SSP. |      * Only can be used by the owner of the server: namely the server console or the player in SSP. | ||||||
| @@ -53,20 +52,20 @@ public enum UserLevel implements Predicate<ServerCommandSource> | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean test( ServerCommandSource source ) |     public boolean test( CommandSourceStack source ) | ||||||
|     { |     { | ||||||
|         if( this == ANYONE ) return true; |         if( this == ANYONE ) return true; | ||||||
|         if( this == OWNER ) return isOwner( source ); |         if( this == OWNER ) return isOwner( source ); | ||||||
|         if( this == OWNER_OP && isOwner( source ) ) return true; |         if( this == OWNER_OP && isOwner( source ) ) return true; | ||||||
|         return source.hasPermissionLevel( toLevel() ); |         return source.hasPermission( toLevel() ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static boolean isOwner( ServerCommandSource source ) |     private static boolean isOwner( CommandSourceStack source ) | ||||||
|     { |     { | ||||||
|         MinecraftServer server = source.getServer(); |         MinecraftServer server = source.getServer(); | ||||||
|         Entity sender = source.getEntity(); |         Entity sender = source.getEntity(); | ||||||
|         return server.isDedicated() |         return server.isDedicatedServer() | ||||||
|             ? source.getEntity() == null && source.hasPermissionLevel( 4 ) && source.getName().equals( "Server" ) |             ? source.getEntity() == null && source.hasPermission( 4 ) && source.getTextName().equals( "Server" ) | ||||||
|             : sender instanceof PlayerEntity && ((PlayerEntity) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ); |             : sender instanceof Player && ((Player) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -8,33 +8,33 @@ package dan200.computercraft.shared.command.arguments; | |||||||
|  |  | ||||||
| import com.mojang.brigadier.arguments.ArgumentType; | import com.mojang.brigadier.arguments.ArgumentType; | ||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import net.minecraft.command.argument.ArgumentTypes; | import net.minecraft.commands.synchronization.ArgumentSerializer; | ||||||
| import net.minecraft.command.argument.serialize.ArgumentSerializer; | import net.minecraft.commands.synchronization.ArgumentTypes; | ||||||
| import net.minecraft.command.argument.serialize.ConstantArgumentSerializer; | import net.minecraft.commands.synchronization.EmptyArgumentSerializer; | ||||||
| import net.minecraft.util.Identifier; | import net.minecraft.resources.ResourceLocation; | ||||||
|  |  | ||||||
| public final class ArgumentSerializers | public final class ArgumentSerializers | ||||||
| { | { | ||||||
|     public static void register() |     public static void register() | ||||||
|     { |     { | ||||||
|         register( new Identifier( ComputerCraft.MOD_ID, "tracking_field" ), TrackingFieldArgumentType.trackingField() ); |         register( new ResourceLocation( ComputerCraft.MOD_ID, "tracking_field" ), TrackingFieldArgumentType.trackingField() ); | ||||||
|         register( new Identifier( ComputerCraft.MOD_ID, "computer" ), ComputerArgumentType.oneComputer() ); |         register( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ), ComputerArgumentType.oneComputer() ); | ||||||
|         register( new Identifier( ComputerCraft.MOD_ID, "computers" ), ComputersArgumentType.class, new ComputersArgumentType.Serializer() ); |         register( new ResourceLocation( ComputerCraft.MOD_ID, "computers" ), ComputersArgumentType.class, new ComputersArgumentType.Serializer() ); | ||||||
|         registerUnsafe( new Identifier( ComputerCraft.MOD_ID, "repeat" ), RepeatArgumentType.class, new RepeatArgumentType.Serializer() ); |         registerUnsafe( new ResourceLocation( ComputerCraft.MOD_ID, "repeat" ), RepeatArgumentType.class, new RepeatArgumentType.Serializer() ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static <T extends ArgumentType<?>> void register( Identifier id, T instance ) |     private static <T extends ArgumentType<?>> void register( ResourceLocation id, T instance ) | ||||||
|     { |     { | ||||||
|         registerUnsafe( id, instance.getClass(), new ConstantArgumentSerializer<>( () -> instance ) ); |         registerUnsafe( id, instance.getClass(), new EmptyArgumentSerializer<>( () -> instance ) ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static <T extends ArgumentType<?>> void register( Identifier id, Class<T> type, ArgumentSerializer<T> serializer ) |     private static <T extends ArgumentType<?>> void register( ResourceLocation id, Class<T> type, ArgumentSerializer<T> serializer ) | ||||||
|     { |     { | ||||||
|         ArgumentTypes.register( id.toString(), type, serializer ); |         ArgumentTypes.register( id.toString(), type, serializer ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @SuppressWarnings( "unchecked" ) |     @SuppressWarnings( "unchecked" ) | ||||||
|     private static <T extends ArgumentType<?>> void registerUnsafe( Identifier id, Class<T> type, ArgumentSerializer<?> serializer ) |     private static <T extends ArgumentType<?>> void registerUnsafe( ResourceLocation id, Class<T> type, ArgumentSerializer<?> serializer ) | ||||||
|     { |     { | ||||||
|         ArgumentTypes.register( id.toString(), type, (ArgumentSerializer<T>) serializer ); |         ArgumentTypes.register( id.toString(), type, (ArgumentSerializer<T>) serializer ); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -14,10 +14,9 @@ import com.mojang.brigadier.suggestion.Suggestions; | |||||||
| import com.mojang.brigadier.suggestion.SuggestionsBuilder; | import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||||||
| import dan200.computercraft.shared.command.arguments.ComputersArgumentType.ComputersSupplier; | import dan200.computercraft.shared.command.arguments.ComputersArgumentType.ComputersSupplier; | ||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import net.minecraft.server.command.ServerCommandSource; |  | ||||||
|  |  | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| import java.util.concurrent.CompletableFuture; | import java.util.concurrent.CompletableFuture; | ||||||
|  | import net.minecraft.commands.CommandSourceStack; | ||||||
|  |  | ||||||
| import static dan200.computercraft.shared.command.Exceptions.COMPUTER_ARG_MANY; | import static dan200.computercraft.shared.command.Exceptions.COMPUTER_ARG_MANY; | ||||||
|  |  | ||||||
| @@ -34,7 +33,7 @@ public final class ComputerArgumentType implements ArgumentType<ComputerArgument | |||||||
|         return INSTANCE; |         return INSTANCE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static ServerComputer getComputerArgument( CommandContext<ServerCommandSource> context, String name ) throws CommandSyntaxException |     public static ServerComputer getComputerArgument( CommandContext<CommandSourceStack> context, String name ) throws CommandSyntaxException | ||||||
|     { |     { | ||||||
|         return context.getArgument( name, ComputerSupplier.class ) |         return context.getArgument( name, ComputerSupplier.class ) | ||||||
|             .unwrap( context.getSource() ); |             .unwrap( context.getSource() ); | ||||||
| @@ -98,6 +97,6 @@ public final class ComputerArgumentType implements ArgumentType<ComputerArgument | |||||||
|     @FunctionalInterface |     @FunctionalInterface | ||||||
|     public interface ComputerSupplier |     public interface ComputerSupplier | ||||||
|     { |     { | ||||||
|         ServerComputer unwrap( ServerCommandSource source ) throws CommandSyntaxException; |         ServerComputer unwrap( CommandSourceStack source ) throws CommandSyntaxException; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -16,11 +16,10 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; | |||||||
| import dan200.computercraft.ComputerCraft; | import dan200.computercraft.ComputerCraft; | ||||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | import dan200.computercraft.shared.computer.core.ServerComputer; | ||||||
| import net.minecraft.command.argument.serialize.ArgumentSerializer; |  | ||||||
| import net.minecraft.network.PacketByteBuf; |  | ||||||
| import net.minecraft.server.command.ServerCommandSource; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nonnull; | import javax.annotation.Nonnull; | ||||||
|  | import net.minecraft.commands.CommandSourceStack; | ||||||
|  | import net.minecraft.commands.synchronization.ArgumentSerializer; | ||||||
|  | import net.minecraft.network.FriendlyByteBuf; | ||||||
| import java.util.*; | import java.util.*; | ||||||
| import java.util.concurrent.CompletableFuture; | import java.util.concurrent.CompletableFuture; | ||||||
| import java.util.function.Function; | import java.util.function.Function; | ||||||
| @@ -54,13 +53,13 @@ public final class ComputersArgumentType implements ArgumentType<ComputersArgume | |||||||
|         return SOME; |         return SOME; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static Collection<ServerComputer> getComputersArgument( CommandContext<ServerCommandSource> context, String name ) throws CommandSyntaxException |     public static Collection<ServerComputer> getComputersArgument( CommandContext<CommandSourceStack> context, String name ) throws CommandSyntaxException | ||||||
|     { |     { | ||||||
|         return context.getArgument( name, ComputersSupplier.class ) |         return context.getArgument( name, ComputersSupplier.class ) | ||||||
|             .unwrap( context.getSource() ); |             .unwrap( context.getSource() ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static Set<ServerComputer> unwrap( ServerCommandSource source, Collection<ComputersSupplier> suppliers ) throws CommandSyntaxException |     public static Set<ServerComputer> unwrap( CommandSourceStack source, Collection<ComputersSupplier> suppliers ) throws CommandSyntaxException | ||||||
|     { |     { | ||||||
|         Set<ServerComputer> computers = new HashSet<>(); |         Set<ServerComputer> computers = new HashSet<>(); | ||||||
|         for( ComputersSupplier supplier : suppliers ) |         for( ComputersSupplier supplier : suppliers ) | ||||||
| @@ -188,21 +187,21 @@ public final class ComputersArgumentType implements ArgumentType<ComputersArgume | |||||||
|     @FunctionalInterface |     @FunctionalInterface | ||||||
|     public interface ComputersSupplier |     public interface ComputersSupplier | ||||||
|     { |     { | ||||||
|         Collection<ServerComputer> unwrap( ServerCommandSource source ) throws CommandSyntaxException; |         Collection<ServerComputer> unwrap( CommandSourceStack source ) throws CommandSyntaxException; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static class Serializer implements ArgumentSerializer<ComputersArgumentType> |     public static class Serializer implements ArgumentSerializer<ComputersArgumentType> | ||||||
|     { |     { | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void toPacket( @Nonnull ComputersArgumentType arg, @Nonnull PacketByteBuf buf ) |         public void toPacket( @Nonnull ComputersArgumentType arg, @Nonnull FriendlyByteBuf buf ) | ||||||
|         { |         { | ||||||
|             buf.writeBoolean( arg.requireSome ); |             buf.writeBoolean( arg.requireSome ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Nonnull |         @Nonnull | ||||||
|         @Override |         @Override | ||||||
|         public ComputersArgumentType fromPacket( @Nonnull PacketByteBuf buf ) |         public ComputersArgumentType deserializeFromNetwork( @Nonnull FriendlyByteBuf buf ) | ||||||
|         { |         { | ||||||
|             return buf.readBoolean() ? SOME : MANY; |             return buf.readBoolean() ? SOME : MANY; | ||||||
|         } |         } | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 Merith
					Merith