diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index db6432f99..6d338db7b 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -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... 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 item : items ) { - FabricModelPredicateProviderRegistry.register( item.get(), id, getter ); + FabricModelPredicateProviderRegistry.register( item.get(), id, unclampedGetter ); } } } diff --git a/src/main/java/dan200/computercraft/fabric/mixin/MixinChunkMap.java b/src/main/java/dan200/computercraft/fabric/mixin/MixinChunkMap.java index c8f35a5ec..99021a333 100644 --- a/src/main/java/dan200/computercraft/fabric/mixin/MixinChunkMap.java +++ b/src/main/java/dan200/computercraft/fabric/mixin/MixinChunkMap.java @@ -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 mutableObject, LevelChunk levelChunk, CallbackInfo ci ) { - MonitorWatcher.onWatch( serverPlayer, levelChunk.getPos() ); + ComputerCraftCustomEvents.SERVER_PLAYER_LOADED_CHUNK_EVENT.invoker().onServerPlayerLoadedChunk( serverPlayer, levelChunk.getPos() ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java index 4f082b0f6..be13b55d3 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java @@ -145,49 +145,24 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile width = nbt.getInt( NBT_WIDTH ); height = nbt.getInt( NBT_HEIGHT ); - if( oldXIndex != xIndex || oldYIndex != yIndex ) + if( level != null && level.isClientSide ) { - // 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( 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 ); + if( xIndex == 0 && yIndex == 0 ) + { + // If we're the origin terminal then create it. + 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() { diff --git a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java index 5e875d045..53091c367 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java @@ -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(); diff --git a/src/main/resources/assets/computercraft/textures/item/pocket_computer_advanced.png b/src/main/resources/assets/computercraft/textures/item/pocket_computer_advanced.png index 96015e297..c84346a2c 100644 Binary files a/src/main/resources/assets/computercraft/textures/item/pocket_computer_advanced.png and b/src/main/resources/assets/computercraft/textures/item/pocket_computer_advanced.png differ diff --git a/src/main/resources/assets/computercraft/textures/item/pocket_computer_blink.png b/src/main/resources/assets/computercraft/textures/item/pocket_computer_blink.png index 2474f6baf..53d89614e 100644 Binary files a/src/main/resources/assets/computercraft/textures/item/pocket_computer_blink.png and b/src/main/resources/assets/computercraft/textures/item/pocket_computer_blink.png differ diff --git a/src/main/resources/assets/computercraft/textures/item/pocket_computer_colour.png b/src/main/resources/assets/computercraft/textures/item/pocket_computer_colour.png index 426015e6c..dd3c350eb 100644 Binary files a/src/main/resources/assets/computercraft/textures/item/pocket_computer_colour.png and b/src/main/resources/assets/computercraft/textures/item/pocket_computer_colour.png differ diff --git a/src/main/resources/assets/computercraft/textures/item/pocket_computer_frame.png b/src/main/resources/assets/computercraft/textures/item/pocket_computer_frame.png index 1f27b7ea9..ae5a70a12 100644 Binary files a/src/main/resources/assets/computercraft/textures/item/pocket_computer_frame.png and b/src/main/resources/assets/computercraft/textures/item/pocket_computer_frame.png differ diff --git a/src/main/resources/assets/computercraft/textures/item/pocket_computer_light.png b/src/main/resources/assets/computercraft/textures/item/pocket_computer_light.png index 52f186fc7..8414ee5ee 100644 Binary files a/src/main/resources/assets/computercraft/textures/item/pocket_computer_light.png and b/src/main/resources/assets/computercraft/textures/item/pocket_computer_light.png differ diff --git a/src/main/resources/assets/computercraft/textures/item/pocket_computer_normal.png b/src/main/resources/assets/computercraft/textures/item/pocket_computer_normal.png index 0ee14134b..33b09b696 100644 Binary files a/src/main/resources/assets/computercraft/textures/item/pocket_computer_normal.png and b/src/main/resources/assets/computercraft/textures/item/pocket_computer_normal.png differ diff --git a/src/main/resources/assets/computercraft/textures/item/pocket_computer_on.png b/src/main/resources/assets/computercraft/textures/item/pocket_computer_on.png index c0d3956bb..bb3de3e94 100644 Binary files a/src/main/resources/assets/computercraft/textures/item/pocket_computer_on.png and b/src/main/resources/assets/computercraft/textures/item/pocket_computer_on.png differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1108f0a72..de8a23f3a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "computercraft", - "name": "CC:Restitched", + "name": "CC: Restitched", "version": "${version}", "description": "CC: Tweaked for Fabric.", "license": "ComputerCraft Public License", @@ -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": "*" diff --git a/src/main/resources/resourcepacks/classic/pack.mcmeta b/src/main/resources/resourcepacks/classic/pack.mcmeta index 0450878b5..d3b795543 100644 --- a/src/main/resources/resourcepacks/classic/pack.mcmeta +++ b/src/main/resources/resourcepacks/classic/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 7, - "description": "The clasic look of ComputerCraft" + "pack_format": 8, + "description": "The classic look of ComputerCraft." } }