More compile cleanups. (#5139)

This commit is contained in:
tterrag authored and LexManos committed 2018-09-14 09:30:56 -07:00
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();