Search in sources :

Example 61 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project SpongeCommon by SpongePowered.

the class SpongeForge method onServerAboutToStart.

@SubscribeEvent
public void onServerAboutToStart(final FMLServerAboutToStartEvent event) {
    // Save config now that registries have been initialized
    ConfigHandle.setSaveSuppressed(false);
    final Lifecycle lifecycle = Launch.instance().lifecycle();
    lifecycle.establishServerServices();
    lifecycle.establishServerFeatures();
    lifecycle.establishServerRegistries((Server) event.getServer());
    lifecycle.callStartingEngineEvent((Server) event.getServer());
}
Also used : Lifecycle(org.spongepowered.common.launch.Lifecycle) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 62 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project SpongeCommon by SpongePowered.

the class SpongeForge method onServerStoppedEvent.

@SubscribeEvent
public void onServerStoppedEvent(final FMLServerStoppedEvent event) {
    final Lifecycle lifecycle = Launch.instance().lifecycle();
    lifecycle.callStoppingEngineEvent((Server) event.getServer());
}
Also used : Lifecycle(org.spongepowered.common.launch.Lifecycle) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 63 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project AgriCraft by AgriCraft.

the class JsonSyncHandler method onConnect.

@SubscribeEvent
@SuppressWarnings("unused")
public void onConnect(PlayerEvent.PlayerLoggedInEvent event) {
    if (event.getPlayer() instanceof ServerPlayerEntity) {
        ServerPlayerEntity player = (ServerPlayerEntity) event.getPlayer();
        MinecraftServer server = player.getServer();
        if (server != null) {
            if (server.isDedicatedServer()) {
                // always sync on dedicated servers
                this.syncJsons(player);
            } else if (server.getPublic()) {
                // only sync when the server is open to LAN on integrated servers
                this.syncJsons(player);
            }
        }
    }
}
Also used : ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) MinecraftServer(net.minecraft.server.MinecraftServer) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 64 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project AgriCraft by AgriCraft.

the class AnvilHandler method onAnvilUpdate.

@SubscribeEvent
@SuppressWarnings("unused")
public void onAnvilUpdate(AnvilUpdateEvent event) {
    ItemStack armor = ItemStack.EMPTY;
    if (event.getLeft().getItem() == AgriCraft.instance.getModItemRegistry().magnifying_glass) {
        armor = event.getRight();
    } else if (event.getRight().getItem() == AgriCraft.instance.getModItemRegistry().magnifying_glass) {
        armor = event.getLeft();
    }
    if (CapabilityGeneInspector.getInstance().shouldApplyCapability(armor)) {
        if (CapabilityGeneInspector.getInstance().hasInspectionCapability(armor)) {
            return;
        }
        ItemStack output = armor.copy();
        if (CapabilityGeneInspector.getInstance().applyInspectionCapability(output)) {
            // Set the name
            String inputName = event.getName();
            if (inputName == null || inputName.isEmpty()) {
                output.clearCustomName();
            } else {
                output.setDisplayName(new StringTextComponent(inputName));
            }
            // set output and cost
            event.setOutput(output);
            event.setCost(1);
        }
    }
}
Also used : StringTextComponent(net.minecraft.util.text.StringTextComponent) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 65 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project AgriCraft by AgriCraft.

the class JournalViewPointHandler method onPlayerRender.

@SuppressWarnings("unused")
@SubscribeEvent
public void onPlayerRender(RenderPlayerEvent.Pre event) {
    if (event.getPlayer() == AgriCraft.instance.getClientPlayer()) {
        if (event.getRenderer().getEntityModel() instanceof IAnimatablePlayerModel) {
            IAnimatablePlayerModel model = (IAnimatablePlayerModel) event.getRenderer().getEntityModel();
            model.setDoArmWobble(!this.isActive());
        }
    }
}
Also used : IAnimatablePlayerModel(com.infinityraider.infinitylib.modules.playeranimations.IAnimatablePlayerModel) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)87 PlayerEntity (net.minecraft.entity.player.PlayerEntity)18 ItemStack (net.minecraft.item.ItemStack)17 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)11 ResourceLocation (net.minecraft.util.ResourceLocation)10 World (net.minecraft.world.World)8 Player (net.minecraft.world.entity.player.Player)8 BlockPos (net.minecraft.util.math.BlockPos)7 Entity (net.minecraft.world.entity.Entity)7 ItemStack (net.minecraft.world.item.ItemStack)7 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 Minecraft (net.minecraft.client.Minecraft)5 BlockPos (net.minecraft.core.BlockPos)5 ServerPlayer (net.minecraft.server.level.ServerPlayer)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)5 Item (net.minecraft.world.item.Item)5 BlockItem (net.minecraft.item.BlockItem)4 ResourceLocation (net.minecraft.resources.ResourceLocation)4 BlockState (net.minecraft.world.level.block.state.BlockState)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4