Fix the rest of the "easy" compile errors (#5151)

* Add Entity.changeDimension patch and transitively required patches

* Fix throws declaration on CommandSetDimension#execute

* Fix rest of errors in fluid package

* Add PLAYER_REACH attribute

* Fix compile errors in fml.client.config and add GuiButton patch

* Delete unnecessary client.config classes, fix all config errors

* Comment some fluid errors in models

* Fix all errors in common package root, except ForgeHooks

* Mass comment network package

* Experimental conversion of extended states to generic base class

* Fix errors in common.util

* Remove config annotation stuff cuz lex said so

* Make extended state stuff compile fully
This commit is contained in:
tterrag authored and GitHub committed 2018-09-18 00:04:02 -04:00
1 parent 6814cbf0df
commit c4cf950863
72 files changed
+610 -5996

No files matched your search

@@ -28,7 +28,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nullable;
@@ -54,7 +53,7 @@ public class BlockSnapshot
@Nullable
private WeakReference<World> world;
private final ResourceLocation registryName;
private final int meta;
private final int meta = 0; // TODO BlockSnapshot needs a total refactor for the absence of metadata
public BlockSnapshot(World world, BlockPos pos, IBlockState state)
{
@@ -68,7 +67,6 @@ public class BlockSnapshot
this.pos = pos.toImmutable();
this.setReplacedBlock(state);
this.registryName = state.getBlock().getRegistryName();
this.meta = state.getBlock().getMetaFromState(state);
this.setFlag(3);
this.nbt = nbt;
if (DEBUG)
@@ -99,7 +97,6 @@ public class BlockSnapshot
this.pos = pos.toImmutable();
this.setFlag(flag);
this.registryName = registryName;
this.meta = meta;
this.nbt = nbt;
}
@@ -143,7 +140,7 @@ public class BlockSnapshot
World world = this.world != null ? this.world.get() : null;
if (world == null)
{
world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(getDimId());
world = null; // TODO Server static access? FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(getDimId());
this.world = new WeakReference<World>(world);
}
return world;
@@ -153,7 +150,7 @@ public class BlockSnapshot
{
if (this.replacedBlock == null)
{
this.replacedBlock = ForgeRegistries.BLOCKS.getValue(getRegistryName()).getStateFromMeta(getMeta());
this.replacedBlock = ForgeRegistries.BLOCKS.getValue(getRegistryName()).func_196257_b(getMeta());
}
return this.replacedBlock;
}
@@ -161,7 +158,7 @@ public class BlockSnapshot
@Nullable
public TileEntity getTileEntity()
{
return getNbt() != null ? TileEntity.create(getWorld(), getNbt()) : null;
return getNbt() != null ? TileEntity.func_203403_c(getNbt()) : null;
}
public boolean restore()
@@ -184,7 +181,7 @@ public class BlockSnapshot
IBlockState current = getCurrentBlock();
IBlockState replaced = getReplacedBlock();
if (current.getBlock() != replaced.getBlock() || current.getBlock().getMetaFromState(current) != replaced.getBlock().getMetaFromState(replaced))
if (current != replaced)
{
if (force)
{
@@ -212,15 +209,15 @@ public class BlockSnapshot
if (DEBUG)
{
System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][Meta: %d ][Block: %s ][TileEntity: %s ][force: %s ][notifyNeighbors: %s]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), replaced.getBlock().getMetaFromState(replaced), replaced.getBlock().delegate.name(), te, force, notifyNeighbors);
System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][State: %s ][Block: %s ][TileEntity: %s ][force: %s ][notifyNeighbors: %s]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), replaced, replaced.getBlock().delegate.name(), te, force, notifyNeighbors);
}
return true;
}
public void writeToNBT(NBTTagCompound compound)
{
compound.setString("blockMod", getRegistryName().getResourceDomain());
compound.setString("blockName", getRegistryName().getResourcePath());
compound.setString("blockMod", getRegistryName().getNamespace());
compound.setString("blockName", getRegistryName().getPath());
compound.setInteger("posX", getPos().getX());
compound.setInteger("posY", getPos().getY());
compound.setInteger("posZ", getPos().getZ());
@@ -1,185 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library 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 version 2.1
* of the License.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.util;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.IDataWalker;
import net.minecraft.util.datafix.IFixType;
import net.minecraft.util.datafix.IFixableData;
public class CompoundDataFixer extends DataFixer
{
private final ModFixs vanilla;
private final Map<String, ModFixs> modFixers = Maps.newHashMap();
private final Map<IFixType, List<IDataWalker>> walkers = Maps.newHashMap();
public CompoundDataFixer(DataFixer vanilla)
{
super(0);
this.vanilla = init("minecraft", vanilla.version);
}
@Override
public NBTTagCompound process(IFixType type, NBTTagCompound nbt)
{
final Map<String, Integer>versions = getVersions(nbt);
final int mcversion = versions.get("minecraft") == null ? -1 : versions.get("minecraft");
final IDataFixerData holder = new IDataFixerData()
{
@Override
public NBTTagCompound process(IFixType type, NBTTagCompound nbt, int version)
{
for (Entry<String, ModFixs> e : modFixers.entrySet())
{
// This is a potential performance hot spot. As it walks all the data for all
// of the fixers... But with the vanilla api there isn't a way to pass down
// the mod specific version numbers, so redundant.. but not hacky...
//Actually, this wont work as the data walkers take versions into account...
ModFixs fixer = e.getValue();
int ver = getVersion(e.getKey());
if (ver < fixer.version)
{
for (IFixableData fix : fixer.getFixes(type))
{
if (fix.getFixVersion() > ver)
nbt = fix.fixTagCompound(nbt);
}
for (IDataWalker walker : getWalkers(type))
nbt = walker.process(this, nbt, version); //We pass in the holder, in case a walker wants to know a mod version
}
}
return nbt;
}
@Override
public int getVersion(String mod)
{
Integer ret = versions.get(mod);
return ret == null ? -1 : ret;
}
};
return holder.process(type, nbt, mcversion);
}
@Override
@Deprecated //MODDERS DO NOT CALL DIRECTLY! Only use from DataWalker!
public NBTTagCompound process(IFixType type, NBTTagCompound nbt, int mcversion)
{
if (type != FixTypes.OPTIONS) //Options are vanilla only
throw new IllegalStateException("Do not call recursive process directly on DataFixer!");
for (IFixableData fix : vanilla.getFixes(type))
{
if (fix.getFixVersion() > mcversion)
nbt = fix.fixTagCompound(nbt);
}
//Options is a hack, and doesn't have any nested components
//for (IDataWalker walker : getWalkers(type))
// nbt = walker.process(this, nbt, version);
return nbt;
}
private List<IDataWalker> getWalkers(IFixType type)
{
return walkers.computeIfAbsent(type, k -> Lists.newArrayList());
}
@Override
@Deprecated //Modders do not use this, this will register you as vanilla. Use the ModID version below.
public void registerFix(IFixType type, IFixableData fixable)
{
vanilla.registerFix(type, fixable);
}
@Override
@Deprecated //Modders do not use this, use add below, To better allow custom fix types.
public void registerWalker(FixTypes type, IDataWalker walker)
{
registerVanillaWalker(type, walker);
}
@Override
public void registerVanillaWalker(IFixType type, IDataWalker walker)
{
getWalkers(type).add(walker);
}
private void validateModId(String mod)
{
//String current = Loader.instance().activeModContainer() == null ? "minecraft" : Loader.instance().activeModContainer().getModId();
//Test active modid?
if (!mod.equals(mod.toLowerCase(Locale.ENGLISH)))
throw new IllegalArgumentException("Mod ID is not lower case: " + mod);
if (mod.length() > 64)
throw new IllegalArgumentException("Mod ID is to long: " + mod);
}
/**
* Initialize your mod specific data fixer.
*
* @param modid You mod id, must be lower case.
* @param version The current data version of your mod
*/
public ModFixs init(String modid, int version)
{
validateModId(modid);
if (modFixers.containsKey(modid))
throw new IllegalStateException("Attempted to initalize DataFixer for " + modid + " twice");
ModFixs ret = new ModFixs(modid, version);
modFixers.put(modid, ret);
return ret;
}
private Map<String, Integer> getVersions(NBTTagCompound nbt)
{
Map<String, Integer> ret = Maps.newHashMap();
ret.put("minecraft", nbt.hasKey("DataVersion", 99) ? nbt.getInteger("DataVersion") : -1);
if (nbt.hasKey("ForgeDataVersion", 10))
{
NBTTagCompound sub = nbt.getCompoundTag("ForgeDataVersion");
for (String key : sub.getKeySet())
{
ret.put(key, sub.hasKey(key, 99) ? sub.getInteger(key) : -1);
}
}
return ret;
}
public void writeVersionData(NBTTagCompound nbt)
{
//nbt.setInteger("DataVersion", vanilla.version);
NBTTagCompound sub = new NBTTagCompound();
nbt.setTag("ForgeDataVersion", sub);
for (ModFixs mod : modFixers.values())
sub.setInteger(mod.mod, mod.version);
}
}
@@ -1,85 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library 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 version 2.1
* of the License.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.util;
import java.lang.reflect.*;
import java.util.*;
import java.util.function.BiPredicate;
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
import org.apache.commons.lang3.ArrayUtils;
import javax.annotation.Nullable;
public class EnumHelper
{
/*
* Everything below this is found at the site below, and updated to be able to compile in Eclipse/Java 1.6+
* Also modified for use in decompiled code.
* Found at: http://niceideas.ch/roller2/badtrash/entry/java_create_enum_instances_dynamically
*/
private static < T extends Enum<? >> T makeEnum(Class<T> enumClass, @Nullable String value, int ordinal, Class<?>[] additionalTypes, @Nullable Object[] additionalValues) throws Exception
{
//new Enum(name, values.size() + 1, params)
}
private static void blankField(Class<?> enumClass, String fieldName) throws Exception
{
for (Field field : Class.class.getDeclaredFields())
{
if (field.getName().contains(fieldName))
{
field.setAccessible(true);
field.set(enumClass, null);
break;
}
}
}
//Class holds caches of the enum constants used for Enum.valueOf() and reflection magic. So we need to invalidate those caches when we add something new. They will automtically be re-built.
public static void cleanEnumCache(Class<?> enumClass) throws Exception
{
blankField(enumClass, "enumConstantDirectory");
blankField(enumClass, "enumConstants");
}
@SuppressWarnings({ "unchecked", "serial" })
@Nullable
private static <T extends Enum<?> & IExpandableEnum<?>> T addEnum(boolean test, final Class<T> enumType, T newValue)
{
try
{
T[] previousValues = enumType.getEnumConstants();
T newValue = makeEnum(enumType, enumName, previousValues.length, paramTypes, paramValues);
newValue.__set_values__(ArrayUtils.add(previousValues, newValue));
cleanEnumCache(enumType);
return newValue;
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}
@@ -22,7 +22,6 @@ package net.minecraftforge.common.util;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.client.CPacketClientSettings;
@@ -39,11 +38,10 @@ public class FakePlayer extends EntityPlayerMP
{
public FakePlayer(WorldServer world, GameProfile name)
{
super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, name, new PlayerInteractionManager(world));
super(world.getMinecraftServer(), world, name, new PlayerInteractionManager(world));
}
@Override public Vec3d getPositionVector(){ return new Vec3d(0, 0, 0); }
@Override public boolean canUseCommand(int i, String s){ return false; }
@Override public void sendStatusMessage(ITextComponent chatComponent, boolean actionBar){}
@Override public void sendMessage(ITextComponent component) {}
@Override public void addStat(StatBase par1StatBase, int par2){}
@@ -1,27 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library 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 version 2.1
* of the License.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.util;
import net.minecraft.util.datafix.IDataFixer;
public interface IDataFixerData extends IDataFixer
{
int getVersion(String mod);
}
@@ -22,7 +22,6 @@ package net.minecraftforge.common.util;
import net.minecraft.entity.Entity;
import net.minecraft.world.Teleporter;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
/**
* Interface for handling the placement of entities during dimension change.
@@ -36,8 +36,9 @@ import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.JsonSyntaxException;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
@@ -103,7 +104,7 @@ public class JsonUtils
try
{
return JsonToNBT.getTagFromJson(net.minecraft.util.JsonUtils.getString(json, key));
} catch (NBTException e)
} catch (CommandSyntaxException e)
{
throw new JsonSyntaxException("Malformed NBT tag", e);
}
@@ -1,78 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library 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 version 2.1
* of the License.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.util;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.util.datafix.IFixType;
import net.minecraft.util.datafix.IFixableData;
public class ModFixs
{
private static final Logger LOGGER = LogManager.getLogger();
final String mod;
final int version;
private final Map<IFixType, List<IFixableData>> fixes = Maps.newHashMap();
ModFixs(String mod, int version)
{
this.mod = mod;
this.version = version;
}
public List<IFixableData> getFixes(IFixType type)
{
return this.fixes.computeIfAbsent(type, k -> Lists.newArrayList());
}
public void registerFix(IFixType type, IFixableData fixer)
{
List<IFixableData> list = getFixes(type);
int ver = fixer.getFixVersion();
if (ver > this.version)
{
LOGGER.warn("[{}] Ignored fix registered for version: {} as the DataVersion of the game is: {}", mod, ver, this.version);
return;
}
if (!list.isEmpty() && list.get(list.size()-1).getFixVersion() > ver)
{
for (int x = 0; x < list.size(); ++x)
{
if (list.get(x).getFixVersion() > ver)
{
list.add(x, fixer);
break;
}
}
}
else
list.add(fixer);
}
}
@@ -45,7 +45,6 @@ public class PacketUtil
{
buffer.writeShort(Item.getIdFromItem(stack.getItem()));
buffer.writeByte(stack.getCount());
buffer.writeShort(stack.getMetadata());
NBTTagCompound nbttagcompound = null;
if (stack.getItem().isDamageable() || stack.getItem().getShareTag())