This commit is contained in:
Srendi 2022-08-30 13:37:15 +02:00
parent f6acd38cba
commit 0a5688ebf7
6 changed files with 13 additions and 10 deletions

View file

@ -3,8 +3,7 @@ package de.srendi.cctutorial.cctutorial;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.Util;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
import net.minecraftforge.server.ServerLifecycleHooks;
import javax.annotation.Nonnull;
@ -82,8 +81,8 @@ public class CCPeripheral implements IPeripheral {
// 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(We use a TextComponent) and a sender UUID. We just pass an empty uuid in here
player.sendMessage(new TextComponent(message), Util.NIL_UUID);
// To send a message, we need a Component(In this case a literal text component).
player.sendSystemMessage(Component.literal(message));
});
}

View file

@ -18,7 +18,7 @@ public class Registration {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, CCtutorial.MODID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, CCtutorial.MODID);
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, CCtutorial.MODID);
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);