Java Code Examples for net.minecraftforge.fml.common.FMLCommonHandler

The following are top voted examples for showing how to use net.minecraftforge.fml.common.FMLCommonHandler. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: pnc-repressurized   File: IGWSupportNotifier.java   Source Code and License 7 votes vote down vote up
/**
 * 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();
    }
}
 
Example 2
Project: ExPetrum   File: ExPHandlerServer.java   Source Code and License 7 votes vote down vote up
@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);
        }
    }
}
 
Example 3
Project: ExPetrum   File: PlayerManager.java   Source Code and License 6 votes vote down vote up
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;
	}
}
 
Example 4
Project: pnc-repressurized   File: GuiHelmetMainOptions.java   Source Code and License 6 votes vote down vote up
@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;
    }
}
 
Example 5
Project: Proyecto-DASI   File: CommandForWheeledRobotNavigationImplementation.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 6
Project: pnc-repressurized   File: TickHandlerPneumaticCraft.java   Source Code and License 6 votes vote down vote up
@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();
        }
    }
}
 
Example 7
Project: Clef   File: AbcLibrary.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 8
Project: DebugServerInfo   File: ServerHelper.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 9
Project: ExPetrum   File: PlayerManager.java   Source Code and License 6 votes vote down vote up
@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);
	}
}
 
Example 10
Project: CustomWorldGen   File: DimensionManager.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 11
Project: Proyecto-DASI   File: MalmoModClient.java   Source Code and License 6 votes vote down vote up
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);
   }
 
Example 12
Project: Torched   File: EventHandlerServer.java   Source Code and License 6 votes vote down vote up
@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();
                }
            }
        }
    }
}
 
Example 13
Project: CreeperHostGui   File: CreeperHostServer.java   Source Code and License 6 votes vote down vote up
@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());
    }
}
 
Example 14
Project: LagGoggles   File: TeleportRequestHandler.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 15
Project: ExPetrum   File: PackInfo.java   Source Code and License 6 votes vote down vote up
@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());
}
 
Example 16
Project: Proyecto-DASI   File: CommandForWheeledRobotNavigationImplementation.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 17
Project: CustomWorldGen   File: EntitySpawnHandler.java   Source Code and License 6 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, final EntityMessage msg) throws Exception
{
    IThreadListener thread = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());
    if (thread.isCallingFromMinecraftThread())
    {
        process(msg);
    }
    else
    {
        thread.addScheduledTask(new Runnable()
        {
            public void run()
            {
                EntitySpawnHandler.this.process(msg);
            }
        });
    }
}
 
Example 18
Project: CustomWorldGen   File: EntityRegistry.java   Source Code and License 6 votes vote down vote up
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
    EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates);
    try
    {
        entityClassRegistrations.put(entityClass, er);
        entityNames.put(entityName, mc);
        if (!EntityList.CLASS_TO_NAME.containsKey(entityClass))
        {
            String entityModName = String.format("%s.%s", mc.getModId(), entityName);
            EntityList.CLASS_TO_NAME.put(entityClass, entityModName);
            EntityList.NAME_TO_CLASS.put(entityModName, entityClass);
            FMLLog.finer("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName);
        }
        else
        {
            FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName());
        }
    }
    catch (IllegalArgumentException e)
    {
        FMLLog.log(Level.WARN, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName());
        return;
    }
    entityRegistrations.put(mc, er);
}
 
Example 19
Project: pnc-repressurized   File: GuiSearchUpgradeOptions.java   Source Code and License 5 votes vote down vote up
@Override
public void actionPerformed(GuiButton button) {
    if (button.id == 10) {
        searchGui = new GuiSearcher(player);
        if (!player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty()) {
            searchGui.setSearchStack(ItemPneumaticArmor.getSearchedStack(player.getItemStackFromSlot(EntityEquipmentSlot.HEAD)));
        }
        FMLClientHandler.instance().showGuiScreen(searchGui);
    } else {
        FMLCommonHandler.instance().showGuiScreen(new GuiMoveStat(renderHandler));
    }
}
 
Example 20
Project: pnc-repressurized   File: EntityDrone.java   Source Code and License 5 votes vote down vote up
private void initializeFakePlayer() {
    fakePlayer = new DroneFakePlayer(
            (WorldServer) world,
            new GameProfile(UUID.fromString(getOwnerUUID()), playerName),
            this);
    fakePlayer.connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer);
    fakePlayer.inventory = new InventoryFakePlayer(fakePlayer);
}
 
Example 21
Project: ExPetrum   File: PacketHandlerPlayerData.java   Source Code and License 5 votes vote down vote up
@Override
public NBTTagCompound handleRequest(String requester)
{
	EntityPlayerMP requesterPlayer = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(requester);
	IExPPlayer player = IExPPlayer.of(requesterPlayer);
	return player.serializeNBT();
}
 
Example 22
Project: World-Border   File: WorldFillTask.java   Source Code and License 5 votes vote down vote up
/** Starts this task by registering the tick handler */
public void start()
{
    if (INSTANCE != this)
        throw new IllegalStateException("Cannot start a stopped task");

    FMLCommonHandler.instance().bus().register(this);
}
 
