Merge branch 'mc-1.18.x/stable' into mc-1.18.x/dev
| @@ -24,7 +24,6 @@ import dan200.computercraft.shared.computer.inventory.ContainerComputerBase; | ||||
| import dan200.computercraft.shared.computer.inventory.ContainerViewComputer; | ||||
| import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive; | ||||
| import dan200.computercraft.shared.peripheral.monitor.ClientMonitor; | ||||
| import dan200.computercraft.shared.peripheral.monitor.MonitorWatcher; | ||||
| import dan200.computercraft.shared.peripheral.printer.ContainerPrinter; | ||||
| import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | ||||
| import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; | ||||
| @@ -43,11 +42,16 @@ import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; | ||||
| import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; | ||||
| import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; | ||||
| import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry; | ||||
| import net.minecraft.client.multiplayer.ClientLevel; | ||||
| import net.minecraft.client.renderer.RenderType; | ||||
| import net.minecraft.client.renderer.item.ClampedItemPropertyFunction; | ||||
| import net.minecraft.resources.ResourceLocation; | ||||
| import net.minecraft.world.entity.LivingEntity; | ||||
| import net.minecraft.world.inventory.InventoryMenu; | ||||
| import net.minecraft.world.item.Item; | ||||
| import net.minecraft.world.item.ItemStack; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
| import org.jetbrains.annotations.Nullable; | ||||
|  | ||||
| import java.util.function.Supplier; | ||||
|  | ||||
| @@ -81,7 +85,6 @@ public final class ComputerCraftProxyClient implements ClientModInitializer | ||||
|     public void onInitializeClient() | ||||
|     { | ||||
|         FrameInfo.init(); | ||||
|         MonitorWatcher.init(); | ||||
|         registerContainers(); | ||||
|  | ||||
|         // While turtles themselves are not transparent, their upgrades may be. | ||||
| @@ -111,7 +114,7 @@ public final class ComputerCraftProxyClient implements ClientModInitializer | ||||
|                 .ordinal(), | ||||
|             () -> Registry.ModItems.POCKET_COMPUTER_NORMAL, | ||||
|             () -> Registry.ModItems.POCKET_COMPUTER_ADVANCED ); | ||||
|         registerItemProperty( "state", | ||||
|         registerItemProperty( "coloured", | ||||
|             ( stack, world, player, integer ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0, | ||||
|             () -> Registry.ModItems.POCKET_COMPUTER_NORMAL, | ||||
|             () -> Registry.ModItems.POCKET_COMPUTER_ADVANCED ); | ||||
| @@ -142,9 +145,25 @@ public final class ComputerCraftProxyClient implements ClientModInitializer | ||||
|     private static void registerItemProperty( String name, ClampedItemPropertyFunction getter, Supplier<? extends Item>... items ) | ||||
|     { | ||||
|         ResourceLocation id = new ResourceLocation( ComputerCraft.MOD_ID, name ); | ||||
|         // Terrible hack, but some of our properties return values greater than 1, so we don't want to clamp. | ||||
|         var unclampedGetter = new ClampedItemPropertyFunction() | ||||
|         { | ||||
|             @Override | ||||
|             @Deprecated | ||||
|             public float call( @NotNull ItemStack itemStack, @Nullable ClientLevel clientLevel, @Nullable LivingEntity livingEntity, int i ) | ||||
|             { | ||||
|                 return getter.unclampedCall( itemStack, clientLevel, livingEntity, i ); | ||||
|             } | ||||
|  | ||||
|             @Override | ||||
|             public float unclampedCall( ItemStack itemStack, @Nullable ClientLevel clientLevel, @Nullable LivingEntity livingEntity, int i ) | ||||
|             { | ||||
|                 return getter.unclampedCall( itemStack, clientLevel, livingEntity, i ); | ||||
|             } | ||||
|         }; | ||||
|         for( Supplier<? extends Item> item : items ) | ||||
|         { | ||||
|             FabricModelPredicateProviderRegistry.register( item.get(), id, getter ); | ||||
|             FabricModelPredicateProviderRegistry.register( item.get(), id, unclampedGetter ); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
|  */ | ||||
| package dan200.computercraft.fabric.mixin; | ||||
|  | ||||
| import dan200.computercraft.shared.peripheral.monitor.MonitorWatcher; | ||||
| import dan200.computercraft.fabric.events.ComputerCraftCustomEvents; | ||||
| import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; | ||||
| import net.minecraft.server.level.ChunkMap; | ||||
| import net.minecraft.server.level.ServerLevel; | ||||
| @@ -46,7 +46,7 @@ public class MixinChunkMap | ||||
|     @Inject( method = "playerLoadedChunk", at = @At( value = "HEAD" ) ) | ||||
|     private void playerLoadedChunk( ServerPlayer serverPlayer, MutableObject<ClientboundLevelChunkWithLightPacket> mutableObject, LevelChunk levelChunk, CallbackInfo ci ) | ||||
|     { | ||||
|         MonitorWatcher.onWatch( serverPlayer, levelChunk.getPos() ); | ||||
|         ComputerCraftCustomEvents.SERVER_PLAYER_LOADED_CHUNK_EVENT.invoker().onServerPlayerLoadedChunk( serverPlayer, levelChunk.getPos() ); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -145,6 +145,8 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile | ||||
|         width = nbt.getInt( NBT_WIDTH ); | ||||
|         height = nbt.getInt( NBT_HEIGHT ); | ||||
|  | ||||
|         if( level != null && level.isClientSide ) | ||||
|         { | ||||
|             if( oldXIndex != xIndex || oldYIndex != yIndex ) | ||||
|             { | ||||
|                 // If our index has changed then it's possible the origin monitor has changed. Thus | ||||
| @@ -159,34 +161,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile | ||||
|                 if( clientMonitor == null ) clientMonitor = new ClientMonitor( advanced, this ); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     //    @Override | ||||
|     //    public final void handleUpdateTag( @Nonnull CompoundTag nbt ) | ||||
|     //    { | ||||
|     //        super.handleUpdateTag( nbt ); | ||||
|     // | ||||
|     //        int oldXIndex = xIndex; | ||||
|     //        int oldYIndex = yIndex; | ||||
|     // | ||||
|     //        xIndex = nbt.getInt( NBT_X ); | ||||
|     //        yIndex = nbt.getInt( NBT_Y ); | ||||
|     //        width = nbt.getInt( NBT_WIDTH ); | ||||
|     //        height = nbt.getInt( NBT_HEIGHT ); | ||||
|     // | ||||
|     //        if( oldXIndex != xIndex || oldYIndex != yIndex ) | ||||
|     //        { | ||||
|     //            // If our index has changed then it's possible the origin monitor has changed. Thus | ||||
|     //            // we'll clear our cache. If we're the origin then we'll need to remove the glList as well. | ||||
|     //            if( oldXIndex == 0 && oldYIndex == 0 && clientMonitor != null ) clientMonitor.destroy(); | ||||
|     //            clientMonitor = null; | ||||
|     //        } | ||||
|     // | ||||
|     //        if( xIndex == 0 && yIndex == 0 ) | ||||
|     //        { | ||||
|     //            // If we're the origin terminal then create it. | ||||
|     //            if( clientMonitor == null ) clientMonitor = new ClientMonitor( advanced, this ); | ||||
|     //        } | ||||
|     //    } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void blockTick() | ||||
|   | ||||
| @@ -27,6 +27,7 @@ import dan200.computercraft.shared.peripheral.commandblock.CommandBlockPeriphera | ||||
| import dan200.computercraft.shared.peripheral.generic.methods.InventoryMethods; | ||||
| import dan200.computercraft.shared.peripheral.modem.wired.BlockCable; | ||||
| import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork; | ||||
| import dan200.computercraft.shared.peripheral.monitor.MonitorWatcher; | ||||
| import dan200.computercraft.shared.turtle.FurnaceRefuelHandler; | ||||
| import dan200.computercraft.shared.util.Config; | ||||
| import dan200.computercraft.shared.util.TickScheduler; | ||||
| @@ -51,6 +52,7 @@ public final class ComputerCraftProxyCommon | ||||
|     public static void init() | ||||
|     { | ||||
|         NetworkHandler.setup(); | ||||
|         MonitorWatcher.init(); | ||||
|  | ||||
|         registerProviders(); | ||||
|         registerHandlers(); | ||||
|   | ||||
| Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 668 B | 
| Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 624 B | 
| Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 614 B | 
| Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 548 B | 
| Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 484 B | 
| Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 656 B | 
| Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 583 B | 
| @@ -20,9 +20,9 @@ | ||||
| 		"Toad-Dev" | ||||
|     ], | ||||
|     "depends": { | ||||
|         "fabricloader": ">=0.11.3", | ||||
|         "fabric": "*", | ||||
|         "minecraft": "1.18.1" | ||||
|         "minecraft": "1.18.x", | ||||
|         "fabricloader": ">=0.12.9", | ||||
|         "fabric": "*" | ||||
|     }, | ||||
|     "suggests": { | ||||
|         "modmenu": "*" | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
| 	"pack": { | ||||
| 		"pack_format": 7, | ||||
| 		"description": "The clasic look of ComputerCraft" | ||||
| 		"pack_format": 8, | ||||
| 		"description": "The classic look of ComputerCraft." | ||||
| 	} | ||||
| } | ||||
|   | ||||
 Toad-Dev
					Toad-Dev