name changes

This commit is contained in:
asie 2019-02-07 12:58:21 +01:00
parent 8bda86f21d
commit 9dffeebaf1
17 changed files with 31 additions and 33 deletions

View file

@ -17,7 +17,6 @@
package net.fabricmc.fabric.api.event;
import net.fabricmc.fabric.impl.event.EventFactoryImpl;
import net.fabricmc.loader.launch.common.FabricLauncherBase;
import java.util.function.Function;
@ -36,11 +35,15 @@ public final class EventFactory {
EventFactoryImpl.invalidate();
}
public static <T> Event<T> arrayBacked(Class<T> type, Function<T[], T> joiner) {
return EventFactoryImpl.arrayBacked(type, joiner);
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> joiner) {
return EventFactoryImpl.createArrayBacked(type, joiner);
}
public static <T> Event<T> arrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> joiner) {
return EventFactoryImpl.arrayBacked(type, emptyInvoker, joiner);
public static <T> Event<T> createArrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> joiner) {
return EventFactoryImpl.createArrayBacked(type, emptyInvoker, joiner);
}
public static String getHandlerName(Object event) {
return event.getClass().getName();
}
}

View file

@ -27,7 +27,7 @@ import java.util.Map;
import java.util.function.Consumer;
public interface ClientSpriteRegistryCallback {
public static final Event<ClientSpriteRegistryCallback> EVENT = EventFactory.arrayBacked(ClientSpriteRegistryCallback.class,
public static final Event<ClientSpriteRegistryCallback> EVENT = EventFactory.createArrayBacked(ClientSpriteRegistryCallback.class,
(listeners) -> (atlasTexture, registry) -> {
for (ClientSpriteRegistryCallback callback : listeners) {
callback.registerSprites(atlasTexture, registry);

View file

@ -18,18 +18,16 @@ package net.fabricmc.fabric.api.event.client;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.ActionResult;
public interface ClientTickCallback {
public static final Event<ClientTickCallback> EVENT = EventFactory.arrayBacked(ClientTickCallback.class,
public static final Event<ClientTickCallback> EVENT = EventFactory.createArrayBacked(ClientTickCallback.class,
(listeners) -> {
if (EventFactory.isProfilingEnabled()) {
return (client) -> {
client.getProfiler().push("fabricClientTick");
for (ClientTickCallback event : listeners) {
client.getProfiler().push(event.getClass().getName());
client.getProfiler().push(EventFactory.getHandlerName(event));
event.tick(client);
client.getProfiler().pop();
}

View file

@ -37,7 +37,7 @@ import net.minecraft.world.World;
* ATTACK_BLOCK does not let you control the packet sending process yet.
*/
public interface AttackBlockCallback {
public static final Event<AttackBlockCallback> EVENT = EventFactory.arrayBacked(AttackBlockCallback.class,
public static final Event<AttackBlockCallback> EVENT = EventFactory.createArrayBacked(AttackBlockCallback.class,
(listeners) -> (player, world, hand, pos, direction) -> {
for (AttackBlockCallback event : listeners) {
ActionResult result = event.interact(player, world, hand, pos, direction);

View file

@ -35,7 +35,7 @@ import net.minecraft.world.World;
* - FAIL cancels further processing and does not send a packet to the server.
*/
public interface AttackEntityCallback {
public static final Event<AttackEntityCallback> EVENT = EventFactory.arrayBacked(AttackEntityCallback.class,
public static final Event<AttackEntityCallback> EVENT = EventFactory.createArrayBacked(AttackEntityCallback.class,
(listeners) -> (player, world, hand, entity, hitResult) -> {
for (AttackEntityCallback event : listeners) {
ActionResult result = event.interact(player, world, hand, entity, hitResult);

View file

@ -22,8 +22,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
/**
@ -36,7 +34,7 @@ import net.minecraft.world.World;
* - FAIL cancels further processing and does not send a packet to the server.
*/
public interface UseBlockCallback {
public static final Event<UseBlockCallback> EVENT = EventFactory.arrayBacked(UseBlockCallback.class,
public static final Event<UseBlockCallback> EVENT = EventFactory.createArrayBacked(UseBlockCallback.class,
(listeners) -> (player, world, hand, hitResult) -> {
for (UseBlockCallback event : listeners) {
ActionResult result = event.interact(player, world, hand, hitResult);

View file

@ -35,7 +35,7 @@ import net.minecraft.world.World;
* - FAIL cancels further processing and does not send a packet to the server.
*/
public interface UseEntityCallback {
public static final Event<UseEntityCallback> EVENT = EventFactory.arrayBacked(UseEntityCallback.class,
public static final Event<UseEntityCallback> EVENT = EventFactory.createArrayBacked(UseEntityCallback.class,
(listeners) -> (player, world, hand, entity, hitResult) -> {
for (UseEntityCallback event : listeners) {
ActionResult result = event.interact(player, world, hand, entity, hitResult);

View file

@ -33,7 +33,7 @@ import net.minecraft.world.World;
* - FAIL cancels further processing and does not send a packet to the server.
*/
public interface UseItemCallback {
public static final Event<UseItemCallback> EVENT = EventFactory.arrayBacked(UseItemCallback.class,
public static final Event<UseItemCallback> EVENT = EventFactory.createArrayBacked(UseItemCallback.class,
(listeners) -> (player, world, hand) -> {
for (UseItemCallback event : listeners) {
ActionResult result = event.interact(player, world, hand);

View file

@ -21,7 +21,7 @@ import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.block.Block;
public interface BlockConstructedCallback {
public static Event<BlockConstructedCallback> EVENT = EventFactory.arrayBacked(BlockConstructedCallback.class,
public static Event<BlockConstructedCallback> EVENT = EventFactory.createArrayBacked(BlockConstructedCallback.class,
(listeners) -> (settings, builtBlock) -> {
for (BlockConstructedCallback callback : listeners) {
callback.building(settings, builtBlock);

View file

@ -21,7 +21,7 @@ import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.item.Item;
public interface ItemConstructedCallback {
public static Event<ItemConstructedCallback> EVENT = EventFactory.arrayBacked(ItemConstructedCallback.class,
public static Event<ItemConstructedCallback> EVENT = EventFactory.createArrayBacked(ItemConstructedCallback.class,
(listeners) -> (settings, builtItem) -> {
for (ItemConstructedCallback callback : listeners) {
callback.building(settings, builtItem);

View file

@ -21,7 +21,7 @@ import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.server.MinecraftServer;
public interface ServerStartCallback {
public static final Event<ServerStartCallback> EVENT = EventFactory.arrayBacked(ServerStartCallback.class,
public static final Event<ServerStartCallback> EVENT = EventFactory.createArrayBacked(ServerStartCallback.class,
(listeners) -> (server) -> {
for (ServerStartCallback event : listeners) {
event.onStartServer(server);

View file

@ -21,7 +21,7 @@ import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.server.MinecraftServer;
public interface ServerStopCallback {
public static final Event<ServerStopCallback> EVENT = EventFactory.arrayBacked(ServerStopCallback.class,
public static final Event<ServerStopCallback> EVENT = EventFactory.createArrayBacked(ServerStopCallback.class,
(listeners) -> (server) -> {
for (ServerStopCallback event : listeners) {
event.onStopServer(server);

View file

@ -21,13 +21,13 @@ import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.server.MinecraftServer;
public interface ServerTickCallback {
public static final Event<ServerTickCallback> EVENT = EventFactory.arrayBacked(ServerTickCallback.class,
public static final Event<ServerTickCallback> EVENT = EventFactory.createArrayBacked(ServerTickCallback.class,
(listeners) -> {
if (EventFactory.isProfilingEnabled()) {
return (server) -> {
server.getProfiler().push("fabricServerTick");
for (ServerTickCallback event : listeners) {
server.getProfiler().push(event.getClass().getName());
server.getProfiler().push(EventFactory.getHandlerName(event));
event.tick(server);
server.getProfiler().pop();
}

View file

@ -21,13 +21,13 @@ import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.world.World;
public interface WorldTickCallback {
public static final Event<WorldTickCallback> EVENT = EventFactory.arrayBacked(WorldTickCallback.class,
public static final Event<WorldTickCallback> EVENT = EventFactory.createArrayBacked(WorldTickCallback.class,
(listeners) -> {
if (EventFactory.isProfilingEnabled()) {
return (world) -> {
world.getProfiler().push("fabricWorldTick");
for (WorldTickCallback event : listeners) {
world.getProfiler().push(event.getClass().getName());
world.getProfiler().push(EventFactory.getHandlerName(event));
event.tick(world);
world.getProfiler().pop();
}

View file

@ -19,7 +19,9 @@ package net.fabricmc.fabric.api.network;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BiConsumer;
@ -34,7 +36,7 @@ public class CustomPayloadPacketRegistry {
protected final Map<Identifier, BiConsumer<PacketContext, PacketByteBuf>> consumerMap;
protected CustomPayloadPacketRegistry() {
consumerMap = new HashMap<>();
consumerMap = new LinkedHashMap<>();
}
/**

View file

@ -19,7 +19,6 @@ package net.fabricmc.fabric.impl.event;
import net.fabricmc.fabric.api.event.Event;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandleProxies;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.*;
@ -38,11 +37,11 @@ public final class EventFactoryImpl {
ARRAY_BACKED_EVENTS.forEach(ArrayBackedEvent::update);
}
public static <T> Event<T> arrayBacked(Class<T> type, Function<T[], T> joiner) {
return arrayBacked(type, null /* buildEmptyInvoker(type, joiner) */, joiner);
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> joiner) {
return createArrayBacked(type, null /* buildEmptyInvoker(type, joiner) */, joiner);
}
public static <T> Event<T> arrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> joiner) {
public static <T> Event<T> createArrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> joiner) {
ArrayBackedEvent<T> event = new ArrayBackedEvent<>(type, emptyInvoker, joiner);
ARRAY_BACKED_EVENTS.add(event);
return event;

View file

@ -35,9 +35,7 @@ public abstract class MixinServerPlayNetworkHandler {
@Inject(method = "<init>", at = @At("RETURN"))
public void init(MinecraftServer server, ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) {
//if (server.isDedicated()) {
// TODO: If integrated and local, don't send the packet
// TODO: If integrated and local, don't send the packet (it's ignored)
sendPacket(RegistrySyncManager.createPacket());
//}
}
}