Search in sources :

Example 31 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project Geolosys by oitsjustjose.

the class ProPickItem method onDrawScreen.

@SubscribeEvent
@OnlyIn(Dist.CLIENT)
@SuppressWarnings("deprecation")
public void onDrawScreen(RenderGameOverlayEvent.Post event) {
    Minecraft mc = Minecraft.getInstance();
    if (event.getType() != RenderGameOverlayEvent.ElementType.ALL || mc.gameSettings.showDebugInfo || mc.gameSettings.showDebugProfilerChart) {
        return;
    }
    if (mc.player.getHeldItemMainhand().getItem() instanceof ProPickItem || mc.player.getHeldItemOffhand().getItem() instanceof ProPickItem) {
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        RenderSystem.disableLighting();
        int seaLvl = mc.player.getEntityWorld().getSeaLevel();
        int level = (int) (seaLvl - mc.player.getPosY());
        if (level < 0) {
            mc.fontRenderer.drawStringWithShadow(event.getMatrixStack(), I18n.format("geolosys.pro_pick.depth.above", Math.abs(level)), (float) ClientConfig.PROPICK_HUD_X.get(), (float) ClientConfig.PROPICK_HUD_Y.get(), 0xFFFFFFFF);
        } else if (level == 0) {
            mc.fontRenderer.drawStringWithShadow(event.getMatrixStack(), I18n.format("geolosys.pro_pick.depth.at"), (float) ClientConfig.PROPICK_HUD_X.get(), (float) ClientConfig.PROPICK_HUD_Y.get(), 0xFFFFFFFF);
        } else {
            mc.fontRenderer.drawStringWithShadow(event.getMatrixStack(), I18n.format("geolosys.pro_pick.depth.below", Math.abs(level)), (float) ClientConfig.PROPICK_HUD_X.get(), (float) ClientConfig.PROPICK_HUD_Y.get(), 0xFFFFFFFF);
        }
        RenderSystem.color4f(1F, 1F, 1F, 1F);
    }
}
Also used : Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 32 with SubscribeEvent

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

the class SpongeForge method onServerStarted.

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

Example 33 with SubscribeEvent

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

the class TropicraftRenderLayers method registerLayers.

