當前位置: 首頁>>代碼示例>>Java>>正文


Java FMLCommonHandler類代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:26,代碼來源:IGWSupportNotifier.java

示例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);
        }
    }
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:17,代碼來源:ExPHandlerServer.java

示例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;
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:19,代碼來源:PlayerManager.java

示例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;
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:20,代碼來源:GuiHelmetMainOptions.java

示例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);
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:18,代碼來源:CommandForWheeledRobotNavigationImplementation.java

示例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();
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:18,代碼來源:TickHandlerPneumaticCraft.java

示例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;
}
 
開發者ID:iChun,項目名稱:Clef,代碼行數:25,代碼來源:AbcLibrary.java

示例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;
}
 
開發者ID:dries007,項目名稱:DebugServerInfo,代碼行數:24,代碼來源:ServerHelper.java

示例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);
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:19,代碼來源:PlayerManager.java

示例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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:DimensionManager.java

示例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);
   }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:18,代碼來源:MalmoModClient.java

示例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();
                }
            }
        }
    }
}
 
開發者ID:iChun,項目名稱:Torched,代碼行數:27,代碼來源:EventHandlerServer.java

示例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());
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:17,代碼來源:CreeperHostServer.java

示例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;
}
 
開發者ID:TerminatorNL,項目名稱:LagGoggles,代碼行數:21,代碼來源:TeleportRequestHandler.java

示例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());
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:25,代碼來源:PackInfo.java


注:本文中的net.minecraftforge.fml.common.FMLCommonHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。