Refactor and 1.17-pre1 (#96)

* Fix #94

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Add Chunk data save and load events, closes #89 (#92)

* Created Chunk save and load event. Closes #89

* Fixed missing licence

* Update common/src/main/java/me/shedaniel/architectury/event/events/ChunkEvent.java

* Update common/src/main/java/me/shedaniel/architectury/event/events/ChunkEvent.java

* Update common/src/main/java/me/shedaniel/architectury/event/events/ChunkEvent.java

* Supply ServerLevel in ChunkEvent.LOAD, style cleanup

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Add "Data" suffix to Chunk IO Events and mark level as nullable for load

* Update common/src/main/java/me/shedaniel/architectury/event/events/ChunkEvent.java

* Bump to 1.16

Co-authored-by: shedaniel <daniel@shedaniel.me>
Co-authored-by: Max <maxh2709@gmail.com>

* Update pr.yml

* Add NetworkManager hook for Entity spawn packets (#88)

* New utility hook for creating a entity spawn packet. before every mod had to implement this in itself.

* Apply suggestions from code review

Co-authored-by: shedaniel <daniel@shedaniel.me>

* Update common/src/main/java/me/shedaniel/architectury/networking/NetworkManager.java

* Update common/src/main/java/me/shedaniel/architectury/networking/NetworkManager.java

* Properly implement SpawnEntityPacket & Format style

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Format

Signed-off-by: shedaniel <daniel@shedaniel.me>

* createEntitySpawnPacket -> createAddEntityPacket for mojmap consistency

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Bump version to 1.17

Co-authored-by: Max <maxh2709@gmail.com>
Co-authored-by: shedaniel <daniel@shedaniel.me>

* Add Javadocs for all events (#91)

* javadoc for ClientChatEvent

* javadoc for ClientPlayerEvent

* javadoc for ClientRawInputEvent

* Added javadoc for ClientScreenInputEvent

* Bit refactoring and removed javadoc @see to the caller methods

* Add javadoc for BlockEvent

* Add javadoc for ChatEvent

* Add javadoc for CommandPerformEvent and CommandRegistrationEvent

* Add javadoc for EntityEvent

* Add javadoc for ExplosionEvent

* Add javadoc for GuiEvent

* Add javadoc for InteractionEvent

* Add javadoc for LightningEvent, RecipeUpdateEvent & TextureStitchEvent

* Add javadoc for LifecycleEvent & ClientLifecycleEvent

* Add javadoc for TooltipEvent

* Add javadoc for TickEvent and partly PlayerEvent

* More javadoc for PlayerEvent

* Finally all event have javadoc

* Update common/src/main/java/me/shedaniel/architectury/event/events/CommandPerformEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/CommandPerformEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/CommandPerformEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/ChatEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/CommandRegistrationEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/EntityEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/EntityEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/EntityEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/EntityEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/client/ClientScreenInputEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/client/ClientScreenInputEvent.java

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/BlockEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/BlockEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/BlockEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/BlockEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/LifecycleEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/LifecycleEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/LifecycleEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Update common/src/main/java/me/shedaniel/architectury/event/events/PlayerEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Apply suggestions from code review

Co-authored-by: Max <maxh2709@gmail.com>
Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>
Co-authored-by: Max <maxh2709@gmail.com>

* Apply suggestions from code review

Co-authored-by: Max <maxh2709@gmail.com>
Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Max <maxh2709@gmail.com>
Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Max <maxh2709@gmail.com>
Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: shedaniel <daniel@shedaniel.me>

* Applied some more reviews

* Applied some more reviews

* Applied suggestions

* Reformat and apply some minor suggestions

* Apply suggestions from review (first batch)

* Remove double return javadoc

* Apply suggestions from code review

Co-authored-by: shedaniel <daniel@shedaniel.me>

* Add "scaled" to mouse coordinates

* Final touches

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Remove invalid tips

Signed-off-by: shedaniel <daniel@shedaniel.me>

Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>
Co-authored-by: Max <maxh2709@gmail.com>
Co-authored-by: shedaniel <daniel@shedaniel.me>

* Refactor

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Update common/src/main/java/dev/architectury/event/events/common/InteractionEvent.java

Co-authored-by: Max <maxh2709@gmail.com>

* Apply suggestions from code review

Co-authored-by: Max <maxh2709@gmail.com>

* attack -> hurt

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Update @param for InteractionEvent#FARMLAND_TRAMPLE

Signed-off-by: shedaniel <daniel@shedaniel.me>

* world -> level

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Relocate hooks

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Organize imports

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Registry -> Registrar Please voice out your opinion!!

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Some more renames
itemOptional -> optionalItem
RegistryBuilder -> RegistrarBuilder
RegistryOption -> RegistrarOption
Not forcing RegistryEntry on new registries, vanilla types don't have them

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Java 16-ification

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Optimise imports after the var change

Signed-off-by: shedaniel <daniel@shedaniel.me>

* Un-minimize architectury-common.mixins.json

Signed-off-by: shedaniel <daniel@shedaniel.me>

Co-authored-by: canitzp <12819060+canitzp@users.noreply.github.com>
Co-authored-by: Max <maxh2709@gmail.com>
Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>
This commit is contained in:
shedaniel
2021-05-30 19:08:11 +08:00
committed by GitHub
parent 28867f012d
commit 8b262d07c0
229 changed files with 3529 additions and 2354 deletions

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury;
package dev.architectury.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury;
package dev.architectury.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.core;
package dev.architectury.core;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeSerializer;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.core;
package dev.architectury.core;
/**
* An entry in registries, will extend {@code ForgeRegistryEntry} on forge.

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event;
package dev.architectury.event;
import net.minecraft.world.InteractionResultHolder;
@@ -28,7 +28,7 @@ import net.minecraft.world.InteractionResultHolder;
* @param <T> the type of the extra result
* @see #pass()
* @see #interrupt(Boolean, Object)
* @see CompoundEventResult
* @see EventResult
*/
public class CompoundEventResult<T> {
private static final CompoundEventResult<?> PASS = new CompoundEventResult<>(EventResult.pass(), null);
@@ -114,6 +114,44 @@ public class CompoundEventResult<T> {
return result.value();
}
/**
* Returns whether the result does not contain an outcome, may be {@code false} only
* if the event is deterministic.
*
* @return whether the result does not contain an outcome
*/
public boolean isEmpty() {
return result.isEmpty();
}
/**
* Returns whether the result contains an outcome, may be {@code true} only
* if the event is deterministic.
*
* @return whether the result contains an outcome
*/
public boolean isPresent() {
return result.isPresent();
}
/**
* Returns whether the result contains a {@code true} outcome
*
* @return whether the result contains a {@code true} outcome
*/
public boolean isTrue() {
return result.isTrue();
}
/**
* Returns whether the result contains a {@code false} outcome
*
* @return whether the result contains a {@code false} outcome
*/
public boolean isFalse() {
return result.isFalse();
}
/**
* Returns the {@link EventResult} view of the result, this returns the same values as
* {@link #interruptsFurtherEvaluation()} and {@link #value()}.
@@ -139,9 +177,6 @@ public class CompoundEventResult<T> {
* @return the Minecraft-facing result
*/
public InteractionResultHolder<T> asMinecraft() {
if (value() != null) {
return value() ? InteractionResultHolder.success(object()) : InteractionResultHolder.fail(object());
}
return InteractionResultHolder.pass(object());
return new InteractionResultHolder<>(result.asMinecraft(), object);
}
}

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event;
package dev.architectury.event;
public interface Event<T> {
T invoker();

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event;
package dev.architectury.event;
@FunctionalInterface
public interface EventActor<T> {

View File

@@ -17,14 +17,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event;
package dev.architectury.event;
import com.google.common.reflect.AbstractInvocationHandler;
import me.shedaniel.architectury.ForgeEvent;
import me.shedaniel.architectury.ForgeEventCancellable;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import dev.architectury.annotations.ForgeEvent;
import dev.architectury.annotations.ForgeEventCancellable;
import dev.architectury.injectables.annotations.ExpectPlatform;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -55,7 +53,7 @@ public final class EventFactory {
return of(listeners -> (T) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{clazz}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
for (T listener : listeners) {
for (var listener : listeners) {
method.invoke(listener, args);
}
return null;
@@ -63,28 +61,6 @@ public final class EventFactory {
}));
}
@SafeVarargs
public static <T> Event<T> createInteractionResult(T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
return createInteractionResult((Class<T>) typeGetter.getClass().getComponentType());
}
@SuppressWarnings("UnstableApiUsage")
public static <T> Event<T> createInteractionResult(Class<T> clazz) {
return of(listeners -> (T) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{clazz}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
for (T listener : listeners) {
InteractionResult result = (InteractionResult) Objects.requireNonNull(method.invoke(listener, args));
if (result != InteractionResult.PASS) {
return result;
}
}
return InteractionResult.PASS;
}
}));
}
@SafeVarargs
public static <T> Event<T> createEventResult(T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
@@ -96,8 +72,8 @@ public final class EventFactory {
return of(listeners -> (T) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{clazz}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
for (T listener : listeners) {
EventResult result = (EventResult) Objects.requireNonNull(method.invoke(listener, args));
for (var listener : listeners) {
var result = (EventResult) Objects.requireNonNull(method.invoke(listener, args));
if (result.interruptsFurtherEvaluation()) {
return result;
}
@@ -107,28 +83,6 @@ public final class EventFactory {
}));
}
@SafeVarargs
public static <T> Event<T> createInteractionResultHolder(T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
return createInteractionResultHolder((Class<T>) typeGetter.getClass().getComponentType());
}
@SuppressWarnings("UnstableApiUsage")
public static <T> Event<T> createInteractionResultHolder(Class<T> clazz) {
return of(listeners -> (T) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{clazz}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
for (T listener : listeners) {
InteractionResultHolder result = (InteractionResultHolder) Objects.requireNonNull(method.invoke(listener, args));
if (result.getResult() != InteractionResult.PASS) {
return result;
}
}
return InteractionResultHolder.pass(null);
}
}));
}
@SafeVarargs
public static <T> Event<T> createCompoundEventResult(T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
@@ -140,8 +94,8 @@ public final class EventFactory {
return of(listeners -> (T) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{clazz}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
for (T listener : listeners) {
CompoundEventResult result = (CompoundEventResult) Objects.requireNonNull(method.invoke(listener, args));
for (var listener : listeners) {
var result = (CompoundEventResult) Objects.requireNonNull(method.invoke(listener, args));
if (result.interruptsFurtherEvaluation()) {
return result;
}
@@ -162,7 +116,7 @@ public final class EventFactory {
Event<Consumer<T>> event = of(listeners -> (Consumer<T>) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{Consumer.class}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
for (Consumer<T> listener : listeners) {
for (var listener : listeners) {
method.invoke(listener, args);
}
return null;
@@ -178,45 +132,6 @@ public final class EventFactory {
return event;
}
@SafeVarargs
public static <T> Event<Actor<T>> createActorLoop(T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
return createActorLoop((Class<T>) typeGetter.getClass().getComponentType());
}
@SuppressWarnings("UnstableApiUsage")
public static <T> Event<Actor<T>> createActorLoop(Class<T> clazz) {
Event<Actor<T>> event = of(listeners -> (Actor<T>) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{Actor.class}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
for (Actor<T> listener : listeners) {
InteractionResult result = (InteractionResult) method.invoke(listener, args);
if (result != InteractionResult.PASS) {
return result;
}
}
return InteractionResult.PASS;
}
}));
Class<?> superClass = clazz;
do {
if (superClass.isAnnotationPresent(ForgeEventCancellable.class)) {
return attachToForgeActorCancellable(event);
}
superClass = superClass.getSuperclass();
} while (superClass != null);
superClass = clazz;
do {
if (superClass.isAnnotationPresent(ForgeEvent.class)) {
return attachToForgeActor(event);
}
superClass = superClass.getSuperclass();
} while (superClass != null);
return event;
}
@SafeVarargs
public static <T> Event<EventActor<T>> createEventActorLoop(T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
@@ -228,8 +143,8 @@ public final class EventFactory {
Event<EventActor<T>> event = of(listeners -> (EventActor<T>) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{EventActor.class}, new AbstractInvocationHandler() {
@Override
protected Object handleInvocation(@NotNull Object proxy, @NotNull Method method, Object @NotNull [] args) throws Throwable {
for (EventActor<T> listener : listeners) {
EventResult result = (EventResult) method.invoke(listener, args);
for (var listener : listeners) {
var result = (EventResult) method.invoke(listener, args);
if (result.interruptsFurtherEvaluation()) {
return result;
}
@@ -262,18 +177,6 @@ public final class EventFactory {
throw new AssertionError();
}
@ExpectPlatform
@ApiStatus.Internal
public static <T> Event<Actor<T>> attachToForgeActor(Event<Actor<T>> event) {
throw new AssertionError();
}
@ExpectPlatform
@ApiStatus.Internal
public static <T> Event<Actor<T>> attachToForgeActorCancellable(Event<Actor<T>> event) {
throw new AssertionError();
}
@ExpectPlatform
@ApiStatus.Internal
public static <T> Event<EventActor<T>> attachToForgeEventActor(Event<EventActor<T>> event) {

View File

@@ -17,14 +17,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event;
package dev.architectury.event;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.event.events.BlockEvent;
import me.shedaniel.architectury.event.events.EntityEvent;
import me.shedaniel.architectury.event.events.PlayerEvent;
import me.shedaniel.architectury.platform.Platform;
import me.shedaniel.architectury.utils.Env;
import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.architectury.platform.Platform;
import dev.architectury.utils.Env;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

View File

@@ -17,7 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event;
package dev.architectury.event;
import net.minecraft.world.InteractionResult;
import org.apache.commons.lang3.BooleanUtils;
/**
* A result from an event, determines if the event should continue to other listeners,
@@ -112,4 +115,54 @@ public final class EventResult {
public Boolean value() {
return value;
}
/**
* Returns whether the result does not contain an outcome, may be {@code false} only
* if the event is deterministic.
*
* @return whether the result does not contain an outcome
*/
public boolean isEmpty() {
return value == null;
}
/**
* Returns whether the result contains an outcome, may be {@code true} only
* if the event is deterministic.
*
* @return whether the result contains an outcome
*/
public boolean isPresent() {
return value != null;
}
/**
* Returns whether the result contains a {@code true} outcome
*
* @return whether the result contains a {@code true} outcome
*/
public boolean isTrue() {
return BooleanUtils.isTrue(value);
}
/**
* Returns whether the result contains a {@code false} outcome
*
* @return whether the result contains a {@code false} outcome
*/
public boolean isFalse() {
return BooleanUtils.isFalse(value);
}
/**
* Returns the Minecraft-facing result, however ignores {@link #interruptsFurtherEvaluation()}.
*
* @return the Minecraft-facing result
*/
public InteractionResult asMinecraft() {
if (isPresent()) {
return value() ? InteractionResult.SUCCESS : InteractionResult.FAIL;
}
return InteractionResult.PASS;
}
}

View File

@@ -0,0 +1,72 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.client;
import dev.architectury.event.CompoundEventResult;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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)
*/
Event<Process> PROCESS = EventFactory.createCompoundEventResult();
/**
* @see Received#process(ChatType, Component, UUID)
*/
Event<Received> RECEIVED = EventFactory.createCompoundEventResult();
@Environment(EnvType.CLIENT)
interface Process {
/**
* 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.
* @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);
}
@Environment(EnvType.CLIENT)
interface Received {
/**
* Event to intercept the receiving of an chat message.
* Invoked as soon as the client receives the chat message packet.
* Equivalent to Forge's {@code ClientChatReceivedEvent} event.
*
* @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 {@link net.minecraft.Util#NIL_UUID}
* @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 UUID sender);
}
}

View File

@@ -0,0 +1,160 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.client;
import com.mojang.blaze3d.vertex.PoseStack;
import dev.architectury.event.CompoundEventResult;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import dev.architectury.hooks.client.screen.ScreenAccess;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screens.Screen;
import java.util.List;
@Environment(EnvType.CLIENT)
public interface ClientGuiEvent {
/**
* @see RenderHud#renderHud(PoseStack, float)
*/
Event<RenderHud> RENDER_HUD = EventFactory.createLoop();
/**
* @see DebugText#gatherText(List)
*/
Event<DebugText> DEBUG_TEXT_LEFT = EventFactory.createLoop();
Event<DebugText> DEBUG_TEXT_RIGHT = EventFactory.createLoop();
/**
* @see ScreenInitPre#init(Screen, ScreenAccess)
*/
Event<ScreenInitPre> INIT_PRE = EventFactory.createEventResult();
/**
* @see ScreenInitPost#init(Screen, ScreenAccess)
*/
Event<ScreenInitPost> INIT_POST = EventFactory.createLoop();
/**
* @see ScreenRenderPre#render(Screen, PoseStack, int, int, float)
*/
Event<ScreenRenderPre> RENDER_PRE = EventFactory.createEventResult();
/**
* @see ScreenRenderPost#render(Screen, PoseStack, int, int, float)
*/
Event<ScreenRenderPost> RENDER_POST = EventFactory.createLoop();
/**
* @see SetScreen#modifyScreen(Screen)
*/
Event<SetScreen> SET_SCREEN = EventFactory.createCompoundEventResult();
@Environment(EnvType.CLIENT)
interface RenderHud {
/**
* Invoked after the in-game hud has been rendered.
* Equivalent to Forge's {@code RenderGameOverlayEvent.Post@ElementType#ALL} and Fabric's {@code HudRenderCallback}.
*
* @param matrices The pose stack.
* @param tickDelta The tick delta.
*/
void renderHud(PoseStack matrices, float tickDelta);
}
@Environment(EnvType.CLIENT)
interface DebugText {
/**
* Invoked when the debug text is being gathered for rendering.
* There are two different versions of this event, one for the left and one for the right side.
* Equivalent to Forge's {@code RenderGameOverlayEvent.Text}, when {@code Minecraft.getInstance().options.renderDebug} is true.
*
* @param strings The current debug text strings.
*/
void gatherText(List<String> strings);
}
@Environment(EnvType.CLIENT)
interface ScreenInitPre {
/**
* Invoked when a screen is being initialized and after the previous widgets have been cleared.
* Equivalent to Forge's {@code GuiScreenEvent.InitGuiEvent.Pre} event.
*
* @param screen The screen.
* @param access The accessor of the screen.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla initialization may be cancelled by the result.
*/
EventResult init(Screen screen, ScreenAccess access);
}
@Environment(EnvType.CLIENT)
interface ScreenInitPost {
/**
* Invoked after a screen has been initialized and all the vanilla initialization logic has happened.
* Equivalent to Forge's {@code GuiScreenEvent.InitGuiEvent.Post} event.
*
* @param screen The screen.
* @param access The accessor of the screen.
*/
void init(Screen screen, ScreenAccess access);
}
@Environment(EnvType.CLIENT)
interface ScreenRenderPre {
/**
* Invoked before any screen is rendered.
* Equivalent to Forge's {@code GuiScreenEvent.DrawScreenEvent.Pre} event.
*
* @param screen The screen.
* @param matrices The pose stack.
* @param mouseX The scaled x-coordinate of the mouse cursor.
* @param mouseY The scaled y-coordinate of the mouse cursor.
* @param delta The current tick delta.
* @return A {@link EventResult} determining the outcome of the event,
* the vanilla render may be cancelled by the result.
*/
EventResult render(Screen screen, PoseStack matrices, int mouseX, int mouseY, float delta);
}
@Environment(EnvType.CLIENT)
interface ScreenRenderPost {
/**
* Invoked after a screen has finished rendering using the vanilla logic.
* Equivalent to Forge's {@code GuiScreenEvent.DrawScreenEvent.Post} event.
*
* @param screen The screen.
* @param matrices The pose stack.
* @param mouseX The scaled x-coordinate of the mouse cursor.
* @param mouseY The scaled y-coordinate of the mouse cursor.
* @param delta The current tick delta.
*/
void render(Screen screen, PoseStack matrices, int mouseX, int mouseY, float delta);
}
@Environment(EnvType.CLIENT)
interface SetScreen {
/**
* Invoked before a new screen is set to open.
* Equivalent to Forge's {@code GuiOpenEvent} event.
*
* @param screen The screen that is going to be opened.
* @return A {@link CompoundEventResult} determining the outcome of the event,
* if an outcome is set, the vanilla screen is overridden.
*/
CompoundEventResult<Screen> modifyScreen(Screen screen);
}
}

View File

@@ -17,11 +17,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events.client;
package dev.architectury.event.events.client;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
import me.shedaniel.architectury.event.events.LifecycleEvent;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.events.common.LifecycleEvent;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
@@ -40,9 +40,15 @@ public interface ClientLifecycleEvent {
@Deprecated
Event<ClientState> CLIENT_STOPPING = EventFactory.createLoop();
/**
* Invoked after a world is loaded only on client, equivalent to forge's {@code WorldEvent.Load}.
* Invoked after a level is loaded only on the client-side.
* Equivalent to Forge's {@code WorldEvent.Load} event (on client).
*/
Event<ClientLevelState> CLIENT_LEVEL_LOAD = EventFactory.createLoop();
/**
* Invoked once client setup has begun.
* <p> This happens during {@code FMLClientSetupEvent} on Forge,
* or when Architectury API's client entrypoint initialises on Fabric.
*/
Event<ClientWorldState> CLIENT_WORLD_LOAD = EventFactory.createLoop();
Event<ClientState> CLIENT_SETUP = EventFactory.createLoop();
@Environment(EnvType.CLIENT)
@@ -50,6 +56,6 @@ public interface ClientLifecycleEvent {
}
@Environment(EnvType.CLIENT)
interface ClientWorldState extends LifecycleEvent.WorldState<ClientLevel> {
interface ClientLevelState extends LifecycleEvent.LevelState<ClientLevel> {
}
}

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events.client;
package dev.architectury.event.events.client;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.player.LocalPlayer;
@@ -28,22 +28,47 @@ import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
public interface ClientPlayerEvent {
/**
* @see ClientPlayerJoin#join(LocalPlayer)
*/
Event<ClientPlayerJoin> CLIENT_PLAYER_JOIN = EventFactory.createLoop();
/**
* @see ClientPlayerQuit#quit(LocalPlayer)
*/
Event<ClientPlayerQuit> CLIENT_PLAYER_QUIT = EventFactory.createLoop();
/**
* @see ClientPlayerRespawn#respawn(LocalPlayer, LocalPlayer)
*/
Event<ClientPlayerRespawn> CLIENT_PLAYER_RESPAWN = EventFactory.createLoop();
@Environment(EnvType.CLIENT)
interface ClientPlayerJoin {
/**
* Invoked whenever a client player joins a level
*
* @param player The player joining.
*/
void join(LocalPlayer player);
}
@Environment(EnvType.CLIENT)
interface ClientPlayerQuit {
/**
* Invoked whenever a client player leaves a level and is cleared on the client side.
*
* @param player The player leaving.
*/
void quit(@Nullable LocalPlayer player);
}
@Environment(EnvType.CLIENT)
interface ClientPlayerRespawn {
/**
* Invoked whenever the player respawn packet is received by the client.
*
* @param oldPlayer The player before the respawn.
* @param newPlayer The player after the respawn.
*/
void respawn(LocalPlayer oldPlayer, LocalPlayer newPlayer);
}
}

View File

@@ -0,0 +1,88 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.client;
import dev.architectury.event.Event;
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;
@Environment(EnvType.CLIENT)
public interface ClientRawInputEvent {
/**
* @see MouseScrolled#mouseScrolled(Minecraft, double)
*/
Event<MouseScrolled> MOUSE_SCROLLED = EventFactory.createEventResult();
/**
* @see MouseClicked#mouseClicked(Minecraft, int, int, int)
*/
Event<MouseClicked> MOUSE_CLICKED_PRE = EventFactory.createEventResult();
Event<MouseClicked> MOUSE_CLICKED_POST = EventFactory.createEventResult();
/**
* @see KeyPressed#keyPressed(Minecraft, int, int, int, int)
*/
Event<KeyPressed> KEY_PRESSED = EventFactory.createEventResult();
interface KeyPressed {
/**
* Invoked whenever a key input is performed.
* Equivalent to Forge's {@code InputEvent.KeyInputEvent} event.
*
* @param client The Minecraft instance performing it.
* @param keyCode The key code.
* @param scanCode The raw keyboard scan code.
* @param action The action that should be performed.
* @param modifiers Additional modifiers.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla pressing mechanism may be cancelled by the result.
*/
EventResult keyPressed(Minecraft client, int keyCode, int scanCode, int action, int modifiers);
}
interface MouseScrolled {
/**
* Invoked whenever the mouse scroll wheel is used.
* Equivalent to Forge's {@code InputEvent.MouseScrollEvent} event.
*
* @param client The Minecraft instance performing it.
* @param amount The amount of movement.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla scrolling mechanism may be cancelled by the result.
*/
EventResult mouseScrolled(Minecraft client, double amount);
}
interface MouseClicked {
/**
* Invoked whenever a mouse button is pressed.
* There are two variants, either a raw mouse input or the input after it is processed by the game.
*
* @param client The Minecraft instance performing it.
* @param button The pressed mouse button.
* @param action The action that should be performed.
* @param mods Additional modifiers.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla clicking mechanism may be cancelled by the result.
*/
EventResult mouseClicked(Minecraft client, int button, int action, int mods);
}
}

View File

@@ -17,17 +17,26 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events;
package dev.architectury.event.events.client;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.item.crafting.RecipeManager;
@Environment(EnvType.CLIENT)
public interface RecipeUpdateEvent {
Event<RecipeUpdateEvent> EVENT = EventFactory.createLoop();
public interface ClientRecipeUpdateEvent {
/**
* @see ClientRecipeUpdateEvent#update(RecipeManager)
*/
Event<ClientRecipeUpdateEvent> EVENT = EventFactory.createLoop();
/**
* Invoked when the client has received an updated list of recipes from the server.
* Equivalent to Forge's {@code RecipesUpdatedEvent} event.
*
* @param recipeManager The recipe manager.
*/
void update(RecipeManager recipeManager);
}

View File

@@ -0,0 +1,201 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.client;
import dev.architectury.event.Event;
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.screens.Screen;
@Environment(EnvType.CLIENT)
public interface ClientScreenInputEvent {
/**
* @see MouseScrolled#mouseScrolled(Minecraft, Screen, double, double, double)
*/
Event<MouseScrolled> MOUSE_SCROLLED_PRE = EventFactory.createEventResult();
Event<MouseScrolled> MOUSE_SCROLLED_POST = EventFactory.createEventResult();
/**
* @see MouseClicked#mouseClicked(Minecraft, Screen, double, double, int)
*/
Event<MouseClicked> MOUSE_CLICKED_PRE = EventFactory.createEventResult();
Event<MouseClicked> MOUSE_CLICKED_POST = EventFactory.createEventResult();
/**
* @see MouseReleased#mouseReleased(Minecraft, Screen, double, double, int)
*/
Event<MouseReleased> MOUSE_RELEASED_PRE = EventFactory.createEventResult();
Event<MouseReleased> MOUSE_RELEASED_POST = EventFactory.createEventResult();
/**
* @see MouseDragged#mouseDragged(Minecraft, Screen, double, double, int, double, double)
*/
Event<MouseDragged> MOUSE_DRAGGED_PRE = EventFactory.createEventResult();
Event<MouseDragged> MOUSE_DRAGGED_POST = EventFactory.createEventResult();
/**
* @see KeyTyped#charTyped(Minecraft, Screen, char, int)
*/
Event<KeyTyped> CHAR_TYPED_PRE = EventFactory.createEventResult();
Event<KeyTyped> CHAR_TYPED_POST = EventFactory.createEventResult();
/**
* @see KeyPressed#keyPressed(Minecraft, Screen, int, int, int)
*/
Event<KeyPressed> KEY_PRESSED_PRE = EventFactory.createEventResult();
Event<KeyPressed> KEY_PRESSED_POST = EventFactory.createEventResult();
/**
* @see KeyReleased#keyReleased(Minecraft, Screen, int, int, int)
*/
Event<KeyReleased> KEY_RELEASED_PRE = EventFactory.createEventResult();
Event<KeyReleased> KEY_RELEASED_POST = EventFactory.createEventResult();
interface KeyPressed {
/**
* Invoked whenever a key press is performed inside a screen.
* Equivalent to Forge's {@code GuiScreenEvent.KeyboardKeyPressedEvent} event.
*
* <p> This event is handled in two phases PRE and POST, which are invoked
* before and after the keys have been processed by the screen, respectively.
*
* @param client The Minecraft instance performing it.
* @param screen The screen this keystroke was performed in.
* @param keyCode The key code.
* @param scanCode The raw keyboard scan code.
* @param modifiers Additional modifiers.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla pressing mechanism may be cancelled by the result.
*/
EventResult keyPressed(Minecraft client, Screen screen, int keyCode, int scanCode, int modifiers);
}
interface KeyReleased {
/**
* Invoked whenever a held key is released inside a screen.
* Equivalent to Forge's {@code GuiScreenEvent.KeyboardKeyReleasedEvent} event.
*
* <p> This event is handled in two phases PRE and POST, which are invoked
* before and after the keys have been processed by the screen, respectively.
*
* @param client The Minecraft instance performing it.
* @param screen The screen this keystroke was performed in.
* @param keyCode The key code.
* @param scanCode The raw keyboard scan code.
* @param modifiers Additional modifiers.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla releasing mechanism may be cancelled by the result.
*/
EventResult keyReleased(Minecraft client, Screen screen, int keyCode, int scanCode, int modifiers);
}
interface KeyTyped {
/**
* Invoked whenever a character is typed within a screen.
* Equivalent to Forge's {@code GuiScreenEvent.KeyboardCharTypedEvent} event.
*
* <p> This event is handled in two phases PRE and POST, which are invoked
* before and after the keys have been processed by the screen, respectively.
*
* @param client The Minecraft instance performing it.
* @param screen The screen this keystroke was performed in.
* @param character The typed character.
* @param keyCode The key code.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla typing mechanism may be cancelled by the result.
*/
EventResult charTyped(Minecraft client, Screen screen, char character, int keyCode);
}
interface MouseScrolled {
/**
* Invoked whenever the mouse scroll wheel is moved.
* Equivalent to Forge's {@code GuiScreenEvent.MouseScrollEvent} event.
*
* <p> This event is handled in two phases PRE and POST, which are invoked
* before and after the keys have been processed by the screen, respectively.
*
* @param client The Minecraft instance performing it.
* @param screen The screen this keystroke was performed in.
* @param mouseX The scaled x-coordinate of the mouse cursor.
* @param mouseY The scaled y-coordinate of the mouse cursor.
* @param amount The amount the scroll wheel is moved.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla scrolling mechanism may be cancelled by the result.
*/
EventResult mouseScrolled(Minecraft client, Screen screen, double mouseX, double mouseY, double amount);
}
interface MouseReleased {
/**
* Invoked whenever a mouse button is released.
* Equivalent to Forge's {@code GuiScreenEvent.MouseReleasedEvent} event.
*
* <p> This event is handled in two phases PRE and POST, which are invoked
* before and after the keys have been processed by the screen, respectively.
*
* @param client The Minecraft instance performing it.
* @param screen The screen this keystroke was performed in.
* @param mouseX The scaled x-coordinate of the mouse cursor.
* @param mouseY The scaled y-coordinate of the mouse cursor.
* @param button The released mouse button.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla releasing mechanism may be cancelled by the result.
*/
EventResult mouseReleased(Minecraft client, Screen screen, double mouseX, double mouseY, int button);
}
interface MouseDragged {
/**
* Invoked whenever the mouse is dragged across a screen.
* Equivalent to Forge's {@code GuiScreenEvent.MouseDragEvent} event.
*
* <p> This event is handled in two phases PRE and POST, which are invoked
* before and after the keys have been processed by the screen, respectively.
*
* @param client The Minecraft instance performing it.
* @param screen The screen this keystroke was performed in.
* @param mouseX1 The initial scaled x-coordinate of the mouse cursor.
* @param mouseY1 The initial scaled y-coordinate of the mouse cursor.
* @param button The dragged mouse button.
* @param mouseX2 The final scaled x-coordinate of the mouse cursor.
* @param mouseY2 The final scaled y-coordinate of the mouse cursor.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla dragging mechanism may be cancelled by the result.
*/
EventResult mouseDragged(Minecraft client, Screen screen, double mouseX1, double mouseY1, int button, double mouseX2, double mouseY2);
}
interface MouseClicked {
/**
* Invoked whenever a mouse click is performed. A click consists of the press and release of a mouse button.
* Equivalent to Forge's {@code GuiScreenEvent.MouseClickedEvent} event.
*
* <p> This event is handled in two phases PRE and POST, which are invoked
* before and after the keys have been processed by the screen, respectively.
*
* @param client The Minecraft instance performing it.
* @param screen The screen this keystroke was performed in.
* @param mouseX The scaled x-coordinate of the mouse cursor.
* @param mouseY The scaled y-coordinate of the mouse cursor.
* @param button The clicked mouse button.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla clicking mechanism may be cancelled by the result.
*/
EventResult mouseClicked(Minecraft client, Screen screen, double mouseX, double mouseY, int button);
}
}

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events;
package dev.architectury.event.events.client;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.texture.TextureAtlas;
@@ -29,17 +29,36 @@ import net.minecraft.resources.ResourceLocation;
import java.util.function.Consumer;
@Environment(EnvType.CLIENT)
public interface TextureStitchEvent {
public interface ClientTextureStitchEvent {
/**
* @see Pre#stitch(TextureAtlas, Consumer)
*/
Event<Pre> PRE = EventFactory.createLoop();
/**
* @see Post#stitch(TextureAtlas)
*/
Event<Post> POST = EventFactory.createLoop();
@Environment(EnvType.CLIENT)
interface Pre {
/**
* Invoked before the texture atlas is stitched together.
* Equivalent to Forge's {@code TextureStitchEvent.Pre} event.
*
* @param atlas The TextureAtlas.
* @param spriteAdder A consumer where you can add your own sprites to be stitched.
*/
void stitch(TextureAtlas atlas, Consumer<ResourceLocation> spriteAdder);
}
@Environment(EnvType.CLIENT)
interface Post {
/**
* Invoked after the texture atlas has been fully stitched.
* Equivalent to Forge's {@code TextureStitchEvent.Post} event.
*
* @param atlas The ready-to-use TextureAtlas.
*/
void stitch(TextureAtlas atlas);
}
}

View File

@@ -17,21 +17,20 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events.client;
package dev.architectury.event.events.client;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
@Environment(EnvType.CLIENT)
public interface ClientTickEvent<T> {
Event<Client> CLIENT_PRE = EventFactory.createLoop();
Event<Client> CLIENT_POST = EventFactory.createLoop();
Event<ClientWorld> CLIENT_WORLD_PRE = EventFactory.createLoop();
Event<ClientWorld> CLIENT_WORLD_POST = EventFactory.createLoop();
Event<ClientLevel> CLIENT_LEVEL_PRE = EventFactory.createLoop();
Event<ClientLevel> CLIENT_LEVEL_POST = EventFactory.createLoop();
void tick(T instance);
@@ -40,6 +39,6 @@ public interface ClientTickEvent<T> {
}
@Environment(EnvType.CLIENT)
interface ClientWorld extends ClientTickEvent<ClientLevel> {
interface ClientLevel extends ClientTickEvent<net.minecraft.client.multiplayer.ClientLevel> {
}
}

View File

@@ -0,0 +1,160 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.client;
import com.mojang.blaze3d.vertex.PoseStack;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import java.util.List;
@Environment(EnvType.CLIENT)
public interface ClientTooltipEvent {
/**
* @see Item#append(ItemStack, List, TooltipFlag)
*/
Event<Item> ITEM = EventFactory.createLoop();
/**
* @see RenderVanilla#renderTooltip(PoseStack, List, int, int)
*/
Event<RenderVanilla> RENDER_VANILLA_PRE = EventFactory.createEventResult();
/**
* @see RenderForge#renderTooltip(PoseStack, List, int, int)
*/
Event<RenderForge> RENDER_FORGE_PRE = EventFactory.createEventResult();
/**
* @see RenderModifyPosition#renderTooltip(PoseStack, PositionContext)
*/
Event<RenderModifyPosition> RENDER_MODIFY_POSITION = EventFactory.createLoop();
/**
* @see RenderModifyColor#renderTooltip(PoseStack, int, int, ColorContext)
*/
Event<RenderModifyColor> RENDER_MODIFY_COLOR = EventFactory.createLoop();
@Environment(EnvType.CLIENT)
interface Item {
/**
* Invoked whenever an item tooltip is rendered.
* Equivalent to Forge's {@code ItemTooltipEvent} event and
* Fabric's {@code ItemTooltipCallback}.
*
* @param stack The rendered stack.
* @param lines The mutable list of tooltip components.
* @param flag A flag indicating if advanced mode is active.
*/
void append(ItemStack stack, List<Component> lines, TooltipFlag flag);
}
@Environment(EnvType.CLIENT)
interface RenderVanilla {
/**
* Invoked before the tooltip for a tooltip is rendered.
*
* <p> This is <b>not</b> invoked on Forge due to
* {@link RenderForge#renderTooltip(PoseStack, List, int, int) fundamental differences}
* in Forge and vanilla tooltip logic.
*
* @param matrices The pose stack.
* @param texts The mutable list of components that are rendered.
* @param x The x-coordinate of the tooltip.
* @param y The y-coordinate of the tooltip.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla tooltip rendering may be cancelled by the result.
*/
EventResult renderTooltip(PoseStack matrices, List<? extends FormattedCharSequence> texts, int x, int y);
}
@Environment(EnvType.CLIENT)
interface RenderForge {
/**
* Invoked before the tooltip for a tooltip is rendered.
*
* <p> This is <b>only</b> invoked on Forge due to
* {@link RenderVanilla#renderTooltip(PoseStack, List, int, int) fundamental differences}
* in Forge and vanilla tooltip logic.
*
* @param matrices The pose stack.
* @param texts The mutable list of components that are rendered.
* @param x The x-coordinate of the tooltip.
* @param y The y-coordinate of the tooltip.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the forge tooltip rendering may be cancelled by the result.
*/
EventResult renderTooltip(PoseStack matrices, List<? extends FormattedText> texts, int x, int y);
}
@Environment(EnvType.CLIENT)
interface RenderModifyPosition {
/**
* Event to manipulate the position of the tooltip.
*
* @param matrices The pose stack.
* @param context The current position context.
*/
void renderTooltip(PoseStack matrices, PositionContext context);
}
@Environment(EnvType.CLIENT)
interface RenderModifyColor {
/**
* Event to manipulate the color of the tooltip.
*
* @param matrices The pose stack.
* @param x The x-coordinate of the tooltip.
* @param y The y-coordinate of the tooltip.
* @param context The current color context.
*/
void renderTooltip(PoseStack matrices, int x, int y, ColorContext context);
}
@Environment(EnvType.CLIENT)
interface PositionContext {
int getTooltipX();
void setTooltipX(int x);
int getTooltipY();
void setTooltipY(int y);
}
@Environment(EnvType.CLIENT)
interface ColorContext {
int getBackgroundColor();
void setBackgroundColor(int color);
int getOutlineGradientTopColor();
void setOutlineGradientTopColor(int color);
int getOutlineGradientBottomColor();
void setOutlineGradientBottomColor(int color);
}
}

View File

@@ -0,0 +1,89 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.common;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import dev.architectury.utils.value.IntValue;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.FallingBlockEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
public interface BlockEvent {
/**
* @see Break#breakBlock(Level, BlockPos, BlockState, ServerPlayer, IntValue)
*/
Event<Break> BREAK = EventFactory.createEventResult();
/**
* @see Place#placeBlock(Level, BlockPos, BlockState, Entity)
*/
Event<Place> PLACE = EventFactory.createEventResult();
/**
* @see FallingLand#onLand(Level, BlockPos, BlockState, BlockState, FallingBlockEntity)
*/
Event<FallingLand> FALLING_LAND = EventFactory.createLoop();
interface Break {
/**
* Invoked when a block is destroyed by a player.
*
* @param level The level the block is in.
* @param pos The position of the block.
* @param state The current state of the block.
* @param player The player who is breaking the block.
* @param xp The experience that are dropped when the block was destroyed. Always {@code null} on fabric.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla block breaking may be cancelled by the result.
*/
EventResult breakBlock(Level level, BlockPos pos, BlockState state, ServerPlayer player, @Nullable IntValue xp);
}
interface Place {
/**
* Invoked when a block is placed.
*
* @param level The level the block is in.
* @param pos The position of the block.
* @param state The future state of the block.
* @param placer The entity who is placing it. Can be {@code null}, e.g. when a dispenser places something.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla block placing may be cancelled by the result.
*/
EventResult placeBlock(Level level, BlockPos pos, BlockState state, @Nullable Entity placer);
}
interface FallingLand {
/**
* Invoked when a falling block is about to land.
*
* @param level The level the block is in.
* @param pos The position of the block.
* @param fallState The current state of the falling block.
* @param landOn The current state of the block the falling one is landing on.
* @param entity The falling block entity.
*/
void onLand(Level level, BlockPos pos, BlockState fallState, BlockState landOn, FallingBlockEntity entity);
}
}

View File

@@ -17,33 +17,42 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events;
package dev.architectury.event.events.common;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
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 net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
public interface ChatEvent {
/**
* Invoked when server receives a message, equivalent to forge's {@code ServerChatEvent}.
* @see Server#process(ServerPlayer, TextFilter.FilteredText, ChatComponent)
*/
Event<Server> SERVER = EventFactory.createInteractionResultHolder();
Event<Server> SERVER = EventFactory.createEventResult();
interface Server {
InteractionResult process(ServerPlayer player, TextFilter.FilteredText message, ChatComponent component);
/**
* 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 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.
*/
EventResult process(ServerPlayer player, TextFilter.FilteredText message, ChatComponent component);
}
interface ChatComponent {
Component getRaw();
Component getFiltered();
void setRaw(Component raw);
void setFiltered(Component filtered);
}
}

View File

@@ -0,0 +1,64 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.common;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.chunk.ChunkAccess;
import org.jetbrains.annotations.Nullable;
public interface ChunkEvent {
/**
* @see SaveData#save(ChunkAccess, ServerLevel, CompoundTag)
*/
Event<SaveData> SAVE_DATA = EventFactory.createLoop();
/**
* @see LoadData#load(ChunkAccess, ServerLevel, CompoundTag)
*/
Event<LoadData> LOAD_DATA = EventFactory.createLoop();
interface SaveData {
/**
* Invoked when a chunk's data is saved, just before the data is written.
* Add your own data to the {@link CompoundTag} parameter to get your data saved as well.
* Equivalent to Forge's {@code ChunkDataEvent.Save}.
*
* @param chunk The chunk that is saved.
* @param level The level the chunk is in.
* @param nbt The chunk data that is written to the save file.
*/
void save(ChunkAccess chunk, ServerLevel level, CompoundTag nbt);
}
interface LoadData {
/**
* Invoked just before a chunk's data is fully read.
* You can read out your own data from the {@link CompoundTag} parameter, when you have saved one before.
* Equivalent to Forge's {@code ChunkDataEvent.Load}.
*
* @param chunk The chunk that is loaded.
* @param level The level the chunk is in, may be {@code null}.
* @param nbt The chunk data that was read from the save file.
*/
void load(ChunkAccess chunk, @Nullable ServerLevel level, CompoundTag nbt);
}
}

View File

@@ -17,43 +17,65 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events;
package dev.architectury.event.events.common;
import com.mojang.brigadier.ParseResults;
import me.shedaniel.architectury.event.Actor;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
import dev.architectury.event.Event;
import dev.architectury.event.EventActor;
import dev.architectury.event.EventFactory;
import net.minecraft.commands.CommandSourceStack;
import org.jetbrains.annotations.Nullable;
/**
* This event is invoked whenever a command is issued.
* The {@link ParseResults} can be modified and even a custom {@link Throwable} can be used to tell the source of failure.
*
* <p>A command fails when any other result than {@link net.minecraft.world.InteractionResult#PASS} is returned.
* When PASS is used, the {@link CommandPerformEvent#getResults()} is used for execution.
*
* <p> Equivalent to Forge's {@code CommandEvent} event.
*/
public class CommandPerformEvent {
/**
* Invoked after server parses a command but before server executes it, equivalent to forge's {@code CommandEvent}.
*/
public static final Event<Actor<CommandPerformEvent>> EVENT = EventFactory.createActorLoop();
public static final Event<EventActor<CommandPerformEvent>> EVENT = EventFactory.createEventActorLoop();
private ParseResults<CommandSourceStack> results;
@Nullable
private Throwable throwable;
/**
* @param results The initial used parsed results.
* @param throwable The initial used throwable.
*/
public CommandPerformEvent(ParseResults<CommandSourceStack> results, @Nullable Throwable throwable) {
this.results = results;
this.throwable = throwable;
}
/**
* @return The parsed results for the issued command.
*/
public ParseResults<CommandSourceStack> getResults() {
return results;
}
/**
* @param results The new results the command should use.
*/
public void setResults(ParseResults<CommandSourceStack> results) {
this.results = results;
}
/**
* @return An throwable to be used as why the command has failed.
*/
@Nullable
public Throwable getThrowable() {
return throwable;
}
/**
* @param throwable The throwable used when the command has failed.
*/
public void setThrowable(@Nullable Throwable throwable) {
this.throwable = throwable;
}

View File

@@ -17,19 +17,26 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events;
package dev.architectury.event.events.common;
import com.mojang.brigadier.CommandDispatcher;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public interface CommandRegistrationEvent {
/**
* Invoked after server registers its commands, equivalent to forge's {@code RegisterCommandsEvent} and fabric's {@code CommandRegistrationCallback}.
* @see CommandRegistrationEvent#register(CommandDispatcher, Commands.CommandSelection)
*/
Event<CommandRegistrationEvent> EVENT = EventFactory.createLoop();
/**
* This event is invoked after the server registers it's commands.
* Equivalent to Forge's {@code RegisterCommandsEvent} and Fabric's {@code CommandRegistrationCallback}.
*
* @param dispatcher The command dispatcher to register commands to.
* @param selection The selection where the command can be executed.
*/
void register(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection selection);
}

View File

@@ -0,0 +1,133 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.common;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import org.jetbrains.annotations.Nullable;
public interface EntityEvent {
/**
* @see LivingDeath#die(LivingEntity, DamageSource)
*/
Event<LivingDeath> LIVING_DEATH = EventFactory.createEventResult();
/**
* @see LivingHurt#hurt(LivingEntity, DamageSource, float)
*/
Event<LivingHurt> LIVING_HURT = EventFactory.createEventResult();
/**
* @see LivingCheckSpawn#canSpawn(LivingEntity, LevelAccessor, double, double, double, MobSpawnType, BaseSpawner)
*/
Event<LivingCheckSpawn> LIVING_CHECK_SPAWN = EventFactory.createEventResult();
/**
* @see Add#add(Entity, Level)
*/
Event<Add> ADD = EventFactory.createEventResult();
/**
* @see EnterSection#enterSection(Entity, int, int, int, int, int, int)
*/
Event<EnterSection> ENTER_SECTION = EventFactory.createLoop();
interface LivingDeath {
/**
* Invoked before a living entity dies.
* Equivalent to Forge's {@code LivingDeathEvent} event.
*
* @param entity The entity that is about to die.
* @param source The source of damage triggering the death.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the entity death may be cancelled by the result.
*/
EventResult die(LivingEntity entity, DamageSource source);
}
interface LivingHurt {
/**
* Invoked before an entity is hurt by a damage source.
* Equivalent to Forge's {@code LivingAttackEvent} event.
*
* <p>You currently cannot override the amount of damage the entity receives.
*
* @param entity The entity that is attacked.
* @param source The reason why the entity takes damage.
* @param amount The amount of damage the entity takes.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the entity attack may be cancelled by the result.
*/
EventResult hurt(LivingEntity entity, DamageSource source, float amount);
}
interface LivingCheckSpawn {
/**
* Invoked before an entity is spawned into the world.
* This specifically concerns <i>spawning</i> through either a {@link BaseSpawner} or during world generation.
* Equivalent to Forge's {@code LivingSpawnEvent.CheckSpawn} event.
*
* @param entity The entity that is about to spawn.
* @param world The level the entity wants to spawn in.
* @param x The x-coordinate of the spawn position.
* @param y The y-coordinate of the spawn position.
* @param z The z-coordinate the spawn position.
* @param type The source of spawning.
* @param spawner The spawner. Can be {@code null}.
* @return A {@link InteractionResultHolder} determining the outcome of the event,
* if an outcome is set, the vanilla result is overridden.
*/
EventResult canSpawn(LivingEntity entity, LevelAccessor world, double x, double y, double z, MobSpawnType type, @Nullable BaseSpawner spawner);
}
interface Add {
/**
* Invoked when an entity is about to be added to the world.
* Equivalent to Forge's {@code EntityJoinWorldEvent} event.
*
* @param entity The entity to add to the level.
* @param world The level the entity is added to.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the entity addition may be cancelled by the result.
*/
EventResult add(Entity entity, Level world);
}
interface EnterSection {
/**
* Invoked whenever an entity enters a chunk.
* Equivalent to Forge's {@code EnteringChunk} event.
*
* @param entity The entity moving to a different chunk.
* @param sectionX The chunk x-coordinate.
* @param sectionY The chunk y-coordinate.
* @param sectionZ The chunk z-coordinate.
* @param prevX The previous chunk x-coordinate.
* @param prevY The previous chunk y-coordinate.
* @param prevZ The previous chunk z-coordinate.
*/
void enterSection(Entity entity, int sectionX, int sectionY, int sectionZ, int prevX, int prevY, int prevZ);
}
}

View File

@@ -0,0 +1,65 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.common;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import java.util.List;
public interface ExplosionEvent {
/**
* @see Pre#explode(Level, Explosion)
*/
Event<Pre> PRE = EventFactory.createEventResult();
/**
* @see Detonate#explode(Level, Explosion, List)
*/
Event<Detonate> DETONATE = EventFactory.createLoop();
interface Pre {
/**
* Invoked before an explosion happens.
* Equivalent to Forge's {@code ExplosionEvent.Start} event.
*
* @param level The level the explosion is happening in.
* @param explosion The explosion.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the vanilla explosion may be cancelled by the result.
*/
EventResult explode(Level level, Explosion explosion);
}
interface Detonate {
/**
* Invoked when an explosion is detonating.
* Equivalent to Forge's {@code ExplosionEvent.Detonate} event.
*
* @param level The level the explosion happens in.
* @param explosion The explosion happening.
* @param affectedEntities The entities affected by the explosion.
*/
void explode(Level level, Explosion explosion, List<Entity> affectedEntities);
}
}

View File

@@ -0,0 +1,161 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.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.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
public interface InteractionEvent {
/**
* @see LeftClickBlock#click(Player, InteractionHand, BlockPos, Direction)
*/
Event<LeftClickBlock> LEFT_CLICK_BLOCK = EventFactory.createEventResult();
/**
* @see RightClickBlock#click(Player, InteractionHand, BlockPos, Direction)
*/
Event<RightClickBlock> RIGHT_CLICK_BLOCK = EventFactory.createEventResult();
/**
* @see RightClickItem#click(Player, InteractionHand)
*/
Event<RightClickItem> RIGHT_CLICK_ITEM = EventFactory.createCompoundEventResult();
/**
* @see ClientLeftClickAir#click(Player, InteractionHand)
*/
Event<ClientLeftClickAir> CLIENT_LEFT_CLICK_AIR = EventFactory.createLoop();
/**
* @see ClientRightClickAir#click(Player, InteractionHand)
*/
Event<ClientRightClickAir> CLIENT_RIGHT_CLICK_AIR = EventFactory.createLoop();
/**
* @see InteractEntity#interact(Player, Entity, InteractionHand)
*/
Event<InteractEntity> INTERACT_ENTITY = EventFactory.createEventResult();
/**
* @see FarmlandTrample#trample(Level, BlockPos, BlockState, float, Entity)
*/
Event<FarmlandTrample> FARMLAND_TRAMPLE = EventFactory.createEventResult();
interface RightClickBlock {
/**
* Invoked whenever a player right clicks a block.
* Equivalent to Forge's {@code PlayerInteractEvent.RightClickBlock} event and Fabric's {@code UseBlockCallback}.
*
* @param player The player right clicking the block.
* @param hand The hand that is used.
* @param pos The position of the block in the level.
* @param face The face of the block clicked.
* @return A {@link EventResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
EventResult click(Player player, InteractionHand hand, BlockPos pos, Direction face);
}
interface LeftClickBlock {
/**
* Invoked whenever a player left clicks a block.
* Equivalent to Forge's {@code PlayerInteractEvent.LeftClickBlock} event and Fabric's {@code AttackBlockCallback}.
*
* @param player The player left clicking the block.
* @param hand The hand that is used.
* @param pos The position of the block in the level. Use {@link Player#getCommandSenderWorld()} to get the level.
* @param face The face of the block clicked.
* @return A {@link EventResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
EventResult click(Player player, InteractionHand hand, BlockPos pos, Direction face);
}
interface RightClickItem {
/**
* Invoked whenever a player uses an item on a block.
* Equivalent to Forge's {@code PlayerInteractEvent.RightClickItem} event and Fabric's {@code UseItemCallback}.
*
* @param player The player right clicking the block.
* @param hand The hand that is used.
* @return A {@link EventResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
CompoundEventResult<ItemStack> click(Player player, InteractionHand hand);
}
interface ClientRightClickAir {
/**
* Invoked whenever a player right clicks the air.
* This only occurs on the client.
* Equivalent to Forge's {@code PlayerInteractEvent.RightClickEmpty} event.
*
* @param player The player. Always {@link net.minecraft.client.player.LocalPlayer}
* @param hand The hand used.
*/
void click(Player player, InteractionHand hand);
}
interface ClientLeftClickAir {
/**
* Invoked whenever a player left clicks the air.
* This only occurs on the client.
* Equivalent to Forge's {@code PlayerInteractEvent.LeftClickEmpty} event.
*
* @param player The player. Always {@link net.minecraft.client.player.LocalPlayer}
* @param hand The hand used.
*/
void click(Player player, InteractionHand hand);
}
interface InteractEntity {
/**
* Invoked whenever a player right clicks an entity.
* Equivalent to Forge's {@code PlayerInteractEvent.EntityInteract} event.
*
* @param player The player clicking the entity.
* @param entity Then entity the player clicks.
* @param hand The used hand.
* @return A {@link EventResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
EventResult interact(Player player, Entity entity, InteractionHand hand);
}
interface FarmlandTrample {
/**
* Invoked when an entity attempts to trample farmland.
* Equivalent to Forge's {@code BlockEvent.FarmlandTrampleEvent} event.
*
* @param world The level where the block and the player are located in.
* @param pos The position of the block.
* @param state The state of the block.
* @param distance The distance of the player to the block.
* @param entity The entity trampling.
* @return A {@link EventResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
EventResult trample(Level world, BlockPos pos, BlockState state, float distance, Entity entity);
}
}

View File

@@ -0,0 +1,115 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.common;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
public interface LifecycleEvent {
/**
* Invoked before initial server startup. This is the earliest point at which the server will be available.
* Equivalent to Forge's {@code FMLServerAboutToStartEvent} event and
* Fabric's {@code ServerLifecycleEvents#SERVER_STARTING}.
*
* @see ServerState#stateChanged(Object)
*/
Event<ServerState> SERVER_BEFORE_START = EventFactory.createLoop();
/**
* Invoked during server startup.
* Equivalent to Forge's {@code FMLServerStartingEvent} event.
*
* @see ServerState#stateChanged(Object)
*/
Event<ServerState> SERVER_STARTING = EventFactory.createLoop();
/**
* Invoked when the server has started and is ready to accept players.
* Equivalent to Forge's {@code FMLServerStartedEvent} event
* and Fabric's {@code ServerLifecycleEvents#SERVER_STARTED}.
*
* @see ServerState#stateChanged(Object)
*/
Event<ServerState> SERVER_STARTED = EventFactory.createLoop();
/**
* Invoked when the server begins shutting down.
* Equivalent to Forge's {@code FMLServerStoppingEvent} event and
* Fabric's {@code ServerLifecycleEvents#SERVER_STOPPING}.
*
* @see ServerState#stateChanged(Object)
*/
Event<ServerState> SERVER_STOPPING = EventFactory.createLoop();
/**
* Invoked when the server has finished stopping, and is about to fully shut down.
* Equivalent to Forge's {@code FMLServerStoppedEvent} event and
* Fabric's {@code ServerLifecycleEvents#SERVER_STOPPED}.
*
* @see ServerState#stateChanged(Object)
*/
Event<ServerState> SERVER_STOPPED = EventFactory.createLoop();
/**
* Invoked when a level is loaded on the server-side.
* Equivalent to Forge's {@code WorldEvent.Load} event (on server)
* and Fabric's {@code ServerWorldEvents#LOAD}.
*
* @see ServerLevelState#act(Level)
*/
Event<ServerLevelState> SERVER_LEVEL_LOAD = EventFactory.createLoop();
/**
* Invoked when a level is unloaded on the server-side.
* Equivalent to Forge's {@code WorldEvent.Unload} event (on server)
* and Fabric's {@code ServerWorldEvents#UNLOAD}.
*
* @see ServerLevelState#act(Level)
*/
Event<ServerLevelState> SERVER_LEVEL_UNLOAD = EventFactory.createLoop();
/**
* Invoked when the level is being saved.
* Equivalent to Forge's {@code WorldEvent.Save} event.
*
* @see ServerLevelState#act(Level)
*/
Event<ServerLevelState> SERVER_LEVEL_SAVE = EventFactory.createLoop();
interface InstanceState<T> {
/**
* Parent event type for any events that are invoked on instance state change.
*
* @param instance The changed state.
*/
void stateChanged(T instance);
}
interface ServerState extends InstanceState<MinecraftServer> {
}
interface LevelState<T extends Level> {
/**
* Parent event type for any events that are invoked on world state change.
*
* @param world The world that has changed.
*/
void act(T world);
}
interface ServerLevelState extends LevelState<ServerLevel> {
}
}

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event.events;
package dev.architectury.event.events.common;
import me.shedaniel.architectury.event.Event;
import me.shedaniel.architectury.event.EventFactory;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.level.Level;
@@ -30,16 +30,22 @@ import java.util.List;
public interface LightningEvent {
// TODO Pre - Called before a lightning bolt entity is added to the world. (cancellable)
// TODO Pre - Invoked before a lightning bolt entity is added to the world. (cancellable)
/**
* Invoked after the lightning has gathered a list of entities to strike.
* Remove entities from the list to stop them from being hit.
* @see Strike#onStrike(LightningBolt, Level, Vec3, List)
*/
Event<Strike> STRIKE = EventFactory.createLoop();
// TODO Post - Called before a lightning bolt entity is removed from the world.
// TODO Post - Invoked before a lightning bolt entity is removed from the world.
interface Strike {
/**
* Invoked after the lightning has gathered a list of entities to strike.
*
* @param bolt The lightning bolt.
* @param level The level the lighting is spawned in.
* @param pos The position the lightning strikes.
* @param toStrike A list of all entities the lightning affects.
*/
void onStrike(LightningBolt bolt, Level level, Vec3 pos, List<Entity> toStrike);
}
}

View File

@@ -0,0 +1,265 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.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.advancements.Advancement;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.Container;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.Nullable;
public interface PlayerEvent {
/**
* @see PlayerJoin#join(ServerPlayer)
*/
Event<PlayerJoin> PLAYER_JOIN = EventFactory.createLoop();
/**
* @see PlayerQuit#quit(ServerPlayer)
*/
Event<PlayerQuit> PLAYER_QUIT = EventFactory.createLoop();
/**
* @see PlayerRespawn#respawn(ServerPlayer, boolean)
*/
Event<PlayerRespawn> PLAYER_RESPAWN = EventFactory.createLoop();
/**
* @see PlayerAdvancement#award(ServerPlayer, Advancement)
*/
Event<PlayerAdvancement> PLAYER_ADVANCEMENT = EventFactory.createLoop();
/**
* @see PlayerClone#clone(ServerPlayer, ServerPlayer, boolean)
*/
Event<PlayerClone> PLAYER_CLONE = EventFactory.createLoop();
/**
* @see CraftItem#craft(Player, ItemStack, Container)
*/
Event<CraftItem> CRAFT_ITEM = EventFactory.createLoop();
/**
* @see SmeltItem#smelt(Player, ItemStack)
*/
Event<SmeltItem> SMELT_ITEM = EventFactory.createLoop();
/**
* @see PickupItemPredicate#canPickup(Player, ItemEntity, ItemStack)
*/
Event<PickupItemPredicate> PICKUP_ITEM_PRE = EventFactory.createEventResult();
/**
* @see PickupItem#pickup(Player, ItemEntity, ItemStack)
*/
Event<PickupItem> PICKUP_ITEM_POST = EventFactory.createLoop();
/**
* @see ChangeDimension#change(ServerPlayer, ResourceKey, ResourceKey)
*/
Event<ChangeDimension> CHANGE_DIMENSION = EventFactory.createLoop();
/**
* @see DropItem#drop(Player, ItemEntity)
*/
Event<DropItem> DROP_ITEM = EventFactory.createEventResult();
/**
* @see OpenMenu#open(Player, AbstractContainerMenu)
*/
Event<OpenMenu> OPEN_MENU = EventFactory.createLoop();
/**
* @see CloseMenu#close(Player, AbstractContainerMenu)
*/
Event<CloseMenu> CLOSE_MENU = EventFactory.createLoop();
/**
* @see FillBucket#fill(Player, Level, ItemStack, HitResult)
*/
Event<FillBucket> FILL_BUCKET = EventFactory.createCompoundEventResult();
interface PlayerJoin {
/**
* Invoked after a player joined a server level.
* Equivalent to Forge's {@code PlayerLoggedInEvent} event.
*
* @param player The joined player.
*/
void join(ServerPlayer player);
}
interface PlayerQuit {
/**
* Invoked after a player logged out of a server level.
* Equivalent to Forge's {@code PlayerLoggedOutEvent} event.
*
* @param player The now logged out player.
*/
void quit(ServerPlayer player);
}
interface PlayerRespawn {
/**
* Invoked when a player is respawned (e.g. changing dimension).
* Equivalent to Forge's {@code PlayerRespawnEvent} event.
* To manipulate the player use {@link PlayerClone#clone(ServerPlayer, ServerPlayer, boolean)}.
*
* @param newPlayer The respawned player.
* @param conqueredEnd Whether the player has conquered the end. This is true when the player joined the end and now is leaving it. {@link ServerPlayer#wonGame}
*/
void respawn(ServerPlayer newPlayer, boolean conqueredEnd);
}
interface PlayerClone {
/**
* Invoked when a player respawns.
* This can be used to manipulate the new player.
* Equivalent to Forge's {@code PlayerEvent.Clone} event.
*
* @param oldPlayer The old player.
* @param newPlayer The new player.
* @param wonGame This is true when the player joined the end and now is leaving it. {@link ServerPlayer#wonGame}
*/
void clone(ServerPlayer oldPlayer, ServerPlayer newPlayer, boolean wonGame);
}
interface PlayerAdvancement {
/**
* Invoked when a player gets an advancement.
* Equivalent to Forge's {@code AdvancementEvent} event.
*
* @param player The player who got the advancement.
* @param advancement The advancement the player got.
*/
void award(ServerPlayer player, Advancement advancement);
}
interface CraftItem {
/**
* Invoked when a player crafts an item.
* Equivalent to Forge's {@code ItemCraftedEvent} event.
* This only applies for the vanilla crafting table (or any crafting table using the {@link net.minecraft.world.inventory.ResultSlot}) and
* the player inventory crafting grid.
* This is invoked when the player takes something out of the result slot.
*
* @param player The player.
* @param constructed The ItemStack that has been crafted.
* @param inventory The inventory of the constructor.
*/
void craft(Player player, ItemStack constructed, Container inventory);
}
interface SmeltItem {
/**
* Invoked when a player smelts an item.
* Equivalent to Forge's {@code ItemSmeltedEvent} event.
* This is invoked when the player takes the stack out of the output slot.
*
* @param player The player.
* @param smelted The smelt result.
*/
void smelt(Player player, ItemStack smelted);
}
interface PickupItemPredicate {
/**
* Invoked when a player tries to pickup an {@link ItemEntity}.
* Equivalent to Forge's {@code EntityItemPickupEvent} event.
*
* @param player The player picking up.
* @param entity The {@link ItemEntity} that the player tries to pick up.
* @param stack The content of the {@link ItemEntity}.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the pickup may be cancelled by the result.
*/
EventResult canPickup(Player player, ItemEntity entity, ItemStack stack);
}
interface PickupItem {
/**
* Invoked when a player has picked up an {@link ItemEntity}.
* Equivalent to Forge's {@code ItemPickupEvent} event.
*
* @param player The player.
* @param entity The {@link ItemEntity} that the player picked up.
* @param stack The content of the {@link ItemEntity}.
*/
void pickup(Player player, ItemEntity entity, ItemStack stack);
}
interface ChangeDimension {
/**
* Invoked when a player changes their dimension.
* Equivalent to Forge's {@code PlayerChangedDimensionEvent} event.
*
* @param player The teleporting player.
* @param oldLevel The level the player comes from.
* @param newLevel The level the player teleports into.
*/
void change(ServerPlayer player, ResourceKey<Level> oldLevel, ResourceKey<Level> newLevel);
}
interface DropItem {
/**
* Invoked when a player drops an item.
* Equivalent to Forge's {@code ItemTossEvent} event.
*
* @param player The player dropping something.
* @param entity The entity that has spawned when the player dropped a ItemStack.
* @return A {@link EventResult} determining the outcome of the event,
* the execution of the drop may be cancelled by the result.
*/
EventResult drop(Player player, ItemEntity entity);
}
interface OpenMenu {
/**
* Invoked when a player opens a menu.
* Equivalent to Forge's {@code PlayerContainerEvent.Open} event.
*
* @param player The player opening the menu.
* @param menu The menu that is opened.
*/
void open(Player player, AbstractContainerMenu menu);
}
interface CloseMenu {
/**
* Invoked when a player closes a menu.
* Equivalent to Forge's {@code PlayerContainerEvent.Close} event.
*
* @param player The player closing the menu.
* @param menu The menu that is closed.
*/
void close(Player player, AbstractContainerMenu menu);
}
interface FillBucket {
/**
* Invoked when a player attempts to fill a bucket using right-click.
* You can return a non-PASS interaction result to cancel further processing by other mods.
*
* @param player The player filling the bucket.
* @param level The level the player is in.
* @param stack The bucket stack.
* @param target The target which the player has aimed at.
* @return A {@link CompoundEventResult} determining the outcome of the event.
*/
CompoundEventResult<ItemStack> fill(Player player, Level level, ItemStack stack, @Nullable HitResult target);
}
}

View File

@@ -0,0 +1,90 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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.event.events.common;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
public interface TickEvent<T> {
/**
* Invoked before a server tick is processed.
* Equivalent to Forge's {@code ServerTickEvent} event in the START Phase.
*
* @see #tick(Object)
*/
Event<Server> SERVER_PRE = EventFactory.createLoop();
/**
* Invoked after a server tick has been processed.
* Equivalent to Forge's {@code ServerTickEvent} event in the END Phase.
*
* @see #tick(Object)
*/
Event<Server> SERVER_POST = EventFactory.createLoop();
/**
* Invoked before a server level tick is processed.
* Equivalent to Forge's {@code WorldTickEvent} event in the START Phase.
*
* @see #tick(Object)
*/
Event<ServerLevelTick> SERVER_LEVEL_PRE = EventFactory.createLoop();
/**
* Invoked after a server level tick has been processed.
* Equivalent to Forge's {@code WorldTickEvent} event in the END Phase.
*
* @see #tick(Object)
*/
Event<ServerLevelTick> SERVER_LEVEL_POST = EventFactory.createLoop();
/**
* Invoked before a player tick is processed.
* Equivalent to Forge's {@code PlayerTickEvent} event in the START Phase.
*
* @see #tick(Object)
*/
Event<Player> PLAYER_PRE = EventFactory.createLoop();
/**
* Invoked after a player tick has been processed.
* Equivalent to Forge's {@code PlayerTickEvent} event in the END Phase.
*
* @see #tick(Object)
*/
Event<Player> PLAYER_POST = EventFactory.createLoop();
/**
* Callback method for tick events.
*
* @param instance The object ticking.
*/
void tick(T instance);
interface Server extends TickEvent<MinecraftServer> {
}
interface LevelTick<T extends Level> extends TickEvent<T> {
}
interface ServerLevelTick extends LevelTick<ServerLevel> {
}
interface Player extends TickEvent<net.minecraft.world.entity.player.Player> {
}
}

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.extensions;
package dev.architectury.extensions;
import me.shedaniel.architectury.hooks.BlockEntityHooks;
import dev.architectury.hooks.block.BlockEntityHooks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.nbt.CompoundTag;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.extensions;
package dev.architectury.extensions;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.fluid;
package dev.architectury.fluid;
import me.shedaniel.architectury.hooks.FluidStackHooks;
import me.shedaniel.architectury.utils.NbtType;
import dev.architectury.hooks.fluid.FluidStackHooks;
import dev.architectury.utils.NbtType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
@@ -133,7 +133,7 @@ public final class FluidStack {
public CompoundTag getOrCreateChildTag(String childName) {
getOrCreateTag();
CompoundTag child = tag.getCompound(childName);
var child = tag.getCompound(childName);
if (!tag.contains(childName, NbtType.COMPOUND)) {
tag.put(childName, child);
}
@@ -159,7 +159,7 @@ public final class FluidStack {
@Override
public final int hashCode() {
int code = 1;
var code = 1;
code = 31 * code + getFluid().hashCode();
code = 31 * code + Long.hashCode(amount);
if (tag != null)

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.item.DyeColor;
public class DyeColorHooks {

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks;
import net.minecraft.world.level.storage.LevelResource;

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.server.packs.repository.RepositorySource;

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks.block;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.level.block.entity.BlockEntity;
public class BlockEntityHooks {

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks.screen;
package dev.architectury.hooks.client.screen;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Widget;

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks.screen;
package dev.architectury.hooks.client.screen;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.components.AbstractWidget;

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks.fluid;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.fluid.FluidStack;
import dev.architectury.fluid.FluidStack;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;

View File

@@ -17,12 +17,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks.item;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
public final class ItemStackHooks {
@@ -30,16 +29,16 @@ public final class ItemStackHooks {
}
public static ItemStack copyWithCount(ItemStack stack, int count) {
ItemStack copy = stack.copy();
var copy = stack.copy();
copy.setCount(count);
return copy;
}
public static void giveItem(ServerPlayer player, ItemStack stack) {
boolean bl = player.getInventory().add(stack);
var bl = player.getInventory().add(stack);
if (bl && stack.isEmpty()) {
stack.setCount(1);
ItemEntity entity = player.drop(stack, false);
var entity = player.drop(stack, false);
if (entity != null) {
entity.makeFakeItem();
}
@@ -47,7 +46,7 @@ public final class ItemStackHooks {
player.level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, 0.2F, ((player.getRandom().nextFloat() - player.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F);
player.inventoryMenu.broadcastChanges();
} else {
ItemEntity entity = player.drop(stack, false);
var entity = player.drop(stack, false);
if (entity != null) {
entity.setNoPickUpDelay();
entity.setOwner(player.getUUID());

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks.level;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.phys.Vec3;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks.biome;
package dev.architectury.hooks.level.biome;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.SoundEvent;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks.biome;
package dev.architectury.hooks.level.biome;
import net.minecraft.world.level.biome.Biome.BiomeCategory;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks.biome;
package dev.architectury.hooks.level.biome;
import net.minecraft.world.level.biome.Biome.Precipitation;
import net.minecraft.world.level.biome.Biome.TemperatureModifier;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks.biome;
package dev.architectury.hooks.level.biome;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.SoundEvent;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks.biome;
package dev.architectury.hooks.level.biome;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks.biome;
package dev.architectury.hooks.level.biome;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks.level.entity;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.shapes.CollisionContext;
import org.jetbrains.annotations.Nullable;

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks.level.entity;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.utils.IntValue;
import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.architectury.utils.value.IntValue;
import net.minecraft.world.entity.item.ItemEntity;
public final class ItemEntityHooks {

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks.level.entity;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.player.Player;
public final class PlayerHooks {

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.hooks;
package dev.architectury.hooks.tags;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.mixin.FluidTagsAccessor;
import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.architectury.mixin.FluidTagsAccessor;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.*;
import net.minecraft.world.entity.EntityType;
@@ -35,23 +35,23 @@ public final class TagHooks {
}
@ExpectPlatform
public static <T> Tag.Named<T> getOptional(ResourceLocation id, Supplier<TagCollection<T>> collection) {
public static <T> Tag.Named<T> optional(ResourceLocation id, Supplier<TagCollection<T>> collection) {
throw new AssertionError();
}
public static Tag.Named<Item> getItemOptional(ResourceLocation id) {
return getOptional(id, ItemTags::getAllTags);
public static Tag.Named<Item> optionalItem(ResourceLocation id) {
return optional(id, ItemTags::getAllTags);
}
public static Tag.Named<Block> getBlockOptional(ResourceLocation id) {
return getOptional(id, BlockTags::getAllTags);
public static Tag.Named<Block> optionalBlock(ResourceLocation id) {
return optional(id, BlockTags::getAllTags);
}
public static Tag.Named<Fluid> getFluidOptional(ResourceLocation id) {
return getOptional(id, FluidTagsAccessor.getHelper()::getAllTags);
public static Tag.Named<Fluid> optionalFluid(ResourceLocation id) {
return optional(id, FluidTagsAccessor.getHelper()::getAllTags);
}
public static Tag.Named<EntityType<?>> getEntityTypeOptional(ResourceLocation id) {
return getOptional(id, EntityTypeTags::getAllTags);
public static Tag.Named<EntityType<?>> optionalEntityType(ResourceLocation id) {
return optional(id, EntityTypeTags::getAllTags);
}
}

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.impl;
package dev.architectury.impl;
import me.shedaniel.architectury.hooks.screen.ScreenAccess;
import me.shedaniel.architectury.hooks.screen.ScreenHooks;
import dev.architectury.hooks.client.screen.ScreenAccess;
import dev.architectury.hooks.client.screen.ScreenHooks;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Widget;
import net.minecraft.client.gui.components.events.GuiEventListener;

View File

@@ -17,13 +17,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.impl;
package dev.architectury.impl;
import me.shedaniel.architectury.event.events.TooltipEvent;
import dev.architectury.event.events.client.ClientTooltipEvent;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
public class TooltipEventColorContextImpl implements TooltipEvent.ColorContext {
public class TooltipEventColorContextImpl implements ClientTooltipEvent.ColorContext {
private int backgroundColor;
private int outlineGradientTopColor;
private int outlineGradientBottomColor;

View File

@@ -17,13 +17,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.impl;
package dev.architectury.impl;
import me.shedaniel.architectury.event.events.TooltipEvent;
import dev.architectury.event.events.client.ClientTooltipEvent;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
public class TooltipEventPositionContextImpl implements TooltipEvent.PositionContext {
public class TooltipEventPositionContextImpl implements ClientTooltipEvent.PositionContext {
private int tooltipX;
private int tooltipY;

View File

@@ -17,11 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.event;
@ApiStatus.Internal
package dev.architectury.impl;
import net.minecraft.world.InteractionResult;
@FunctionalInterface
public interface Actor<T> {
InteractionResult act(T t);
}
import org.jetbrains.annotations.ApiStatus;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.mixin;
package dev.architectury.mixin;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.StaticTagHelper;

View File

@@ -17,18 +17,15 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.mixin;
package dev.architectury.mixin;
import me.shedaniel.architectury.event.events.BlockEvent;
import dev.architectury.event.events.common.BlockEvent;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.FallingBlockEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.AnvilBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ConcretePowderBlock;
import net.minecraft.world.level.block.FallingBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -47,7 +44,7 @@ public abstract class MixinFallingBlockEntity extends Entity {
private BlockState blockState;
@Inject(method = "tick", at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/level/block/Fallable;onLand(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/item/FallingBlockEntity;)V"),
target = "Lnet/minecraft/world/level/block/Fallable;onLand(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/item/FallingBlockEntity;)V"),
locals = LocalCapture.CAPTURE_FAILHARD)
public void handleLand(CallbackInfo ci, Block block, BlockPos blockPos2, boolean bl, boolean bl2, BlockState blockState) {
BlockEvent.FALLING_LAND.invoker().onLand(this.level, blockPos2, this.blockState, blockState, (FallingBlockEntity) (Object) this);

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.mixin;
package dev.architectury.mixin;
import me.shedaniel.architectury.event.events.LightningEvent;
import dev.architectury.event.events.common.LightningEvent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LightningBolt;
@@ -47,7 +47,7 @@ public abstract class MixinLightningBolt extends Entity {
shift = At.Shift.BY,
by = 1
), locals = LocalCapture.CAPTURE_FAILHARD)
public void handleLightning(CallbackInfo ci, double d0, List<Entity> list) {
public void handleLightning(CallbackInfo ci, List<Entity> list) {
if (this.isRemoved() || this.level.isClientSide) {
return;
}

View File

@@ -17,13 +17,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.networking;
package dev.architectury.networking;
import com.google.common.collect.Maps;
import dev.architectury.networking.NetworkManager.PacketContext;
import dev.architectury.platform.Platform;
import dev.architectury.utils.Env;
import io.netty.buffer.Unpooled;
import me.shedaniel.architectury.networking.NetworkManager.PacketContext;
import me.shedaniel.architectury.platform.Platform;
import me.shedaniel.architectury.utils.Env;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
@@ -31,12 +31,10 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.ApiStatus;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.function.Function;
@@ -59,8 +57,8 @@ public final class NetworkChannel {
public <T> void register(Class<T> type, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, BiConsumer<T, Supplier<PacketContext>> messageConsumer) {
// TODO: this is pretty wasteful; add a way to specify custom or numeric ids
String s = UUID.nameUUIDFromBytes(type.getName().getBytes(StandardCharsets.UTF_8)).toString().replace("-", "");
MessageInfo<T> info = new MessageInfo<>(new ResourceLocation(id + "/" + s), encoder, decoder, messageConsumer);
var s = UUID.nameUUIDFromBytes(type.getName().getBytes(StandardCharsets.UTF_8)).toString().replace("-", "");
var info = new MessageInfo<T>(new ResourceLocation(id + "/" + s), encoder, decoder, messageConsumer);
encoders.put(type, info);
NetworkManager.NetworkReceiver receiver = (buf, context) -> {
info.messageConsumer.accept(info.decoder.apply(buf), () -> context);
@@ -73,16 +71,16 @@ public final class NetworkChannel {
public static long hashCodeString(String str) {
long h = 0;
int length = str.length();
for (int i = 0; i < length; i++) {
var length = str.length();
for (var i = 0; i < length; i++) {
h = 31 * h + str.charAt(i);
}
return h;
}
public <T> Packet<?> toPacket(NetworkManager.Side side, T message) {
MessageInfo<T> messageInfo = (MessageInfo<T>) Objects.requireNonNull(encoders.get(message.getClass()), "Unknown message type! " + message);
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
var messageInfo = (MessageInfo<T>) Objects.requireNonNull(encoders.get(message.getClass()), "Unknown message type! " + message);
var buf = new FriendlyByteBuf(Unpooled.buffer());
messageInfo.encoder.accept(message, buf);
return NetworkManager.toPacket(side, messageInfo.packetId, buf);
}
@@ -92,8 +90,8 @@ public final class NetworkChannel {
}
public <T> void sendToPlayers(Iterable<ServerPlayer> players, T message) {
Packet<?> packet = toPacket(NetworkManager.s2c(), message);
for (ServerPlayer player : players) {
var packet = toPacket(NetworkManager.s2c(), message);
for (var player : players) {
Objects.requireNonNull(player, "Unable to send packet to a 'null' player!").connection.send(packet);
}
}
@@ -116,17 +114,11 @@ public final class NetworkChannel {
return NetworkManager.canPlayerReceive(player, encoders.get(type).packetId);
}
private static final class MessageInfo<T> {
private final ResourceLocation packetId;
private final BiConsumer<T, FriendlyByteBuf> encoder;
private final Function<FriendlyByteBuf, T> decoder;
private final BiConsumer<T, Supplier<PacketContext>> messageConsumer;
public MessageInfo(ResourceLocation packetId, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, BiConsumer<T, Supplier<PacketContext>> messageConsumer) {
this.packetId = packetId;
this.encoder = encoder;
this.decoder = decoder;
this.messageConsumer = messageConsumer;
}
private record MessageInfo<T>(
ResourceLocation packetId,
BiConsumer<T, FriendlyByteBuf> encoder,
Function<FriendlyByteBuf, T> decoder,
BiConsumer<T, Supplier<PacketContext>> messageConsumer
) {
}
}

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.networking;
package dev.architectury.networking;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.utils.Env;
import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.architectury.utils.Env;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
@@ -28,6 +28,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import java.util.Objects;
@@ -48,8 +49,8 @@ public final class NetworkManager {
}
public static void sendToPlayers(Iterable<ServerPlayer> players, ResourceLocation id, FriendlyByteBuf buf) {
Packet<?> packet = toPacket(serverToClient(), id, buf);
for (ServerPlayer player : players) {
var packet = toPacket(serverToClient(), id, buf);
for (var player : players) {
Objects.requireNonNull(player, "Unable to send packet to a 'null' player!").connection.send(packet);
}
}
@@ -74,6 +75,20 @@ public final class NetworkManager {
throw new AssertionError();
}
/**
* Easy to use utility method to create an entity spawn packet.
* This packet is needed everytime any mod adds a non-living entity.
* The entity should override {@link Entity#getAddEntityPacket()} to point to this method!
*
* @param entity The entity which should be spawned.
* @return The ready to use packet to spawn the entity on the client.
* @see Entity#getAddEntityPacket()
*/
@ExpectPlatform
public static Packet<?> createAddEntityPacket(Entity entity) {
throw new AssertionError();
}
@FunctionalInterface
public interface NetworkReceiver {
void receive(FriendlyByteBuf buf, PacketContext context);

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.platform;
package dev.architectury.platform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

View File

@@ -17,15 +17,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.platform;
package dev.architectury.platform;
import me.shedaniel.architectury.Architectury;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.targets.ArchitecturyTarget;
import me.shedaniel.architectury.utils.Env;
import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.architectury.injectables.targets.ArchitecturyTarget;
import dev.architectury.utils.Env;
import net.fabricmc.api.EnvType;
import net.minecraft.SharedConstants;
import org.jetbrains.annotations.ApiStatus;
import java.nio.file.Path;
import java.util.Collection;
@@ -37,17 +35,6 @@ public final class Platform {
private static int simpleLoaderCache = -1;
/**
* @return the current mod loader, either "fabric" or "forge"
* @deprecated does not reflect the true mod loader, "quilt" is never returned,
* use {@link ArchitecturyTarget#getCurrentTarget()} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")
public static String getModLoader() {
return Architectury.getModLoader();
}
public static boolean isFabric() {
updateLoaderCache();
return simpleLoaderCache == 0;
@@ -63,13 +50,9 @@ public final class Platform {
return;
}
switch (getModLoader()) {
case "fabric":
simpleLoaderCache = 0;
return;
case "forge":
simpleLoaderCache = 1;
return;
switch (ArchitecturyTarget.getCurrentTarget()) {
case "fabric" -> simpleLoaderCache = 0;
case "forge" -> simpleLoaderCache = 1;
}
}
@@ -87,6 +70,11 @@ public final class Platform {
throw new AssertionError();
}
@ExpectPlatform
public static Path getModsFolder() {
throw new AssertionError();
}
@ExpectPlatform
public static Env getEnvironment() {
throw new AssertionError();

View File

@@ -17,17 +17,17 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import java.util.function.Supplier;
public final class CreativeTabs {
private CreativeTabs() {
public final class CreativeTabRegistry {
private CreativeTabRegistry() {
}
// I am sorry, fabric wants a resource location instead of the translation key for whatever reason

View File

@@ -17,18 +17,18 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.resources.PreparableReloadListener;
public final class ReloadListeners {
private ReloadListeners() {
public final class ReloadListenerRegistry {
private ReloadListenerRegistry() {
}
@ExpectPlatform
public static void registerReloadListener(PackType type, PreparableReloadListener listener) {
public static void register(PackType type, PreparableReloadListener listener) {
throw new AssertionError();
}
}

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.block;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.block;
public interface BlockPropertiesExtension {
default BlockProperties tool(ToolType type) {

View File

@@ -17,10 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.block;
import com.google.common.collect.Maps;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.Item;

View File

@@ -17,20 +17,20 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.client.keymappings;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.KeyMapping;
@Environment(EnvType.CLIENT)
public final class KeyBindings {
private KeyBindings() {
public final class KeyMappingRegistry {
private KeyMappingRegistry() {
}
@ExpectPlatform
public static void registerKeyBinding(KeyMapping binding) {
public static void register(KeyMapping mapping) {
throw new AssertionError();
}
}

View File

@@ -17,26 +17,22 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.client.rendering;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import java.util.function.Function;
@Environment(EnvType.CLIENT)
public final class BlockEntityRenderers {
private BlockEntityRenderers() {
public final class BlockEntityRendererRegistry {
private BlockEntityRendererRegistry() {
}
@ExpectPlatform
public static <T extends BlockEntity> void registerRenderer(BlockEntityType<T> type, BlockEntityRendererProvider<? super T> provider) {
public static <T extends BlockEntity> void register(BlockEntityType<T> type, BlockEntityRendererProvider<? super T> provider) {
throw new AssertionError();
}
}

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.client.rendering;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.color.block.BlockColor;
@@ -31,14 +31,14 @@ import java.util.Objects;
import java.util.function.Supplier;
@Environment(EnvType.CLIENT)
public final class ColorHandlers {
private ColorHandlers() {
public final class ColorHandlerRegistry {
private ColorHandlerRegistry() {
}
public static void registerItemColors(ItemColor color, ItemLike... items) {
Supplier<ItemLike>[] array = new Supplier[items.length];
for (int i = 0; i < items.length; i++) {
ItemLike item = Objects.requireNonNull(items[i], "items[i] is null!");
for (var i = 0; i < items.length; i++) {
var item = Objects.requireNonNull(items[i], "items[i] is null!");
array[i] = () -> item;
}
registerItemColors(color, array);
@@ -46,8 +46,8 @@ public final class ColorHandlers {
public static void registerBlockColors(BlockColor color, Block... blocks) {
Supplier<Block>[] array = new Supplier[blocks.length];
for (int i = 0; i < blocks.length; i++) {
Block block = Objects.requireNonNull(blocks[i], "blocks[i] is null!");
for (var i = 0; i < blocks.length; i++) {
var block = Objects.requireNonNull(blocks[i], "blocks[i] is null!");
array[i] = () -> block;
}
registerBlockColors(color, array);

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.client.rendering;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.RenderType;
@@ -27,8 +27,8 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.material.Fluid;
@Environment(EnvType.CLIENT)
public final class RenderTypes {
private RenderTypes() {
public final class RenderTypeRegistry {
private RenderTypeRegistry() {
}
@ExpectPlatform

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.fuel;
package dev.architectury.registry.fuel;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.level;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.GameRules;

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.level;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.level.GameRules;
/**

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.level.advancement;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.advancements.CriterionTrigger;
public final class CriteriaTriggersRegistry {

View File

@@ -17,11 +17,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.level.biome;
import com.google.common.base.Predicates;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.hooks.biome.BiomeProperties;
import dev.architectury.hooks.level.biome.BiomeProperties;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.resources.ResourceLocation;
import java.util.function.BiConsumer;

View File

@@ -17,17 +17,17 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.entity;
package dev.architectury.registry.level.entity;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import java.util.function.Supplier;
public final class EntityAttributes {
private EntityAttributes() {
public final class EntityAttributeRegistry {
private EntityAttributeRegistry() {
}
/**

View File

@@ -17,26 +17,22 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.entity;
package dev.architectury.registry.level.entity;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import java.util.function.Function;
@Environment(EnvType.CLIENT)
public final class EntityRenderers {
private EntityRenderers() {
public final class EntityRendererRegistry {
private EntityRendererRegistry() {
}
@ExpectPlatform
public static <T extends Entity> void register(EntityType<T> type, EntityRendererProvider<T> provider) {
public static <T extends Entity> void register(EntityType<? extends T> type, EntityRendererProvider<T> provider) {
throw new AssertionError();
}
}

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.trade;
package dev.architectury.registry.level.entity.trade;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.npc.VillagerTrades;
@@ -37,14 +37,9 @@ import java.util.Random;
* or
* {@link TradeRegistry#registerTradeForWanderingTrader(boolean, VillagerTrades.ItemListing...)}.
*/
public class SimpleTrade implements VillagerTrades.ItemListing {
private final ItemStack primaryPrice;
private final ItemStack secondaryPrice;
private final ItemStack sale;
private final int maxTrades;
private final int experiencePoints;
private final float priceMultiplier;
public record SimpleTrade(ItemStack primaryPrice, ItemStack secondaryPrice,
ItemStack sale, int maxTrades, int experiencePoints,
float priceMultiplier) implements VillagerTrades.ItemListing {
/**
* Constructor for creating the trade.
* You can take a look at all the values the vanilla game uses right here {@link VillagerTrades#TRADES}.
@@ -56,13 +51,7 @@ public class SimpleTrade implements VillagerTrades.ItemListing {
* @param experiencePoints How much experience points does the player get, when trading. Vanilla uses between 2 and 30 for this.
* @param priceMultiplier How much should the price rise, after the trade is used. It is added to the stack size of the primary price. Vanilla uses between 0.05 and 0.2.
*/
public SimpleTrade(ItemStack primaryPrice, ItemStack secondaryPrice, ItemStack sale, int maxTrades, int experiencePoints, float priceMultiplier) {
this.primaryPrice = primaryPrice;
this.secondaryPrice = secondaryPrice;
this.sale = sale;
this.maxTrades = maxTrades;
this.experiencePoints = experiencePoints;
this.priceMultiplier = priceMultiplier;
public SimpleTrade {
}
@Nullable

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.trade;
package dev.architectury.registry.level.entity.trade;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerTrades;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.menu;
package dev.architectury.registry.menu;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.MenuProvider;

View File

@@ -17,10 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.menu;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.registry.menu.ExtendedMenuProvider;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screens.Screen;

View File

@@ -17,9 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.registries;
import com.google.common.base.Suppliers;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
@@ -31,19 +32,19 @@ import java.util.function.Supplier;
public class DeferredRegister<T> {
private final Supplier<Registries> registriesSupplier;
private final ResourceKey<net.minecraft.core.Registry<T>> key;
private final ResourceKey<Registry<T>> key;
private final List<Entry<T>> entries = new ArrayList<>();
private boolean registered = false;
@Nullable
private String modId;
private DeferredRegister(Supplier<Registries> registriesSupplier, ResourceKey<net.minecraft.core.Registry<T>> key, @Nullable String modId) {
private DeferredRegister(Supplier<Registries> registriesSupplier, ResourceKey<Registry<T>> key, @Nullable String modId) {
this.registriesSupplier = Objects.requireNonNull(registriesSupplier);
this.key = Objects.requireNonNull(key);
this.modId = modId;
}
public static <T> DeferredRegister<T> create(String modId, ResourceKey<net.minecraft.core.Registry<T>> key) {
public static <T> DeferredRegister<T> create(String modId, ResourceKey<Registry<T>> key) {
Supplier<Registries> value = Suppliers.memoize(() -> Registries.get(modId));
return new DeferredRegister<>(value, key, Objects.requireNonNull(modId));
}
@@ -57,11 +58,11 @@ public class DeferredRegister<T> {
}
public <R extends T> RegistrySupplier<R> register(ResourceLocation id, Supplier<? extends R> supplier) {
Entry<T> entry = new Entry<>(id, (Supplier<T>) supplier);
var entry = new Entry<T>(id, (Supplier<T>) supplier);
this.entries.add(entry);
if (registered) {
Registry<T> registry = registriesSupplier.get().get(key);
entry.value = registry.registerSupplied(entry.id, entry.supplier);
var registrar = registriesSupplier.get().get(key);
entry.value = registrar.register(entry.id, entry.supplier);
}
return (RegistrySupplier<R>) entry;
}
@@ -71,9 +72,9 @@ public class DeferredRegister<T> {
throw new IllegalStateException("Cannot register a deferred register twice!");
}
registered = true;
Registry<T> registry = registriesSupplier.get().get(key);
for (Entry<T> entry : entries) {
entry.value = registry.registerSupplied(entry.id, entry.supplier);
var registrar = registriesSupplier.get().get(key);
for (var entry : entries) {
entry.value = registrar.register(entry.id, entry.supplier);
}
}
@@ -118,8 +119,7 @@ public class DeferredRegister<T> {
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof RegistrySupplier)) return false;
RegistrySupplier<?> other = (RegistrySupplier<?>) obj;
if (!(obj instanceof RegistrySupplier<?> other)) return false;
return other.getRegistryId().equals(getRegistryId()) && other.getId().equals(getId());
}

View File

@@ -17,8 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.registries;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
@@ -28,18 +29,10 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
public interface Registry<T> extends Iterable<T> {
default Supplier<T> delegate(ResourceLocation id) {
return delegateSupplied(id);
}
public interface Registrar<T> extends Iterable<T> {
RegistrySupplier<T> delegate(ResourceLocation id);
RegistrySupplier<T> delegateSupplied(ResourceLocation id);
default <E extends T> Supplier<E> register(ResourceLocation id, Supplier<E> supplier) {
return registerSupplied(id, supplier);
}
<E extends T> RegistrySupplier<E> registerSupplied(ResourceLocation id, Supplier<E> supplier);
<E extends T> RegistrySupplier<E> register(ResourceLocation id, Supplier<E> supplier);
@Nullable
ResourceLocation getId(T obj);
@@ -62,5 +55,5 @@ public interface Registry<T> extends Iterable<T> {
Set<Map.Entry<ResourceKey<T>, T>> entrySet();
ResourceKey<? extends net.minecraft.core.Registry<T>> key();
ResourceKey<? extends Registry<T>> key();
}

View File

@@ -17,21 +17,21 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.registries;
package dev.architectury.registry.registries;
import me.shedaniel.architectury.core.RegistryEntry;
import me.shedaniel.architectury.registry.Registry;
import dev.architectury.registry.registries.options.RegistrarOption;
import dev.architectury.registry.registries.options.StandardRegistrarOption;
public interface RegistryBuilder<T extends RegistryEntry<T>> {
Registry<T> build();
public interface RegistrarBuilder<T> {
Registrar<T> build();
RegistryBuilder<T> option(RegistryOption option);
RegistrarBuilder<T> option(RegistrarOption option);
default RegistryBuilder<T> saveToDisc() {
return option(StandardRegistryOption.SAVE_TO_DISC);
default RegistrarBuilder<T> saveToDisc() {
return option(StandardRegistrarOption.SAVE_TO_DISC);
}
default RegistryBuilder<T> syncToClients() {
return option(StandardRegistryOption.SYNC_TO_CLIENTS);
default RegistrarBuilder<T> syncToClients() {
return option(StandardRegistrarOption.SYNC_TO_CLIENTS);
}
}

View File

@@ -17,11 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.registries;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import me.shedaniel.architectury.core.RegistryEntry;
import me.shedaniel.architectury.registry.registries.RegistryBuilder;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;
@@ -47,17 +46,17 @@ public final class Registries {
this.modId = modId;
}
public <T> Registry<T> get(ResourceKey<net.minecraft.core.Registry<T>> key) {
public <T> Registrar<T> get(ResourceKey<Registry<T>> key) {
return this.provider.get(key);
}
@Deprecated
public <T> Registry<T> get(net.minecraft.core.Registry<T> registry) {
public <T> Registrar<T> get(Registry<T> registry) {
return this.provider.get(registry);
}
@SafeVarargs
public final <T extends RegistryEntry<T>> RegistryBuilder<T> builder(ResourceLocation registryId, T... typeGetter) {
public final <T> RegistrarBuilder<T> builder(ResourceLocation registryId, T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
return this.provider.builder((Class<T>) typeGetter.getClass().getComponentType(), registryId);
}
@@ -68,7 +67,7 @@ public final class Registries {
*/
@Nullable
@ExpectPlatform
public static <T> ResourceLocation getId(T object, @Nullable ResourceKey<net.minecraft.core.Registry<T>> fallback) {
public static <T> ResourceLocation getId(T object, @Nullable ResourceKey<Registry<T>> fallback) {
throw new AssertionError();
}
@@ -79,7 +78,7 @@ public final class Registries {
@Nullable
@Deprecated
@ExpectPlatform
public static <T> ResourceLocation getId(T object, @Nullable net.minecraft.core.Registry<T> fallback) {
public static <T> ResourceLocation getId(T object, @Nullable Registry<T> fallback) {
throw new AssertionError();
}
@@ -90,7 +89,7 @@ public final class Registries {
@Nullable
@Deprecated
public static <T> ResourceLocation getRegistryName(T object) {
return getId(object, (ResourceKey<net.minecraft.core.Registry<T>>) null);
return getId(object, (ResourceKey<Registry<T>>) null);
}
@ExpectPlatform
@@ -104,11 +103,11 @@ public final class Registries {
@ApiStatus.Internal
public interface RegistryProvider {
<T> Registry<T> get(ResourceKey<net.minecraft.core.Registry<T>> key);
<T> Registrar<T> get(ResourceKey<Registry<T>> key);
@Deprecated
<T> Registry<T> get(net.minecraft.core.Registry<T> registry);
<T> Registrar<T> get(Registry<T> registry);
<T extends RegistryEntry<T>> RegistryBuilder<T> builder(Class<T> type, ResourceLocation registryId);
<T> RegistrarBuilder<T> builder(Class<T> type, ResourceLocation registryId);
}
}

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry;
package dev.architectury.registry.registries;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.registries;
package dev.architectury.registry.registries.options;
public interface RegistryOption {
public interface RegistrarOption {
}

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.registry.registries;
package dev.architectury.registry.registries.options;
public enum StandardRegistryOption implements RegistryOption {
public enum StandardRegistrarOption implements RegistrarOption {
/**
* Denote that the registry should save to disc and persist. Defaulted false.
*/

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.utils;
package dev.architectury.utils;
import net.fabricmc.api.EnvType;

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.utils;
package dev.architectury.utils;
import me.shedaniel.architectury.platform.Platform;
import dev.architectury.platform.Platform;
import net.fabricmc.api.EnvType;
import java.util.Optional;

View File

@@ -17,9 +17,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.utils;
package dev.architectury.utils;
import me.shedaniel.architectury.annotations.ExpectPlatform;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package me.shedaniel.architectury.utils;
package dev.architectury.utils;
import net.minecraft.nbt.CompoundTag;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.utils;
package dev.architectury.utils;
public class PlatformExpectedError extends Error {
public PlatformExpectedError() {

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.utils;
package dev.architectury.utils.value;
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.utils;
package dev.architectury.utils.value;
import it.unimi.dsi.fastutil.doubles.DoubleConsumer;

View File

@@ -17,7 +17,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package me.shedaniel.architectury.utils;
package dev.architectury.utils.value;
@FunctionalInterface
public interface FloatSupplier {

Some files were not shown because too many files have changed in this diff Show More