mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-22 09:27:39 +00:00
Update to 1.20.4
This commit is contained in:
@@ -20,11 +20,3 @@ dependencies {
|
||||
tasks.javadoc {
|
||||
include("dan200/computercraft/api/**/*.java")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
named("maven", MavenPublication::class) {
|
||||
fg.component(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,13 +5,13 @@
|
||||
package dan200.computercraft.api.client.turtle;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeType;
|
||||
import dan200.computercraft.impl.client.ComputerCraftAPIClientService;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import dan200.computercraft.api.upgrades.UpgradeSerialiser;
|
||||
import net.neoforged.bus.api.Event;
|
||||
import net.neoforged.fml.event.IModBusEvent;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* This event is fired to register {@link TurtleUpgradeModeller}s for a mod's {@linkplain TurtleUpgradeType turtle
|
||||
@@ -22,11 +22,18 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
* dispatched). Subscribers should be careful not to
|
||||
*/
|
||||
public class RegisterTurtleModellersEvent extends Event implements IModBusEvent, RegisterTurtleUpgradeModeller {
|
||||
private final RegisterTurtleUpgradeModeller dispatch;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterTurtleModellersEvent(RegisterTurtleUpgradeModeller dispatch) {
|
||||
this.dispatch = dispatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public <T extends ITurtleUpgrade> void register(TurtleUpgradeSerialiser<T> serialiser, TurtleUpgradeModeller<T> modeller) {
|
||||
ComputerCraftAPIClientService.get().registerTurtleUpgradeModeller(serialiser, modeller);
|
||||
public <T extends ITurtleUpgrade> void register(UpgradeSerialiser<T> serialiser, TurtleUpgradeModeller<T> modeller) {
|
||||
dispatch.register(serialiser, modeller);
|
||||
}
|
||||
}
|
||||
|
@@ -5,15 +5,9 @@
|
||||
package dan200.computercraft.api;
|
||||
|
||||
import dan200.computercraft.api.lua.GenericSource;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import dan200.computercraft.impl.ComputerCraftAPIForgeService;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||
|
||||
/**
|
||||
* The forge-specific entrypoint for ComputerCraft's API.
|
||||
@@ -22,40 +16,16 @@ public final class ForgeComputerCraftAPI {
|
||||
private ForgeComputerCraftAPI() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a peripheral provider to convert blocks into {@link IPeripheral} implementations.
|
||||
*
|
||||
* @param provider The peripheral provider to register.
|
||||
* @see IPeripheral
|
||||
* @see IPeripheralProvider
|
||||
*/
|
||||
public static void registerPeripheralProvider(IPeripheralProvider provider) {
|
||||
getInstance().registerPeripheralProvider(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a capability that can be used by generic peripherals.
|
||||
*
|
||||
* @param capability The capability to register.
|
||||
* @see GenericSource
|
||||
*/
|
||||
public static void registerGenericCapability(Capability<?> capability) {
|
||||
public static void registerGenericCapability(BlockCapability<?, Direction> capability) {
|
||||
getInstance().registerGenericCapability(capability);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wired network element for a block in world.
|
||||
*
|
||||
* @param world The world the block exists in
|
||||
* @param pos The position the block exists in
|
||||
* @param side The side to extract the network element from
|
||||
* @return The element's node
|
||||
* @see WiredElement#getNode()
|
||||
*/
|
||||
public static LazyOptional<WiredElement> getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) {
|
||||
return getInstance().getWiredElementAt(world, pos, side);
|
||||
}
|
||||
|
||||
private static ComputerCraftAPIForgeService getInstance() {
|
||||
return ComputerCraftAPIForgeService.get();
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
package dan200.computercraft.api.detail;
|
||||
|
||||
import dan200.computercraft.impl.ComputerCraftAPIForgeService;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.neoforged.neoforge.fluids.FluidStack;
|
||||
|
||||
/**
|
||||
* {@link DetailRegistry}s for Forge-specific types.
|
||||
|
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package dan200.computercraft.api.network.wired;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||
|
||||
/**
|
||||
* A {@linkplain BlockCapability block capability} for {@link WiredElement}s. This should be used to query wired elements
|
||||
* from a block.
|
||||
*/
|
||||
public final class WiredElementCapability {
|
||||
public static final ResourceLocation ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "wired_node");
|
||||
|
||||
private static final BlockCapability<WiredElement, Direction> capability = BlockCapability.create(ID, WiredElement.class, Direction.class);
|
||||
|
||||
private WiredElementCapability() {
|
||||
}
|
||||
|
||||
public static BlockCapability<WiredElement, Direction> get() {
|
||||
return capability;
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
// Copyright Daniel Ratcliffe, 2011-2022. This API may be redistributed unmodified and in full only.
|
||||
//
|
||||
// SPDX-License-Identifier: LicenseRef-CCPL
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import dan200.computercraft.api.ForgeComputerCraftAPI;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
/**
|
||||
* This interface is used to create peripheral implementations for blocks.
|
||||
* <p>
|
||||
* If you have a {@link BlockEntity} which acts as a peripheral, you may alternatively expose the {@link IPeripheral}
|
||||
* capability.
|
||||
* <p>
|
||||
* {@link ForgeComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)} should be used to register a peripheral
|
||||
* provider.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IPeripheralProvider {
|
||||
/**
|
||||
* Produce an peripheral implementation from a block location.
|
||||
*
|
||||
* @param world The world the block is in.
|
||||
* @param pos The position the block is at.
|
||||
* @param side The side to get the peripheral from.
|
||||
* @return A peripheral, or {@link LazyOptional#empty()} if there is not a peripheral here you'd like to handle.
|
||||
*/
|
||||
LazyOptional<IPeripheral> getPeripheral(Level world, BlockPos pos, Direction side);
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||
|
||||
/**
|
||||
* A {@linkplain BlockCapability block capability} for {@link IPeripheral}s. This should be used to register peripherals
|
||||
* for a block. It should <em>NOT</em> be used to query peripherals.
|
||||
*/
|
||||
public final class PeripheralCapability {
|
||||
public static final ResourceLocation ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "peripheral");
|
||||
|
||||
private static final BlockCapability<IPeripheral, Direction> capability = BlockCapability.create(ID, IPeripheral.class, Direction.class);
|
||||
|
||||
private PeripheralCapability() {
|
||||
}
|
||||
|
||||
public static BlockCapability<IPeripheral, Direction> get() {
|
||||
return capability;
|
||||
}
|
||||
}
|
@@ -6,14 +6,9 @@ package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.ForgeComputerCraftAPI;
|
||||
import dan200.computercraft.api.detail.DetailRegistry;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||
import net.neoforged.neoforge.fluids.FluidStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
@@ -29,11 +24,7 @@ public interface ComputerCraftAPIForgeService extends ComputerCraftAPIService {
|
||||
return (ComputerCraftAPIForgeService) ComputerCraftAPIService.get();
|
||||
}
|
||||
|
||||
void registerPeripheralProvider(IPeripheralProvider provider);
|
||||
|
||||
void registerGenericCapability(Capability<?> capability);
|
||||
|
||||
LazyOptional<WiredElement> getWiredElementAt(BlockGetter world, BlockPos pos, Direction side);
|
||||
void registerGenericCapability(BlockCapability<?, Direction> capability);
|
||||
|
||||
DetailRegistry<FluidStack> getFluidStackDetailRegistry();
|
||||
}
|
||||
|
Reference in New Issue
Block a user