mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-29 08:42:17 +00:00
Auto stash before merge of "fabric" and "origin/fabric"
This commit is contained in:
parent
84bca21b0c
commit
64f5ca02b3
@ -120,5 +120,4 @@ public final class ClientRegistry {
|
|||||||
.apply(spriteIdentifier.getTextureId()),
|
.apply(spriteIdentifier.getTextureId()),
|
||||||
ModelRotation.X0_Y0, identifier);
|
ModelRotation.X0_Y0, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,15 @@
|
|||||||
|
|
||||||
package dan200.computercraft.client;
|
package dan200.computercraft.client;
|
||||||
|
|
||||||
|
import dan200.computercraft.ComputerCraft;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
|
||||||
|
public final class FrameInfo
|
||||||
public final class FrameInfo {
|
{
|
||||||
private static int tick;
|
private static int tick;
|
||||||
private static long renderFrame;
|
private static long renderFrame;
|
||||||
static {
|
static {
|
||||||
@ -41,4 +44,10 @@ public final class FrameInfo {
|
|||||||
renderFrame++;
|
renderFrame++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onRenderTick( TickEvent.RenderTickEvent event )
|
||||||
|
{
|
||||||
|
if( event.phase == TickEvent.Phase.START ) renderFrame++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dan200.computercraft.shared;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
|
||||||
|
|
||||||
public final class Capabilities
|
|
||||||
{
|
|
||||||
@CapabilityInject( IPeripheral.class )
|
|
||||||
public static Capability<IPeripheral> CAPABILITY_PERIPHERAL = null;
|
|
||||||
|
|
||||||
@CapabilityInject( IWiredElement.class )
|
|
||||||
public static Capability<IWiredElement> CAPABILITY_WIRED_ELEMENT = null;
|
|
||||||
|
|
||||||
private Capabilities()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,25 +12,22 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
|||||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
||||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class TileComputer extends TileComputerBase
|
public class TileComputer extends TileComputerBase
|
||||||
{
|
{
|
||||||
private ComputerProxy proxy;
|
private ComputerProxy proxy;
|
||||||
private LazyOptional<IPeripheral> peripheral;
|
private Optional<IPeripheral> peripheral;
|
||||||
|
|
||||||
public TileComputer( ComputerFamily family, BlockEntityType<? extends TileComputer> type )
|
public TileComputer( ComputerFamily family, BlockEntityType<? extends TileComputer> type )
|
||||||
{
|
{
|
||||||
@ -87,30 +84,4 @@ public class TileComputer extends TileComputerBase
|
|||||||
{
|
{
|
||||||
return new ContainerComputer( id, this );
|
return new ContainerComputer( id, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public <T> LazyOptional<T> getCapability( @Nonnull Capability<T> cap, @Nullable Direction side )
|
|
||||||
{
|
|
||||||
if( cap == CAPABILITY_PERIPHERAL )
|
|
||||||
{
|
|
||||||
if( peripheral == null )
|
|
||||||
{
|
|
||||||
peripheral = LazyOptional.of( () -> {
|
|
||||||
if( proxy == null ) proxy = new ComputerProxy( () -> this );
|
|
||||||
return new ComputerPeripheral( "computer", proxy );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
return peripheral.cast();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getCapability( cap, side );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void invalidateCaps()
|
|
||||||
{
|
|
||||||
super.invalidateCaps();
|
|
||||||
peripheral = CapabilityUtil.invalidate( peripheral );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,13 @@ import dan200.computercraft.shared.network.NetworkMessage;
|
|||||||
import dan200.computercraft.shared.network.client.ComputerDataClientMessage;
|
import dan200.computercraft.shared.network.client.ComputerDataClientMessage;
|
||||||
import dan200.computercraft.shared.network.client.ComputerDeletedClientMessage;
|
import dan200.computercraft.shared.network.client.ComputerDeletedClientMessage;
|
||||||
import dan200.computercraft.shared.network.client.ComputerTerminalClientMessage;
|
import dan200.computercraft.shared.network.client.ComputerTerminalClientMessage;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
|
||||||
import net.minecraftforge.versions.mcp.MCPVersion;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -169,20 +168,20 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
|
|||||||
|
|
||||||
if( hasTerminalChanged() || force )
|
if( hasTerminalChanged() || force )
|
||||||
{
|
{
|
||||||
|
if (FabricLoader.getInstance().getGameInstance() instanceof MinecraftServer) {
|
||||||
// Send terminal state to clients who are currently interacting with the computer.
|
// Send terminal state to clients who are currently interacting with the computer.
|
||||||
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
MinecraftServer server = (MinecraftServer) FabricLoader.getInstance().getGameInstance();
|
||||||
|
|
||||||
NetworkMessage packet = null;
|
NetworkMessage packet = null;
|
||||||
for( PlayerEntity player : server.getPlayerManager().getPlayerList() )
|
for (PlayerEntity player : server.getPlayerManager().getPlayerList()) {
|
||||||
{
|
if (isInteracting(player)) {
|
||||||
if( isInteracting( player ) )
|
|
||||||
{
|
|
||||||
if (packet == null) packet = createTerminalPacket();
|
if (packet == null) packet = createTerminalPacket();
|
||||||
NetworkHandler.sendToPlayer(player, packet);
|
NetworkHandler.sendToPlayer(player, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void sendComputerState( PlayerEntity player )
|
public void sendComputerState( PlayerEntity player )
|
||||||
{
|
{
|
||||||
@ -347,7 +346,7 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
|
|||||||
@Override
|
@Override
|
||||||
public String getHostString()
|
public String getHostString()
|
||||||
{
|
{
|
||||||
return String.format( "ComputerCraft %s (Minecraft %s)", ComputerCraftAPI.getInstalledVersion(), MCPVersion.getMCVersion() );
|
return String.format( "ComputerCraft %s (Minecraft %s)", ComputerCraftAPI.getInstalledVersion(), "1.16.2" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -12,33 +12,32 @@ import net.minecraft.screen.NamedScreenHandlerFactory;
|
|||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extension over the basic {@link IForgeContainerType}/{@link NetworkHooks#openGui(ServerPlayerEntity, INamedContainerProvider, Consumer)}
|
* An extension over the basic
|
||||||
* hooks, with a more convenient way of reading and writing data.
|
* hooks, with a more convenient way of reading and writing data.
|
||||||
*/
|
*/
|
||||||
public interface ContainerData
|
public interface ContainerData
|
||||||
{
|
{
|
||||||
void toBytes( PacketByteBuf buf );
|
void toBytes( PacketByteBuf buf );
|
||||||
|
|
||||||
default void open( PlayerEntity player, NamedScreenHandlerFactory owner )
|
//TODO Figure out what the heck to do here
|
||||||
{
|
// default void open( PlayerEntity player, NamedScreenHandlerFactory owner )
|
||||||
NetworkHooks.openGui( (ServerPlayerEntity) player, owner, this::toBytes );
|
// {
|
||||||
}
|
// NetworkHooks.openGui( (ServerPlayerEntity) player, owner, this::toBytes );
|
||||||
|
// }
|
||||||
static <C extends ScreenHandler, T extends ContainerData> ScreenHandlerType<C> toType( Function<PacketByteBuf, T> reader, Factory<C, T> factory )
|
//
|
||||||
{
|
// static <C extends ScreenHandler, T extends ContainerData> ScreenHandlerType<C> toType( Function<PacketByteBuf, T> reader, Factory<C, T> factory )
|
||||||
return IForgeContainerType.create( ( id, player, data ) -> factory.create( id, player, reader.apply( data ) ) );
|
// {
|
||||||
}
|
// return IForgeContainerType.create( ( id, player, data ) -> factory.create( id, player, reader.apply( data ) ) );
|
||||||
|
// }
|
||||||
interface Factory<C extends ScreenHandler, T extends ContainerData>
|
//
|
||||||
{
|
// interface Factory<C extends ScreenHandler, T extends ContainerData>
|
||||||
C create( int id, @Nonnull PlayerInventory inventory, T data );
|
// {
|
||||||
}
|
// C create( int id, @Nonnull PlayerInventory inventory, T data );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,6 @@ import net.minecraft.util.Hand;
|
|||||||
import net.minecraft.util.TypedActionResult;
|
import net.minecraft.util.TypedActionResult;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user