Update to 22w19a

This commit is contained in:
shedaniel
2022-05-13 08:11:11 +08:00
parent 2ec54ce20a
commit 0adf9a2e6d
15 changed files with 324 additions and 142 deletions

View File

@@ -22,7 +22,6 @@ package dev.architectury.core.fluid;
import dev.architectury.fluid.FluidStack;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.Item;
@@ -65,7 +64,7 @@ public interface ArchitecturyFluidAttributes {
* @return the name
*/
default Component getName(@Nullable FluidStack stack) {
return new TranslatableComponent(getTranslationKey(stack));
return Component.translatable(getTranslationKey(stack));
}
/**

View File

@@ -29,16 +29,14 @@ import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
@Environment(EnvType.CLIENT)
public interface ClientChatEvent {
/**
* @see Process#process(String)
* @see Process#process(ChatType, Component, ChatSender)
*/
Event<Process> PROCESS = EventFactory.createCompoundEventResult();
/**
* @see Received#process(ChatType, Component, UUID)
* @see Received#process(ChatType, Component, ChatSender)
*/
Event<Received> RECEIVED = EventFactory.createCompoundEventResult();
@@ -48,11 +46,11 @@ public interface ClientChatEvent {
* Event to modify the chat message a clients sends.
* Equivalent to Forge's {@code ClientChatEvent} event.
*
* @param message The raw chat message the client wants to send.
* @param message The chat message the client wants to send.
* @return A {@link CompoundEventResult} determining the outcome of the event,
* if an outcome is set, the sent message is overridden.
*/
CompoundEventResult<String> process(String message);
CompoundEventResult<Component> process(ChatType chatType, Component message, @Nullable ChatSender sender);
}
@Environment(EnvType.CLIENT)

View File

@@ -19,16 +19,16 @@
package dev.architectury.event.events.common;
import dev.architectury.event.CompoundEventResult;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.TextFilter;
import org.jetbrains.annotations.Nullable;
public interface ChatEvent {
/**
* @see Server#process(ServerPlayer, TextFilter.FilteredText, ChatComponent)
* @see Server#process(ServerPlayer, Component)
*/
Event<Server> SERVER = EventFactory.createEventResult();
@@ -37,22 +37,11 @@ public interface ChatEvent {
* Invoked when the server receives a message from a client.
* Equivalent to Forge's {@code ServerChatEvent} event.
*
* @param player The player who has sent the message.
* @param message The raw message itself.
* @param player The player who has sent the message, or null.
* @param component The message as component.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla message may be cancelled by the result.
* @return A {@link CompoundEventResult} determining the outcome of the event,
* if an outcome is set, the sent message is overridden.
*/
EventResult process(ServerPlayer player, TextFilter.FilteredText message, ChatComponent component);
}
interface ChatComponent {
Component getRaw();
Component getFiltered();
void setRaw(Component raw);
void setFiltered(Component filtered);
CompoundEventResult<Component> process(@Nullable ServerPlayer player, Component component);
}
}