本文整理汇总了Java中net.minecraftforge.fml.common.FMLCommonHandler类的典型用法代码示例。如果您正苦于以下问题:Java FMLCommonHandler类的具体用法?Java FMLCommonHandler怎么用?Java FMLCommonHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FMLCommonHandler类属于net.minecraftforge.fml.common包,在下文中一共展示了FMLCommonHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IGWSupportNotifier
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
/**
* Needs to be instantiated somewhere in your mod's loading stage.
*/
public IGWSupportNotifier() {
if (FMLCommonHandler.instance().getSide() == Side.CLIENT && !Loader.isModLoaded("IGWMod")) {
File dir = new File(".", "config");
Configuration config = new Configuration(new File(dir, "IGWMod.cfg"));
config.load();
if (config.get(Configuration.CATEGORY_GENERAL, "enable_missing_notification", true, "When enabled, this will notify players when IGW-Mod is not installed even though mods add support.").getBoolean()) {
ModContainer mc = Loader.instance().activeModContainer();
String modid = mc.getModId();
List<ModContainer> loadedMods = Loader.instance().getActiveModList();
for (ModContainer container : loadedMods) {
if (container.getModId().equals(modid)) {
supportingMod = container.getName();
MinecraftForge.EVENT_BUS.register(this);
ClientCommandHandler.instance.registerCommand(new CommandDownloadIGW());
break;
}
}
}
config.save();
}
}
示例2: onClientLogIn
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@SubscribeEvent
public void onClientLogIn(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event)
{
// Should be always true but mods can throw this event at any time...
if (event.player instanceof EntityPlayerMP)
{
if (FMLCommonHandler.instance().getMinecraftServerInstance().isDedicatedServer())
{
SettingsManager.restoreAllClientData();
}
else
{
SettingsManager.sendSettingsToClient((EntityPlayerMP) event.player);
}
}
}
示例3: getExhaustion
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
public static float getExhaustion(EntityPlayer of)
{
FoodStats stats = of.getFoodStats();
if (!foodExhaustionLevelFld.isAccessible())
{
foodExhaustionLevelFld.setAccessible(true);
}
try
{
return foodExhaustionLevelFld.getFloat(stats);
}
catch (Exception ex)
{
FMLCommonHandler.instance().raiseException(ex, "ExPetrum was unable to reflect player's FoodStats!", true);
return -1;
}
}
示例4: actionPerformed
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@Override
public void actionPerformed(GuiButton button) {
switch (button.id) {
case 10:
FMLClientHandler.instance().getClient().player.closeScreen();
FMLCommonHandler.instance().showGuiScreen(new GuiMoveStat(renderHandler));
break;
case 11:
FMLClientHandler.instance().getClient().player.closeScreen();
renderHandler.testMessageStat = new GuiAnimatedStat(null, "Test Message, keep in mind messages can be long!", renderHandler.messagesStatX, renderHandler.messagesStatY, 0x7000AA00, null, renderHandler.messagesStatLeftSided);
renderHandler.testMessageStat.openWindow();
FMLCommonHandler.instance().showGuiScreen(new GuiMoveStat(renderHandler, renderHandler.testMessageStat));
break;
case 12:
changingKeybinding = !changingKeybinding;
updateKeybindingButtonText();
break;
}
}
示例5: install
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@Override
public void install(MissionInit missionInit)
{
// Create our movement hook, which allows us to override the Minecraft movement.
this.overrideMovement = new MovementHook(Minecraft.getMinecraft().gameSettings);
EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
if (player != null)
{
// Insert it into the player, keeping a record of the original movement object
// so we can restore it later.
this.originalMovement = player.movementInput;
player.movementInput = this.overrideMovement;
}
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
}
示例6: tickEnd
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@SubscribeEvent
public void tickEnd(TickEvent.WorldTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
World world = event.world;
checkLightning(world);
DroneClaimManager.getInstance(world).update();
if (!event.world.isRemote && event.world.provider.getDimension() == 0 && event.world.getWorldTime() % (24000 / AmadronOfferPeriodicConfig.timesPerDay) == 1) {
AmadronOfferManager.getInstance().shufflePeriodicOffers();
}
if (!event.world.isRemote && event.world.getTotalWorldTime() % 100 == 0) {
double tickTime = net.minecraft.util.math.MathHelper.average(FMLCommonHandler.instance().getMinecraftServerInstance().tickTimeArray) * 1.0E-6D;//In case world are going to get their own thread: MinecraftServer.getServer().worldTickTimes.get(event.world.provider.getDimension())
NetworkHandler.sendToDimension(new PacketServerTickTime(tickTime), event.world.provider.getDimension());
if (event.world.getTotalWorldTime() % 600 == 0)
AmadronOfferManager.getInstance().tryRestockCustomOffers();
}
}
}
示例7: readAbc
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
public static boolean readAbc(File file, ArrayList<TrackFile> tracks)
{
if(file.exists() && file.getName().endsWith(".abc"))
{
String md5 = IOUtil.getMD5Checksum(file);
if(!(tracks == AbcLibrary.tracks && hasTrack(md5)))
{
TrackInfo track = AbcParser.parse(file);
if(track != null)
{
tracks.add(new TrackFile(track, file, md5));
Collections.sort(tracks);
if(FMLCommonHandler.instance().getEffectiveSide().isServer() && tracksWaitingForTrackInfo.containsKey(md5))
{
tracksWaitingForTrackInfo.get(md5).setTrack(md5, track);
tracksWaitingForTrackInfo.remove(md5);
}
return true;
}
}
}
return false;
}
示例8: getData
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
public static Data getData()
{
if (data != null) return data;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
Integer[] dimsObj = DimensionManager.getIDs();
TIntDoubleMap map = new TIntDoubleHashMap(dimsObj.length);
for (Integer dim : dimsObj)
{
map.put(dim, mean(server.worldTickTimes.get(dim)) * 1.0E-6D);
}
double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;
int total = (int) (Runtime.getRuntime().totalMemory() / 1024 / 1024);
int max = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024);
int free = (int) (Runtime.getRuntime().freeMemory() / 1024 / 1024);
data = new Data(meanTickTime, map, free, total, max);
return data;
}
示例9: setExhaustion
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@SuppressWarnings("SameParameterValue")
public static void setExhaustion(EntityPlayer of, float f)
{
FoodStats stats = of.getFoodStats();
if (!foodExhaustionLevelFld.isAccessible())
{
foodExhaustionLevelFld.setAccessible(true);
}
try
{
foodExhaustionLevelFld.setFloat(stats, f);
}
catch (Exception ex)
{
FMLCommonHandler.instance().raiseException(ex, "ExPetrum was unable to reflect player's FoodStats!", true);
}
}
示例10: createProviderFor
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
public static WorldProvider createProviderFor(int dim)
{
try
{
if (dimensions.containsKey(dim))
{
WorldProvider ret = getProviderType(dim).createDimension();
ret.setDimension(dim);
return ret;
}
else
{
throw new RuntimeException(String.format("No WorldProvider bound for dimension %d", dim)); //It's going to crash anyway at this point. Might as well be informative
}
}
catch (Exception e)
{
FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occurred trying to create an instance of WorldProvider %d (%s)",
dim, getProviderType(dim)),e);
throw new RuntimeException(e);
}
}
示例11: init
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
public void init(FMLInitializationEvent event)
{
// Register for various events:
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
GameSettings settings = Minecraft.getMinecraft().gameSettings;
setUpExtraKeys(settings);
this.stateMachine = new ClientStateMachine(ClientState.WAITING_FOR_MOD_READY, this);
this.originalMouseHelper = Minecraft.getMinecraft().mouseHelper;
this.mouseHook = new MouseHook();
this.mouseHook.isOverriding = true;
Minecraft.getMinecraft().mouseHelper = this.mouseHook;
setInputType(InputType.AI);
}
示例12: onServerTick
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event)
{
if(event.phase == TickEvent.Phase.END)
{
Iterator<Map.Entry<String, Integer>> ite = playerDelay.entrySet().iterator();
while(ite.hasNext())
{
Map.Entry<String, Integer> e = ite.next();
e.setValue(e.getValue() - 1);
if(e.getValue() == 0)
{
EntityPlayer player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(e.getKey());
if(player != null)
{
shootTorch(player);
}
else
{
ite.remove();
}
}
}
}
}
示例13: clientConnectedtoServer
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@SubscribeEvent
public void clientConnectedtoServer(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
if (!CreeperHost.instance.active)
return;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null || server.isSinglePlayer() || discoverMode != Discoverability.PUBLIC)
return;
INetHandlerPlayServer handler = event.getHandler();
if (handler instanceof NetHandlerPlayServer)
{
EntityPlayerMP entity = ((NetHandlerPlayServer)handler).playerEntity;
playersJoined.add(entity.getUniqueID());
}
}
示例14: onMessage
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@Override
public IMessage onMessage(TeleportRequest message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().player;
if(Perms.isOP(player) == false){
Main.LOGGER.info(player.getName() + " tried to teleport, but was denied to do so!");
return null;
}
new RunInServerThread(new Runnable() {
@Override
public void run() {
Entity e = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityFromUuid(message.uuid);
if(e == null){
player.sendMessage(new TextComponentString(TextFormatting.RED + "Woops! This tile entity no longer exists!"));
return;
}
Teleport.teleportPlayer(player, e.dimension, e.posX, e.posY, e.posZ);
}
});
return null;
}
示例15: getPackLeaderAsEntity
import net.minecraftforge.fml.common.FMLCommonHandler; //导入依赖的package包/类
@Override
public Optional<EntityLivingBase> getPackLeaderAsEntity()
{
if (this.leaderUUID == null)
{
return Optional.empty();
}
if (refPackLeader == null || refPackLeader.get() == null)
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
for (WorldServer world : server.worlds)
{
Entity e = world.getEntityFromUuid(this.leaderUUID);
if (e != null && e instanceof EntityLivingBase)
{
this.refPackLeader = new WeakReference<>((EntityLivingBase) e);
break;
}
}
}
return Optional.ofNullable(refPackLeader.get());
}