From 190a1102966b4a7d40be590bf66f599607f78836 Mon Sep 17 00:00:00 2001 From: Toad-Dev <748280+toad-dev@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:19:30 -0800 Subject: [PATCH 1/4] Update classic resource pack.mcmeta. Gets rid of "pack made for old version of MC" warning. --- src/main/resources/resourcepacks/classic/pack.mcmeta | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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." } } From 57cfcd87096ae6f3b9b1aaa6f962f4e457219254 Mon Sep 17 00:00:00 2001 From: Toad-Dev <748280+toad-dev@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:50:15 -0800 Subject: [PATCH 2/4] Don't hard depend on 1.18.1 It looks like other big mods are not fussed about forcing users over to 1.18.1. Since fabric loader 0.12.9 addresses the log4j issue we will depend on that instead to help push users to safe configurations. Everyone should be able to update their loader version, right? --- src/main/resources/fabric.mod.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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": "*" From cc08eced48744dcf0e61cb051f782d100ec62218 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sun, 19 Dec 2021 13:04:19 +0000 Subject: [PATCH 3/4] Fix some problems with pocket computer model properties - We were setting state twice, rather than state and coloured. - Fabric forces us to use the clamped item property getter, which doesn't work with our computer state, as it takes a value [0, 2]. - Fixup new pocket computer textures to match original ones. Co-authored-by: Jummit --- .../proxy/ComputerCraftProxyClient.java | 25 ++++++++++++++++-- .../item/pocket_computer_advanced.png | Bin 283 -> 668 bytes .../textures/item/pocket_computer_blink.png | Bin 249 -> 624 bytes .../textures/item/pocket_computer_colour.png | Bin 196 -> 614 bytes .../textures/item/pocket_computer_frame.png | Bin 125 -> 548 bytes .../textures/item/pocket_computer_light.png | Bin 246 -> 484 bytes .../textures/item/pocket_computer_normal.png | Bin 260 -> 656 bytes .../textures/item/pocket_computer_on.png | Bin 245 -> 583 bytes 8 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index ca7f86112..539523975 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -40,11 +40,16 @@ import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; 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; @@ -101,7 +106,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 ); @@ -132,9 +137,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/resources/assets/computercraft/textures/item/pocket_computer_advanced.png b/src/main/resources/assets/computercraft/textures/item/pocket_computer_advanced.png index 96015e297ece65d4f96b151510b7429275f6701e..c84346a2cdff62ecdb9819a9ba95fd4afd6b6c11 100644 GIT binary patch delta 644 zcmbQuG>3J9ay?^yrn7TEW^ytEgT}g;&`(xnk`xvIA_&|_9Shw zxy;jFz4X4iG3g~7=?d+uDblC|Had$XX`m^qYLUnFK@Bkaii^@yK&yp|0>&k z!i_ld(=Y7h*}MJ1&Zv{CcAb04e8lW&XI{d8hPKrD^SAV`Go^o@`l7jvfq{XuzQ7~0 zn1O*?2!t6g-L3n>z`$_X)5S5w!aq4dBI7{EyN3DIQ~x&~`S)RS!_o-5e~gzE>^jcA zs}XnQ=VD*>^U~bw5w^>gD{+aro3SME3Nd7stxh;rAn9>(UElTpiERhA7$|19SxU$6 zShU*Fuwe#AV=HHv_yX@F;|WRP3#4nkiXpl0cX#!>g-)FIQdKi=2d`G5E6!p3^<8SF*ZgBda} zvmWRTE_riI^WGPwH4M3SZGpL46ZbO*H0?;cWY{x9UutW^S))^xicx-s7jpMcn)x{5 z)0#`hD_Lhuw|{xy%5mcg&Wh)pX?~gfo3a-$L@lme`?E~Kes$UPZ?*#aj{miBR5j{n z3{eu?H+_CIqw8WX6|IRpX^ITXbN62geX5^w-66Aht{t^y06!^LpjX6Q9Mv Pz`)??>gTe~DWM4f2Q+f> 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 2474f6baf45049dc4f9d650e26f2036f73e7cfbf..53d89614ea5b3503b739af1ab44768fad233dae3 100644 GIT binary patch delta 600 zcmey#_g;&`(xnk`xvIA_&|_9Shw zxy;jFz4X4iG3g~7=?d+uDblC|Had$XX`m^qYLUnFK@Bkaii^@yK&yp|0>&k z!i_ld(=Y7h*}MJ1&Zv{CcAb04e8lW&XI{d8hPKrD^SAV`Go^o@`l7jvfq{XuzQ7~0 zn1O*?2!t6g-L3n>z`(HF)5S5w!~1PWG+%=PkMuF_1Cl%bcUmyZIBw?WnV5UUeUag( z?C9NrUL_xQ*xDc45iv`1Y2W6D?kQ}mBwAwrUr9&A;Xx_nc zjw<1DxihtPYZs({RZvn>Vl$ZaqU@maxt*HD-VQDuhEcxf=07hlJlpJlrg^&Pnu4>< f%&he`{Ble37iQY^{8-Guz`)??>gTe~DWM4f;`Cnt 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 426015e6cb339d224505e3f1d31a8c01ddcd7990..dd3c350ebdb1d283de50167321c528636b1deb59 100644 GIT binary patch delta 590 zcmX@Y_>5(Oay?^yrn7TEW^ytEgT}g;&`(xnk`xvIA_&|_9Shw zxy;jFz4X4iG3g~7=?d+uDblC|Had$XX`m^qYLUnFK@Bkaii^@yK&yp|0>&k z!i_ld(=Y7h*}MJ1&Zv{CcAb04e8lW&XI{d8hPKrD^SAV`Go^o@`l7jvfq{XuzQ7~0 zn1O*?2!t6g-L3n>z`!uq)5S5w!vARSZQcV499NbxzfgO(zeRgTW8Q@>PRFMa;ZaEJu1tr yPPzrnJ;4~1E!iN~u(@H?`6XpyX;Z3>%qhDO;^JR)`7Hwj1B0ilpUXO@geCxjO%X)^ delta 169 zcmaFHa)fb$aymT7NUE{pCnh<#|TGW~pp>36SyY*vOAftbVB`;|^!WEE5ryqfV=s^YS!X)f=% b&kW~8ty3oc`enetz`)??>gTe~DWM4fUnWPU 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 1f27b7ea9208d2e47715ce0b1b5f5d5b156eb4c2..ae5a70a12f6147bc24c7b52e0d919e1cc6b3e33c 100644 GIT binary patch delta 523 zcmbv_{`kzC z(`O_LT8*o&<;k|^tV?ipcD#S-Q`h;=UDM-sNiJ1hcl%k6O1;psmp^tbcfGp1;nmfe z_`?^c8sx}E-D+K4a#@SxJV(1Z*Rn^l5AAGa{W;`0`y-1S9%e7i7Oe}Mv+6^8lD61f z=IO6qdSBfbcD(A=DXxBw-M^ zVgB#=Y;}FP*neuOI)zK>J-W+%t}H4sU83e{{^WE((9ZwoFZ=oVh3u+szVPjh#e3%m zH(Td#dR!xKeeOKxj`f^&Ga*1$Cj9x7hBu(e}^XIPd6xmF+&^ zMx6QS7xwb(-F{(b)X7!5&b?$lV)nE%FX2B!TWbCJTl&|T(!WoA(OkyBz`$8w;1OBO zz`!j8!i<;h*8O2%V2Ji~aSXBWPfl1MV6f01Y-(zX*!%I{-)f%c#(@%TJd4>3c$y3j%;MW{)O_6wH7zMe&Hfcryn2*M fOhul%F+2~Ga-4Fvv4nwvfx*+&kJV+JQ$iB}fSK+9 delta 96 zcmZ3&QaeF8ih;2>$lZxy-8q?;3=9nBo-U3d7QM*{3j_=naZ5-^{X4$=;h&$MC8|2E z^@Q^p&f2&#RVhqZ&mil-3dRsa2G$9a#Wl|LGN?BSHp|_A!^6P9z~JfX=d#Wzp$Pz) C03w0_ 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 52f186fc7ba3a286d8080d4a3d67f2ac4f48ed95..8414ee5ee3db7ac2a7aacd8936fb590a7367332b 100644 GIT binary patch delta 442 zcmeyy_=I_aay?^yrn7TEW^ytEgT}g;&`(xnk`xvIA_&|_9Shw zxy;jFz4X4iG3g~7=?d+uDblC|Had$XX`m^qYLUnFK@Bkaii^@yK&yp|0>&k z!i_ld(=Y7h*}MJ1&Zv{CcAb04e8lW&XI{d8hPKrD^SAV`Go^o@`l7jvfq{W@qLYY$ zw5N+>h=qT0f&}YgMFT0OFWim)103w7JvVYPT&`gMxt{;Rb_NCp22WQ%mvv4FO#nXq B%0vJF delta 200 zcmaFD{EcyfvNQu@age(c!@6@aFBupZSkfJR9T^xl_H+M9WSu;RQKFu`#M9T6{XP#D zuM+oOPu3$03=EPbt`Q}{`DrEPiAAXl1&Nt?C3<IO=zXDqsOslqUj?a%-J^3KXU!f%;k+Af@D-SI)eJmK-N z-Uw60eU5iQ?7#J8lUHx3vIVCg! E0DZkc;%gW-zfr)H5nq2>duV~SLUQ# zyJ7zC`D}H4x!8Ydsyc;B>OH#4eXcAjFiZ+cuKZ+-4O=Z^UgjKV)ZS6%+n|Ke%Wv-KRd(FJv(m$%sNxY72{-8k>)f0gY% z;YOVK=@<6$?A?B0XVl46yUx92K4SK?GcVykLtAS7`CIzenbN;cebHRTz`(#+U*Hj0 z%)r1c1j3A$?$-TbU|=}z>Eak-;eRyfH1A;ro~5DX4~{T+oVDncXyiWZB9pLwOJsv^ zaDe31Nk3TvzXo_~{Iju_>y!MwJvNIm>NSg{qKjUuz$fvf4|~76`U@s}F228;f49E( zx!_6By)DnK7n+>1+tH$OqkJigMs=adb*W&1Gk*l;c!oR1z7hPlW`Ww@DmLe)nd&_0 z3QJS^OKs<>USV)vdz1N`W%0SC63NFLdDskp%y6I7)?n7ee>`fo_-TpB*XKlSF1)=> pbx-HLzN{%h>Csl3-E^Pv3aNTroaq=5!N9=4;OXk;vd$@?2>>2M9cusp delta 233 zcmbQh+QKwJxt@U~-O<;Pfnj4`&F{d;3=9mrJzX3_EP9VlKFHf_Ai%;tMeffc2JeM3 zI$jT)4LjJsq&hLz#fm;D?YJSK+O_D-`*Yi?Ur*)z?Jli&y|uQrV%eE9sSA^4&fz-JZeJ+y_%V+j z>%Eg;&`(xnk`xvIA_&|_9Shw zxy;jFz4X4iG3g~7=?d+uDblC|Had$XX`m^qYLUnFK@Bkaii^@yK&yp|0>&k z!i_ld(=Y7h*}MJ1&Zv{CcAb04e8lW&XI{d8hPKrD^SAV`Go^o@`l7jvfq{W@qLWB{ zou`Xqh=u>rU`M_K3LMF&?H1%e_^Y zgZa<5|MeF4D<}mTr$^xWnf?k@^o Date: Sat, 25 Dec 2021 22:30:51 -0800 Subject: [PATCH 4/4] Fix two bugs with monitors on dedicated server (#45). - ClientMonitors were being created on the server. This caused a crash when TileMonitors unload and attempt to clean up their client side buffers because the method to do that only exists on the client. We don't have the split semantics of load and handleUpdateTag that forge has, so our TileMonitor#load method has to do double duty and check if the level is client side before doing client side stuff. - Monitor contents were never sent to clients connected to a dedicated server because MonitorWatcher was never initialized on the dedicated server! (My bad...) To fix, I moved its initialization to the common setup. --- .../proxy/ComputerCraftProxyClient.java | 2 - .../fabric/mixin/MixinChunkMap.java | 4 +- .../peripheral/monitor/TileMonitor.java | 51 +++++-------------- .../proxy/ComputerCraftProxyCommon.java | 2 + 4 files changed, 17 insertions(+), 42 deletions(-) diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index 539523975..d39ad764d 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -23,7 +23,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; @@ -76,7 +75,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. 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();