mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 20:52:34 +00:00
Remove deprecations
This commit is contained in:
1 parent
5b67354e24
commit
1558362583
17 files changed
+15
-287
No files matched your search
@@ -22,10 +22,10 @@ package net.minecraftforge.fml;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
import net.minecraftforge.registries.ObjectHolderRegistry;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -42,20 +42,10 @@ public final class RegistryObject<T extends IForgeRegistryEntry<? super T>> impl
|
||||
@Nullable
|
||||
private T value;
|
||||
|
||||
@Deprecated
|
||||
public static <T extends IForgeRegistryEntry<T>, U extends T> RegistryObject<U> of(final String name, Supplier<Class<? super T>> registryType) {
|
||||
return of(new ResourceLocation(name), registryType);
|
||||
}
|
||||
|
||||
public static <T extends IForgeRegistryEntry<T>, U extends T> RegistryObject<U> of(final ResourceLocation name, Supplier<Class<? super T>> registryType) {
|
||||
return new RegistryObject<>(name, registryType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static <T extends IForgeRegistryEntry<T>, U extends T> RegistryObject<U> of(final String name, IForgeRegistry<T> registry) {
|
||||
return of(new ResourceLocation(name), registry);
|
||||
}
|
||||
|
||||
public static <T extends IForgeRegistryEntry<T>, U extends T> RegistryObject<U> of(final ResourceLocation name, IForgeRegistry<T> registry) {
|
||||
return new RegistryObject<>(name, registry);
|
||||
}
|
||||
@@ -93,11 +83,13 @@ public final class RegistryObject<T extends IForgeRegistryEntry<? super T>> impl
|
||||
/**
|
||||
* Directly retrieves the wrapped Registry Object. This value will automatically be updated when the backing registry is updated.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
@Nonnull
|
||||
public T get()
|
||||
{
|
||||
return this.value;
|
||||
T ret = this.value;
|
||||
Objects.requireNonNull(ret, "Registry Object not present");
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void updateReference(IForgeRegistry<? extends T> registry)
|
||||
@@ -110,14 +102,6 @@ public final class RegistryObject<T extends IForgeRegistryEntry<? super T>> impl
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Prefer {@link #getId()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getName() {
|
||||
return getId().toString();
|
||||
}
|
||||
|
||||
public Stream<T> stream() {
|
||||
return isPresent() ? Stream.of(get()) : Stream.of();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.function.Supplier;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -145,12 +144,6 @@ public class ClientModLoader
|
||||
return VersionChecker.Status.UP_TO_DATE;
|
||||
}
|
||||
|
||||
@Deprecated // TODO: remove in 1.15
|
||||
public static void complete()
|
||||
{
|
||||
completeModLoading();
|
||||
}
|
||||
|
||||
public static boolean completeModLoading()
|
||||
{
|
||||
RenderSystem.disableTexture();
|
||||
|
||||
@@ -64,37 +64,6 @@ public class ObfuscationReflectionHelper
|
||||
return FMLLoader.getNameFunction("srg").map(f->f.apply(domain, name)).orElse(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value a field with the specified index in the given class.
|
||||
* Note: For performance, use {@link #findField(Class, int)} if you are getting the value more than once.
|
||||
* <p>
|
||||
* Throws an exception if the field is not found or the value of the field cannot be gotten.
|
||||
*
|
||||
* @param classToAccess The class to find the field on.
|
||||
* @param instance The instance of the {@code classToAccess}.
|
||||
* @param fieldIndex The index of the field in the {@code classToAccess}.
|
||||
* @param <T> The type of the value.
|
||||
* @param <E> The type of the {@code classToAccess}.
|
||||
* @return The value of the field with the specified index in the {@code classToAccess}.
|
||||
* @throws UnableToAccessFieldException If there was a problem getting the field or the value.
|
||||
* @deprecated Use {@link #getPrivateValue(Class, Object, String)} because field indices change a lot more often than field names do.
|
||||
* TODO: Remove in 1.15
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T) findField(classToAccess, fieldIndex).get(instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(REFLECTION, "There was a problem getting field index {} from {}", fieldIndex, classToAccess.getName(), e);
|
||||
throw new UnableToAccessFieldException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value a field with the specified name in the given class.
|
||||
* Note: For performance, use {@link #findField(Class, String)} if you are getting the value more than once.
|
||||
@@ -129,36 +98,6 @@ public class ObfuscationReflectionHelper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value a field with the specified index in the given class.
|
||||
* Note: For performance, use {@link #findField(Class, int)} if you are setting the value more than once.
|
||||
* <p>
|
||||
* Throws an exception if the field is not found or the value of the field cannot be set.
|
||||
*
|
||||
* @param classToAccess The class to find the field on.
|
||||
* @param instance The instance of the {@code classToAccess}.
|
||||
* @param value The new value for the field
|
||||
* @param fieldIndex The index of the field in the {@code classToAccess}.
|
||||
* @param <T> The type of the value.
|
||||
* @param <E> The type of the {@code classToAccess}.
|
||||
* @throws UnableToAccessFieldException If there was a problem setting the value of the field.
|
||||
* @deprecated Use {@link #setPrivateValue(Class, Object, Object, String)} because field indices change a lot more often than field names do.
|
||||
* TODO: Remove in 1.15
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T, E> void setPrivateValue(@Nonnull final Class<? super T> classToAccess, @Nonnull final T instance, @Nullable final E value, int fieldIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
findField(classToAccess, fieldIndex).set(instance, value);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
LOGGER.error("There was a problem setting field index {} on type {}", fieldIndex, classToAccess.getName(), e);
|
||||
throw new UnableToAccessFieldException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value a field with the specified name in the given class.
|
||||
* Note: For performance, use {@link #findField(Class, String)} if you are setting the value more than once.
|
||||
@@ -304,35 +243,6 @@ public class ObfuscationReflectionHelper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a field with the specified index in the given class and makes it accessible.
|
||||
* Note: For performance, store the returned value and avoid calling this repeatedly.
|
||||
* <p>
|
||||
* Throws an exception if the field is not found.
|
||||
*
|
||||
* @param clazz The class to find the field on.
|
||||
* @param fieldIndex The index of the field on the class
|
||||
* @param <T> The type.
|
||||
* @return The constructor with the specified parameters in the given class.
|
||||
* @throws NullPointerException If {@code clazz} is null.
|
||||
* @throws UnableToFindFieldException If the field could not be found.
|
||||
* @deprecated Use {@link #findField(Class, String)} because field indices change a lot more often than field names do.
|
||||
* TODO: Remove in 1.15
|
||||
*/
|
||||
@Deprecated
|
||||
@Nonnull
|
||||
public static <T> Field findField(final Class<? super T> clazz, final int fieldIndex) {
|
||||
Preconditions.checkNotNull(clazz, "Class to find field on cannot be null.");
|
||||
|
||||
try {
|
||||
final Field f = clazz.getDeclaredFields()[fieldIndex];
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
} catch (Exception e) {
|
||||
throw new UnableToFindFieldException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnableToAccessFieldException extends RuntimeException
|
||||
{
|
||||
private UnableToAccessFieldException(Exception e)
|
||||
|
||||
Reference in new issue
Block a user