@SubscribeEvent
public static void registerLayers(EntityRenderersEvent.RegisterLayerDefinitions event) {
    KOA_HUNTER_LAYER = registerMain("koa_hunter", KoaModel::create, event);
    TROPI_CREEPER_LAYER = registerMain("tropi_creeper", TropiCreeperModel::create, event);
    IGUANA_LAYER = registerMain("iguana", IguanaModel::create, event);
    UMBRELLA_LAYER = registerMain("umbrella", UmbrellaModel::create, event);
    BEACH_FLOAT_LAYER = registerMain("beach_float", BeachFloatModel::create, event);
    CHAIR_LAYER = registerMain("chair", ChairModel::create, event);
    TROPI_SKELLY_LAYER = registerMain("tropi_skelly", TropiSkellyModel::create, event);
    EIH_LAYER = registerMain("eih", EIHModel::create, event);
    SEA_TURTLE_LAYER = registerMain("sea_turtle", SeaTurtleModel::create, event);
    MARLIN_LAYER = registerMain("marlin", MarlinModel::create, event);
    FAILGULL_LAYER = registerMain("failgull", FailgullModel::create, event);
    DOLPHIN_LAYER = registerMain("dolphin", TropicraftDolphinModel::create, event);
    SEAHORSE_LAYER = registerMain("seahorse", SeahorseModel::create, event);
    TREE_FROG_LAYER = registerMain("tree_frog", TreeFrogModel::create, event);
    SEA_URCHIN_LAYER = registerMain("sea_urchin", SeaUrchinModel::create, event);
    SEA_URCHIN_EGG_ENTITY_LAYER = registerMain("sea_urchin_egg", EggModel::create, event);
    STARFISH_EGG_LAYER = registerMain("starfish_egg", EggModel::create, event);
    V_MONKEY_LAYER = registerMain("v_monkey", VMonkeyModel::create, event);
    PIRANHA_LAYER = registerMain("piranha", PiranhaModel::create, event);
    RIVER_SARDINE_LAYER = registerMain("river_sardine", SardineModel::create, event);
    TROPICAL_FISH_LAYER = registerMain("tropical_fish", TropicraftTropicalFishModel::create, event);
    EAGLE_RAY_LAYER = registerMain("eagle_ray", EagleRayModel::create, event);
    TROPI_SPIDER_EGG_LAYER = registerMain("tropi_spider_egg", EggModel::create, event);
    ASHEN_LAYER = registerMain("ashen", AshenModel::create, event);
    HAMMERHEAD_LAYER = registerMain("hammerhead", SharkModel::create, event);
    SEA_TURTLE_EGG_LAYER = registerMain("turtle_egg", EggModel::create, event);
    TROPI_BEE_LAYER = registerMain("tropi_bee", TropiBeeModel::createBodyLayer, event);
    COWKTAIL_LAYER = registerMain("cowktail", CowModel::createBodyLayer, event);
    MAN_O_WAR_OUTER_LAYER = registerMain("man_o_war", ManOWarModel::createOuterModel, event);
    MAN_O_WAR_GEL_LAYER = registerMain("man_o_war_gel", ManOWarModel::createGelLayerModel, event);
    BAMBOO_MUG = registerMain("bamboo_mug", BambooMugModel::create, event);
    // BAMBOO_CHEST = registerMain("bamboo_chest", BambooChestRenderer);
    // BAMBOO_DOUBLE_CHEST_LEFT = registerMain("bamboo_double_chest_left", () -> BambooChestBlockEntityRenderer.getLeftDoubleTexturedModelData());
    // BAMBOO_DOUBLE_CHEST_RIGHT = registerMain("bamboo_double_chest_right", () -> BambooChestBlockEntityRenderer.getRightDoubleTexturedModelData());
    EIHMACHINE_LAYER = registerMain("drink_mixer", EIHMachineModel::create, event);
    AIRCOMPRESSOR_LAYER = registerMain("air_compressor", EIHMachineModel::create, event);
    BASILISK_LIZARD_LAYER = registerMain("basilisk_lizard", BasiliskLizardModel::create, event);
    CUBERA_LAYER = registerMain("cubera", CuberaModel::create, event);
    FIDDLER_CRAB_LAYER = registerMain("fiddler_crab", FiddlerCrabModel::create, event);
    HUMMINGBIRD_LAYER = registerMain("hummingbird", HummingbirdModel::create, event);
    JAGUAR_LAYER = registerMain("jaguar", JaguarModel::create, event);
    TAPIR_LAYER = registerMain("tapir", TapirModel::create, event);
    SPIDER_MONKEY_LAYER = registerMain("spider_monkey", SpiderMonkeyModel::create, event);
    WHITE_LIPPED_PECCARY_LAYER = registerMain("white_lipped_peccary", WhiteLippedPeccaryModel::create, event);
    // ArrayList<MaskArmorProvider> MASK_PROVIDER = new ArrayList<>();
    final List<RegistryObject<AshenMaskItem>> masks = TropicraftItems.ASHEN_MASKS.values().asList();
    for (RegistryObject<AshenMaskItem> maskItem : masks) {
        ModelLayerLocation ashen_mask_layer = registerMain("ashen_mask_" + maskItem.get().getMaskType().name().toLowerCase(Locale.ROOT), PlayerHeadpieceModel::create, event);
        ASHEN_MASK_LAYERS.add(ashen_mask_layer);
    }
    STACHE_LAYER = registerMain("nigel_stache", PlayerHeadpieceModel::create, event);
    HEAD_SCUBA_LAYER = registerMain("scuba_goggles", ModelScubaGear::create, event);
    CHEST_SCUBA_LAYER = registerMain("scuba_harness", ModelScubaGear::create, event);
    FEET_SCUBA_LAYER = registerMain("scuba_flippers", ModelScubaGear::create, event);
    TANK_SCUBA_LAYER = registerMain("pony_bottle", ModelScubaGear::create, event);
    setupScubaGearModels();
}
Also used : PlayerHeadpieceModel(net.tropicraft.core.client.entity.model.PlayerHeadpieceModel) AshenMaskItem(net.tropicraft.core.common.item.AshenMaskItem) RegistryObject(net.minecraftforge.fmllegacy.RegistryObject) ModelLayerLocation(net.minecraft.client.model.geom.ModelLayerLocation) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 34 with SubscribeEvent

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

