1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-31 01:27:55 +00:00

Merge branch 'mc-1.18.x/stable' into mc-1.18.x/dev

This commit is contained in:
Toad-Dev
2021-12-26 12:42:34 -08:00
13 changed files with 46 additions and 50 deletions

View File

@@ -24,7 +24,6 @@ import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer; import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive; import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor; 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.peripheral.printer.ContainerPrinter;
import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; 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.client.ClientSpriteRegistryCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
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.multiplayer.ClientLevel;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction; import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.item.Item; 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; import java.util.function.Supplier;
@@ -81,7 +85,6 @@ public final class ComputerCraftProxyClient implements ClientModInitializer
public void onInitializeClient() public void onInitializeClient()
{ {
FrameInfo.init(); FrameInfo.init();
MonitorWatcher.init();
registerContainers(); registerContainers();
// While turtles themselves are not transparent, their upgrades may be. // While turtles themselves are not transparent, their upgrades may be.
@@ -111,7 +114,7 @@ public final class ComputerCraftProxyClient implements ClientModInitializer
.ordinal(), .ordinal(),
() -> Registry.ModItems.POCKET_COMPUTER_NORMAL, () -> Registry.ModItems.POCKET_COMPUTER_NORMAL,
() -> Registry.ModItems.POCKET_COMPUTER_ADVANCED ); () -> Registry.ModItems.POCKET_COMPUTER_ADVANCED );
registerItemProperty( "state", registerItemProperty( "coloured",
( stack, world, player, integer ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0, ( stack, world, player, integer ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0,
() -> Registry.ModItems.POCKET_COMPUTER_NORMAL, () -> Registry.ModItems.POCKET_COMPUTER_NORMAL,
() -> Registry.ModItems.POCKET_COMPUTER_ADVANCED ); () -> 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 ) private static void registerItemProperty( String name, ClampedItemPropertyFunction getter, Supplier<? extends Item>... items )
{ {
ResourceLocation id = new ResourceLocation( ComputerCraft.MOD_ID, name ); 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 ) for( Supplier<? extends Item> item : items )
{ {
FabricModelPredicateProviderRegistry.register( item.get(), id, getter ); FabricModelPredicateProviderRegistry.register( item.get(), id, unclampedGetter );
} }
} }
} }

View File

@@ -5,7 +5,7 @@
*/ */
package dan200.computercraft.fabric.mixin; 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.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -46,7 +46,7 @@ public class MixinChunkMap
@Inject( method = "playerLoadedChunk", at = @At( value = "HEAD" ) ) @Inject( method = "playerLoadedChunk", at = @At( value = "HEAD" ) )
private void playerLoadedChunk( ServerPlayer serverPlayer, MutableObject<ClientboundLevelChunkWithLightPacket> mutableObject, LevelChunk levelChunk, CallbackInfo ci ) 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() );
} }
} }

View File

@@ -145,49 +145,24 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
width = nbt.getInt( NBT_WIDTH ); width = nbt.getInt( NBT_WIDTH );
height = nbt.getInt( NBT_HEIGHT ); 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 if( oldXIndex != xIndex || oldYIndex != yIndex )
// 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(); // If our index has changed then it's possible the origin monitor has changed. Thus
clientMonitor = null; // 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( xIndex == 0 && yIndex == 0 )
{ {
// If we're the origin terminal then create it. // If we're the origin terminal then create it.
if( clientMonitor == null ) clientMonitor = new ClientMonitor( advanced, this ); 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 @Override
public void blockTick() public void blockTick()
{ {

View File

@@ -27,6 +27,7 @@ import dan200.computercraft.shared.peripheral.commandblock.CommandBlockPeriphera
import dan200.computercraft.shared.peripheral.generic.methods.InventoryMethods; import dan200.computercraft.shared.peripheral.generic.methods.InventoryMethods;
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable; import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork; 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.turtle.FurnaceRefuelHandler;
import dan200.computercraft.shared.util.Config; import dan200.computercraft.shared.util.Config;
import dan200.computercraft.shared.util.TickScheduler; import dan200.computercraft.shared.util.TickScheduler;
@@ -51,6 +52,7 @@ public final class ComputerCraftProxyCommon
public static void init() public static void init()
{ {
NetworkHandler.setup(); NetworkHandler.setup();
MonitorWatcher.init();
registerProviders(); registerProviders();
registerHandlers(); registerHandlers();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 B

After

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 583 B

View File

@@ -1,7 +1,7 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"id": "computercraft", "id": "computercraft",
"name": "CC:Restitched", "name": "CC: Restitched",
"version": "${version}", "version": "${version}",
"description": "CC: Tweaked for Fabric.", "description": "CC: Tweaked for Fabric.",
"license": "ComputerCraft Public License", "license": "ComputerCraft Public License",
@@ -20,9 +20,9 @@
"Toad-Dev" "Toad-Dev"
], ],
"depends": { "depends": {
"fabricloader": ">=0.11.3", "minecraft": "1.18.x",
"fabric": "*", "fabricloader": ">=0.12.9",
"minecraft": "1.18.1" "fabric": "*"
}, },
"suggests": { "suggests": {
"modmenu": "*" "modmenu": "*"

View File

@@ -1,6 +1,6 @@
{ {
"pack": { "pack": {
"pack_format": 7, "pack_format": 8,
"description": "The clasic look of ComputerCraft" "description": "The classic look of ComputerCraft."
} }
} }