Example 23
Project: pnc-repressurized   File: PlayerHealthSensor.java   Source Code and License 5 votes vote down vote up
@Override
public int getRedstoneValue(World world, BlockPos pos, int sensorRange, String textBoxText) {
    EntityPlayer player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(textBoxText);
    if (player != null) {
        return (int) (15 * player.getHealth() / player.getMaxHealth());
    } else {
        return 0;
    }
}
 
Example 24
Project: pnc-repressurized   File: WorldTicktimeSensor.java   Source Code and License 5 votes vote down vote up
@Override
public int getRedstoneValue(World world, BlockPos pos, int sensorRange, String textBoxText) {
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    double worldTickTime = mean(server.worldTickTimes.get(world.provider.getDimension())) * 1.0E-6D;
    try {
        int redstoneStrength = (int) (worldTickTime * Double.parseDouble(textBoxText));
        return Math.min(15, redstoneStrength);
    } catch (Exception e) {
        return 0;
    }
}
 
Example 25
Project: Proyecto-DASI   File: VideoHook.java   Source Code and License 5 votes vote down vote up
/**
 * Stop sending video.
 */
public void stop()
{
    if( !this.isRunning )
    {
        return;
    }
    if (this.videoProducer != null)
        this.videoProducer.cleanup();

    // stop sending video frames
    try
    {
        MinecraftForge.EVENT_BUS.unregister(this);
        FMLCommonHandler.instance().bus().unregister(this); 
    }
    catch(Exception e)
    {
        System.out.println("Failed to unregister video hook: " + e);
    }
    // Close our TCP socket:
    this.connection.close();
    this.isRunning = false;

    // allow the user to resize the window again
    Display.setResizable(true);
}
 
Example 26
Project: pnc-repressurized   File: TileEntityProgrammableController.java   Source Code and License 5 votes vote down vote up
private void initializeFakePlayer() {
    String playerName = "Drone";
    fakePlayer = new DroneFakePlayer((WorldServer) getWorld(), new GameProfile(null, playerName), this);
    fakePlayer.connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer);
    fakePlayer.inventory = new InventoryPlayer(fakePlayer) {
        private ItemStack oldStack;

        @Override
        public int getSizeInventory() {
            return getDroneSlots();
        }

        @Override
        public void setInventorySlotContents(int slot, ItemStack stack) {
            super.setInventorySlotContents(slot, stack);
            if (slot == 0) {
                for (EntityEquipmentSlot ee : EntityEquipmentSlot.values()) {
                    if (!oldStack.isEmpty()) {
                        getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers(ee));
                    }
                    if (!stack.isEmpty()) {
                        getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers(ee));
                    }
                }
                oldStack = stack;
            }
        }
    };
}
 
Example 27
Project: ModularMachinery   File: IntegrationIC2EventHandlerHelper.java   Source Code and License 5 votes vote down vote up
public static void fireLoadEvent(World world, IEnergyTile tileEnergyInputHatch) {
    MinecraftServer ms = FMLCommonHandler.instance().getMinecraftServerInstance();
    if(ms != null) {
        ms.addScheduledTask(() -> {
            if(!world.isRemote) {
                MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(tileEnergyInputHatch));
            }
        });
    }
}
 
Example 28
Project: Teleporting-XP   File: TeleportingXP.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
	World world = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld();
	
	world.getGameRules().setOrCreateGameRule("teleportXP", "false");
}
 
Example 29
Project: Proyecto-DASI   File: CommandForWheeledRobotNavigationImplementation.java   Source Code and License 5 votes vote down vote up
@Override
public void deinstall(MissionInit missionInit)
{
    // Restore the player's normal movement control:
    EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
    if (player != null)
    {
        player.movementInput = this.originalMovement;
    }
    
    FMLCommonHandler.instance().bus().unregister(this);
    MinecraftForge.EVENT_BUS.unregister(this);
}
 
