mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 19:59:42 +00:00
Well, it works, for a game, now.
This commit is contained in:
1 parent
06b16aaa19
commit
d0ab0e166c
208 files changed
+2328
-5883
No files matched your search
@@ -57,12 +57,17 @@ import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.WorldServerMulti;
|
||||
import net.minecraft.world.storage.ISaveHandler;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DimensionManager
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger("FML");
|
||||
private static final Marker DIMMGR = MarkerManager.getMarker("DIMS");
|
||||
private static class Dimension
|
||||
{
|
||||
private final DimensionType type;
|
||||
@@ -187,11 +192,11 @@ public class DimensionManager
|
||||
int leakCount = leakedWorlds.count(System.identityHashCode(w));
|
||||
if (leakCount == 5)
|
||||
{
|
||||
FMLLog.log.debug("The world {} ({}) may have leaked: first encounter (5 occurrences).\n", Integer.toHexString(System.identityHashCode(w)), w.getWorldInfo().getWorldName());
|
||||
LOGGER.debug(DIMMGR,"The world {} ({}) may have leaked: first encounter (5 occurrences).\n", Integer.toHexString(System.identityHashCode(w)), w.getWorldInfo().getWorldName());
|
||||
}
|
||||
else if (leakCount % 5 == 0)
|
||||
{
|
||||
FMLLog.log.debug("The world {} ({}) may have leaked: seen {} times.\n", Integer.toHexString(System.identityHashCode(w)), w.getWorldInfo().getWorldName(), leakCount);
|
||||
LOGGER.debug(DIMMGR,"The world {} ({}) may have leaked: seen {} times.\n", Integer.toHexString(System.identityHashCode(w)), w.getWorldInfo().getWorldName(), leakCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,13 +215,13 @@ public class DimensionManager
|
||||
worlds.put(id, world);
|
||||
weakWorldMap.put(world, world);
|
||||
server.worldTickTimes.put(id, new long[100]);
|
||||
FMLLog.log.info("Loading dimension {} ({}) ({})", id, world.getWorldInfo().getWorldName(), world.getMinecraftServer());
|
||||
LOGGER.info(DIMMGR,"Loading dimension {} ({}) ({})", id, world.getWorldInfo().getWorldName(), world.getMinecraftServer());
|
||||
}
|
||||
else
|
||||
{
|
||||
worlds.remove(id);
|
||||
server.worldTickTimes.remove(id);
|
||||
FMLLog.log.info("Unloading dimension {}", id);
|
||||
LOGGER.info(DIMMGR,"Unloading dimension {}", id);
|
||||
}
|
||||
|
||||
ArrayList<WorldServer> tmp = new ArrayList<WorldServer>();
|
||||
@@ -253,7 +258,7 @@ public class DimensionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("Cannot Hotload Dim: {}", dim, e);
|
||||
LOGGER.error(DIMMGR,"Cannot Hotload Dim: {}", dim, e);
|
||||
return; // If a provider hasn't been registered then we can't hotload the dim
|
||||
}
|
||||
MinecraftServer mcServer = overworld.getMinecraftServer();
|
||||
@@ -321,7 +326,7 @@ public class DimensionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("An error occurred trying to create an instance of WorldProvider {} ({})",
|
||||
LOGGER.error(DIMMGR,"An error occurred trying to create an instance of WorldProvider {} ({})",
|
||||
dim, getProviderType(dim), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -357,7 +362,7 @@ public class DimensionManager
|
||||
|
||||
if (unloadQueue.add(id))
|
||||
{
|
||||
FMLLog.log.debug("Queueing dimension {} to unload", id);
|
||||
LOGGER.debug(DIMMGR,"Queueing dimension {} to unload", id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +381,7 @@ public class DimensionManager
|
||||
{
|
||||
int id = queueIterator.nextInt();
|
||||
Dimension dimension = dimensions.get(id);
|
||||
if (dimension.ticksWaited < ForgeModContainer.dimensionUnloadQueueDelay)
|
||||
if (dimension.ticksWaited < ForgeMod.dimensionUnloadQueueDelay)
|
||||
{
|
||||
dimension.ticksWaited++;
|
||||
continue;
|
||||
@@ -387,7 +392,7 @@ public class DimensionManager
|
||||
// Don't unload the world if the status changed
|
||||
if (w == null || !canUnloadWorld(w))
|
||||
{
|
||||
FMLLog.log.debug("Aborting unload for dimension {} as status changed", id);
|
||||
LOGGER.debug(DIMMGR,"Aborting unload for dimension {} as status changed", id);
|
||||
continue;
|
||||
}
|
||||
try
|
||||
@@ -396,7 +401,7 @@ public class DimensionManager
|
||||
}
|
||||
catch (MinecraftException e)
|
||||
{
|
||||
FMLLog.log.error("Caught an exception while saving all chunks:", e);
|
||||
LOGGER.error(DIMMGR,"Caught an exception while saving all chunks:", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.ServerLifecycleHooks;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
@@ -626,7 +627,7 @@ public class ForgeChunkManager
|
||||
dormantChunkCache.remove(world);
|
||||
}
|
||||
// integrated server is shutting down
|
||||
if (!FMLCommonHandler.instance().getMinecraftServerInstance().isServerRunning())
|
||||
if (!ServerLifecycleHooks.getCurrentServer().isServerRunning())
|
||||
{
|
||||
playerTickets.clear();
|
||||
tickets.clear();
|
||||
|
||||
@@ -24,13 +24,16 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -114,7 +117,6 @@ import net.minecraft.world.storage.loot.LootEntry;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
import net.minecraft.world.storage.loot.LootTableManager;
|
||||
import net.minecraft.world.storage.loot.conditions.LootCondition;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
import net.minecraftforge.event.DifficultyChangeEvent;
|
||||
@@ -142,13 +144,17 @@ import net.minecraftforge.event.entity.player.AdvancementEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.event.world.NoteBlockEvent;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.ConnectionType;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.network.ConnectionType;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
@@ -157,10 +163,15 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
public class ForgeHooks
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger("FML");
|
||||
private static final Marker FORGEHOOKS = MarkerManager.getMarker("FORGEHOOKS");
|
||||
//TODO: Loot tables?
|
||||
static class SeedEntry extends WeightedRandom.Item
|
||||
{
|
||||
@@ -645,7 +656,7 @@ public class ForgeHooks
|
||||
{
|
||||
boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer)entity).isSpectator());
|
||||
if (isSpectator) return false;
|
||||
if (!ForgeModContainer.fullBoundingBoxLadders)
|
||||
if (!ForgeMod.fullBoundingBoxLadders)
|
||||
{
|
||||
return state.getBlock().isLadder(state, world, pos, entity);
|
||||
}
|
||||
@@ -1304,13 +1315,10 @@ public class ForgeHooks
|
||||
public static boolean loadAdvancements(Map<ResourceLocation, Advancement.Builder> map)
|
||||
{
|
||||
boolean errored = false;
|
||||
setActiveModContainer(null);
|
||||
//Loader.instance().getActiveModList().forEach((mod) -> loadFactories(mod));
|
||||
for (ModContainer mod : Loader.instance().getActiveModList())
|
||||
for (ModFileInfo mod : ModList.get().getModFiles())
|
||||
{
|
||||
errored |= !loadAdvancements(map, mod);
|
||||
errored |= !loadAdvancements(map, mod.getFile());
|
||||
}
|
||||
setActiveModContainer(null);
|
||||
return errored;
|
||||
}
|
||||
|
||||
@@ -1326,7 +1334,7 @@ public class ForgeHooks
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void setActiveModContainer(ModContainer mod)
|
||||
private static boolean loadAdvancements(Map<ResourceLocation, Advancement.Builder> map, ModFile mod)
|
||||
{
|
||||
if (Loader.instance().getLoaderState() != LoaderState.NOINIT) //Unit Tests..
|
||||
Loader.instance().setActiveModContainer(mod);
|
||||
@@ -1357,12 +1365,12 @@ public class ForgeHooks
|
||||
}
|
||||
catch (JsonParseException jsonparseexception)
|
||||
{
|
||||
FMLLog.log.error("Parsing error loading built-in advancement " + key, (Throwable)jsonparseexception);
|
||||
LOGGER.error("Parsing error loading built-in advancement " + key, (Throwable)jsonparseexception);
|
||||
return false;
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
FMLLog.log.error("Couldn't read advancement " + key + " from " + file, (Throwable)ioexception);
|
||||
LOGGER.error("Couldn't read advancement " + key + " from " + file, (Throwable)ioexception);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
@@ -1385,13 +1393,11 @@ public class ForgeHooks
|
||||
if (type == ConnectionType.VANILLA)
|
||||
{
|
||||
IForgeRegistry<IRecipe> vanilla = RegistryManager.VANILLA.getRegistry(IRecipe.class);
|
||||
if (recipes.size() > 0)
|
||||
recipes = recipes.stream().filter(e -> vanilla.containsValue(e)).collect(Collectors.toList());
|
||||
if (display.size() > 0)
|
||||
display = display.stream().filter(e -> vanilla.containsValue(e)).collect(Collectors.toList());
|
||||
recipes = recipes.stream().filter(vanilla::containsValue).collect(Collectors.toList());
|
||||
display = display.stream().filter(vanilla::containsValue).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (recipes.size() > 0 || display.size() > 0)
|
||||
if (!recipes.isEmpty() || !display.isEmpty())
|
||||
connection.sendPacket(new SPacketRecipeBook(state, recipes, display, isGuiOpen, isFilteringCraftable));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.client.CloudRenderer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
@@ -93,7 +94,7 @@ public class ForgeInternalHandler
|
||||
public void checkSettings(ClientTickEvent event)
|
||||
{
|
||||
if (event.phase == Phase.END)
|
||||
FMLClientHandler.instance().updateCloudSettings();
|
||||
CloudRenderer.updateCloudSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import static net.minecraftforge.common.config.Configuration.CATEGORY_CLIENT;
|
||||
import static net.minecraftforge.common.config.Configuration.CATEGORY_GENERAL;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.fml.ModLoadingClassLoader;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.fml.WorldPersistenceHooks;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLModContainer;
|
||||
import net.minecraftforge.fml.javafmlmod.ModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.DefaultModInfos;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent.MissingMappings;
|
||||
import net.minecraftforge.event.terraingen.DeferredBiomeDecorator;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.fluids.UniversalBucket;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.server.command.ForgeCommand;
|
||||
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLModIdMappingEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
{
|
||||
public static final String VERSION_CHECK_CAT = "version_checking";
|
||||
public static int clumpingThreshold = 64;
|
||||
public static boolean removeErroringEntities = false;
|
||||
public static boolean removeErroringTileEntities = false;
|
||||
public static boolean fullBoundingBoxLadders = false;
|
||||
public static double zombieSummonBaseChance = 0.1;
|
||||
public static int[] blendRanges = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 };
|
||||
public static float zombieBabyChance = 0.05f;
|
||||
public static boolean shouldSortRecipies = true;
|
||||
public static boolean disableVersionCheck = false;
|
||||
public static boolean forgeLightPipelineEnabled = true;
|
||||
@Deprecated // TODO remove in 1.13
|
||||
public static boolean replaceVanillaBucketModel = true;
|
||||
public static boolean zoomInMissingModelTextInGui = false;
|
||||
public static boolean forgeCloudsEnabled = true;
|
||||
public static boolean disableStairSlabCulling = false; // Also known as the "DontCullStairsBecauseIUseACrappyTexturePackThatBreaksBasicBlockShapesSoICantTrustBasicBlockCulling" flag
|
||||
public static boolean alwaysSetupTerrainOffThread = false; // In RenderGlobal.setupTerrain, always force the chunk render updates to be queued to the thread
|
||||
public static int dimensionUnloadQueueDelay = 0;
|
||||
public static boolean logCascadingWorldGeneration = true; // see Chunk#logCascadingWorldGeneration()
|
||||
public static boolean fixVanillaCascading = false; // There are various places in vanilla that cause cascading worldgen. Enabling this WILL change where blocks are placed to prevent this.
|
||||
// DO NOT contact Forge about worldgen not 'matching' vanilla if this flag is set.
|
||||
|
||||
static final Logger log = LogManager.getLogger(ForgeVersion.MOD_ID);
|
||||
|
||||
private static Configuration config;
|
||||
private static ForgeMod INSTANCE;
|
||||
public static ForgeMod getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private URL updateJSONUrl = null;
|
||||
public UniversalBucket universalBucket;
|
||||
|
||||
public ForgeMod()
|
||||
{
|
||||
INSTANCE = this;
|
||||
ModLoadingContext.get().getModEventBus().addListener(this::preInit);
|
||||
ModLoadingContext.get().getModEventBus().addListener(this::postInit);
|
||||
ModLoadingContext.get().getModEventBus().addListener(this::onAvailable);
|
||||
}
|
||||
|
||||
public static Configuration getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
private static void remapGeneralPropertyToClient(String key)
|
||||
{
|
||||
ConfigCategory GENERAL = config.getCategory(CATEGORY_GENERAL);
|
||||
if (GENERAL.containsKey(key))
|
||||
{
|
||||
FMLLog.log.debug("Remapping property {} from category general to client", key);
|
||||
Property property = GENERAL.get(key);
|
||||
GENERAL.remove(key);
|
||||
config.getCategory(CATEGORY_CLIENT).put(key, property);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronizes the local fields with the values in the Configuration object.
|
||||
*/
|
||||
private static void syncConfig(boolean load)
|
||||
{
|
||||
// By adding a property order list we are defining the order that the properties will appear both in the config file and on the GUIs.
|
||||
// Property order lists are defined per-ConfigCategory.
|
||||
List<String> propOrder = new ArrayList<String>();
|
||||
|
||||
if (!config.isChild)
|
||||
{
|
||||
if (load)
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
Property enableGlobalCfg = config.get(Configuration.CATEGORY_GENERAL, "enableGlobalConfig", false).setShowInGui(false);
|
||||
if (enableGlobalCfg.getBoolean(false))
|
||||
{
|
||||
Configuration.enableGlobalConfig();
|
||||
}
|
||||
}
|
||||
|
||||
Property prop;
|
||||
|
||||
// clean up old properties that are not used anymore
|
||||
if (config.getCategory(CATEGORY_GENERAL).containsKey("defaultSpawnFuzz")) config.getCategory(CATEGORY_GENERAL).remove("defaultSpawnFuzz");
|
||||
if (config.getCategory(CATEGORY_GENERAL).containsKey("spawnHasFuzz")) config.getCategory(CATEGORY_GENERAL).remove("spawnHasFuzz");
|
||||
if (config.getCategory(CATEGORY_GENERAL).containsKey("disableStitchedFileSaving")) config.getCategory(CATEGORY_GENERAL).remove("disableStitchedFileSaving");
|
||||
if (config.getCategory(CATEGORY_CLIENT).containsKey("java8Reminder")) config.getCategory(CATEGORY_CLIENT).remove("java8Reminder");
|
||||
if (config.getCategory(CATEGORY_CLIENT).containsKey("replaceVanillaBucketModel")) config.getCategory(CATEGORY_CLIENT).remove("replaceVanillaBucketModel");
|
||||
|
||||
// remap properties wrongly listed as general properties to client properties
|
||||
remapGeneralPropertyToClient("biomeSkyBlendRange");
|
||||
remapGeneralPropertyToClient("forgeLightPipelineEnabled");
|
||||
|
||||
prop = config.get(CATEGORY_GENERAL, "disableVersionCheck", false);
|
||||
prop.setComment("Set to true to disable Forge's version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github.");
|
||||
// Language keys are a good idea to implement if you are using config GUIs. This allows you to use a .lang file that will hold the
|
||||
// "pretty" version of the property name as well as allow others to provide their own localizations.
|
||||
// This language key is also used to get the tooltip for a property. The tooltip language key is langKey + ".tooltip".
|
||||
// If no tooltip language key is defined in your .lang file, the tooltip will default to the property comment field.
|
||||
prop.setLanguageKey("forge.configgui.disableVersionCheck");
|
||||
disableVersionCheck = prop.getBoolean(disableVersionCheck);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "clumpingThreshold", 64,
|
||||
"Controls the number threshold at which Packet51 is preferred over Packet52, default and minimum 64, maximum 1024", 64, 1024);
|
||||
prop.setLanguageKey("forge.configgui.clumpingThreshold").setRequiresWorldRestart(true);
|
||||
clumpingThreshold = prop.getInt(64);
|
||||
if (clumpingThreshold > 1024 || clumpingThreshold < 64)
|
||||
{
|
||||
clumpingThreshold = 64;
|
||||
prop.set(64);
|
||||
}
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(CATEGORY_GENERAL, "sortRecipies", true);
|
||||
prop.setComment("Set to true to enable the post initialization sorting of crafting recipes using Forge's sorter. May cause desyncing on conflicting recipes. MUST RESTART MINECRAFT IF CHANGED FROM THE CONFIG GUI.");
|
||||
prop.setLanguageKey("forge.configgui.sortRecipies").setRequiresMcRestart(true);
|
||||
shouldSortRecipies = prop.getBoolean(true);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringEntities", false);
|
||||
prop.setComment("Set this to true to remove any Entity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.");
|
||||
prop.setLanguageKey("forge.configgui.removeErroringEntities").setRequiresWorldRestart(true);
|
||||
removeErroringEntities = prop.getBoolean(false);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
if (removeErroringEntities)
|
||||
{
|
||||
FMLLog.log.warn("Enabling removal of erroring Entities - USE AT YOUR OWN RISK");
|
||||
}
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringTileEntities", false);
|
||||
prop.setComment("Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.");
|
||||
prop.setLanguageKey("forge.configgui.removeErroringTileEntities").setRequiresWorldRestart(true);
|
||||
removeErroringTileEntities = prop.getBoolean(false);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
if (removeErroringTileEntities)
|
||||
{
|
||||
FMLLog.log.warn("Enabling removal of erroring Tile Entities - USE AT YOUR OWN RISK");
|
||||
}
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false);
|
||||
prop.setComment("Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticeable differences in mechanics so default is vanilla behavior. Default: false");
|
||||
prop.setLanguageKey("forge.configgui.fullBoundingBoxLadders").setRequiresWorldRestart(true);
|
||||
fullBoundingBoxLadders = prop.getBoolean(false);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBaseSummonChance", 0.1,
|
||||
"Base zombie summoning spawn chance. Allows changing the bonus zombie summoning mechanic.", 0.0D, 1.0D);
|
||||
prop.setLanguageKey("forge.configgui.zombieBaseSummonChance").setRequiresWorldRestart(true);
|
||||
zombieSummonBaseChance = prop.getDouble(0.1);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBabyChance", 0.05,
|
||||
"Chance that a zombie (or subclass) is a baby. Allows changing the zombie spawning mechanic.", 0.0D, 1.0D);
|
||||
prop.setLanguageKey("forge.configgui.zombieBabyChance").setRequiresWorldRestart(true);
|
||||
zombieBabyChance = (float) prop.getDouble(0.05);
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "logCascadingWorldGeneration", true,
|
||||
"Log cascading chunk generation issues during terrain population.");
|
||||
logCascadingWorldGeneration = prop.getBoolean();
|
||||
prop.setLanguageKey("forge.configgui.logCascadingWorldGeneration");
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "fixVanillaCascading", false,
|
||||
"Fix vanilla issues that cause worldgen cascading. This DOES change vanilla worldgen so DO NOT report bugs related to world differences if this flag is on.");
|
||||
fixVanillaCascading = prop.getBoolean();
|
||||
prop.setLanguageKey("forge.configgui.fixVanillaCascading");
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "dimensionUnloadQueueDelay", 0,
|
||||
"The time in ticks the server will wait when a dimension was queued to unload. " +
|
||||
"This can be useful when rapidly loading and unloading dimensions, like e.g. throwing items through a nether portal a few time per second.");
|
||||
dimensionUnloadQueueDelay = prop.getInt(0);
|
||||
prop.setLanguageKey("forge.configgui.dimensionUnloadQueueDelay");
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
config.setCategoryPropertyOrder(CATEGORY_GENERAL, propOrder);
|
||||
|
||||
propOrder = new ArrayList<String>();
|
||||
prop = config.get(VERSION_CHECK_CAT, "Global", true, "Enable the entire mod update check system. This only applies to mods using the Forge system.");
|
||||
propOrder.add("Global");
|
||||
|
||||
config.setCategoryPropertyOrder(VERSION_CHECK_CAT, propOrder);
|
||||
|
||||
// Client-Side only properties
|
||||
propOrder = new ArrayList<String>();
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_CLIENT, "zoomInMissingModelTextInGui", false,
|
||||
"Toggle off to make missing model text in the gui fit inside the slot.");
|
||||
zoomInMissingModelTextInGui = prop.getBoolean(false);
|
||||
prop.setLanguageKey("forge.configgui.zoomInMissingModelTextInGui");
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_CLIENT, "forgeCloudsEnabled", true,
|
||||
"Enable uploading cloud geometry to the GPU for faster rendering.");
|
||||
prop.setLanguageKey("forge.configgui.forgeCloudsEnabled");
|
||||
forgeCloudsEnabled = prop.getBoolean();
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_CLIENT, "disableStairSlabCulling", false,
|
||||
"Disable culling of hidden faces next to stairs and slabs. Causes extra rendering, but may fix some resource packs that exploit this vanilla mechanic.");
|
||||
disableStairSlabCulling = prop.getBoolean(false);
|
||||
prop.setLanguageKey("forge.configgui.disableStairSlabCulling");
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_CLIENT, "alwaysSetupTerrainOffThread", false,
|
||||
"Enable forge to queue all chunk updates to the Chunk Update thread. May increase FPS significantly, but may also cause weird rendering lag. Not recommended for computers " +
|
||||
"without a significant number of cores available.");
|
||||
alwaysSetupTerrainOffThread = prop.getBoolean(false);
|
||||
prop.setLanguageKey("forge.configgui.alwaysSetupTerrainOffThread");
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_CLIENT, "biomeSkyBlendRange", new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 });
|
||||
prop.setComment("Control the range of sky blending for colored skies in biomes.");
|
||||
prop.setLanguageKey("forge.configgui.biomeSkyBlendRange");
|
||||
blendRanges = prop.getIntList();
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_CLIENT, "forgeLightPipelineEnabled", true,
|
||||
"Enable the forge block rendering pipeline - fixes the lighting of custom models.");
|
||||
forgeLightPipelineEnabled = prop.getBoolean(true);
|
||||
prop.setLanguageKey("forge.configgui.forgeLightPipelineEnabled");
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
config.setCategoryPropertyOrder(CATEGORY_CLIENT, propOrder);
|
||||
|
||||
if (config.hasChanged())
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* By subscribing to the OnConfigChangedEvent we are able to execute code when our config screens are closed.
|
||||
* This implementation uses the optional configID string to handle multiple Configurations using one event handler.
|
||||
*/
|
||||
public void onConfigChanged(OnConfigChangedEvent event)
|
||||
{
|
||||
if (getModId().equals(event.getModID()))
|
||||
{
|
||||
if ("chunkLoader".equals(event.getConfigID()))
|
||||
{
|
||||
ForgeChunkManager.syncConfigDefaults();
|
||||
ForgeChunkManager.loadConfiguration();
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean tmpStairs = disableStairSlabCulling;
|
||||
|
||||
syncConfig(false);
|
||||
|
||||
if (event.isWorldRunning() && tmpStairs != disableStairSlabCulling)
|
||||
{
|
||||
FMLCommonHandler.instance().reloadRenderers();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void missingMapping(RegistryEvent.MissingMappings<Item> event)
|
||||
{
|
||||
for (MissingMappings.Mapping<Item> entry : event.getAllMappings())
|
||||
{
|
||||
if (entry.key.toString().equals("minecraft:totem")) //This item changed from 1.11 -> 1.11.2
|
||||
{
|
||||
ResourceLocation newTotem = new ResourceLocation("minecraft:totem_of_undying");
|
||||
entry.remap(ForgeRegistries.ITEMS.getValue(newTotem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
UsernameCache.setUsername(event.player.getPersistentID(), event.player.getGameProfile().getName());
|
||||
}
|
||||
|
||||
|
||||
public void preInit(FMLPreInitializationEvent evt)
|
||||
{
|
||||
CapabilityItemHandler.register();
|
||||
CapabilityFluidHandler.register();
|
||||
CapabilityAnimation.register();
|
||||
CapabilityEnergy.register();
|
||||
MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER);
|
||||
// ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
if (!ForgeMod.disableVersionCheck)
|
||||
{
|
||||
VersionChecker.startVersionCheck();
|
||||
}
|
||||
}
|
||||
|
||||
public void registrItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
// Add and register the forge universal bucket, if it's enabled
|
||||
if(FluidRegistry.isUniversalBucketEnabled())
|
||||
{
|
||||
universalBucket = new UniversalBucket();
|
||||
universalBucket.setUnlocalizedName("forge.bucketFilled");
|
||||
event.getRegistry().register(universalBucket.setRegistryName(ForgeVersion.MOD_ID, "bucketFilled"));
|
||||
MinecraftForge.EVENT_BUS.register(universalBucket);
|
||||
}
|
||||
}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent evt)
|
||||
{
|
||||
registerAllBiomesAndGenerateEvents();
|
||||
//ForgeChunkManager.loadConfiguration();
|
||||
}
|
||||
|
||||
private static void registerAllBiomesAndGenerateEvents()
|
||||
{
|
||||
for (Biome biome : ForgeRegistries.BIOMES.getValuesCollection())
|
||||
{
|
||||
if (biome.decorator instanceof DeferredBiomeDecorator)
|
||||
{
|
||||
DeferredBiomeDecorator decorator = (DeferredBiomeDecorator)biome.decorator;
|
||||
decorator.fireCreateEventAndReplace(biome);
|
||||
}
|
||||
|
||||
BiomeDictionary.ensureHasTypes(biome);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAvailable(FMLLoadCompleteEvent evt)
|
||||
{
|
||||
FluidRegistry.validateFluidRegistry();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStarting(FMLServerStartingEvent evt)
|
||||
{
|
||||
evt.registerServerCommand(new ForgeCommand());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStopping(FMLServerStoppingEvent evt)
|
||||
{
|
||||
WorldWorkerManager.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info)
|
||||
{
|
||||
NBTTagCompound forgeData = new NBTTagCompound();
|
||||
NBTTagCompound dimData = DimensionManager.saveDimensionDataMap();
|
||||
forgeData.setTag("DimensionData", dimData);
|
||||
FluidRegistry.writeDefaultFluidList(forgeData);
|
||||
return forgeData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(SaveHandler handler, WorldInfo info, Map<String, NBTBase> propertyMap, NBTTagCompound tag)
|
||||
{
|
||||
DimensionManager.loadDimensionDataMap(tag.hasKey("DimensionData") ? tag.getCompoundTag("DimensionData") : null);
|
||||
FluidRegistry.loadFluidDefaults(tag);
|
||||
}
|
||||
|
||||
public void mappingChanged(FMLModIdMappingEvent evt)
|
||||
{
|
||||
OreDictionary.rebakeMap();
|
||||
StatList.reinit();
|
||||
Ingredient.invalidateAll();
|
||||
FMLCommonHandler.instance().reloadSearchTrees();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModId()
|
||||
{
|
||||
return ForgeVersion.MOD_ID;
|
||||
}
|
||||
}
|
||||
@@ -19,91 +19,13 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import static net.minecraftforge.common.config.Configuration.CATEGORY_CLIENT;
|
||||
import static net.minecraftforge.common.config.Configuration.CATEGORY_GENERAL;
|
||||
import net.minecraftforge.fml.ModLoadingClassLoader;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLModContainer;
|
||||
import net.minecraftforge.fml.loading.DefaultModInfos;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
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.crash.ICrashReportDetail;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.classloading.FMLForgePlugin;
|
||||
import net.minecraftforge.client.ForgeClientHandler;
|
||||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigManager;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.common.network.ForgeNetworkHandler;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent.MissingMappings;
|
||||
import net.minecraftforge.event.terraingen.DeferredBiomeDecorator;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.fluids.UniversalBucket;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.server.command.ForgeCommand;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import net.minecraftforge.fml.client.FMLFileResourcePack;
|
||||
import net.minecraftforge.fml.client.FMLFolderResourcePack;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.DummyModContainer;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.ICrashCallable;
|
||||
import net.minecraftforge.fml.common.LoadController;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.ModMetadata;
|
||||
import net.minecraftforge.fml.common.WorldAccessContainer;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import net.minecraftforge.fml.common.discovery.json.JsonAnnotationLoader;
|
||||
import net.minecraftforge.fml.common.event.FMLConstructionEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLModIdMappingEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@EventBusSubscriber(modid = "forge")
|
||||
public class ForgeModContainer extends DummyModContainer implements WorldAccessContainer
|
||||
public class ForgeModContainer extends FMLModContainer
|
||||
{
|
||||
/*
|
||||
public static final String VERSION_CHECK_CAT = "version_checking";
|
||||
public static int clumpingThreshold = 64;
|
||||
public static boolean removeErroringEntities = false;
|
||||
@@ -192,7 +114,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
|
||||
/**
|
||||
* Synchronizes the local fields with the values in the Configuration object.
|
||||
*/
|
||||
* /
|
||||
private static void syncConfig(boolean load)
|
||||
{
|
||||
// By adding a property order list we are defining the order that the properties will appear both in the config file and on the GUIs.
|
||||
@@ -376,7 +298,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
/**
|
||||
* By subscribing to the OnConfigChangedEvent we are able to execute code when our config screens are closed.
|
||||
* This implementation uses the optional configID string to handle multiple Configurations using one event handler.
|
||||
*/
|
||||
* /
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(OnConfigChangedEvent event)
|
||||
{
|
||||
@@ -644,4 +566,10 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
return updateJSONUrl;
|
||||
}
|
||||
|
||||
*/
|
||||
public ForgeModContainer(ModLoadingClassLoader classLoader)
|
||||
{
|
||||
super(DefaultModInfos.forgeModInfo, "net.minecraftforge.common.ForgeMod", classLoader, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,7 +31,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class ForgeVersion
|
||||
{
|
||||
// This is Forge's Mod Id, used for the ForgeModContainer and resource locations
|
||||
// This is Forge's Mod Id, used for the ForgeMod and resource locations
|
||||
public static final String MOD_ID = "forge";
|
||||
//This number is incremented every time we remove deprecated code/major API changes, never reset
|
||||
public static final int majorVersion = 14;
|
||||
|
||||
@@ -22,8 +22,6 @@ package net.minecraftforge.common;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.ICrashCallable;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -111,11 +109,11 @@ public class MinecraftForge
|
||||
if (all.size() == 0)
|
||||
return;
|
||||
|
||||
ForgeModContainer.log.debug("Preloading CrashReport Classes");
|
||||
ForgeMod.log.debug("Preloading CrashReport Classes");
|
||||
Collections.sort(all); //Sort it because I like pretty output ;)
|
||||
for (String name : all)
|
||||
{
|
||||
ForgeModContainer.log.debug("\t{}", name);
|
||||
ForgeMod.log.debug("\t{}", name);
|
||||
try
|
||||
{
|
||||
Class.forName(name.replace('/', '.'), false, MinecraftForge.class.getClassLoader());
|
||||
|
||||
@@ -42,8 +42,6 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.FMLInjectionData;
|
||||
|
||||
/**
|
||||
* Caches player's last known usernames
|
||||
* <p>
|
||||
|
||||
@@ -39,8 +39,6 @@ import net.minecraftforge.common.config.Config.Name;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderException;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModAnnotation.EnumHolder;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -57,7 +57,6 @@ 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.Loader;
|
||||
import net.minecraftforge.fml.relauncher.FMLInjectionData;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,28 +20,26 @@
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.util.RecipeBookClient;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.SidedExecutor;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -57,7 +55,6 @@ import com.google.gson.JsonSyntaxException;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
@@ -68,10 +65,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.OreIngredient;
|
||||
@@ -80,14 +73,20 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
public class CraftingHelper {
|
||||
|
||||
private static final boolean DEBUG_LOAD_MINECRAFT = false;
|
||||
private static final Logger LOGGER = LogManager.getLogger("FML");
|
||||
private static final Marker CRAFTHELPER = MarkerManager.getMarker("CRAFTHELPER");
|
||||
private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
private static Map<ResourceLocation, IConditionFactory> conditions = Maps.newHashMap();
|
||||
private static Map<ResourceLocation, IIngredientFactory> ingredients = Maps.newHashMap();
|
||||
private static Map<ResourceLocation, IRecipeFactory> recipes = Maps.newHashMap();
|
||||
private static Map<ResourceLocation, IConditionFactory> conditions = new HashMap<>();
|
||||
private static Map<ResourceLocation, IIngredientFactory> ingredients = new HashMap<>();
|
||||
private static Map<ResourceLocation, IRecipeFactory> recipes = new HashMap<>();
|
||||
|
||||
static {
|
||||
init();
|
||||
@@ -420,7 +419,7 @@ public class CraftingHelper {
|
||||
|
||||
registerC("forge:mod_loaded", (context, json) -> {
|
||||
String modid = JsonUtils.getString(json, "modid");
|
||||
return () -> Loader.isModLoaded(modid);
|
||||
return () -> ModList.get().isLoaded(modid);
|
||||
});
|
||||
registerC("minecraft:item_exists", (context, json) -> {
|
||||
String itemName = context.appendModId(JsonUtils.getString(json, "item"));
|
||||
@@ -548,7 +547,7 @@ public class CraftingHelper {
|
||||
register(new ResourceLocation(name), fac);
|
||||
}
|
||||
|
||||
static void loadFactories(JsonObject json, JsonContext context)
|
||||
private static void loadFactories(JsonObject json, JsonContext context)
|
||||
{
|
||||
if (json.has("ingredients"))
|
||||
{
|
||||
@@ -581,11 +580,12 @@ public class CraftingHelper {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T getClassInstance(String clsName, Class<T> expected)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> cls = Class.forName(clsName);
|
||||
Class<?> cls = Class.forName(clsName, true, Thread.currentThread().getContextClassLoader());
|
||||
if (!expected.isAssignableFrom(cls))
|
||||
throw new JsonSyntaxException("Class '" + clsName + "' is not an " + expected.getSimpleName());
|
||||
return (T)cls.newInstance();
|
||||
@@ -612,229 +612,97 @@ public class CraftingHelper {
|
||||
reg.clear();
|
||||
else if (revertFrozen)
|
||||
GameData.revert(RegistryManager.FROZEN, GameData.RECIPES, false);
|
||||
//ModContainer old = Loader.instance().activeModContainer();
|
||||
Loader.instance().setActiveModContainer(null);
|
||||
Loader.instance().getActiveModList().forEach(CraftingHelper::loadFactories);
|
||||
Loader.instance().getActiveModList().forEach(CraftingHelper::loadRecipes);
|
||||
Loader.instance().setActiveModContainer(null);
|
||||
|
||||
ModList.get().forEachModFile(CraftingHelper::loadFactories);
|
||||
ModList.get().forEachModFile(CraftingHelper::loadRecipes);
|
||||
|
||||
GameData.fireRegistryEvents(rl -> rl.equals(GameData.RECIPES));
|
||||
|
||||
//reg.freeze();
|
||||
FMLCommonHandler.instance().resetClientRecipeBook();
|
||||
SidedExecutor.runOn(Dist.CLIENT, ()-> {
|
||||
RecipeBookClient.rebuildTable();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private static void loadFactories(ModContainer mod)
|
||||
private static void loadFactories(final ModFile modFile)
|
||||
{
|
||||
FileSystem fs = null;
|
||||
BufferedReader reader = null;
|
||||
try
|
||||
{
|
||||
JsonContext ctx = new JsonContext(mod.getModId());
|
||||
Path fPath = null;
|
||||
if (mod.getSource().isFile())
|
||||
{
|
||||
fs = FileSystems.newFileSystem(mod.getSource().toPath(), null);
|
||||
fPath = fs.getPath("/assets/" + ctx.getModId() + "/recipes/_factories.json");
|
||||
}
|
||||
else if (mod.getSource().isDirectory())
|
||||
{
|
||||
fPath = mod.getSource().toPath().resolve("assets/" + ctx.getModId() + "/recipes/_factories.json");
|
||||
}
|
||||
modFile.getModInfos().forEach(modInfo-> {
|
||||
final String modId = modInfo.getModId();
|
||||
JsonContext ctx = new JsonContext(modId);
|
||||
final Path fPath = modFile.getLocator().findPath(modFile, "assets", modId, "recipes","_factories.json");
|
||||
if (fPath != null && Files.exists(fPath))
|
||||
{
|
||||
reader = Files.newBufferedReader(fPath);
|
||||
JsonObject json = JsonUtils.fromJson(GSON, reader, JsonObject.class);
|
||||
loadFactories(json, ctx);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(fs);
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean loadRecipes(ModContainer mod)
|
||||
{
|
||||
JsonContext ctx = new JsonContext(mod.getModId());
|
||||
|
||||
return findFiles(mod, "assets/" + mod.getModId() + "/recipes",
|
||||
root ->
|
||||
{
|
||||
Path fPath = root.resolve("_constants.json");
|
||||
if (fPath != null && Files.exists(fPath))
|
||||
try (final BufferedReader reader = Files.newBufferedReader(fPath))
|
||||
{
|
||||
BufferedReader reader = null;
|
||||
try
|
||||
{
|
||||
reader = Files.newBufferedReader(fPath);
|
||||
JsonObject[] json = JsonUtils.fromJson(GSON, reader, JsonObject[].class);
|
||||
ctx.loadConstants(json);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("Error loading _constants.json: ", e);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
(root, file) ->
|
||||
{
|
||||
Loader.instance().setActiveModContainer(mod);
|
||||
|
||||
String relative = root.relativize(file).toString();
|
||||
if (!"json".equals(FilenameUtils.getExtension(file.toString())) || relative.startsWith("_"))
|
||||
return true;
|
||||
|
||||
String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/");
|
||||
ResourceLocation key = new ResourceLocation(ctx.getModId(), name);
|
||||
|
||||
BufferedReader reader = null;
|
||||
try
|
||||
{
|
||||
reader = Files.newBufferedReader(file);
|
||||
JsonObject json = JsonUtils.fromJson(GSON, reader, JsonObject.class);
|
||||
if (json.has("conditions") && !CraftingHelper.processConditions(JsonUtils.getJsonArray(json, "conditions"), ctx))
|
||||
return true;
|
||||
IRecipe recipe = CraftingHelper.getRecipe(json, ctx);
|
||||
ForgeRegistries.RECIPES.register(recipe.setRegistryName(key));
|
||||
loadFactories(json, ctx);
|
||||
}
|
||||
catch (JsonParseException e)
|
||||
catch (final IOException e)
|
||||
{
|
||||
FMLLog.log.error("Parsing error loading recipe {}", key, e);
|
||||
return false;
|
||||
LOGGER.error(CRAFTHELPER,"Encountered error reading recipe factories for {}", modId, e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("Couldn't read recipe {} from {}", key, file, e);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
true, true
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link CraftingHelper#findFiles(ModContainer, String, Function, BiFunction, boolean, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean findFiles(ModContainer mod, String base, Function<Path, Boolean> preprocessor, BiFunction<Path, Path, Boolean> processor)
|
||||
private static boolean loadRecipes(final ModFile modFile)
|
||||
{
|
||||
return findFiles(mod, base, preprocessor, processor, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link CraftingHelper#findFiles(ModContainer, String, Function, BiFunction, boolean, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean findFiles(ModContainer mod, String base, Function<Path, Boolean> preprocessor, BiFunction<Path, Path, Boolean> processor, boolean defaultUnfoundRoot)
|
||||
{
|
||||
return findFiles(mod, base, preprocessor, processor, defaultUnfoundRoot, false);
|
||||
}
|
||||
|
||||
public static boolean findFiles(ModContainer mod, String base, Function<Path, Boolean> preprocessor, BiFunction<Path, Path, Boolean> processor, boolean defaultUnfoundRoot, boolean visitAllFiles)
|
||||
{
|
||||
FileSystem fs = null;
|
||||
try
|
||||
{
|
||||
File source = mod.getSource();
|
||||
|
||||
if ("minecraft".equals(mod.getModId()))
|
||||
final AtomicBoolean errored = new AtomicBoolean(false);
|
||||
modFile.getModInfos().forEach(modInfo-> {
|
||||
final String modId = modInfo.getModId();
|
||||
JsonContext ctx = new JsonContext(modId);
|
||||
final Path root = modFile.getLocator().findPath(modFile, "assets", modId, "recipes");
|
||||
if (!Files.exists(root)) return;
|
||||
final Path constants = modFile.getLocator().findPath(modFile, "assets", modId, "recipes", "_constants.json");
|
||||
if (Files.exists(constants))
|
||||
{
|
||||
if (!DEBUG_LOAD_MINECRAFT)
|
||||
return true;
|
||||
|
||||
try
|
||||
try (BufferedReader reader = Files.newBufferedReader(constants))
|
||||
{
|
||||
URI tmp = CraftingManager.class.getResource("/assets/.mcassetsroot").toURI();
|
||||
source = new File(tmp.resolve("..").getPath());
|
||||
JsonObject[] json = JsonUtils.fromJson(GSON, reader, JsonObject[].class);
|
||||
ctx.loadConstants(json);
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
catch (final IOException e)
|
||||
{
|
||||
FMLLog.log.error("Error finding Minecraft jar: ", e);
|
||||
return false;
|
||||
LOGGER.error(CRAFTHELPER, "Error loading _constants.json: ", e);
|
||||
errored.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
Path root = null;
|
||||
if (source.isFile())
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
fs = FileSystems.newFileSystem(source.toPath(), null);
|
||||
root = fs.getPath("/" + base);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("Error loading FileSystem from jar: ", e);
|
||||
return false;
|
||||
}
|
||||
Files.walk(root).
|
||||
filter(p -> p.getFileName().toString().startsWith("_") || Objects.equals(FilenameUtils.getExtension(p.getFileName().toString()), "json")).
|
||||
forEach(p -> {
|
||||
final String relative = root.relativize(p).toString();
|
||||
final String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/");
|
||||
final ResourceLocation key = new ResourceLocation(modId, name);
|
||||
try (BufferedReader reader = Files.newBufferedReader(constants))
|
||||
{
|
||||
JsonObject json = JsonUtils.fromJson(GSON, reader, JsonObject.class);
|
||||
if (json.has("conditions") && !CraftingHelper.processConditions(JsonUtils.getJsonArray(json, "conditions"), ctx))
|
||||
return;
|
||||
IRecipe recipe = CraftingHelper.getRecipe(json, ctx);
|
||||
ForgeRegistries.RECIPES.register(recipe.setRegistryName(key));
|
||||
}
|
||||
catch (final JsonParseException e)
|
||||
{
|
||||
LOGGER.error(CRAFTHELPER, "Parsing error loading recipe {}", key, e);
|
||||
errored.set(true);
|
||||
}
|
||||
catch (final IOException e)
|
||||
{
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't read recipe {} from {}", key, p, e);
|
||||
errored.set(true);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else if (source.isDirectory())
|
||||
catch (final IOException e)
|
||||
{
|
||||
root = source.toPath().resolve(base);
|
||||
LOGGER.error(CRAFTHELPER, "Error occurred walking file tree", e);
|
||||
errored.set(true);
|
||||
}
|
||||
|
||||
if (root == null || !Files.exists(root))
|
||||
return defaultUnfoundRoot;
|
||||
|
||||
if (preprocessor != null)
|
||||
{
|
||||
Boolean cont = preprocessor.apply(root);
|
||||
if (cont == null || !cont.booleanValue())
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean success = true;
|
||||
|
||||
if (processor != null)
|
||||
{
|
||||
Iterator<Path> itr = null;
|
||||
try
|
||||
{
|
||||
itr = Files.walk(root).iterator();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.error("Error iterating filesystem for: {}", mod.getModId(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
while (itr != null && itr.hasNext())
|
||||
{
|
||||
Boolean cont = processor.apply(root, itr.next());
|
||||
|
||||
if (visitAllFiles)
|
||||
{
|
||||
success &= cont != null && cont;
|
||||
}
|
||||
else if (cont == null || !cont)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(fs);
|
||||
}
|
||||
});
|
||||
return errored.get();
|
||||
}
|
||||
}
|
||||
@@ -39,14 +39,14 @@ import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import java.util.Optional;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/*
|
||||
@@ -93,50 +93,26 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
||||
full = true;
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #from(ItemTransformVec3f)} */
|
||||
@Deprecated // TODO: remove / make private
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TRSRTransformation(ItemTransformVec3f transform)
|
||||
{
|
||||
this(toVecmath(transform.translation), quatFromXYZDegrees(toVecmath(transform.rotation)), toVecmath(transform.scale), null);
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #from(ModelRotation)} */
|
||||
@Deprecated // TODO: remove
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TRSRTransformation(ModelRotation rotation)
|
||||
{
|
||||
this(rotation.getMatrix());
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #from(EnumFacing)} */
|
||||
@Deprecated // TODO: remove
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TRSRTransformation(EnumFacing facing)
|
||||
{
|
||||
this(getMatrix(facing));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static TRSRTransformation from(ItemTransformVec3f transform)
|
||||
{
|
||||
return transform.equals(ItemTransformVec3f.DEFAULT) ? identity : new TRSRTransformation(transform);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static TRSRTransformation from(ModelRotation rotation)
|
||||
{
|
||||
return Cache.get(rotation);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static TRSRTransformation from(EnumFacing facing)
|
||||
{
|
||||
return Cache.get(getRotation(facing));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static Matrix4f getMatrix(EnumFacing facing)
|
||||
{
|
||||
return getRotation(facing).getMatrix();
|
||||
@@ -558,8 +534,8 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
||||
* Don't use this if you don't need to, conversion is lossy (second rotation component is lost).
|
||||
*/
|
||||
@Deprecated
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemTransformVec3f toItemTransform()
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public net.minecraft.client.renderer.block.model.ItemTransformVec3f toItemTransform()
|
||||
{
|
||||
return new ItemTransformVec3f(toLwjgl(toXYZDegrees(getLeftRot())), toLwjgl(getTranslation()), toLwjgl(getScale()));
|
||||
}
|
||||
@@ -712,19 +688,19 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
||||
return Objects.equals(matrix, other.matrix);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static Vector3f toVecmath(org.lwjgl.util.vector.Vector3f vec)
|
||||
{
|
||||
return new Vector3f(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static Vector4f toVecmath(org.lwjgl.util.vector.Vector4f vec)
|
||||
{
|
||||
return new Vector4f(vec.x, vec.y, vec.z, vec.w);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static Matrix4f toVecmath(org.lwjgl.util.vector.Matrix4f m)
|
||||
{
|
||||
return new Matrix4f(
|
||||
@@ -734,19 +710,19 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
||||
m.m03, m.m13, m.m23, m.m33);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static org.lwjgl.util.vector.Vector3f toLwjgl(Vector3f vec)
|
||||
{
|
||||
return new org.lwjgl.util.vector.Vector3f(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static org.lwjgl.util.vector.Vector4f toLwjgl(Vector4f vec)
|
||||
{
|
||||
return new org.lwjgl.util.vector.Vector4f(vec.x, vec.y, vec.z, vec.w);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static org.lwjgl.util.vector.Matrix4f toLwjgl(Matrix4f m)
|
||||
{
|
||||
org.lwjgl.util.vector.Matrix4f r = new org.lwjgl.util.vector.Matrix4f();
|
||||
@@ -847,7 +823,7 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static final class Cache
|
||||
{
|
||||
private static final Map<ModelRotation, TRSRTransformation> rotations = new EnumMap<>(ModelRotation.class);
|
||||
|
||||
@@ -43,14 +43,14 @@ import com.google.gson.stream.JsonWriter;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.animation.Event;
|
||||
import net.minecraftforge.common.animation.ITimeValue;
|
||||
import net.minecraftforge.common.animation.TimeValues;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.util.JsonUtils;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
@@ -213,7 +213,7 @@ public final class AnimationStateMachine implements IAnimationStateMachine
|
||||
/**
|
||||
* Load a new instance if AnimationStateMachine at specified location, with specified custom parameters.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static IAnimationStateMachine load(IResourceManager manager, ResourceLocation location, ImmutableMap<String, ITimeValue> customParameters)
|
||||
{
|
||||
try (IResource resource = manager.getResource(location))
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.animation.Event;
|
||||
@@ -33,8 +34,7 @@ import net.minecraftforge.common.model.IModelPart;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -88,7 +88,7 @@ public final class Clips
|
||||
/**
|
||||
* Retrieves the clip from the model.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static IClip getModelClipNode(ResourceLocation modelLocation, String clipName)
|
||||
{
|
||||
IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
|
||||
|
||||
@@ -20,21 +20,22 @@
|
||||
package net.minecraftforge.common.network;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
|
||||
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
|
||||
import net.minecraftforge.fml.common.network.FMLOutboundHandler.OutboundTarget;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
public class ForgeNetworkHandler
|
||||
{
|
||||
private static EnumMap<Side, FMLEmbeddedChannel> channelPair;
|
||||
|
||||
public static void registerChannel(ForgeModContainer forgeModContainer, Side side)
|
||||
public static void registerChannel(ForgeMod forgeMod, Side side)
|
||||
{
|
||||
channelPair = NetworkRegistry.INSTANCE.newChannel(forgeModContainer, "FORGE", new ForgeRuntimeCodec());
|
||||
channelPair = NetworkRegistry.INSTANCE.newChannel(forgeMod, "FORGE", new ForgeRuntimeCodec());
|
||||
if (side == Side.CLIENT)
|
||||
{
|
||||
addClientHandlers();
|
||||
@@ -46,7 +47,7 @@ public class ForgeNetworkHandler
|
||||
serverChannel.pipeline().addAfter(handlerName, "ServerToClientConnection", new ServerToClientConnectionEstablishedHandler());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void addClientHandlers()
|
||||
{
|
||||
FMLEmbeddedChannel clientChannel = channelPair.get(Side.CLIENT);
|
||||
|
||||
Reference in new issue
Block a user