Search in sources :

Example 76 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project RFToolsDimensions by McJty.

the class ForgeEventHandlers method onOreGenEvent.

@SubscribeEvent
public void onOreGenEvent(OreGenEvent.GenerateMinable event) {
    World world = event.getWorld();
    if (world == null) {
        return;
    }
    WorldProvider provider = world.provider;
    if (!(provider instanceof GenericWorldProvider))
        return;
    DimensionInformation information = ((GenericWorldProvider) provider).getDimensionInformation();
    if (information != null && information.hasFeatureType(FeatureType.FEATURE_CLEAN)) {
        event.setResult(Event.Result.DENY);
    }
}
Also used : GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 77 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Gaspunk by Ladysnake.

the class GasRecipeDeserializer method loadRecipes.

@SubscribeEvent
public static void loadRecipes(RegistryEvent.Register<IRecipe> event) {
    ModContainer gaspunkContainer = Loader.instance().activeModContainer();
    Loader.instance().getActiveModList().forEach(GasRecipeDeserializer::loadRecipes);
    Loader.instance().setActiveModContainer(gaspunkContainer);
    File configFolder = new File(GasPunk.lib.getConfigFolder(), GasPunk.MOD_ID + "/custom_recipes");
    // if the config folder was just created or couldn't be created, no need to search it
    if (!configFolder.mkdirs() && configFolder.exists()) {
        JsonContext context = new JsonContext(GasPunk.MOD_ID);
        try {
            Files.walk(configFolder.toPath()).forEach(path -> loadRecipes(configFolder.toPath(), path, context));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : JsonContext(net.minecraftforge.common.crafting.JsonContext) ModContainer(net.minecraftforge.fml.common.ModContainer) IOException(java.io.IOException) File(java.io.File) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 78 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Gaspunk by Ladysnake.

the class ModItems method registerRenders.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void registerRenders(ModelRegistryEvent event) {
    ModelLoader.setCustomModelResourceLocation(EMPTY_SYRINGE, 0, new ModelResourceLocation(new ResourceLocation("pathos:empty_syringe"), "inventory"));
    ModelLoader.setCustomModelResourceLocation(FILLED_SYRINGE, 0, new ModelResourceLocation(new ResourceLocation("pathos:filled_syringe"), "inventory"));
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 79 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.

the class ClientEventHandler method onRenderGameOverlay.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onRenderGameOverlay(RenderGameOverlayEvent event) {
    if (event.getType().equals(RenderGameOverlayEvent.ElementType.ALL)) {
        if (this.mc.gameSettings.thirdPersonView == 0) {
            if (this.mc.player.isPotionActive(MPPotions.INFECTED_CRYSTALLIZE)) {
                Tessellator tessellator = Tessellator.getInstance();
                BufferBuilder worldrenderer = tessellator.getBuffer();
                GlStateManager.color(1.0F, 1.0F, 1.0F, 0.9F);
                GlStateManager.depthFunc(519);
                GlStateManager.depthMask(false);
                GlStateManager.enableBlend();
                GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
                float f = 1.0F;
                for (int i = 0; i < 2; ++i) {
                    GlStateManager.pushMatrix();
                    TextureAtlasSprite textureatlassprite = this.mc.getTextureMapBlocks().getAtlasSprite("moreplanets:blocks/infected_crystallize");
                    this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
                    float f1 = textureatlassprite.getMinU();
                    float f2 = textureatlassprite.getMaxU();
                    float f3 = textureatlassprite.getMinV();
                    float f4 = textureatlassprite.getMaxV();
                    float f5 = (0.0F - f) / 2.0F;
                    float f6 = f5 + f;
                    float f7 = 0.0F - f / 2.0F;
                    float f8 = f7 + f;
                    float f9 = -0.5F;
                    GlStateManager.translate(-(i * 2 - 1) * 0.24F, -0.3F, 0.0F);
                    GlStateManager.rotate((i * 2 - 1) * 10.0F, 0.0F, 1.0F, 0.0F);
                    worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
                    worldrenderer.pos(f5, f7, f9).tex(f2, f4).endVertex();
                    worldrenderer.pos(f6, f7, f9).tex(f1, f4).endVertex();
                    worldrenderer.pos(f6, f8, f9).tex(f1, f3).endVertex();
                    worldrenderer.pos(f5, f8, f9).tex(f2, f3).endVertex();
                    tessellator.draw();
                    GlStateManager.popMatrix();
                }
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                GlStateManager.disableBlend();
                GlStateManager.depthMask(true);
                GlStateManager.depthFunc(515);
            }
            if (this.isEntityInsideBlock(ChalosBlocks.CHEESE_OF_MILK_GAS_BLOCK)) {
                this.renderOverlay("cheese_of_milk_gas", this.mc.player.getBrightness(), 0.75F, event.getPartialTicks(), -0.25D);
            }
            if (this.isEntityInsideBlock(NibiruBlocks.HELIUM_GAS_BLOCK)) {
                this.renderOverlay("helium_gas", this.mc.player.getBrightness(), 0.75F, event.getPartialTicks(), -0.25D);
            }
        }
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 80 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.

the class ClientEventHandler method onClientTick.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onClientTick(ClientTickEvent event) {
    if (MorePlanetsCore.isObfuscatedEnvironment()) {
        if (Keyboard.isKeyDown(Keyboard.KEY_F7)) {
            try {
                // used for real time debugging item description
                Object proxy = Class.forName("mezz.jei.JustEnoughItems").getDeclaredMethod("getProxy").invoke(Class.forName("mezz.jei.startup.ProxyCommonClient"));
                Field pluginsField = proxy.getClass().getDeclaredField("plugins");
                pluginsField.setAccessible(true);
                Class<?> starter = Class.forName("mezz.jei.startup.JeiStarter");
                Object obj = starter.newInstance();
                Method method = obj.getClass().getDeclaredMethod("start", List.class);
                method.invoke(obj, (ArrayList<Object>) pluginsField.get(proxy));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_NUMPAD5) && !this.mc.player.getHeldItemMainhand().isEmpty()) {
            this.mc.displayGuiScreen(new GuiGetItemName());
        }
    }
    if (ClientEventHandler.loadRenderers) {
        if (--this.loadRendererTick == 0) {
            MPLog.debug("Reload renderer");
            this.mc.renderGlobal.loadRenderers();
            this.loadRendererTick = 30;
            ClientEventHandler.loadRenderers = false;
        }
    }
    if (this.mc.player != null) {
        if (ConfigManagerMP.enableStartedPlanet && this.mc.player.dimension == -1 && this.mc.currentScreen instanceof GuiGameOver && !(this.mc.currentScreen instanceof GuiGameOverMP)) {
            this.mc.displayGuiScreen(new GuiGameOverMP());
        }
    }
    if (this.mc.currentScreen instanceof GuiMainMenu) {
        ClientEventHandler.receiverRenderPos.clear();
        ClientEventHandler.wasteRenderPos.clear();
        ClientEventHandler.entityId.clear();
        ClientEventHandler.bossList.clear();
        ClientEventHandler.itemRendererTicks = 0;
    }
    if (event.phase == Phase.START) {
        ClientEventHandler.itemRendererTicks++;
        this.partialTicks++;
        WeatherRendererNibiru.INSTANCE.runRenderTick();
        CloudRendererNibiru.INSTANCE.runRenderTick();
    }
}
Also used : Field(java.lang.reflect.Field) GuiGameOver(net.minecraft.client.gui.GuiGameOver) GuiMainMenu(net.minecraft.client.gui.GuiMainMenu) GuiGameOverMP(stevekung.mods.moreplanets.util.client.gui.GuiGameOverMP) Method(java.lang.reflect.Method) GuiGetItemName(stevekung.mods.moreplanets.util.debug.GuiGetItemName) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1135 ItemStack (net.minecraft.item.ItemStack)316 EntityPlayer (net.minecraft.entity.player.EntityPlayer)314 World (net.minecraft.world.World)196 BlockPos (net.minecraft.util.math.BlockPos)179 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)136 IBlockState (net.minecraft.block.state.IBlockState)120 ResourceLocation (net.minecraft.util.ResourceLocation)102 Entity (net.minecraft.entity.Entity)93 Block (net.minecraft.block.Block)86 EntityLivingBase (net.minecraft.entity.EntityLivingBase)84 Minecraft (net.minecraft.client.Minecraft)72 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)66 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)64 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)55 Item (net.minecraft.item.Item)53 EntityItem (net.minecraft.entity.item.EntityItem)48 TileEntity (net.minecraft.tileentity.TileEntity)46 TextComponentString (net.minecraft.util.text.TextComponentString)42 Random (java.util.Random)37