Update to 1.19.1 (#302)

* Update to 1.19.1

* Make it compile

* Update to 1.19.1

* Set 1.19.1 as the publishing version
This commit is contained in:
shedaniel
2022-07-28 19:45:57 +08:00
committed by GitHub
parent 2f5d4444c8
commit b316dde8ba
25 changed files with 260 additions and 546 deletions

View File

@@ -26,8 +26,8 @@ import net.minecraft.world.item.RecordItem;
public class ArchitecturyRecordItem extends RecordItem {
private final RegistrySupplier<SoundEvent> sound;
public ArchitecturyRecordItem(int analogOutput, RegistrySupplier<SoundEvent> sound, Properties properties) {
super(analogOutput, sound.orElse(null), properties);
public ArchitecturyRecordItem(int analogOutput, RegistrySupplier<SoundEvent> sound, Properties properties, int lengthInSeconds) {
super(analogOutput, sound.orElse(null), properties, lengthInSeconds);
this.sound = sound;
if (!sound.isPresent()) {

View File

@@ -25,49 +25,33 @@ import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.chat.ClientChatPreview;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.network.chat.ChatSender;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;
import java.util.function.Function;
@Environment(EnvType.CLIENT)
public interface ClientChatEvent {
/**
* @see Process#process(ChatProcessor)
* @see Send#send(String, Component)
*/
Event<Process> PROCESS = EventFactory.createEventResult();
Event<Send> SEND = EventFactory.createEventResult();
/**
* @see Received#process(ChatType, Component, ChatSender)
* @see Received#process(ChatType.Bound, Component)
*/
Event<Received> RECEIVED = EventFactory.createCompoundEventResult();
@Environment(EnvType.CLIENT)
interface Process {
interface Send {
/**
* Event to modify the chat message a clients sends.
* Event to cancel clients sending the chat message.
* Equivalent to Forge's {@code ClientChatEvent} event.
*
* @param processor The chat message the client wants to send.
* @param message The chat message.
* @param component The chat component that was decorated, can be {@code null}.
* @return A {@link EventResult} determining the outcome of the event,
* if an outcome is set, the sent message is overridden.
* if an outcome is set, the message and component will be ignored.
*/
EventResult process(ChatProcessor processor);
}
interface ChatProcessor {
String getMessage();
@Nullable
Component getComponent();
void setMessage(String message);
void setComponent(@Nullable Component component);
EventResult send(String message, @Nullable Component component);
}
@Environment(EnvType.CLIENT)
@@ -79,10 +63,9 @@ public interface ClientChatEvent {
*
* @param type Where was the message emitted from.
* @param message The chat message.
* @param sender The packet sender. Can be {@code null}, but probably is the sending player UUID or null for system messages.
* @return A {@link CompoundEventResult} determining the outcome of the event,
* if an outcome is set, the received message is overridden.
*/
CompoundEventResult<Component> process(ChatType type, Component message, @Nullable ChatSender sender);
CompoundEventResult<Component> process(ChatType.Bound type, Component message);
}
}

View File

@@ -19,7 +19,6 @@
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;
@@ -27,15 +26,30 @@ import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.Nullable;
import java.util.function.Function;
public interface ChatEvent {
/**
* @see Server#process(ServerPlayer, ChatComponent)
* @see Decorate#decorate(ServerPlayer, ChatComponent)
*/
Event<Server> SERVER = EventFactory.createEventResult();
Event<Decorate> DECORATE = EventFactory.createLoop();
/**
* @see Received#received(ServerPlayer, Component)
*/
Event<Received> RECEIVED = EventFactory.createEventResult();
interface Server {
@FunctionalInterface
interface Decorate {
/**
* 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, or null.
* @param component The message as component.
*/
void decorate(@Nullable ServerPlayer player, ChatComponent component);
}
@FunctionalInterface
interface Received {
/**
* Invoked when the server receives a message from a client.
* Equivalent to Forge's {@code ServerChatEvent} event.
@@ -45,34 +59,12 @@ public interface ChatEvent {
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla message may be cancelled by the result.
*/
EventResult process(@Nullable ServerPlayer player, ChatComponent component);
EventResult received(@Nullable ServerPlayer player, Component component);
}
interface ChatComponent {
Component getRaw();
Component get();
@Nullable
Component getFiltered();
void setRaw(Component raw);
void setFiltered(@Nullable Component filtered);
default void modifyRaw(Function<Component, Component> function) {
setRaw(function.apply(getRaw()));
}
default void modifyFiltered(Function<Component, Component> function) {
Component filtered = getFiltered();
if (filtered != null) {
setFiltered(function.apply(filtered));
}
}
default void modifyBoth(Function<Component, Component> function) {
modifyRaw(function);
modifyFiltered(function);
}
void set(Component component);
}
}

View File

@@ -22,12 +22,13 @@ package dev.architectury.event.events.common;
import com.mojang.brigadier.CommandDispatcher;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public interface CommandRegistrationEvent {
/**
* @see CommandRegistrationEvent#register(CommandDispatcher, Commands.CommandSelection)
* @see CommandRegistrationEvent#register(CommandDispatcher, CommandBuildContext, Commands.CommandSelection)
*/
Event<CommandRegistrationEvent> EVENT = EventFactory.createLoop();
@@ -36,7 +37,8 @@ public interface CommandRegistrationEvent {
* Equivalent to Forge's {@code RegisterCommandsEvent} and Fabric's {@code CommandRegistrationCallback}.
*
* @param dispatcher The command dispatcher to register commands to.
* @param registry The command registry for building arguments.
* @param selection The selection where the command can be executed.
*/
void register(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection selection);
void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext registry, Commands.CommandSelection selection);
}

View File

@@ -1,60 +0,0 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021, 2022 architectury
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package dev.architectury.impl;
import dev.architectury.event.events.client.ClientChatEvent;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
@ApiStatus.Internal
public class ChatProcessorImpl implements ClientChatEvent.ChatProcessor {
private String message;
@Nullable
private Component component;
public ChatProcessorImpl(String message, @Nullable Component component) {
this.message = message;
this.component = component;
}
@Override
public String getMessage() {
return message;
}
@Override
@Nullable
public Component getComponent() {
return component;
}
@Override
public void setMessage(String message) {
this.message = Objects.requireNonNull(message);
}
@Override
public void setComponent(@Nullable Component component) {
this.component = component;
}
}

View File

@@ -146,7 +146,7 @@ transitive-accessible method net/minecraft/world/item/AxeItem <init> (Lnet/minec
transitive-accessible method net/minecraft/world/item/DiggerItem <init> (FFLnet/minecraft/world/item/Tier;Lnet/minecraft/tags/TagKey;Lnet/minecraft/world/item/Item$Properties;)V
transitive-accessible method net/minecraft/world/item/HoeItem <init> (Lnet/minecraft/world/item/Tier;IFLnet/minecraft/world/item/Item$Properties;)V
transitive-accessible method net/minecraft/world/item/PickaxeItem <init> (Lnet/minecraft/world/item/Tier;IFLnet/minecraft/world/item/Item$Properties;)V
transitive-accessible method net/minecraft/world/item/RecordItem <init> (ILnet/minecraft/sounds/SoundEvent;Lnet/minecraft/world/item/Item$Properties;)V
transitive-accessible method net/minecraft/world/item/RecordItem <init> (ILnet/minecraft/sounds/SoundEvent;Lnet/minecraft/world/item/Item$Properties;I)V
# Constructors of non-abstract block classes
transitive-accessible method net/minecraft/world/level/block/AirBlock <init> (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V