mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
More compile cleanups. (#5139)
This commit is contained in:
1 parent
dbf649225a
commit
3f743887e7
71 files changed
+901
-411
No files matched your search
@@ -48,13 +48,12 @@ import com.google.common.collect.Multiset;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.MinecraftException;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorldEventHandler;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.WorldServerMulti;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.storage.ISaveHandler;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -68,11 +67,11 @@ public class DimensionManager
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker DIMMGR = MarkerManager.getMarker("DIMS");
|
||||
private static class Dimension
|
||||
private static class DimensionData
|
||||
{
|
||||
private final DimensionType type;
|
||||
private int ticksWaited;
|
||||
private Dimension(DimensionType type)
|
||||
private DimensionData(DimensionType type)
|
||||
{
|
||||
this.type = type;
|
||||
this.ticksWaited = 0;
|
||||
@@ -82,7 +81,7 @@ public class DimensionManager
|
||||
private static boolean hasInit = false;
|
||||
|
||||
private static final Int2ObjectMap<WorldServer> worlds = Int2ObjectMaps.synchronize(new Int2ObjectLinkedOpenHashMap<>());
|
||||
private static final Int2ObjectMap<Dimension> dimensions = Int2ObjectMaps.synchronize(new Int2ObjectLinkedOpenHashMap<>());
|
||||
private static final Int2ObjectMap<DimensionData> dimensions = Int2ObjectMaps.synchronize(new Int2ObjectLinkedOpenHashMap<>());
|
||||
private static final IntSet keepLoaded = IntSets.synchronize(new IntOpenHashSet());
|
||||
private static final IntSet unloadQueue = IntSets.synchronize(new IntLinkedOpenHashSet());
|
||||
private static final BitSet dimensionMap = new BitSet(Long.SIZE << 4);
|
||||
@@ -96,7 +95,7 @@ public class DimensionManager
|
||||
{
|
||||
int[] ret = new int[dimensions.size()];
|
||||
int x = 0;
|
||||
for (Int2ObjectMap.Entry<Dimension> ent : dimensions.int2ObjectEntrySet())
|
||||
for (Int2ObjectMap.Entry<DimensionData> ent : dimensions.int2ObjectEntrySet())
|
||||
{
|
||||
if (ent.getValue().type == type)
|
||||
{
|
||||
@@ -110,7 +109,7 @@ public class DimensionManager
|
||||
public static Map<DimensionType, IntSortedSet> getRegisteredDimensions()
|
||||
{
|
||||
Map<DimensionType, IntSortedSet> map = new IdentityHashMap<>();
|
||||
for (Int2ObjectMap.Entry<Dimension> entry : dimensions.int2ObjectEntrySet())
|
||||
for (Int2ObjectMap.Entry<DimensionData> entry : dimensions.int2ObjectEntrySet())
|
||||
{
|
||||
map.computeIfAbsent(entry.getValue().type, k -> new IntRBTreeSet()).add(entry.getIntKey());
|
||||
}
|
||||
@@ -138,7 +137,7 @@ public class DimensionManager
|
||||
{
|
||||
throw new IllegalArgumentException(String.format("Failed to register dimension for id %d, One is already registered", id));
|
||||
}
|
||||
dimensions.put(id, new Dimension(type));
|
||||
dimensions.put(id, new DimensionData(type));
|
||||
if (id >= 0)
|
||||
{
|
||||
dimensionMap.set(id);
|
||||
@@ -171,7 +170,7 @@ public class DimensionManager
|
||||
return dimensions.get(dim).type;
|
||||
}
|
||||
|
||||
public static WorldProvider getProvider(int dim)
|
||||
public static Dimension getProvider(int dim)
|
||||
{
|
||||
return getWorld(dim).provider;
|
||||
}
|
||||
@@ -309,14 +308,14 @@ public class DimensionManager
|
||||
return dimensions.keySet().toArray(new Integer[0]);
|
||||
}
|
||||
|
||||
public static WorldProvider createProviderFor(int dim)
|
||||
public static Dimension createProviderFor(int dim)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dimensions.containsKey(dim))
|
||||
{
|
||||
WorldProvider ret = getProviderType(dim).createDimension();
|
||||
ret.setDimension(dim);
|
||||
Dimension ret = getProviderType(dim).createDimension();
|
||||
ret.setId(dim);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
@@ -348,7 +347,7 @@ public class DimensionManager
|
||||
return ForgeChunkManager.getPersistentChunksFor(world).isEmpty()
|
||||
&& world.playerEntities.isEmpty()
|
||||
&& !world.provider.getDimensionType().shouldLoadSpawn()
|
||||
&& !keepLoaded.contains(world.provider.getDimension());
|
||||
&& !keepLoaded.contains(world.provider.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,7 +379,7 @@ public class DimensionManager
|
||||
while (queueIterator.hasNext())
|
||||
{
|
||||
int id = queueIterator.nextInt();
|
||||
Dimension dimension = dimensions.get(id);
|
||||
DimensionData dimension = dimensions.get(id);
|
||||
if (dimension.ticksWaited < ForgeMod.dimensionUnloadQueueDelay)
|
||||
{
|
||||
dimension.ticksWaited++;
|
||||
|
||||
@@ -110,7 +110,7 @@ import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.GameType;
|
||||
@@ -209,7 +209,7 @@ public class ForgeHooks
|
||||
private static boolean toolInit = false;
|
||||
//static HashSet<List> toolEffectiveness = new HashSet<List>();
|
||||
|
||||
public static boolean canHarvestBlock(@Nonnull Block block, @Nonnull EntityPlayer player, @Nonnull IBlockAccess world, @Nonnull BlockPos pos)
|
||||
public static boolean canHarvestBlock(@Nonnull Block block, @Nonnull EntityPlayer player, @Nonnull IWorldReader world, @Nonnull BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
state = state.getBlock().getActualState(state, world, pos);
|
||||
@@ -234,7 +234,7 @@ public class ForgeHooks
|
||||
return toolLevel >= block.getHarvestLevel(state);
|
||||
}
|
||||
|
||||
public static boolean canToolHarvestBlock(IBlockAccess world, BlockPos pos, @Nonnull ItemStack stack)
|
||||
public static boolean canToolHarvestBlock(IWorldReader world, BlockPos pos, @Nonnull ItemStack stack)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
state = state.getBlock().getActualState(state, world, pos);
|
||||
@@ -261,7 +261,7 @@ public class ForgeHooks
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isToolEffective(IBlockAccess world, BlockPos pos, @Nonnull ItemStack stack)
|
||||
public static boolean isToolEffective(IWorldReader world, BlockPos pos, @Nonnull ItemStack stack)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
state = state.getBlock().getActualState(state, world, pos);
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ForgeModContainer extends FMLModContainer
|
||||
ConfigCategory GENERAL = config.getCategory(CATEGORY_GENERAL);
|
||||
if (GENERAL.containsKey(key))
|
||||
{
|
||||
FMLLog.log.debug("Remapping property {} from category general to client", key);
|
||||
LOGGER.debug("Remapping property {} from category general to client", key);
|
||||
Property property = GENERAL.get(key);
|
||||
GENERAL.remove(key);
|
||||
config.getCategory(CATEGORY_CLIENT).put(key, property);
|
||||
@@ -182,7 +182,7 @@ public class ForgeModContainer extends FMLModContainer
|
||||
|
||||
if (removeErroringEntities)
|
||||
{
|
||||
FMLLog.log.warn("Enabling removal of erroring Entities - USE AT YOUR OWN RISK");
|
||||
LOGGER.warn("Enabling removal of erroring Entities - USE AT YOUR OWN RISK");
|
||||
}
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringTileEntities", false);
|
||||
@@ -193,7 +193,7 @@ public class ForgeModContainer extends FMLModContainer
|
||||
|
||||
if (removeErroringTileEntities)
|
||||
{
|
||||
FMLLog.log.warn("Enabling removal of erroring Tile Entities - USE AT YOUR OWN RISK");
|
||||
LOGGER.warn("Enabling removal of erroring Tile Entities - USE AT YOUR OWN RISK");
|
||||
}
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false);
|
||||
|
||||
@@ -21,10 +21,10 @@ package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
public interface IPlantable
|
||||
{
|
||||
EnumPlantType getPlantType(IBlockAccess world, BlockPos pos);
|
||||
IBlockState getPlant(IBlockAccess world, BlockPos pos);
|
||||
EnumPlantType getPlantType(IWorldReader world, BlockPos pos);
|
||||
IBlockState getPlant(IWorldReader world, BlockPos pos);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -35,7 +35,7 @@ import javax.annotation.Nonnull;
|
||||
* to support mod-shears as well.
|
||||
*
|
||||
*/
|
||||
//TODO Change to World, not IBlockAccess and make Implementor responsible for removing itself from the world.
|
||||
//TODO Change to World, not IWorldReader and make Implementor responsible for removing itself from the world.
|
||||
//Better mimics vanilla behavior and allows more control for the user.
|
||||
public interface IShearable
|
||||
{
|
||||
@@ -48,7 +48,7 @@ public interface IShearable
|
||||
* @param pos Block's position in world.
|
||||
* @return If this is shearable, and onSheared should be called.
|
||||
*/
|
||||
boolean isShearable(@Nonnull ItemStack item, IBlockAccess world, BlockPos pos);
|
||||
boolean isShearable(@Nonnull ItemStack item, IWorldReader world, BlockPos pos);
|
||||
|
||||
/**
|
||||
* Performs the shear function on this object.
|
||||
@@ -69,5 +69,5 @@ public interface IShearable
|
||||
* @return A List containing all items from this shearing. May be empty.
|
||||
*/
|
||||
@Nonnull
|
||||
List<ItemStack> onSheared(@Nonnull ItemStack item, IBlockAccess world, BlockPos pos, int fortune);
|
||||
List<ItemStack> onSheared(@Nonnull ItemStack item, IWorldReader world, BlockPos pos, int fortune);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class MinecraftForge
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("Could not find class for name '{}'.", name, e);
|
||||
LOGGER.error("Could not find class for name '{}'.", name, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
@@ -40,6 +42,8 @@ import net.minecraft.world.WorldServer;
|
||||
|
||||
public class WorldSpecificSaveHandler implements ISaveHandler
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private WorldServer world;
|
||||
private ISaveHandler parent;
|
||||
private File dataDir;
|
||||
@@ -95,7 +99,7 @@ public class WorldSpecificSaveHandler implements ISaveHandler
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("A critical error occurred copying {} to world specific dat folder - new file will be created.", parentFile.getName(), e);
|
||||
LOGGER.error("A critical error occurred copying {} to world specific dat folder - new file will be created.", parentFile.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,11 @@ public class OptionalCapabilityInstance<T>
|
||||
{
|
||||
return instanceSupplier == null ? EMPTY.cast() : new OptionalCapabilityInstance<>(instanceSupplier);
|
||||
}
|
||||
|
||||
public static <T, R> OptionalCapabilityInstance<R> orEmpty(Capability<R> cap, Capability<T> toCheck, OptionalCapabilityInstance<T> inst)
|
||||
{
|
||||
return cap == toCheck ? inst.cast() : EMPTY.cast();
|
||||
}
|
||||
|
||||
private @Nullable T getValue()
|
||||
{
|
||||
|
||||
@@ -27,16 +27,20 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
public class ChunkIOExecutor
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final int BASE_THREADS = 1;
|
||||
private static final int PLAYERS_PER_THREAD = 50;
|
||||
|
||||
@@ -120,7 +124,7 @@ public class ChunkIOExecutor
|
||||
ChunkIOProvider task = tasks.get(key);
|
||||
if (task == null)
|
||||
{
|
||||
FMLLog.log.warn("Attempted to dequeue chunk that wasn't queued? {} @ ({}, {})", world.provider.getDimension(), x, z);
|
||||
LOGGER.warn("Attempted to dequeue chunk that wasn't queued? {} @ ({}, {})", world.provider.getId(), x, z);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,14 +65,14 @@ class ChunkIOProvider implements Runnable
|
||||
try
|
||||
{
|
||||
Object[] data = null;
|
||||
try
|
||||
{
|
||||
/*try
|
||||
{ TODO Chunk loading
|
||||
data = this.loader.loadChunk__Async(chunkInfo.world, chunkInfo.x, chunkInfo.z);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e); // Allow exception to bubble up to afterExecute
|
||||
}
|
||||
}*/
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ class ChunkIOProvider implements Runnable
|
||||
return;
|
||||
}
|
||||
|
||||
// Load Entities
|
||||
/*/ Load Entities TODO Chunk loading
|
||||
this.loader.loadEntities(this.chunkInfo.world, this.nbt.getCompoundTag("Level"), this.chunk);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(this.chunk, this.nbt)); // Don't call ChunkDataEvent.Load async
|
||||
@@ -108,7 +108,7 @@ class ChunkIOProvider implements Runnable
|
||||
provider.id2ChunkMap.put(ChunkPos.asLong(this.chunkInfo.x, this.chunkInfo.z), this.chunk);
|
||||
this.chunk.onLoad();
|
||||
this.chunk.populate(provider, provider.chunkGenerator);
|
||||
|
||||
*/
|
||||
this.runCallbacks();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,13 @@ import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
class ChunkIOThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public ChunkIOThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
|
||||
{
|
||||
@@ -41,14 +44,14 @@ class ChunkIOThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
{
|
||||
try
|
||||
{
|
||||
FMLLog.log.error("Unhandled exception loading chunk:", t);
|
||||
LOGGER.error("Unhandled exception loading chunk:", t);
|
||||
QueuedChunk queuedChunk = ((ChunkIOProvider) r).getChunkInfo();
|
||||
FMLLog.log.error(queuedChunk);
|
||||
FMLLog.log.error(CrashReportCategory.getCoordinateInfo(queuedChunk.x << 4, 64, queuedChunk.z << 4));
|
||||
LOGGER.error(queuedChunk);
|
||||
LOGGER.error(CrashReportCategory.getCoordinateInfo(queuedChunk.x << 4, 64, queuedChunk.z << 4));
|
||||
}
|
||||
catch (Throwable t2)
|
||||
{
|
||||
FMLLog.log.error(t2);
|
||||
LOGGER.error(t2);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ class QueuedChunk {
|
||||
result.append(" x: " + x + NEW_LINE);
|
||||
result.append(" z: " + z + NEW_LINE);
|
||||
result.append(" world: " + world.getWorldInfo().getWorldName() + NEW_LINE);
|
||||
result.append(" dimension: " + world.provider.getDimension() + NEW_LINE);
|
||||
result.append(" dimension: " + world.provider.getId() + NEW_LINE);
|
||||
result.append(" provider: " + world.provider.getClass().getName() + NEW_LINE);
|
||||
result.append("}");
|
||||
|
||||
|
||||
@@ -36,16 +36,19 @@ import com.google.common.collect.Sets;
|
||||
import net.minecraftforge.common.config.Config.Comment;
|
||||
import net.minecraftforge.common.config.Config.LangKey;
|
||||
import net.minecraftforge.common.config.Config.Name;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.FMLPaths;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderException;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModAnnotation.EnumHolder;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ConfigManager
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static Map<String, Multimap<Config.Type, ASMData>> asm_data = Maps.newHashMap();
|
||||
static Map<Class<?>, ITypeAdapter> ADAPTERS = Maps.newHashMap();
|
||||
static Map<Class<?>, Class<?>> ARRAY_REMAP = Maps.newHashMap();
|
||||
@@ -102,7 +105,7 @@ public class ConfigManager
|
||||
|
||||
public static void loadData(ASMDataTable data)
|
||||
{
|
||||
FMLLog.log.debug("Loading @Config anotation data");
|
||||
LOGGER.debug("Loading @Config anotation data");
|
||||
for (ASMData target : data.getAll(Config.class.getName()))
|
||||
{
|
||||
String modid = (String)target.getAnnotationInfo().get("modid");
|
||||
@@ -143,7 +146,7 @@ public class ConfigManager
|
||||
*/
|
||||
public static void sync(String modid, Config.Type type)
|
||||
{
|
||||
FMLLog.log.debug("Attempting to inject @Config classes into {} for type {}", modid, type);
|
||||
LOGGER.debug("Attempting to inject @Config classes into {} for type {}", modid, type);
|
||||
ClassLoader mcl = Loader.instance().getModClassLoader();
|
||||
File configDir = FMLPaths.FMLCONFIG.get().toFile();
|
||||
Multimap<Config.Type, ASMData> map = asm_data.get(modid);
|
||||
@@ -186,7 +189,7 @@ public class ConfigManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("An error occurred trying to load a config for {} into {}", targ.getClassName(), e);
|
||||
LOGGER.error("An error occurred trying to load a config for {} into {}", targ.getClassName(), e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,10 +55,11 @@ import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
import net.minecraftforge.fml.client.config.GuiConfigEntries;
|
||||
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.FMLPaths;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* This class offers advanced configurations capabilities, allowing to provide
|
||||
@@ -66,6 +67,8 @@ import org.apache.commons.io.IOUtils;
|
||||
*/
|
||||
public class Configuration
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static final String CATEGORY_GENERAL = "general";
|
||||
public static final String CATEGORY_CLIENT = "client";
|
||||
public static final String ALLOWED_CHARS = "._-";
|
||||
@@ -132,7 +135,7 @@ public class Configuration
|
||||
{
|
||||
File fileBak = new File(file.getAbsolutePath() + "_" +
|
||||
new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".errored");
|
||||
FMLLog.log.fatal("An exception occurred while loading config file {}. This file will be renamed to {} " +
|
||||
LOGGER.fatal("An exception occurred while loading config file {}. This file will be renamed to {} " +
|
||||
"and a new config file will be generated.", file.getName(), fileBak.getName(), e);
|
||||
|
||||
file.renameTo(fileBak);
|
||||
@@ -1047,7 +1050,7 @@ public class Configuration
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("Error while loading config {}.", fileName, e);
|
||||
LOGGER.error("Error while loading config {}.", fileName, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -1108,7 +1111,7 @@ public class Configuration
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("Error while saving config {}.", fileName, e);
|
||||
LOGGER.error("Error while saving config {}.", fileName, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1719,7 +1722,7 @@ public class Configuration
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("Failed to get float for {}/{}", name, category, e);
|
||||
LOGGER.error("Failed to get float for {}/{}", name, category, e);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,17 @@ public interface IForgeDimension
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the providers current dimension ID, used in default getSaveFolder()
|
||||
* Added to allow default providers to be registered for multiple dimensions.
|
||||
* This is to denote the exact dimension ID opposed to the 'type' in WorldType
|
||||
*
|
||||
* @param id Dimension ID
|
||||
*/
|
||||
void setId(int id);
|
||||
|
||||
int getId();
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Nullable
|
||||
IRenderHandler getSkyRenderer();
|
||||
|
||||
@@ -52,9 +52,10 @@ public class CapabilityAnimation
|
||||
|
||||
public static class DefaultItemAnimationCapabilityProvider implements ICapabilityProvider
|
||||
{
|
||||
private final IAnimationStateMachine asm;
|
||||
@Nonnull
|
||||
private final OptionalCapabilityInstance<IAnimationStateMachine> asm;
|
||||
|
||||
public DefaultItemAnimationCapabilityProvider(IAnimationStateMachine asm)
|
||||
public DefaultItemAnimationCapabilityProvider(@Nonnull OptionalCapabilityInstance<IAnimationStateMachine> asm)
|
||||
{
|
||||
this.asm = asm;
|
||||
}
|
||||
@@ -63,11 +64,7 @@ public class CapabilityAnimation
|
||||
@Nonnull
|
||||
public <T> OptionalCapabilityInstance<T> getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
if(capability == ANIMATION_CAPABILITY)
|
||||
{
|
||||
return OptionalCapabilityInstance.of(() -> asm).cast();
|
||||
}
|
||||
return OptionalCapabilityInstance.empty();
|
||||
return OptionalCapabilityInstance.orEmpty(capability, ANIMATION_CAPABILITY, asm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,13 +21,18 @@ package net.minecraftforge.common.network;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.network.ForgeMessage.DimensionRegisterMessage;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class DimensionMessageHandler extends SimpleChannelInboundHandler<ForgeMessage.DimensionRegisterMessage>{
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, DimensionRegisterMessage msg) throws Exception
|
||||
{
|
||||
@@ -39,7 +44,7 @@ public class DimensionMessageHandler extends SimpleChannelInboundHandler<ForgeMe
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
||||
{
|
||||
FMLLog.log.error("DimensionMessageHandler exception", cause);
|
||||
LOGGER.error("DimensionMessageHandler exception", cause);
|
||||
super.exceptionCaught(ctx, cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,15 @@ package net.minecraftforge.common.network;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
public class FluidIdRegistryMessageHandler extends SimpleChannelInboundHandler<ForgeMessage.FluidIdMapMessage> {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, ForgeMessage.FluidIdMapMessage msg) throws Exception
|
||||
{
|
||||
@@ -36,7 +39,7 @@ public class FluidIdRegistryMessageHandler extends SimpleChannelInboundHandler<F
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
||||
{
|
||||
FMLLog.log.error("FluidIdRegistryMessageHandler exception", cause);
|
||||
LOGGER.error("FluidIdRegistryMessageHandler exception", cause);
|
||||
super.exceptionCaught(ctx, cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
@@ -30,11 +33,12 @@ import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public abstract class ForgeMessage {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static class DimensionRegisterMessage extends ForgeMessage {
|
||||
/** The dimension ID to register on client */
|
||||
int dimensionId;
|
||||
@@ -108,7 +112,7 @@ public abstract class ForgeMessage {
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.info("Legacy server message contains no default fluid list - there may be problems with fluids");
|
||||
LOGGER.info("Legacy server message contains no default fluid list - there may be problems with fluids");
|
||||
defaultFluids.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,25 +21,32 @@ package net.minecraftforge.common.property;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.state.AbstractStateHolder;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
|
||||
public class ExtendedBlockState extends BlockStateContainer
|
||||
public class ExtendedBlockState extends StateContainer<Block, IBlockState>
|
||||
{
|
||||
private final ImmutableSet<IUnlistedProperty<?>> unlistedProperties;
|
||||
|
||||
public ExtendedBlockState(Block blockIn, IProperty<?>[] properties, IUnlistedProperty<?>[] unlistedProperties)
|
||||
public <A extends AbstractStateHolder<Block, IBlockState>> ExtendedBlockState(Block blockIn, StateContainer.IFactory<Block, IBlockState, ?> stateFactory, net.minecraft.state.IProperty<?>[] properties, IUnlistedProperty<?>[] unlistedProperties)
|
||||
{
|
||||
super(blockIn, properties, buildUnlistedMap(unlistedProperties));
|
||||
super(blockIn, stateFactory, buildListedMap(properties));// TODO Unlisted properties?, buildUnlistedMap(unlistedProperties));
|
||||
ImmutableSet.Builder<IUnlistedProperty<?>> builder = ImmutableSet.builder();
|
||||
for(IUnlistedProperty<?> property : unlistedProperties)
|
||||
{
|
||||
@@ -53,6 +60,11 @@ public class ExtendedBlockState extends BlockStateContainer
|
||||
return unlistedProperties;
|
||||
}
|
||||
|
||||
private static Map<String, IProperty<?>> buildListedMap(IProperty<?>[] properties)
|
||||
{
|
||||
return Arrays.stream(properties).collect(Collectors.toMap(IProperty::getName, Function.identity()));
|
||||
}
|
||||
|
||||
private static ImmutableMap<IUnlistedProperty<?>, Optional<?>> buildUnlistedMap(IUnlistedProperty<?>[] unlistedProperties)
|
||||
{
|
||||
ImmutableMap.Builder<IUnlistedProperty<?>, Optional<?>> builder = ImmutableMap.builder();
|
||||
|
||||
@@ -21,6 +21,9 @@ package net.minecraftforge.fluids;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -34,8 +37,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
|
||||
/**
|
||||
@@ -56,6 +57,8 @@ import net.minecraft.item.EnumRarity;
|
||||
*/
|
||||
public class Fluid
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
|
||||
/** The unique identification name for this fluid. */
|
||||
@@ -189,7 +192,7 @@ public class Fluid
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.warn("A mod has attempted to assign Block {} to the Fluid '{}' but this Fluid has already been linked to the Block {}. "
|
||||
LOGGER.warn("A mod has attempted to assign Block {} to the Fluid '{}' but this Fluid has already been linked to the Block {}. "
|
||||
+ "You may have duplicate Fluid Blocks as a result. It *may* be possible to configure your mods to avoid this.", block, fluidName, this.block);
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -22,7 +22,6 @@ package net.minecraftforge.fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -40,8 +40,9 @@ public class ItemFluidContainer extends Item
|
||||
/**
|
||||
* @param capacity The maximum capacity of this fluid container.
|
||||
*/
|
||||
public ItemFluidContainer(int capacity)
|
||||
public ItemFluidContainer(Item.Builder builder, int capacity)
|
||||
{
|
||||
super(builder);
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,10 @@ package net.minecraftforge.fluids.capability;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
@@ -32,6 +34,13 @@ import javax.annotation.Nullable;
|
||||
public class TileFluidHandler extends TileEntity
|
||||
{
|
||||
protected FluidTank tank = new FluidTank(Fluid.BUCKET_VOLUME);
|
||||
|
||||
private final OptionalCapabilityInstance<IFluidHandler> holder = OptionalCapabilityInstance.of(() -> tank);
|
||||
|
||||
public TileFluidHandler(@Nonnull TileEntityType<?> p_i48289_1_)
|
||||
{
|
||||
super(p_i48289_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
@@ -49,18 +58,11 @@ public class TileFluidHandler extends TileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
@Nonnull
|
||||
public <T> OptionalCapabilityInstance<T> getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
return (T) tank;
|
||||
return holder.cast();
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
+6
-10
@@ -27,6 +27,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.FluidTankProperties;
|
||||
@@ -45,6 +46,8 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProvider
|
||||
{
|
||||
public static final String FLUID_NBT_KEY = "Fluid";
|
||||
|
||||
private final OptionalCapabilityInstance<IFluidHandlerItem> holder = OptionalCapabilityInstance.of(() -> this);
|
||||
|
||||
@Nonnull
|
||||
protected ItemStack container;
|
||||
@@ -201,17 +204,10 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
|
||||
@Nonnull
|
||||
public <T> OptionalCapabilityInstance<T> getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY ? (T) this : null;
|
||||
return OptionalCapabilityInstance.orEmpty(capability, CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, holder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-10
@@ -27,6 +27,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.FluidTankProperties;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
@@ -42,6 +43,8 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabilityProvider
|
||||
{
|
||||
public static final String FLUID_NBT_KEY = "Fluid";
|
||||
|
||||
private final OptionalCapabilityInstance<IFluidHandlerItem> holder = OptionalCapabilityInstance.of(() -> this);
|
||||
|
||||
@Nonnull
|
||||
protected ItemStack container;
|
||||
@@ -178,17 +181,10 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
|
||||
@Nonnull
|
||||
public <T> OptionalCapabilityInstance<T> getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY ? (T) this : null;
|
||||
return OptionalCapabilityInstance.orEmpty(capability, CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, holder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/* TODO Fluids
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2018.
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fluids.capability.wrappers;
|
||||
|
||||
/*
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
@@ -40,7 +40,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
/**
|
||||
* Wrapper to handle vanilla Water or Lava as an IFluidHandler.
|
||||
* Methods are modeled after {@link ItemBucket#onItemRightClick(World, EntityPlayer, EnumHand)}
|
||||
*/
|
||||
* /
|
||||
public class BlockLiquidWrapper implements IFluidHandler
|
||||
{
|
||||
protected final BlockLiquid blockLiquid;
|
||||
@@ -155,3 +155,4 @@ public class BlockLiquidWrapper implements IFluidHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
+7
-14
@@ -30,6 +30,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -45,6 +46,8 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
*/
|
||||
public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvider
|
||||
{
|
||||
private final OptionalCapabilityInstance<IFluidHandlerItem> holder = OptionalCapabilityInstance.of(() -> this);
|
||||
|
||||
@Nonnull
|
||||
protected ItemStack container;
|
||||
|
||||
@@ -176,21 +179,11 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
|
||||
@Nonnull
|
||||
public <T> OptionalCapabilityInstance<T> getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY)
|
||||
{
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY.cast(this);
|
||||
}
|
||||
return null;
|
||||
return OptionalCapabilityInstance.orEmpty(capability, CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, holder);
|
||||
}
|
||||
}
|
||||
@@ -20,11 +20,11 @@
|
||||
package net.minecraftforge.fml.client;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public interface IDisplayableError
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
GuiScreen createGui();
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public class SplashProgress
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
FMLLog.log.error("Could not save the splash.properties file", e);
|
||||
LOGGER.error("Could not save the splash.properties file", e);
|
||||
}
|
||||
|
||||
miscPack = createResourcePack(miscPackFile);
|
||||
@@ -240,7 +240,7 @@ public class SplashProgress
|
||||
}
|
||||
catch (LWJGLException e)
|
||||
{
|
||||
FMLLog.log.error("Error starting SplashProgress:", e);
|
||||
LOGGER.error("Error starting SplashProgress:", e);
|
||||
disableSplash(e);
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ public class SplashProgress
|
||||
}
|
||||
catch (LWJGLException e)
|
||||
{
|
||||
FMLLog.log.error("Error setting GL context:", e);
|
||||
LOGGER.error("Error setting GL context:", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
glClearColor((float)((backgroundColor >> 16) & 0xFF) / 0xFF, (float)((backgroundColor >> 8) & 0xFF) / 0xFF, (float)(backgroundColor & 0xFF) / 0xFF, 1);
|
||||
@@ -564,7 +564,7 @@ public class SplashProgress
|
||||
}
|
||||
catch (LWJGLException e)
|
||||
{
|
||||
FMLLog.log.error("Error releasing GL context:", e);
|
||||
LOGGER.error("Error releasing GL context:", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally
|
||||
@@ -578,7 +578,7 @@ public class SplashProgress
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e)
|
||||
{
|
||||
FMLLog.log.error("Splash thread Exception", e);
|
||||
LOGGER.error("Splash thread Exception", e);
|
||||
threadError = e;
|
||||
}
|
||||
});
|
||||
@@ -629,7 +629,7 @@ public class SplashProgress
|
||||
}
|
||||
catch (LWJGLException e)
|
||||
{
|
||||
FMLLog.log.error("Error setting GL context:", e);
|
||||
LOGGER.error("Error setting GL context:", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@@ -650,7 +650,7 @@ public class SplashProgress
|
||||
}
|
||||
catch (LWJGLException e)
|
||||
{
|
||||
FMLLog.log.error("Error releasing GL context:", e);
|
||||
LOGGER.error("Error releasing GL context:", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
lock.unlock();
|
||||
@@ -673,7 +673,7 @@ public class SplashProgress
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("Error finishing SplashProgress:", e);
|
||||
LOGGER.error("Error finishing SplashProgress:", e);
|
||||
disableSplash(e);
|
||||
}
|
||||
}
|
||||
@@ -726,7 +726,7 @@ public class SplashProgress
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
FMLLog.log.error("Could not save the splash.properties file", e);
|
||||
LOGGER.error("Could not save the splash.properties file", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -843,7 +843,7 @@ public class SplashProgress
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
FMLLog.log.error("Error reading texture from file: {}", location, e);
|
||||
LOGGER.error("Error reading texture from file: {}", location, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -38,10 +38,11 @@ import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.eventbus.api.Event.Result;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -54,6 +55,8 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class GuiConfig extends GuiScreen
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* A reference to the screen object that created this. Used for navigating between screens.
|
||||
*/
|
||||
@@ -289,7 +292,7 @@ public class GuiConfig extends GuiScreen
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
FMLLog.log.error("Error performing GuiConfig action:", e);
|
||||
LOGGER.error("Error performing GuiConfig action:", e);
|
||||
}
|
||||
|
||||
if (flag)
|
||||
|
||||
@@ -36,9 +36,11 @@ import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
/**
|
||||
@@ -49,6 +51,8 @@ import org.lwjgl.input.Keyboard;
|
||||
*/
|
||||
public class GuiConfigEntries extends GuiListExtended
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public final GuiConfig owningScreen;
|
||||
public final Minecraft mc;
|
||||
public List<IConfigEntry> listEntries;
|
||||
@@ -129,7 +133,7 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
FMLLog.log.error("There was a critical error instantiating the custom IConfigEntry for config element {}.", configElement.getName(), e);
|
||||
LOGGER.error("There was a critical error instantiating the custom IConfigEntry for config element {}.", configElement.getName(), e);
|
||||
}
|
||||
else if (configElement.isProperty())
|
||||
{
|
||||
|
||||
@@ -33,7 +33,8 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import static net.minecraftforge.fml.client.config.GuiUtils.RESET_CHAR;
|
||||
import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
/**
|
||||
@@ -44,6 +45,8 @@ import org.lwjgl.input.Keyboard;
|
||||
*/
|
||||
public class GuiEditArray extends GuiScreen
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
protected GuiScreen parentScreen;
|
||||
protected IConfigElement configElement;
|
||||
protected GuiEditArrayEntries entryList;
|
||||
@@ -129,7 +132,7 @@ public class GuiEditArray extends GuiScreen
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
FMLLog.log.error("Error performing GuiEditArray action:", e);
|
||||
LOGGER.error("Error performing GuiEditArray action:", e);
|
||||
}
|
||||
this.mc.displayGuiScreen(this.parentScreen);
|
||||
}
|
||||
|
||||
@@ -29,8 +29,9 @@ import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.client.config.GuiConfigEntries.ArrayEntry;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import static net.minecraftforge.fml.client.config.GuiUtils.INVALID;
|
||||
@@ -42,6 +43,8 @@ import static net.minecraftforge.fml.client.config.GuiUtils.VALID;
|
||||
*/
|
||||
public class GuiEditArrayEntries extends GuiListExtended
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
protected GuiEditArray owningGui;
|
||||
public IConfigElement configElement;
|
||||
public List<IArrayEntry> listEntries;
|
||||
@@ -80,7 +83,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
FMLLog.log.error("There was a critical error instantiating the custom IGuiEditListEntry for property {}.", configElement.getName(), e);
|
||||
LOGGER.error("There was a critical error instantiating the custom IGuiEditListEntry for property {}.", configElement.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,7 +158,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
FMLLog.log.error("There was a critical error instantiating the custom IGuiEditListEntry for property {}.", configElement.getName(), e);
|
||||
LOGGER.error("There was a critical error instantiating the custom IGuiEditListEntry for property {}.", configElement.getName(), e);
|
||||
}
|
||||
}
|
||||
else if (configElement.isList() && configElement.getType() == ConfigGuiType.BOOLEAN)
|
||||
@@ -559,7 +562,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
}
|
||||
}
|
||||
|
||||
public static class BaseEntry implements IArrayEntry
|
||||
public static class BaseEntry extends GuiListExtended.IGuiListEntry implements IArrayEntry
|
||||
{
|
||||
protected final GuiEditArray owningScreen;
|
||||
protected final GuiEditArrayEntries owningEntryList;
|
||||
@@ -592,31 +595,31 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partial)
|
||||
public void func_194999_a(int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float partial)
|
||||
{
|
||||
if (this.getValue() != null && this.isValidated)
|
||||
owningEntryList.getMC().fontRenderer.drawString(
|
||||
owningEntryList.getMC().fontRenderer.func_211126_b(
|
||||
isValidValue ? TextFormatting.GREEN + VALID : TextFormatting.RED + INVALID,
|
||||
listWidth / 4 - owningEntryList.getMC().fontRenderer.getStringWidth(VALID) - 2,
|
||||
y + slotHeight / 2 - owningEntryList.getMC().fontRenderer.FONT_HEIGHT / 2,
|
||||
entryWidth / 4 - owningEntryList.getMC().fontRenderer.getStringWidth(VALID) - 2,
|
||||
entryHeight / 2 - owningEntryList.getMC().fontRenderer.FONT_HEIGHT / 2,
|
||||
16777215);
|
||||
|
||||
int half = listWidth / 2;
|
||||
int half = entryWidth / 2;
|
||||
if (owningEntryList.canAddMoreEntries)
|
||||
{
|
||||
this.btnAddNewEntryAbove.visible = true;
|
||||
this.btnAddNewEntryAbove.x = half + ((half / 2) - 44);
|
||||
this.btnAddNewEntryAbove.y = y;
|
||||
this.btnAddNewEntryAbove.y = this.func_195001_c();
|
||||
this.btnAddNewEntryAbove.drawButton(owningEntryList.getMC(), mouseX, mouseY, partial);
|
||||
}
|
||||
else
|
||||
this.btnAddNewEntryAbove.visible = false;
|
||||
|
||||
if (!configElement.isListLengthFixed() && slotIndex != owningEntryList.listEntries.size() - 1)
|
||||
if (!configElement.isListLengthFixed() && this.field_195005_b != owningEntryList.listEntries.size() - 1)
|
||||
{
|
||||
this.btnRemoveEntry.visible = true;
|
||||
this.btnRemoveEntry.x = half + ((half / 2) - 22);
|
||||
this.btnRemoveEntry.y = y;
|
||||
this.btnRemoveEntry.y = this.func_195001_c();
|
||||
this.btnRemoveEntry.drawButton(owningEntryList.getMC(), mouseX, mouseY, partial);
|
||||
}
|
||||
else
|
||||
@@ -689,7 +692,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
public void updatePosition(int p_178011_1_, int p_178011_2_, int p_178011_3_, float partial){}
|
||||
}
|
||||
|
||||
public static interface IArrayEntry extends GuiListExtended.IGuiListEntry
|
||||
public static interface IArrayEntry
|
||||
{
|
||||
void keyTyped(char eventChar, int eventKey);
|
||||
|
||||
|
||||
@@ -25,12 +25,14 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import static net.minecraftforge.fml.client.config.GuiUtils.RESET_CHAR;
|
||||
import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR;
|
||||
@@ -42,6 +44,8 @@ import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR;
|
||||
*/
|
||||
public class GuiSelectString extends GuiScreen
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
protected GuiScreen parentScreen;
|
||||
protected IConfigElement configElement;
|
||||
protected GuiSelectStringEntries entryList;
|
||||
@@ -129,7 +133,7 @@ public class GuiSelectString extends GuiScreen
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
FMLLog.log.error("Error performing GuiSelectString action:", e);
|
||||
LOGGER.error("Error performing GuiSelectString action:", e);
|
||||
}
|
||||
this.mc.displayGuiScreen(this.parentScreen);
|
||||
}
|
||||
|
||||
+2
@@ -21,7 +21,9 @@ package net.minecraftforge.fml.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.IDisplayableError;
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException;
|
||||
import net.minecraftforge.fml.common.IFMLHandledException;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@@ -22,17 +22,21 @@ package net.minecraftforge.fml.client.gui;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.StartupQuery;
|
||||
import net.minecraftforge.fml.common.ZipperUtil;
|
||||
|
||||
public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private String dirName;
|
||||
private String saveName;
|
||||
private File zip;
|
||||
@@ -75,7 +79,7 @@ public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.info("Capturing current state of world {} into file {}", saveName, zip.getAbsolutePath());
|
||||
LOGGER.info("Capturing current state of world {} into file {}", saveName, zip.getAbsolutePath());
|
||||
try
|
||||
{
|
||||
String skip = System.getProperty("fml.doNotBackup");
|
||||
@@ -86,11 +90,11 @@ public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < 10; x++)
|
||||
FMLLog.log.fatal("!!!!!!!!!! UPDATING WORLD WITHOUT DOING BACKUP !!!!!!!!!!!!!!!!");
|
||||
LOGGER.fatal("!!!!!!!!!! UPDATING WORLD WITHOUT DOING BACKUP !!!!!!!!!!!!!!!!");
|
||||
}
|
||||
} catch (IOException e)
|
||||
{
|
||||
FMLLog.log.warn("There was a problem saving the backup {}. Please fix and try again", zip.getName(), e);
|
||||
LOGGER.warn("There was a problem saving the backup {}. Please fix and try again", zip.getName(), e);
|
||||
FMLClientHandler.instance().showGuiScreen(new GuiBackupFailed(parent, zip));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ public class GuiSortingProblem extends GuiScreen {
|
||||
this.drawCenteredString(this.fontRenderer, "The remainder of the cycle involves these mods", this.width / 2, offset, 0xFFFFFF);
|
||||
offset+=5;
|
||||
for (ModContainer mc : failedList.getVisitedNodes())
|
||||
{
|
||||
{/* TODO Mod dependencies
|
||||
offset+=10;
|
||||
this.drawCenteredString(this.fontRenderer, String.format("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()), this.width / 2, offset, 0xEEEEEE);
|
||||
}
|
||||
*/}
|
||||
offset+=20;
|
||||
this.drawCenteredString(this.fontRenderer, "The file 'ForgeModLoader-client-0.log' contains more information", this.width / 2, offset, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ public class ClientRegistry
|
||||
* @param tileEntityClass
|
||||
* @param id
|
||||
* @param specialRenderer
|
||||
*/
|
||||
* / TODO GameRegistry
|
||||
public static <T extends TileEntity> void registerTileEntity(Class<T> tileEntityClass, String id, TileEntityRenderer<? super T> specialRenderer)
|
||||
{
|
||||
GameRegistry.registerTileEntity(tileEntityClass, id);
|
||||
bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer);
|
||||
}
|
||||
|
||||
*/
|
||||
public static <T extends TileEntity> void bindTileEntitySpecialRenderer(Class<T> tileEntityClass, TileEntityRenderer<? super T> specialRenderer)
|
||||
{
|
||||
TileEntityRendererDispatcher.instance.renderers.put(tileEntityClass, specialRenderer);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.common;
|
||||
|
||||
/* TODO ReflectionHelper
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraftforge.fml.common.asm.deobf.FMLDeobfuscatingRemapper;
|
||||
@@ -31,7 +31,7 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToFindFieldExcep
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
* /
|
||||
public class ObfuscationReflectionHelper
|
||||
{
|
||||
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
|
||||
@@ -42,7 +42,7 @@ public class ObfuscationReflectionHelper
|
||||
}
|
||||
catch (UnableToAccessFieldException e)
|
||||
{
|
||||
FMLLog.log.error("There was a problem getting field index {} from {}", classToAccess.getName(), e);
|
||||
LOGGER.error("There was a problem getting field index {} from {}", classToAccess.getName(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -67,12 +67,12 @@ public class ObfuscationReflectionHelper
|
||||
}
|
||||
catch (UnableToFindFieldException e)
|
||||
{
|
||||
FMLLog.log.error("Unable to locate any field {} on type {}", Arrays.toString(fieldNames), classToAccess.getName(), e);
|
||||
LOGGER.error("Unable to locate any field {} on type {}", Arrays.toString(fieldNames), classToAccess.getName(), e);
|
||||
throw e;
|
||||
}
|
||||
catch (UnableToAccessFieldException e)
|
||||
{
|
||||
FMLLog.log.error("Unable to access any field {} on type {}", classToAccess.getName(), e);
|
||||
LOGGER.error("Unable to access any field {} on type {}", classToAccess.getName(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class ObfuscationReflectionHelper
|
||||
}
|
||||
catch (UnableToAccessFieldException e)
|
||||
{
|
||||
FMLLog.log.error("There was a problem setting field index {} on type {}", classToAccess.getName(), e);
|
||||
LOGGER.error("There was a problem setting field index {} on type {}", classToAccess.getName(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -98,13 +98,14 @@ public class ObfuscationReflectionHelper
|
||||
}
|
||||
catch (UnableToFindFieldException e)
|
||||
{
|
||||
FMLLog.log.error("Unable to locate any field {} on type {}", classToAccess.getName(), e);
|
||||
LOGGER.error("Unable to locate any field {} on type {}", classToAccess.getName(), e);
|
||||
throw e;
|
||||
}
|
||||
catch (UnableToAccessFieldException e)
|
||||
{
|
||||
FMLLog.log.error("Unable to set any field {} on type {}", classToAccess.getName(), e);
|
||||
LOGGER.error("Unable to set any field {} on type {}", classToAccess.getName(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
+2
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.common.asm.transformers;
|
||||
|
||||
/* TODO Class transformers
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -167,3 +167,4 @@ public class SoundEngineFixTransformer implements IClassTransformer
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -31,6 +31,7 @@ import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityVillager.ITradeList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
@@ -43,18 +44,17 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class VillagerRegistry
|
||||
{
|
||||
/*
|
||||
|
||||
public static final RegistryObject<VillagerProfession> FARMER = RegistryObject.of("minecraft:farmer", ()->VillagerProfession.class);
|
||||
private static final VillagerRegistry INSTANCE = new VillagerRegistry();
|
||||
|
||||
/* TODO village creation
|
||||
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
|
||||
|
||||
*/
|
||||
private VillagerRegistry()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Allow access to the {@link net.minecraft.world.gen.structure.StructureVillagePieces} array controlling new village
|
||||
* creation so you can insert your own new village pieces
|
||||
@@ -100,13 +100,12 @@ public class VillagerRegistry
|
||||
Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1,
|
||||
int p2, int p3, EnumFacing facing, int p5);
|
||||
}
|
||||
|
||||
*/
|
||||
public static VillagerRegistry instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Register a new village creation handler
|
||||
*
|
||||
@@ -132,7 +131,7 @@ public class VillagerRegistry
|
||||
{
|
||||
return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5);
|
||||
}
|
||||
|
||||
*/
|
||||
RegistryNamespaced<ResourceLocation, VillagerProfession> REGISTRY = GameData.getWrapper(VillagerProfession.class);
|
||||
|
||||
private void register(VillagerProfession prof, int id)
|
||||
@@ -178,9 +177,9 @@ public class VillagerRegistry
|
||||
"minecraft:textures/entity/zombie_villager/zombie_smith.png");
|
||||
{
|
||||
register(prof, 3);
|
||||
(new VillagerCareer(prof, "armor")).init(VanillaTrades.trades[3][0]);
|
||||
(new VillagerCareer(prof, "weapon")).init(VanillaTrades.trades[3][1]);
|
||||
(new VillagerCareer(prof, "tool")).init(VanillaTrades.trades[3][2]);
|
||||
(new VillagerCareer(prof, "armorer")).init(VanillaTrades.trades[3][0]);
|
||||
(new VillagerCareer(prof, "weapon_smith")).init(VanillaTrades.trades[3][1]);
|
||||
(new VillagerCareer(prof, "tool_smith")).init(VanillaTrades.trades[3][2]);
|
||||
}
|
||||
prof = new VillagerProfession("minecraft:butcher",
|
||||
"minecraft:textures/entity/villager/butcher.png",
|
||||
@@ -188,7 +187,7 @@ public class VillagerRegistry
|
||||
{
|
||||
register(prof, 4);
|
||||
(new VillagerCareer(prof, "butcher")).init(VanillaTrades.trades[4][0]);
|
||||
(new VillagerCareer(prof, "leather")).init(VanillaTrades.trades[4][1]);
|
||||
(new VillagerCareer(prof, "leatherworker")).init(VanillaTrades.trades[4][1]);
|
||||
}
|
||||
prof = new VillagerProfession("minecraft:nitwit",
|
||||
"minecraft:textures/entity/villager/villager.png",
|
||||
@@ -312,13 +311,12 @@ public class VillagerRegistry
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* Hook called when spawning a Villager, sets it's profession to a random registered profession.
|
||||
*
|
||||
* @param entity The new entity
|
||||
* @param rand The world's RNG
|
||||
*//*
|
||||
*/
|
||||
|
||||
public static void setRandomProfession(EntityVillager entity, Random rand)
|
||||
{
|
||||
@@ -369,5 +367,5 @@ public class VillagerRegistry
|
||||
//It is nasty I know but it's vanilla.
|
||||
private static final ITradeList[][][][] trades = EntityVillager.GET_TRADES_DONT_USE();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -22,12 +22,12 @@ package net.minecraftforge.fml.common.toposort;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.client.GuiSortingProblem;
|
||||
import net.minecraftforge.fml.client.IDisplayableError;
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.client.IDisplayableError;
|
||||
import net.minecraftforge.fml.client.gui.GuiSortingProblem;
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException;
|
||||
|
||||
public class ModSortingException extends EnhancedRuntimeException implements IDisplayableError
|
||||
{
|
||||
@@ -76,14 +76,14 @@ public class ModSortingException extends EnhancedRuntimeException implements IDi
|
||||
stream.println("The first mod in the cycle is " + exceptionData.getFirstBadNode());
|
||||
stream.println("The mod cycle involves:");
|
||||
for (ModContainer mc : exceptionData.getVisitedNodes())
|
||||
{
|
||||
{/* TODO Mod dependencies
|
||||
stream.println(String.format("\t%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()));
|
||||
}
|
||||
*/}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public GuiScreen createGui()
|
||||
{
|
||||
return new GuiSortingProblem(this);
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.net.URISyntaxException;
|
||||
import java.security.CodeSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@@ -46,17 +47,22 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Files;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import cpw.mods.modlauncher.Launcher;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
|
||||
import net.minecraftforge.fml.loading.FMLCommonLaunchHandler;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
|
||||
public class LibraryManager
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static final boolean DISABLE_EXTERNAL_MANIFEST = Boolean.parseBoolean(System.getProperty("forge.disable_external_manifest", "false"));
|
||||
public static final boolean ENABLE_AUTO_MOD_MOVEMENT = Boolean.parseBoolean(System.getProperty("forge.enable_auto_mod_movement", "false"));
|
||||
private static final String LIBRARY_DIRECTORY_OVERRIDE = System.getProperty("forge.lib_folder", null);
|
||||
@@ -75,10 +81,10 @@ public class LibraryManager
|
||||
public static void setup(File minecraftHome)
|
||||
{
|
||||
File libDir = findLibraryFolder(minecraftHome);
|
||||
FMLLog.log.debug("Determined Minecraft Libraries Root: {}", libDir);
|
||||
LOGGER.debug("Determined Minecraft Libraries Root: {}", libDir);
|
||||
Repository old = Repository.replace(libDir, "libraries");
|
||||
if (old != null)
|
||||
FMLLog.log.debug(" Overwriting Previous: {}", old);
|
||||
LOGGER.debug(" Overwriting Previous: {}", old);
|
||||
libraries_dir = Repository.get("libraries");
|
||||
|
||||
File mods = new File(minecraftHome, "mods");
|
||||
@@ -119,14 +125,14 @@ public class LibraryManager
|
||||
{
|
||||
if (LIBRARY_DIRECTORY_OVERRIDE != null)
|
||||
{
|
||||
FMLLog.log.error("System variable set to override Library Directory: {}", LIBRARY_DIRECTORY_OVERRIDE);
|
||||
LOGGER.error("System variable set to override Library Directory: {}", LIBRARY_DIRECTORY_OVERRIDE);
|
||||
return new File(LIBRARY_DIRECTORY_OVERRIDE);
|
||||
}
|
||||
|
||||
CodeSource source = ArtifactVersion.class.getProtectionDomain().getCodeSource();
|
||||
if (source == null)
|
||||
{
|
||||
FMLLog.log.error("Unable to determine codesource for {}. Using default libraries directory.", ArtifactVersion.class.getName());
|
||||
LOGGER.error("Unable to determine codesource for {}. Using default libraries directory.", ArtifactVersion.class.getName());
|
||||
return new File(minecraftHome, "libraries");
|
||||
}
|
||||
|
||||
@@ -142,9 +148,9 @@ public class LibraryManager
|
||||
|
||||
if (!comp.endsWith("/org/apache/maven/maven-artifact/"))
|
||||
{
|
||||
FMLLog.log.error("Apache Maven library folder was not in the format expected. Using default libraries directory.");
|
||||
FMLLog.log.error("Full: {}", new File(source.getLocation().toURI()));
|
||||
FMLLog.log.error("Trimmed: {}", comp);
|
||||
LOGGER.error("Apache Maven library folder was not in the format expected. Using default libraries directory.");
|
||||
LOGGER.error("Full: {}", new File(source.getLocation().toURI()));
|
||||
LOGGER.error("Trimmed: {}", comp);
|
||||
return new File(minecraftHome, "libraries");
|
||||
}
|
||||
// maven-artifact /maven /apache /org /libraries
|
||||
@@ -152,7 +158,7 @@ public class LibraryManager
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("Unable to determine file for {}. Using default libraries directory.", ArtifactVersion.class.getName()), e);
|
||||
LOGGER.error(LOGGER.getMessageFactory().newMessage("Unable to determine file for {}. Using default libraries directory.", ArtifactVersion.class.getName()), e);
|
||||
}
|
||||
|
||||
return new File(minecraftHome, "libraries"); //Everything else failed, return the default.
|
||||
@@ -163,7 +169,7 @@ public class LibraryManager
|
||||
if (!dir.exists())
|
||||
return;
|
||||
|
||||
FMLLog.log.debug("Cleaning up mods folder: {}", dir);
|
||||
LOGGER.debug("Cleaning up mods folder: {}", dir);
|
||||
for (File file : dir.listFiles(f -> f.isFile() && f.getName().endsWith(".jar")))
|
||||
{
|
||||
Pair<Artifact, byte[]> ret = extractPacked(file, modlist, modDirs);
|
||||
@@ -183,7 +189,7 @@ public class LibraryManager
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("Error updating modlist file {}", modlist.getName()), e);
|
||||
LOGGER.error(LOGGER.getMessageFactory().newMessage("Error updating modlist file {}", modlist.getName()), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,20 +197,20 @@ public class LibraryManager
|
||||
{
|
||||
if (processed.contains(file))
|
||||
{
|
||||
FMLLog.log.debug("File already proccessed {}, Skipping", file.getAbsolutePath());
|
||||
LOGGER.debug("File already proccessed {}, Skipping", file.getAbsolutePath());
|
||||
return null;
|
||||
}
|
||||
JarFile jar = null;
|
||||
try
|
||||
{
|
||||
jar = new JarFile(file);
|
||||
FMLLog.log.debug("Examining file: {}", file.getName());
|
||||
LOGGER.debug("Examining file: {}", file.getName());
|
||||
processed.add(file);
|
||||
return extractPacked(jar, modlist, modDirs);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
FMLLog.log.error("Unable to read the jar file {} - ignoring", file.getName(), ioe);
|
||||
LOGGER.error("Unable to read the jar file {} - ignoring", file.getName(), ioe);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -228,7 +234,7 @@ public class LibraryManager
|
||||
attrs = jar.getManifest().getMainAttributes();
|
||||
|
||||
String modSide = attrs.getValue(LibraryManager.MODSIDE);
|
||||
if (modSide != null && !"BOTH".equals(modSide) && !FMLLaunchHandler.side().name().equals(modSide))
|
||||
if (modSide != null && !"BOTH".equals(modSide) && !FMLEnvironment.dist.name().equals(modSide))
|
||||
return null;
|
||||
|
||||
if (attrs.containsKey(MODCONTAINSDEPS))
|
||||
@@ -237,7 +243,7 @@ public class LibraryManager
|
||||
{
|
||||
if (!dep.endsWith(".jar"))
|
||||
{
|
||||
FMLLog.log.error("Contained Dep is not a jar file: {}", dep);
|
||||
LOGGER.error("Contained Dep is not a jar file: {}", dep);
|
||||
throw new IllegalStateException("Invalid contained dep, Must be jar: " + dep);
|
||||
}
|
||||
|
||||
@@ -247,14 +253,14 @@ public class LibraryManager
|
||||
JarEntry depEntry = jar.getJarEntry(dep);
|
||||
if (depEntry == null)
|
||||
{
|
||||
FMLLog.log.error("Contained Dep is not in the jar: {}", dep);
|
||||
LOGGER.error("Contained Dep is not in the jar: {}", dep);
|
||||
throw new IllegalStateException("Invalid contained dep, Missing from jar: " + dep);
|
||||
}
|
||||
|
||||
String depEndName = new File(dep).getName(); // extract last part of name
|
||||
if (skipContainedDeps.contains(dep) || skipContainedDeps.contains(depEndName))
|
||||
{
|
||||
FMLLog.log.error("Skipping dep at request: {}", dep);
|
||||
LOGGER.error("Skipping dep at request: {}", dep);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -294,14 +300,14 @@ public class LibraryManager
|
||||
File target = new File(dir, depEndName);
|
||||
if (target.exists())
|
||||
{
|
||||
FMLLog.log.debug("Found existing ContainDep extracted to {}, skipping extraction", target.getCanonicalPath());
|
||||
LOGGER.debug("Found existing ContainDep extracted to {}, skipping extraction", target.getCanonicalPath());
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
File target = new File(modDirs[0], depEndName);
|
||||
FMLLog.log.debug("Extracting ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath());
|
||||
LOGGER.debug("Extracting ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath());
|
||||
try
|
||||
{
|
||||
Files.createParentDirs(target);
|
||||
@@ -313,12 +319,12 @@ public class LibraryManager
|
||||
{
|
||||
ByteStreams.copy(in, out);
|
||||
}
|
||||
FMLLog.log.debug("Extracted ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath());
|
||||
LOGGER.debug("Extracted ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath());
|
||||
extractPacked(target, modlist, modDirs);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("An error occurred extracting dependency", e);
|
||||
LOGGER.error("An error occurred extracting dependency", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,7 +336,7 @@ public class LibraryManager
|
||||
File target = artifact.getFile();
|
||||
if (target.exists())
|
||||
{
|
||||
FMLLog.log.debug("Found existing ContainedDep {}({}) from {} extracted to {}, skipping extraction", dep, artifact.toString(), target.getCanonicalPath(), jar.getName());
|
||||
LOGGER.debug("Found existing ContainedDep {}({}) from {} extracted to {}, skipping extraction", dep, artifact.toString(), target.getCanonicalPath(), jar.getName());
|
||||
if (!ENABLE_AUTO_MOD_MOVEMENT)
|
||||
{
|
||||
Pair<?, ?> child = extractPacked(target, modlist, modDirs); //If we're not building a real list we have to re-build the dep list every run. So search down.
|
||||
@@ -342,7 +348,7 @@ public class LibraryManager
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.debug("Extracting ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
|
||||
LOGGER.debug("Extracting ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
|
||||
Files.createParentDirs(target);
|
||||
try
|
||||
(
|
||||
@@ -352,7 +358,7 @@ public class LibraryManager
|
||||
{
|
||||
ByteStreams.copy(in, out);
|
||||
}
|
||||
FMLLog.log.debug("Extracted ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
|
||||
LOGGER.debug("Extracted ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
|
||||
|
||||
if (artifact.isSnapshot())
|
||||
{
|
||||
@@ -375,11 +381,11 @@ public class LibraryManager
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("An error occurred extracting dependency. Invalid Timestamp: {}", meta.getValue(TIMESTAMP)), nfe);
|
||||
LOGGER.error(LOGGER.getMessageFactory().newMessage("An error occurred extracting dependency. Invalid Timestamp: {}", meta.getValue(TIMESTAMP)), nfe);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("An error occurred extracting dependency", e);
|
||||
LOGGER.error("An error occurred extracting dependency", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -443,26 +449,26 @@ public class LibraryManager
|
||||
List<File> list = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String,String> args = (Map<String, String>)Launch.blackboard.get("launchArgs");
|
||||
Map<String,String> args = Collections.emptyMap(); // TODO Launch args - do we need this? (Map<String, String>)Launcher.INSTANCE.blackboard().get("launchArgs");
|
||||
String extraMods = args.get("--mods");
|
||||
if (extraMods != null)
|
||||
{
|
||||
FMLLog.log.info("Found mods from the command line:");
|
||||
LOGGER.info("Found mods from the command line:");
|
||||
for (String mod : extraMods.split(","))
|
||||
{
|
||||
File file = new File(mcDir, mod);
|
||||
if (!file.exists())
|
||||
{
|
||||
FMLLog.log.info(" Failed to find mod file {} ({})", mod, file.getAbsolutePath());
|
||||
LOGGER.info(" Failed to find mod file {} ({})", mod, file.getAbsolutePath());
|
||||
}
|
||||
else if (!list.contains(file))
|
||||
{
|
||||
FMLLog.log.debug(" Adding {} ({}) to the mod list", mod, file.getAbsolutePath());
|
||||
LOGGER.debug(" Adding {} ({}) to the mod list", mod, file.getAbsolutePath());
|
||||
list.add(file);
|
||||
}
|
||||
else if (!list.contains(file))
|
||||
{
|
||||
FMLLog.log.debug(" Duplicte command line mod detected {} ({})", mod, file.getAbsolutePath());
|
||||
LOGGER.debug(" Duplicte command line mod detected {} ({})", mod, file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -473,12 +479,12 @@ public class LibraryManager
|
||||
if (!base.isDirectory() || !base.exists())
|
||||
continue;
|
||||
|
||||
FMLLog.log.info("Searching {} for mods", base.getAbsolutePath());
|
||||
LOGGER.info("Searching {} for mods", base.getAbsolutePath());
|
||||
for (File f : base.listFiles(MOD_FILENAME_FILTER))
|
||||
{
|
||||
if (!list.contains(f))
|
||||
{
|
||||
FMLLog.log.debug(" Adding {} to the mod list", f.getName());
|
||||
LOGGER.debug(" Adding {} to the mod list", f.getName());
|
||||
list.add(f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LinkRepository extends Repository
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private Map<String, File> artifact_to_file = new HashMap<>();
|
||||
private Map<String, File> filesystem = new HashMap<>();
|
||||
private Map<String, Artifact> snapshots = new HashMap<>();
|
||||
@@ -46,14 +49,14 @@ public class LinkRepository extends Repository
|
||||
known.add(file);
|
||||
if (artifact_to_file.containsKey(key))
|
||||
{
|
||||
FMLLog.log.debug("Maven file already exists for {}({}) at {}, ignoring duplicate.", file.getName(), artifact.toString(), artifact_to_file.get(key).getAbsolutePath());
|
||||
LOGGER.debug("Maven file already exists for {}({}) at {}, ignoring duplicate.", file.getName(), artifact.toString(), artifact_to_file.get(key).getAbsolutePath());
|
||||
|
||||
if (artifact.isSnapshot())
|
||||
{
|
||||
Artifact old = snapshots.get(key);
|
||||
if (old == null || old.compareVersion(artifact) < 0)
|
||||
{
|
||||
FMLLog.log.debug("Overriding Snapshot {} -> {}", old == null ? "null" : old.getTimestamp(), artifact.getTimestamp());
|
||||
LOGGER.debug("Overriding Snapshot {} -> {}", old == null ? "null" : old.getTimestamp(), artifact.getTimestamp());
|
||||
snapshots.put(key, artifact);
|
||||
artifact_to_file.put(key, file);
|
||||
filesystem.put(artifact.getPath(), file);
|
||||
@@ -62,7 +65,7 @@ public class LinkRepository extends Repository
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.debug("Making maven link for {} in memory to {}.", key, file.getAbsolutePath());
|
||||
LOGGER.debug("Making maven link for {} in memory to {}.", key, file.getAbsolutePath());
|
||||
artifact_to_file.put(key, file);
|
||||
filesystem.put(artifact.getPath(), file);
|
||||
|
||||
|
||||
@@ -30,18 +30,21 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
public class ModList
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setLenient().create();
|
||||
static final Map<String, ModList> cache = new HashMap<>();
|
||||
|
||||
@@ -54,7 +57,7 @@ public class ModList
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("Unable to load ModList json at {}.", json.getAbsoluteFile()), e);
|
||||
LOGGER.error(LOGGER.getMessageFactory().newMessage("Unable to load ModList json at {}.", json.getAbsoluteFile()), e);
|
||||
}
|
||||
|
||||
return new ModList(json, mcdir);
|
||||
@@ -63,7 +66,7 @@ public class ModList
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<ModList> getKnownLists(File mcdir)
|
||||
{
|
||||
for (String list : new String[] {"mods/mod_list.json", "mods/" + ForgeVersion.mcVersion + "/mod_list.json", ((Map<String, String>)Launch.blackboard.get("launchArgs")).get("--modListFile")})
|
||||
for (String list : new String[] {"mods/mod_list.json", "mods/" + ForgeVersion.mcVersion + "/mod_list.json"/* , TODO Launch args ((Map<String, String>)Launch.blackboard.get("launchArgs")).get("--modListFile")*/})
|
||||
{
|
||||
if (list != null)
|
||||
{
|
||||
@@ -84,7 +87,7 @@ public class ModList
|
||||
if (memory != null)
|
||||
lst.add(memory);
|
||||
|
||||
for (String list : new String[] {"mods/mod_list.json", "mods/" + ForgeVersion.mcVersion + "/mod_list.json", ((Map<String, String>)Launch.blackboard.get("launchArgs")).get("--modListFile")})
|
||||
for (String list : new String[] {"mods/mod_list.json", "mods/" + ForgeVersion.mcVersion + "/mod_list.json"/* TODO Launch args, ((Map<String, String>)Launch.blackboard.get("launchArgs")).get("--modListFile")*/})
|
||||
{
|
||||
if (list != null)
|
||||
{
|
||||
@@ -127,11 +130,11 @@ public class ModList
|
||||
}
|
||||
catch (JsonSyntaxException jse)
|
||||
{
|
||||
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Failed to parse modList json file {}.", path), jse);
|
||||
LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to parse modList json file {}.", path), jse);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Failed to read modList json file {}.", path), ioe);
|
||||
LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to read modList json file {}.", path), ioe);
|
||||
}
|
||||
}
|
||||
this.mod_list = temp_list == null ? new JsonModList() : temp_list;
|
||||
@@ -148,7 +151,7 @@ public class ModList
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Failed to create repository for modlist at {}.", mod_list.repositoryRoot), e);
|
||||
LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to create repository for modlist at {}.", mod_list.repositoryRoot), e);
|
||||
}
|
||||
}
|
||||
this.repo = temp;
|
||||
@@ -209,7 +212,7 @@ public class ModList
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Unable to canonicalize path {} relative to {}", path, root.getAbsolutePath()));
|
||||
LOGGER.info(LOGGER.getMessageFactory().newMessage("Unable to canonicalize path {} relative to {}", path, root.getAbsolutePath()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,13 +25,16 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
public class Repository
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
static final Map<String, Repository> cache = new LinkedHashMap<>();
|
||||
|
||||
public static Repository create(File root) throws IOException
|
||||
@@ -129,12 +132,12 @@ public class Repository
|
||||
{
|
||||
if (target.exists())
|
||||
{
|
||||
FMLLog.log.debug("Maven file already exists for {}({}) at {}, deleting duplicate.", file.getName(), artifact.toString(), target.getAbsolutePath());
|
||||
LOGGER.debug("Maven file already exists for {}({}) at {}, deleting duplicate.", file.getName(), artifact.toString(), target.getAbsolutePath());
|
||||
file.delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.debug("Moving file {}({}) to maven repo at {}.", file.getName(), artifact.toString(), target.getAbsolutePath());
|
||||
LOGGER.debug("Moving file {}({}) to maven repo at {}.", file.getName(), artifact.toString(), target.getAbsolutePath());
|
||||
Files.move(file, target);
|
||||
|
||||
if (artifact.isSnapshot())
|
||||
@@ -154,7 +157,7 @@ public class Repository
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("Error moving file {} to {}", file, target.getAbsolutePath()), e);
|
||||
LOGGER.error(LOGGER.getMessageFactory().newMessage("Error moving file {} to {}", file, target.getAbsolutePath()), e);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -133,19 +133,19 @@ public class ServerLifecycleHooks
|
||||
{
|
||||
try
|
||||
{
|
||||
FMLLog.log.info("Waiting for the server to terminate/save.");
|
||||
LOGGER.info("Waiting for the server to terminate/save.");
|
||||
if (!latch.await(10, TimeUnit.SECONDS))
|
||||
{
|
||||
FMLLog.log.warn("The server didn't stop within 10 seconds, exiting anyway.");
|
||||
LOGGER.warn("The server didn't stop within 10 seconds, exiting anyway.");
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.info("Server terminated.");
|
||||
LOGGER.info("Server terminated.");
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
FMLLog.log.warn("Interrupted wait, exiting.");
|
||||
LOGGER.warn("Interrupted wait, exiting.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,10 +74,11 @@ public class ItemHandlerHelper
|
||||
|
||||
// Metadata value only matters when the item has subtypes
|
||||
// Vanilla stacks non-subtype items with different metadata together
|
||||
// e.g. a stick with metadata 0 and a stick with metadata 1 stack
|
||||
// TODO Item subtypes, is this still necessary?
|
||||
/* e.g. a stick with metadata 0 and a stick with metadata 1 stack
|
||||
if (a.getHasSubtypes() && a.getMetadata() != b.getMetadata())
|
||||
return false;
|
||||
|
||||
*/
|
||||
if (a.hasTagCompound() != b.hasTagCompound())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -24,12 +24,13 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryBasic;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SlotItemHandler extends Slot
|
||||
{
|
||||
private static IInventory emptyInventory = new InventoryBasic("[Null]", true, 0);
|
||||
private static IInventory emptyInventory = new InventoryBasic(new TextComponentString("[Null]"), 0);
|
||||
private final IItemHandler itemHandler;
|
||||
private final int index;
|
||||
|
||||
@@ -140,10 +141,10 @@ public class SlotItemHandler extends Slot
|
||||
{
|
||||
return itemHandler;
|
||||
}
|
||||
|
||||
/* TODO Slot patches
|
||||
@Override
|
||||
public boolean isSameInventory(Slot other)
|
||||
{
|
||||
return other instanceof SlotItemHandler && ((SlotItemHandler) other).getItemHandler() == this.itemHandler;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.minecraftforge.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
@@ -58,7 +59,7 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||
if (world == null || pos == null || !world.isBlockLoaded(pos))
|
||||
return null; // Still loading
|
||||
|
||||
Block blockType = chest.getBlockType();
|
||||
IBlockState state = chest.func_195044_w();
|
||||
|
||||
EnumFacing[] horizontals = EnumFacing.HORIZONTALS;
|
||||
for (int i = horizontals.length - 1; i >= 0; i--) // Use reverse order so we can return early
|
||||
@@ -67,7 +68,7 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||
BlockPos blockpos = pos.offset(enumfacing);
|
||||
Block block = world.getBlockState(blockpos).getBlock();
|
||||
|
||||
if (block == blockType)
|
||||
if (block == state.getBlock())
|
||||
{
|
||||
TileEntity otherTE = world.getTileEntity(blockpos);
|
||||
|
||||
@@ -125,7 +126,7 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||
TileEntityChest chest = getChest(accessingUpperChest);
|
||||
if (chest != null)
|
||||
{
|
||||
IItemHandler singleHandler = chest.getSingleChestHandler();
|
||||
IItemHandler singleHandler = null; // TODO TileEntityChest patches chest.getSingleChestHandler();
|
||||
if (singleHandler instanceof IItemHandlerModifiable)
|
||||
{
|
||||
((IItemHandlerModifiable) singleHandler).setStackInSlot(targetSlot, stack);
|
||||
@@ -148,7 +149,7 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||
return stack;
|
||||
|
||||
int starting = stack.getCount();
|
||||
ItemStack ret = chest.getSingleChestHandler().insertItem(targetSlot, stack, simulate);
|
||||
ItemStack ret = ItemStack.EMPTY; // TODO TileEntityChest patches chest.getSingleChestHandler().insertItem(targetSlot, stack, simulate);
|
||||
if (ret.getCount() != starting && !simulate)
|
||||
{
|
||||
chest = getChest(!accessingUpperChest);
|
||||
@@ -169,7 +170,7 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||
if (chest == null)
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
ItemStack ret = chest.getSingleChestHandler().extractItem(targetSlot, amount, simulate);
|
||||
ItemStack ret = ItemStack.EMPTY; // TODO TileEntityChest patches chest.getSingleChestHandler().extractItem(targetSlot, amount, simulate);
|
||||
if (!ret.isEmpty() && !simulate)
|
||||
{
|
||||
chest = getChest(!accessingUpperChest);
|
||||
@@ -195,7 +196,7 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||
TileEntityChest chest = getChest(accessingUpperChest);
|
||||
if (chest != null)
|
||||
{
|
||||
return chest.getSingleChestHandler().isItemValid(targetSlot, stack);
|
||||
return false; // TODO TileEntityChest patches chest.getSingleChestHandler().isItemValid(targetSlot, stack);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -46,38 +48,38 @@ public class VanillaInventoryCodeHooks
|
||||
@Nullable
|
||||
public static Boolean extractHook(IHopper dest)
|
||||
{
|
||||
Pair<IItemHandler, Object> itemHandlerResult = getItemHandler(dest, EnumFacing.UP);
|
||||
if (itemHandlerResult == null)
|
||||
return null;
|
||||
|
||||
IItemHandler handler = itemHandlerResult.getKey();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++)
|
||||
{
|
||||
ItemStack extractItem = handler.extractItem(i, 1, true);
|
||||
if (!extractItem.isEmpty())
|
||||
{
|
||||
for (int j = 0; j < dest.getSizeInventory(); j++)
|
||||
{
|
||||
ItemStack destStack = dest.getStackInSlot(j);
|
||||
if (dest.isItemValidForSlot(j, extractItem) && (destStack.isEmpty() || destStack.getCount() < destStack.getMaxStackSize() && destStack.getCount() < dest.getInventoryStackLimit() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack)))
|
||||
return getItemHandler(dest, EnumFacing.UP)
|
||||
.map(itemHandlerResult -> {
|
||||
IItemHandler handler = itemHandlerResult.getKey();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++)
|
||||
{
|
||||
extractItem = handler.extractItem(i, 1, false);
|
||||
if (destStack.isEmpty())
|
||||
dest.setInventorySlotContents(j, extractItem);
|
||||
else
|
||||
ItemStack extractItem = handler.extractItem(i, 1, true);
|
||||
if (!extractItem.isEmpty())
|
||||
{
|
||||
destStack.grow(1);
|
||||
dest.setInventorySlotContents(j, destStack);
|
||||
for (int j = 0; j < dest.getSizeInventory(); j++)
|
||||
{
|
||||
ItemStack destStack = dest.getStackInSlot(j);
|
||||
if (dest.isItemValidForSlot(j, extractItem) && (destStack.isEmpty() || destStack.getCount() < destStack.getMaxStackSize() && destStack.getCount() < dest.getInventoryStackLimit() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack)))
|
||||
{
|
||||
extractItem = handler.extractItem(i, 1, false);
|
||||
if (destStack.isEmpty())
|
||||
dest.setInventorySlotContents(j, extractItem);
|
||||
else
|
||||
{
|
||||
destStack.grow(1);
|
||||
dest.setInventorySlotContents(j, destStack);
|
||||
}
|
||||
dest.markDirty();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
dest.markDirty();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
return false;
|
||||
})
|
||||
.orElse(null); // TODO bad null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,31 +89,27 @@ public class VanillaInventoryCodeHooks
|
||||
{
|
||||
EnumFacing enumfacing = world.getBlockState(pos).getValue(BlockDropper.FACING);
|
||||
BlockPos blockpos = pos.offset(enumfacing);
|
||||
Pair<IItemHandler, Object> destinationResult = getItemHandler(world, (double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), enumfacing.getOpposite());
|
||||
if (destinationResult == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IItemHandler itemHandler = destinationResult.getKey();
|
||||
Object destination = destinationResult.getValue();
|
||||
ItemStack dispensedStack = stack.copy().splitStack(1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(dropper, destination, itemHandler, dispensedStack);
|
||||
|
||||
if (remainder.isEmpty())
|
||||
{
|
||||
remainder = stack.copy();
|
||||
remainder.shrink(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainder = stack.copy();
|
||||
}
|
||||
|
||||
dropper.setInventorySlotContents(slot, remainder);
|
||||
return false;
|
||||
}
|
||||
return getItemHandler(world, (double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), enumfacing.getOpposite())
|
||||
.map(destinationResult -> {
|
||||
IItemHandler itemHandler = destinationResult.getKey();
|
||||
Object destination = destinationResult.getValue();
|
||||
ItemStack dispensedStack = stack.copy().splitStack(1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(dropper, destination, itemHandler, dispensedStack);
|
||||
|
||||
if (remainder.isEmpty())
|
||||
{
|
||||
remainder = stack.copy();
|
||||
remainder.shrink(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainder = stack.copy();
|
||||
}
|
||||
|
||||
dropper.setInventorySlotContents(slot, remainder);
|
||||
return false;
|
||||
})
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,42 +117,38 @@ public class VanillaInventoryCodeHooks
|
||||
*/
|
||||
public static boolean insertHook(TileEntityHopper hopper)
|
||||
{
|
||||
EnumFacing hopperFacing = BlockHopper.getFacing(hopper.getBlockMetadata());
|
||||
Pair<IItemHandler, Object> destinationResult = getItemHandler(hopper, hopperFacing);
|
||||
if (destinationResult == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
IItemHandler itemHandler = destinationResult.getKey();
|
||||
Object destination = destinationResult.getValue();
|
||||
if (isFull(itemHandler))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < hopper.getSizeInventory(); ++i)
|
||||
{
|
||||
if (!hopper.getStackInSlot(i).isEmpty())
|
||||
EnumFacing hopperFacing = hopper.func_195044_w().getValue(BlockHopper.FACING);
|
||||
return getItemHandler(hopper, hopperFacing)
|
||||
.map(destinationResult -> {
|
||||
IItemHandler itemHandler = destinationResult.getKey();
|
||||
Object destination = destinationResult.getValue();
|
||||
if (isFull(itemHandler))
|
||||
{
|
||||
ItemStack originalSlotContents = hopper.getStackInSlot(i).copy();
|
||||
ItemStack insertStack = hopper.decrStackSize(i, 1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(hopper, destination, itemHandler, insertStack);
|
||||
|
||||
if (remainder.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
hopper.setInventorySlotContents(i, originalSlotContents);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < hopper.getSizeInventory(); ++i)
|
||||
{
|
||||
if (!hopper.getStackInSlot(i).isEmpty())
|
||||
{
|
||||
ItemStack originalSlotContents = hopper.getStackInSlot(i).copy();
|
||||
ItemStack insertStack = hopper.decrStackSize(i, 1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(hopper, destination, itemHandler, insertStack);
|
||||
|
||||
if (remainder.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
hopper.setInventorySlotContents(i, originalSlotContents);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
private static ItemStack putStackInInventoryAllSlots(TileEntity source, Object destination, IItemHandler destInventory, ItemStack stack)
|
||||
@@ -200,7 +194,7 @@ public class VanillaInventoryCodeHooks
|
||||
if (!destinationHopper.mayTransfer())
|
||||
{
|
||||
int k = 0;
|
||||
|
||||
/* TODO TileEntityHopper patches
|
||||
if (source instanceof TileEntityHopper)
|
||||
{
|
||||
if (destinationHopper.getLastUpdateTime() >= ((TileEntityHopper) source).getLastUpdateTime())
|
||||
@@ -208,7 +202,7 @@ public class VanillaInventoryCodeHooks
|
||||
k = 1;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
destinationHopper.setTransferCooldown(8 - k);
|
||||
}
|
||||
}
|
||||
@@ -218,12 +212,11 @@ public class VanillaInventoryCodeHooks
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Pair<IItemHandler, Object> getItemHandler(IHopper hopper, EnumFacing hopperFacing)
|
||||
private static OptionalCapabilityInstance<Pair<IItemHandler, Object>> getItemHandler(IHopper hopper, EnumFacing hopperFacing)
|
||||
{
|
||||
double x = hopper.getXPos() + (double) hopperFacing.getFrontOffsetX();
|
||||
double y = hopper.getYPos() + (double) hopperFacing.getFrontOffsetY();
|
||||
double z = hopper.getZPos() + (double) hopperFacing.getFrontOffsetZ();
|
||||
double x = hopper.getXPos() + (double) hopperFacing.getXOffset();
|
||||
double y = hopper.getYPos() + (double) hopperFacing.getYOffset();
|
||||
double z = hopper.getZPos() + (double) hopperFacing.getZOffset();
|
||||
return getItemHandler(hopper.getWorld(), x, y, z, hopperFacing.getOpposite());
|
||||
}
|
||||
|
||||
@@ -253,10 +246,8 @@ public class VanillaInventoryCodeHooks
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Pair<IItemHandler, Object> getItemHandler(World worldIn, double x, double y, double z, final EnumFacing side)
|
||||
public static OptionalCapabilityInstance<Pair<IItemHandler, Object>> getItemHandler(World worldIn, double x, double y, double z, final EnumFacing side)
|
||||
{
|
||||
Pair<IItemHandler, Object> destination = null;
|
||||
int i = MathHelper.floor(x);
|
||||
int j = MathHelper.floor(y);
|
||||
int k = MathHelper.floor(z);
|
||||
@@ -264,19 +255,16 @@ public class VanillaInventoryCodeHooks
|
||||
net.minecraft.block.state.IBlockState state = worldIn.getBlockState(blockpos);
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (block.hasTileEntity(state))
|
||||
if (block.hasTileEntity(/* TODO Block patches // state */))
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
if (tileentity != null)
|
||||
{
|
||||
if (tileentity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
|
||||
{
|
||||
IItemHandler capability = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
|
||||
destination = ImmutablePair.<IItemHandler, Object>of(capability, tileentity);
|
||||
}
|
||||
return tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)
|
||||
.map(capability -> ImmutablePair.<IItemHandler, Object>of(capability, tileentity));
|
||||
}
|
||||
}
|
||||
|
||||
return destination;
|
||||
return OptionalCapabilityInstance.empty();
|
||||
}
|
||||
}
|
||||
@@ -98,17 +98,17 @@ public class ModelLoaderErrorMessage extends SimpleMessage
|
||||
if(exception instanceof ModelLoader.ItemLoadingException)
|
||||
{
|
||||
ModelLoader.ItemLoadingException ex = (ModelLoader.ItemLoadingException)exception;
|
||||
// FMLLog.log.error("{}, normal location exception: ", errorMsg, ex.normalException);
|
||||
// FMLLog.log.error("{}, blockstate location exception: ", errorMsg, ex.blockstateException);
|
||||
// LOGGER.error("{}, normal location exception: ", errorMsg, ex.normalException);
|
||||
// LOGGER.error("{}, blockstate location exception: ", errorMsg, ex.blockstateException);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FMLLog.log.error(errorMsg, entry.getValue());
|
||||
// LOGGER.error(errorMsg, entry.getValue());
|
||||
}
|
||||
// ResourceLocation blockstateLocation = new ResourceLocation(resourceLocation.getResourceDomain(), resourceLocation.getResourcePath());
|
||||
// if(loadingExceptions.containsKey(blockstateLocation) && !printedBlockStateErrors.contains(blockstateLocation))
|
||||
// {
|
||||
// FMLLog.log.error("Exception loading blockstate for the variant {}: ", location, loadingExceptions.get(blockstateLocation));
|
||||
// LOGGER.error("Exception loading blockstate for the variant {}: ", location, loadingExceptions.get(blockstateLocation));
|
||||
// printedBlockStateErrors.add(blockstateLocation);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.oredict;
|
||||
|
||||
/*
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -53,7 +52,6 @@ import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
*/
|
||||
|
||||
public class OreDictionary
|
||||
{
|
||||
/*
|
||||
@@ -381,7 +379,7 @@ public class OreDictionary
|
||||
ItemStack.EMPTY //So the above can have a comma and we don't have to keep editing extra lines.
|
||||
};
|
||||
|
||||
FMLLog.log.info("Starts to replace vanilla recipe ingredients with ore ingredients.");
|
||||
LOGGER.info("Starts to replace vanilla recipe ingredients with ore ingredients.");
|
||||
int replaced = 0;
|
||||
// Search vanilla recipes for recipes to replace
|
||||
for(IRecipe obj : CraftingManager.REGISTRY)
|
||||
@@ -413,7 +411,7 @@ public class OreDictionary
|
||||
matches = true;
|
||||
if (oreName != null && !oreName.equals(ent.getValue()))
|
||||
{
|
||||
FMLLog.log.info("Invalid recipe found with multiple oredict ingredients in the same ingredient..."); //TODO: Write a dumper?
|
||||
LOGGER.info("Invalid recipe found with multiple oredict ingredients in the same ingredient..."); //TODO: Write a dumper?
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
@@ -441,14 +439,14 @@ public class OreDictionary
|
||||
if(DEBUG && replacedIngs.add(ing))
|
||||
{
|
||||
String recipeName = obj.getRegistryName().getResourcePath();
|
||||
FMLLog.log.debug("Replaced {} of the recipe \'{}\' with \"{}\".", ing.getMatchingStacks(), recipeName, oreName);
|
||||
LOGGER.debug("Replaced {} of the recipe \'{}\' with \"{}\".", ing.getMatchingStacks(), recipeName, oreName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMLLog.log.info("Replaced {} ore ingredients", replaced);
|
||||
LOGGER.info("Replaced {} ore ingredients", replaced);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -504,7 +502,7 @@ public class OreDictionary
|
||||
int id;
|
||||
if (registryName == null)
|
||||
{
|
||||
FMLLog.log.debug("Attempted to find the oreIDs for an unregistered object ({}). This won't work very well.", stack);
|
||||
LOGGER.debug("Attempted to find the oreIDs for an unregistered object ({}). This won't work very well.", stack);
|
||||
return new int[0];
|
||||
}
|
||||
else
|
||||
@@ -736,7 +734,7 @@ public class OreDictionary
|
||||
int hash;
|
||||
if (name == null)
|
||||
{
|
||||
FMLLog.log.debug("Defaulting unregistered ore dictionary entry for ore dictionary {}: type {} to -1", getOreName(id), ore.getItem().getClass());
|
||||
LOGGER.debug("Defaulting unregistered ore dictionary entry for ore dictionary {}: type {} to -1", getOreName(id), ore.getItem().getClass());
|
||||
hash = -1;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.oredict;
|
||||
|
||||
/*
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -30,7 +30,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
*/
|
||||
public class OreIngredient //extends Ingredient
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.oredict;
|
||||
|
||||
/*
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.RecipeItemHelper;
|
||||
@@ -42,7 +42,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
*/
|
||||
public class ShapelessOreRecipe {} /*extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
{
|
||||
@Nonnull
|
||||
|
||||
@@ -22,6 +22,7 @@ package net.minecraftforge.registries;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.init.Bootstrap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
@@ -50,10 +51,9 @@ public class ForgeRegistries
|
||||
public static final IForgeRegistry<PotionType> POTION_TYPES = RegistryManager.ACTIVE.getRegistry(PotionType.class);
|
||||
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Enchantment.class);
|
||||
public static final IForgeRegistry<VillagerProfession> VILLAGER_PROFESSIONS = RegistryManager.ACTIVE.getRegistry(VillagerProfession.class);
|
||||
public static final IForgeRegistry<EntityEntry> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityEntry.class);
|
||||
public static final IForgeRegistry<EntityType<?>> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityType.class);
|
||||
public static final IForgeRegistry<IRecipe> RECIPES = RegistryManager.ACTIVE.getRegistry(IRecipe.class);
|
||||
|
||||
|
||||
/**
|
||||
* This function is just to make sure static inializers in other classes have run and setup their registries before we query them.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.potion.Potion;
|
||||
@@ -42,6 +43,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent.MissingMappings;
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
import net.minecraftforge.fml.ModThreadContext;
|
||||
import net.minecraftforge.fml.StartupQuery;
|
||||
|
||||
@@ -127,8 +129,9 @@ public class GameData
|
||||
makeRegistry(POTIONTYPES, PotionType.class, MAX_POTIONTYPE_ID, new ResourceLocation("empty")).create();
|
||||
makeRegistry(ENCHANTMENTS, Enchantment.class, MAX_ENCHANTMENT_ID).create();
|
||||
// makeRegistry(RECIPES, IRecipe.class, MAX_RECIPE_ID).disableSaving().allowModification().addCallback(RecipeCallbacks.INSTANCE).create();
|
||||
// makeRegistry(PROFESSIONS, VillagerProfession.class, MAX_PROFESSION_ID).create();
|
||||
// entityRegistry = (ForgeRegistry<EntityEntry>)makeRegistry(ENTITIES, EntityEntry.class, MAX_ENTITY_ID).addCallback(EntityCallbacks.INSTANCE).create();
|
||||
makeRegistry(PROFESSIONS, VillagerProfession.class, MAX_PROFESSION_ID).create();
|
||||
// TODO do we need the callback and the static field anymore?
|
||||
makeRegistry(ENTITIES, EntityType.class, MAX_ENTITY_ID).create();
|
||||
}
|
||||
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, int min, int max)
|
||||
|
||||
@@ -46,7 +46,7 @@ public enum ObjectHolderRegistry
|
||||
INSTANCE;
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private List<ObjectHolderRef> objectHolders = Lists.newArrayList();
|
||||
|
||||
/* TODO annotation data
|
||||
public void findObjectHolders(ASMDataTable table)
|
||||
{
|
||||
LOGGER.info("Processing ObjectHolder annotations");
|
||||
@@ -69,7 +69,7 @@ public enum ObjectHolderRegistry
|
||||
});
|
||||
LOGGER.info("Found {} ObjectHolder annotations", objectHolders.size());
|
||||
}
|
||||
|
||||
*/
|
||||
private void scanTarget(Map<String, String> classModIds, Map<String, Class<?>> classCache, String className, @Nullable String annotationTarget, String value, boolean isClass, boolean extractFromValue)
|
||||
{
|
||||
Class<?> clazz;
|
||||
|
||||
@@ -41,12 +41,12 @@ public class TextComponentHelper
|
||||
{
|
||||
if (isVanillaClient(source))
|
||||
{
|
||||
return new TextComponentString(LanguageMap.getInstance().translateKey(translation, args));
|
||||
return new TextComponentString(String.format(LanguageMap.getInstance().translateKey(translation), args));
|
||||
}
|
||||
return new TextComponentTranslation(translation, args);
|
||||
}
|
||||
|
||||
private static boolean isVanillaClient(ICommandSender sender)
|
||||
private static boolean isVanillaClient(ICommandSource sender)
|
||||
{
|
||||
if (sender instanceof EntityPlayerMP)
|
||||
{
|
||||
|
||||
@@ -22,8 +22,10 @@ package net.minecraftforge.server.console;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -60,7 +62,7 @@ final class ConsoleCommandCompleter implements Completer
|
||||
}
|
||||
|
||||
final String input = buffer;
|
||||
Future<List<String>> tabComplete = this.server.callFromMainThread(() -> this.server.getTabCompletions(this.server, input, this.server.getPosition(), false));
|
||||
Future<List<String>> tabComplete = new FutureTask<>(() -> Collections.emptyList());// TODO commands this.server.callFromMainThread(() -> this.server.getTabCompletions(this.server, input, this.server.getPosition(), false));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -71,9 +71,9 @@ public final class TerminalHandler
|
||||
|
||||
line = line.trim();
|
||||
if (!line.isEmpty())
|
||||
{
|
||||
{/* TODO Commands
|
||||
server.addPendingCommand(line, server);
|
||||
}
|
||||
*/}
|
||||
}
|
||||
}
|
||||
catch (UserInterruptException e)
|
||||
|
||||
@@ -21,7 +21,6 @@ package net.minecraftforge.server.permission;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.server.permission.context.IContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -72,7 +71,7 @@ public enum DefaultPermissionHandler implements IPermissionHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
MinecraftServer server = null; // TODO FMLCommonHandler FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
return server != null && server.getPlayerList().canSendCommands(profile);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,18 @@ package net.minecraftforge.server.permission;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.server.permission.context.IContext;
|
||||
import net.minecraftforge.server.permission.context.PlayerContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class PermissionAPI
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static IPermissionHandler permissionHandler = DefaultPermissionHandler.INSTANCE;
|
||||
|
||||
/**
|
||||
@@ -39,8 +42,8 @@ public class PermissionAPI
|
||||
public static void setPermissionHandler(IPermissionHandler handler)
|
||||
{
|
||||
Preconditions.checkNotNull(handler, "Permission handler can't be null!");
|
||||
Preconditions.checkState(Loader.instance().getLoaderState().ordinal() <= LoaderState.PREINITIALIZATION.ordinal(), "Can't register after IPermissionHandler PreInit!");
|
||||
FMLLog.log.warn("Replacing {} with {}", permissionHandler.getClass().getName(), handler.getClass().getName());
|
||||
// TODO Loader states Preconditions.checkState(Loader.instance().getLoaderState().ordinal() <= LoaderState.PREINITIALIZATION.ordinal(), "Can't register after IPermissionHandler PreInit!");
|
||||
LOGGER.warn("Replacing {} with {}", permissionHandler.getClass().getName(), handler.getClass().getName());
|
||||
permissionHandler = handler;
|
||||
}
|
||||
|
||||
@@ -62,7 +65,7 @@ public class PermissionAPI
|
||||
Preconditions.checkNotNull(level, "Permission level can't be null!");
|
||||
Preconditions.checkNotNull(desc, "Permission description can't be null!");
|
||||
Preconditions.checkArgument(!node.isEmpty(), "Permission node can't be empty!");
|
||||
Preconditions.checkState(Loader.instance().getLoaderState().ordinal() > LoaderState.PREINITIALIZATION.ordinal(), "Can't register permission nodes before Init!");
|
||||
// TODO Loader states Preconditions.checkState(Loader.instance().getLoaderState().ordinal() > LoaderState.PREINITIALIZATION.ordinal(), "Can't register permission nodes before Init!");
|
||||
permissionHandler.registerNode(node, level, desc);
|
||||
return node;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user