do not deprecate so hastily!

This commit is contained in:
Adrian Siekierka 2018-12-14 20:02:15 +01:00
parent 41db1633a8
commit f53fe80c6d
16 changed files with 69 additions and 16 deletions

View file

@ -16,7 +16,7 @@
package net.fabricmc.fabric.events;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;

View file

@ -16,7 +16,7 @@
package net.fabricmc.fabric.events;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerRegistry;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
@ -74,7 +74,7 @@ public final class PlayerInteractionEvent {
public static final HandlerRegistry<Entity> ATTACK_ENTITY = new HandlerArray<>(Entity.class);
// TODO: For completeness' sake, but requires us to add a custom packet. Is it worth the complexity?
/* public static final HandlerRegistry<Item> ATTACK_ITEM = new HandlerArray<>(); */
/* public static final HandlerRegistry<Item> ATTACK_ITEM = new HanderList<>(); */
/**
* Event emitted when a player interacts with a block.

View file

@ -16,7 +16,7 @@
package net.fabricmc.fabric.events;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerRegistry;
import net.minecraft.server.MinecraftServer;

View file

@ -16,7 +16,7 @@
package net.fabricmc.fabric.events;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerRegistry;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Profiler;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.events.client;
import net.fabricmc.fabric.events.TickEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerRegistry;
import net.minecraft.client.MinecraftClient;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.events.client;
import net.fabricmc.fabric.client.texture.SpriteRegistry;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerRegistry;
public class SpriteEvent {

View file

@ -20,7 +20,7 @@ import com.google.common.base.Joiner;
import net.fabricmc.fabric.client.texture.*;
import net.fabricmc.fabric.impl.client.texture.FabricSprite;
import net.fabricmc.fabric.events.client.SpriteEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.minecraft.class_1050;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.resource.metadata.AnimationResourceMetadata;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.mixin.events.objectbuilder;
import net.fabricmc.fabric.events.ObjectBuilderEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.minecraft.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.mixin.events.objectbuilder;
import net.fabricmc.fabric.events.ObjectBuilderEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.mixin.events.playerinteraction;
import net.fabricmc.fabric.events.PlayerInteractionEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.mixin.events.playerinteraction;
import net.fabricmc.fabric.events.PlayerInteractionEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.network.packet.PlayerInteractEntityServerPacket;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.mixin.events.playerinteraction;
import net.fabricmc.fabric.events.PlayerInteractionEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.mixin.events.playerinteraction;
import net.fabricmc.fabric.events.PlayerInteractionEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.minecraft.client.network.packet.BlockUpdateClientPacket;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;

View file

@ -17,7 +17,7 @@
package net.fabricmc.fabric.mixin.events.server;
import net.fabricmc.fabric.events.ServerEvent;
import net.fabricmc.fabric.impl.util.HandlerArray;
import net.fabricmc.fabric.util.HandlerArray;
import net.minecraft.server.MinecraftServer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View file

@ -0,0 +1,53 @@
/*
* Copyright (c) 2016, 2017, 2018 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.util;
import java.lang.reflect.Array;
/**
* @deprecated Use HandlerArray.
*/
@Deprecated
public class HanderList<T> implements HandlerRegistry<T> {
private final Class tClass;
private T[] array;
@SuppressWarnings("unchecked")
public HanderList(Class theClass) {
this.tClass = theClass;
this.array = (T[]) Array.newInstance(tClass, 0);
}
@Override
public void register(T handler) {
for (int i = 0; i < array.length; i++) {
if (array[i] == handler) {
throw new RuntimeException("Handler " + handler + " already registered!");
}
}
//noinspection unchecked
T[] newArray = (T[]) Array.newInstance(tClass, array.length + 1);
System.arraycopy(array, 0, newArray, 0, array.length);
newArray[array.length] = handler;
array = newArray;
}
public T[] getBackingArray() {
return array;
}
}

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
package net.fabricmc.fabric.impl.util;
package net.fabricmc.fabric.util;
import net.fabricmc.fabric.util.HandlerRegistry;