All of time and space

This commit is contained in:
Andrey Nikitin 2023-01-28 08:49:14 +03:00
parent f92a65bdb5
commit f90500fdd4
10 changed files with 52 additions and 16 deletions

View file

@ -90,6 +90,9 @@ dependencies {
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
implementation files("/home/andrew71/.local/share/multimc/instances/TardimInControl/.minecraft/mods/tardim-1.1.5.jar")
implementation fg.deobf("org.squiddev:cc-tweaked-1.19.1:${cc_version}")
}

View file

@ -6,6 +6,9 @@ import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.network.chat.Component;
import net.minecraftforge.server.ServerLifecycleHooks;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
@ -72,26 +75,28 @@ public class CCPeripheral implements IPeripheral {
return tileEntity;
}
public TardimData getTardimData() {
return TardimManager.getFromPos(getTileEntity().getPos());
}
/**
* To register functions for our block, wee need to create final methods with the {@link LuaFunction} annotation
* This function will send a message to every player on the Server
*/
@LuaFunction
public final void sendMessage(String message) {
// Used to get the current server and all online players.
ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers().forEach(player -> {
// Now, send the message
// To send a message, we need a Component(In this case a literal text component).
player.sendSystemMessage(Component.literal(message));
});
}
/**
* Because we want to access the world, we need to run this function on the main thread.
*/
@LuaFunction(mainThread = true)
public final boolean isRaining() {
return getTileEntity().getLevel().getRainLevel(0) > 0;
public final double get_fuel() {
return getTardimData().getFuel();
}
@LuaFunction(mainThread = true)
public final boolean is_locked() {
return getTardimData().isLocked();
}
@LuaFunction(mainThread = true)
public final void set_locked(boolean locked) {
getTardimData().setLocked(locked);
}
}

View file

@ -22,6 +22,9 @@ public class CCTileEntity extends BlockEntity {
*/
protected CCPeripheral peripheral = new CCPeripheral(this);
private LazyOptional<IPeripheral> peripheralCap;
public BlockPos getPos() {
return this.worldPosition;
}
/**
* When a computer modem tries to wrap our block, the modem will call getCapability to receive our peripheral.

View file

@ -21,7 +21,7 @@ public class Registration {
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, CCtutorial.MODID);
// Blocks
public static final RegistryObject<Block> CC_BLOCK = register("tutorial_block", CCBlock::new);
public static final RegistryObject<Block> CC_BLOCK = register("digital_tardim_interface", CCBlock::new);
private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
RegistryObject<T> registryObject = BLOCKS.register(name, block);
@ -30,7 +30,7 @@ public class Registration {
}
// Tile Entities
public static final RegistryObject<BlockEntityType<CCTileEntity>> CC_TILEENTITY = Registration.BLOCK_ENTITIES.register("tutorial_block", () -> new BlockEntityType<>(CCTileEntity::new, Sets.newHashSet(CC_BLOCK.get()), null));
public static final RegistryObject<BlockEntityType<CCTileEntity>> CC_TILEENTITY = Registration.BLOCK_ENTITIES.register("digital_tardim_interface", () -> new BlockEntityType<>(CCTileEntity::new, Sets.newHashSet(CC_BLOCK.get()), null));
// Register our stuff
public static void register() {

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "cctutorial:block/digital_tardim_interface"
}
}
}

View file

@ -0,0 +1,3 @@
{
"block.cctutorial.digital_tardim_interface": "Digital TARDIM Interface"
}

View file

@ -0,0 +1,3 @@
{
"block.cctutorial.digital_tardim_interface": "Digital TARDIM Interface"
}

View file

@ -0,0 +1,3 @@
{
"block.cctutorial.digital_tardim_interface": "Циферный Интерфейсъ Хрономашины"
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "cctutorial:blocks/digital_tardim_interface"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "cctutorial:block/digital_tardim_interface"
}