Example 30
Project: Dynamic-GUIs   File: PacketToServer.java   Source Code and License 5 votes vote down vote up
@Override
public IMessage onMessage(final PacketToServer message, final MessageContext ctx) {
	FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(new Runnable() {
		
		@Override
		public void run() {
			if (message.tag != null && message.handler != null) {
				message.handler.manageData(message.tag, ctx);
			}
		}
	});
	return null;
}
 
Example 31
Project: mc-XPBox   File: MessageXP.java   Source Code and License 5 votes vote down vote up
@Override
public IMessage onMessage(MessageXP message, MessageContext ctx) {
   FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(
         () -> {
            if (null == GuiXPBox.instance)
               Minecraft.getMinecraft().displayGuiScreen(
                     new GuiXPBox(message.xp, message.playerXP));
            else
               GuiXPBox.instance.setXPAndPlayerXP(message.xp, message.playerXP);
         });
   return null;
}
 
Example 32
Project: JustJunk   File: ClientProxy.java   Source Code and License 5 votes vote down vote up
@Override
public void init() {
    ModItems.registerRenders();
    ModBlocks.registerRenders();
    MinecraftForge.EVENT_BUS.register(new EventHandlerCommon());
    FMLCommonHandler.instance().bus().register(new FMLEventHandlerCommon());
}
 
Example 33
Project: Bewitchment   File: ClientProxy.java   Source Code and License 5 votes vote down vote up
private boolean doParticle() {
	if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
		return false;

	float chance = 1F;
	if (Minecraft.getMinecraft().gameSettings.particleSetting == 1)
		chance = 0.6F;
	else if (Minecraft.getMinecraft().gameSettings.particleSetting == 2)
		chance = 0.2F;

	return chance == 1F || Math.random() < chance;
}
 
Example 34
Project: harshencastle   File: HarshenUtils.java   Source Code and License 5 votes vote down vote up
public static void registerHandlers(Object... handlers)
{
	for(Object o : handlers)
   	{
   		MinecraftForge.EVENT_BUS.register(o);
       	FMLCommonHandler.instance().bus().register(o);
   	}
}
 
Example 35
Project: GlobalXP   File: CPacketRequestXPBlockUpdate.java   Source Code and License 5 votes vote down vote up
@Override
public SPacketUpdateXPBlock onMessage(CPacketRequestXPBlockUpdate message, MessageContext ctx)
{
	TileEntityXPBlock te = (TileEntityXPBlock)FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.dimension).getTileEntity(message.pos);
	
	if(te != null)
		return new SPacketUpdateXPBlock(te);
	else
		return null;
}
 
Example 36
Project: BetterBeginningsReborn   File: ChatUtil.java   Source Code and License 5 votes vote down vote up
public static void sendChatToServer(String message)
{
	MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
	for (EntityPlayerMP aPlayerEntityList : server.getPlayerList().getPlayers())
	{
		EntityPlayerMP player = aPlayerEntityList;
		player.sendMessage(new TextComponentString(message));
	}
}
 
Example 37
Project: Proyecto-DASI   File: BuildBattleDecoratorImplementation.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(MissionInit missionInit)
{
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    updateAndScorePlayerVolume(MinecraftServer.getServer().getEntityWorld(), false);
}
 
Example 38
Project: VanillaExtras   File: PacketGetWorker.java   Source Code and License 5 votes vote down vote up
@Override
public IMessage onMessage(PacketGetWorker message, MessageContext ctx) {
	if (!message.messageValid && ctx.side != Side.SERVER)
		return null;
	FMLCommonHandler.instance().getWorldThread(ctx.netHandler)
			.addScheduledTask(() -> processMessage(message, ctx));
	return null;
}
 
Example 39
Project: RunicArcana   File: PacketSendDust.java   Source Code and License 5 votes vote down vote up
@Override
public IMessage onMessage(PacketSendDust message, MessageContext ctx) {
    // Always use a construct like this to actually handle your message. This ensures that
    // your 'handle' code is run on the main Minecraft thread. 'onMessage' itself
    // is called on the networking thread so it is not safe to do a lot of things
    // here.
    int breakP = 0;
    FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> handle(message, ctx));
    return null;
}
 
Example 40
Project: World-Border   File: WorldTrimTask.java   Source Code and License 5 votes vote down vote up
/** Starts this task by registering the tick handler */
public void start()
{
    if (INSTANCE != this)
        throw new IllegalStateException("Cannot start a stopped task");

    FMLCommonHandler.instance().bus().register(this);
}