the class PlayerRotationHandler method onRenderPlayerPost.

@SubscribeEvent
public static void onRenderPlayerPost(RenderPlayerEvent.Post event) {
    Player p = event.getPlayer();
    if (p.getVehicle() instanceof BeachFloatEntity || p.getVehicle() instanceof SeaTurtleEntity) {
        event.getMatrixStack().popPose();
        p.setXRot(rotationPitch);
        p.xRotO = prevRotationPitch;
    }
    if (p.getVehicle() instanceof BeachFloatEntity) {
        p.yHeadRot = rotationYawHead;
        p.yHeadRotO = prevRotationYawHead;
    }
}
Also used : Player(net.minecraft.world.entity.player.Player) BeachFloatEntity(net.tropicraft.core.common.entity.placeable.BeachFloatEntity) SeaTurtleEntity(net.tropicraft.core.common.entity.SeaTurtleEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 35 with SubscribeEvent

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

the class ScubaHUD method renderHUD.

@SubscribeEvent
public static void renderHUD(RenderGameOverlayEvent event) {
    Entity renderViewEntity = Minecraft.getInstance().cameraEntity;
    if (event.getType() == ElementType.TEXT && renderViewEntity instanceof Player) {
        Player player = (Player) renderViewEntity;
        // TODO support other slots than chest?
        ItemStack chestStack = player.getItemBySlot(EquipmentSlot.CHEST);
        Item chestItem = chestStack.getItem();
        if (chestItem instanceof ScubaArmorItem) {
            LazyOptional<ScubaData> data = player.getCapability(ScubaData.CAPABILITY);
            int airRemaining = ((ScubaArmorItem) chestItem).getRemainingAir(chestStack);
            ChatFormatting airColor = getAirTimeColor(airRemaining, player.level);
            double depth = ScubaData.getDepth(player);
            String depthStr;
            if (depth > 0) {
                depthStr = String.format("%.1fm", depth);
            } else {
                depthStr = TropicraftLangKeys.NA.getLocalizedText();
            }
            data.ifPresent(d -> drawHUDStrings(event.getMatrixStack(), TropicraftLangKeys.SCUBA_AIR_TIME.format(airColor + formatTime(airRemaining)), TropicraftLangKeys.SCUBA_DIVE_TIME.format(formatTime(d.getDiveTime())), TropicraftLangKeys.SCUBA_DEPTH.format(depthStr), TropicraftLangKeys.SCUBA_MAX_DEPTH.format(String.format("%.1fm", d.getMaxDepth()))));
        }
    }
}
Also used : Entity(net.minecraft.world.entity.Entity) Item(net.minecraft.world.item.Item) ScubaArmorItem(net.tropicraft.core.common.item.scuba.ScubaArmorItem) ScubaData(net.tropicraft.core.common.item.scuba.ScubaData) Player(net.minecraft.world.entity.player.Player) ChatFormatting(net.minecraft.ChatFormatting) ScubaArmorItem(net.tropicraft.core.common.item.scuba.ScubaArmorItem) ItemStack(net.minecraft.world.item.ItemStack) 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