2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2018-07-01 21:17:28 +00:00
|
|
|
* Copyright (c) 2016-2018.
|
2016-06-23 03:49:47 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2012-08-05 05:45:31 +00:00
|
|
|
package net.minecraftforge.common;
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.fml.common.FMLLog;
|
2016-05-29 09:37:37 +00:00
|
|
|
import net.minecraftforge.fml.common.ICrashCallable;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.fml.common.Loader;
|
2018-06-11 01:12:46 +00:00
|
|
|
import net.minecraftforge.eventbus.api.IEventBus;
|
2016-05-29 09:37:37 +00:00
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
|
|
import net.minecraft.crash.CrashReport;
|
|
|
|
import net.minecraft.crash.ICrashReportDetail;
|
2012-12-13 07:27:57 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2012-08-06 02:14:02 +00:00
|
|
|
import net.minecraftforge.common.ForgeHooks.SeedEntry;
|
2015-07-09 20:53:31 +00:00
|
|
|
import net.minecraftforge.fluids.FluidRegistry;
|
2012-11-13 01:07:33 +00:00
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
2018-06-22 04:43:25 +00:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
import org.apache.logging.log4j.Marker;
|
|
|
|
import org.apache.logging.log4j.MarkerManager;
|
2012-08-05 05:45:31 +00:00
|
|
|
|
2016-11-18 21:24:03 +00:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2012-08-05 05:45:31 +00:00
|
|
|
public class MinecraftForge
|
2014-02-02 17:34:34 +00:00
|
|
|
{
|
2012-08-06 02:14:02 +00:00
|
|
|
/**
|
2012-11-19 04:27:43 +00:00
|
|
|
* The core Forge EventBusses, all events for Forge will be fired on these,
|
2012-08-06 02:14:02 +00:00
|
|
|
* you should use this to register all your listeners.
|
|
|
|
* This replaces every register*Handler() function in the old version of Forge.
|
2012-11-19 04:27:43 +00:00
|
|
|
* TERRAIN_GEN_BUS for terrain gen events
|
|
|
|
* ORE_GEN_BUS for ore gen events
|
|
|
|
* EVENT_BUS for everything else
|
2012-08-06 02:14:02 +00:00
|
|
|
*/
|
2018-06-11 01:12:46 +00:00
|
|
|
public static final IEventBus EVENT_BUS = IEventBus.create();
|
|
|
|
public static final IEventBus TERRAIN_GEN_BUS = IEventBus.create();
|
|
|
|
public static final IEventBus ORE_GEN_BUS = IEventBus.create();
|
2013-01-20 23:47:04 +00:00
|
|
|
|
2014-02-02 17:34:34 +00:00
|
|
|
static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler();
|
2018-08-27 17:10:07 +00:00
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
2018-06-22 04:43:25 +00:00
|
|
|
private static final Marker FORGE = MarkerManager.getMarker("FORGE");
|
2012-09-22 05:43:54 +00:00
|
|
|
|
|
|
|
/**
|
2012-08-06 02:14:02 +00:00
|
|
|
* Register a new seed to be dropped when breaking tall grass.
|
2012-09-22 05:43:54 +00:00
|
|
|
*
|
2012-08-06 02:14:02 +00:00
|
|
|
* @param seed The item to drop as a seed.
|
2012-09-22 05:43:54 +00:00
|
|
|
* @param weight The relative probability of the seeds,
|
2012-08-06 02:14:02 +00:00
|
|
|
* where wheat seeds are 10.
|
2016-03-15 08:17:38 +00:00
|
|
|
*
|
|
|
|
* Note: These functions may be going away soon, we're looking into loot tables....
|
2012-08-06 02:14:02 +00:00
|
|
|
*/
|
2016-11-18 21:24:03 +00:00
|
|
|
public static void addGrassSeed(@Nonnull ItemStack seed, int weight)
|
2012-08-06 02:14:02 +00:00
|
|
|
{
|
2016-03-15 08:17:38 +00:00
|
|
|
addGrassSeed(new SeedEntry(seed, weight));
|
|
|
|
}
|
|
|
|
public static void addGrassSeed(SeedEntry seed)
|
|
|
|
{
|
|
|
|
ForgeHooks.seedList.add(seed);
|
2012-08-06 02:14:02 +00:00
|
|
|
}
|
2012-09-22 05:43:54 +00:00
|
|
|
|
2012-08-06 10:35:57 +00:00
|
|
|
/**
|
|
|
|
* Method invoked by FML before any other mods are loaded.
|
|
|
|
*/
|
|
|
|
public static void initialize()
|
|
|
|
{
|
2018-06-22 04:43:25 +00:00
|
|
|
LOGGER.info(FORGE,"MinecraftForge v{} Initialized", ForgeVersion.getVersion());
|
2012-09-12 00:35:53 +00:00
|
|
|
|
2012-11-13 01:07:33 +00:00
|
|
|
OreDictionary.getOreName(0);
|
2013-03-09 04:31:37 +00:00
|
|
|
|
2014-10-15 21:14:36 +00:00
|
|
|
UsernameCache.load();
|
2015-07-09 20:53:31 +00:00
|
|
|
// Load before all the mods, so MC owns the MC fluids
|
|
|
|
FluidRegistry.validateFluidRegistry();
|
2016-05-29 05:58:39 +00:00
|
|
|
ForgeHooks.initTools();
|
2016-05-29 09:37:37 +00:00
|
|
|
|
|
|
|
//For all the normal CrashReport classes to be defined. We're in MC's classloader so this should all be fine
|
|
|
|
new CrashReport("ThisIsFake", new Exception("Not real"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void preloadCrashClasses(ASMDataTable table, String modID, Set<String> classes)
|
|
|
|
{
|
|
|
|
//Find all ICrashReportDetail's handlers and preload them.
|
|
|
|
List<String> all = Lists.newArrayList();
|
|
|
|
for (ASMData asm : table.getAll(ICrashReportDetail.class.getName().replace('.', '/')))
|
|
|
|
all.add(asm.getClassName());
|
|
|
|
for (ASMData asm : table.getAll(ICrashCallable.class.getName().replace('.', '/')))
|
|
|
|
all.add(asm.getClassName());
|
|
|
|
|
|
|
|
all.retainAll(classes);
|
|
|
|
|
|
|
|
if (all.size() == 0)
|
|
|
|
return;
|
|
|
|
|
2018-06-21 19:37:32 +00:00
|
|
|
ForgeMod.log.debug("Preloading CrashReport Classes");
|
2016-05-29 09:37:37 +00:00
|
|
|
Collections.sort(all); //Sort it because I like pretty output ;)
|
|
|
|
for (String name : all)
|
|
|
|
{
|
2018-06-21 19:37:32 +00:00
|
|
|
ForgeMod.log.debug("\t{}", name);
|
2016-05-29 09:37:37 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Class.forName(name.replace('/', '.'), false, MinecraftForge.class.getClassLoader());
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2017-06-28 05:56:54 +00:00
|
|
|
FMLLog.log.error("Could not find class for name '{}'.", name, e);
|
2016-05-29 09:37:37 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|
2012-08-05 05:45:31 +00:00
|
|
|
}
|