Search in sources :

Example 51 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project GregTech by GregTechCE.

the class CustomDataTileHandler method onClientTick.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
    if (event.phase != Phase.END)
        return;
    World clientWorld = Minecraft.getMinecraft().world;
    if (clientWorld == null)
        return;
    Iterator<BlockPos> keyIterator = pendingInitialSyncData.keySet().iterator();
    while (keyIterator.hasNext()) {
        BlockPos blockPos = keyIterator.next();
        TileEntity tileEntity = clientWorld.getTileEntity(blockPos);
        if (tileEntity instanceof ICustomDataTile) {
            pendingInitialSyncData.get(blockPos).forEach(((ICustomDataTile) tileEntity)::handleDataPacket);
            keyIterator.remove();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ICustomDataTile(gregtech.api.capability.ICustomDataTile) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 52 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project GregTech by GregTechCE.

the class NetworkHandler method onClientPacket.

@SubscribeEvent
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void onClientPacket(FMLNetworkEvent.ClientCustomPacketEvent event) {
    Packet packet = proxy2packet(event.getPacket());
    if (clientExecutors.containsKey(packet.getClass())) {
        PacketExecutor<Packet, NetHandlerPlayClient> executor = (PacketExecutor<Packet, NetHandlerPlayClient>) clientExecutors.get(packet.getClass());
        executor.execute(packet, (NetHandlerPlayClient) event.getHandler());
    }
}
Also used : FMLProxyPacket(net.minecraftforge.fml.common.network.internal.FMLProxyPacket) NetHandlerPlayClient(net.minecraft.client.network.NetHandlerPlayClient) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 53 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project GregTech by GregTechCE.

the class ChestGenHooks method onWorldLoad.

@SubscribeEvent
public void onWorldLoad(LootTableLoadEvent event) {
    LootPool mainPool = event.getTable().getPool("main");
    if (mainPool != null && lootEntryItems.containsKey(event.getName())) {
        ArrayList<LootEntryItem> entryItems = lootEntryItems.get(event.getName());
        for (LootEntryItem entry : entryItems) {
            mainPool.addEntry(entry);
        }
    }
    if (mainPool != null && rollVals.containsKey(event.getName())) {
        RandomValueRange rangeAdd = rollVals.get(event.getName());
        RandomValueRange range = mainPool.getRolls();
        mainPool.setRolls(new RandomValueRange(range.getMin() + rangeAdd.getMin(), range.getMax() + rangeAdd.getMax()));
    }
}
Also used : RandomValueRange(net.minecraft.world.storage.loot.RandomValueRange) LootEntryItem(net.minecraft.world.storage.loot.LootEntryItem) LootPool(net.minecraft.world.storage.loot.LootPool) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 54 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Gaia-Dimension by Andromander.

the class GDBlocksRegister method onRegisterBlocks.

@SubscribeEvent
public static void onRegisterBlocks(RegistryEvent.Register<Block> event) {
    BlockRegistryHelper blocks = new BlockRegistryHelper(event.getRegistry());
    blocks.register("gaia_portal", (new GDGaiaPortal()).setUnlocalizedName("gaia_portal"));
    // blocks.register("key_block", (new GDKeyBlock()).setUnlocalizedName("key_block"));
    blocks.register("pyrite_torch", (new GDPyriteTorch()).setUnlocalizedName("pyrite_torch"));
    blocks.register("agate_crafting_table", (new GDAgateCraftingTable()).setUnlocalizedName("agate_crafting_table"));
    blocks.register("heavy_soil", (new GDHeavySoil()).setUnlocalizedName("heavy_soil"));
    blocks.register("corrupt_soil", (new GDCorruptSoil()).setUnlocalizedName("corrupt_soil"));
    blocks.register("glitter_grass", (new GDGlitterGrass()).setUnlocalizedName("glitter_grass"));
    blocks.register("cool_grass", (new GDGlitterGrass()).setUnlocalizedName("cool_grass"));
    blocks.register("verdant_grass", (new GDGlitterGrass()).setUnlocalizedName("verdant_grass"));
    blocks.register("scented_grass", (new GDGlitterGrass()).setUnlocalizedName("scented_grass"));
    blocks.register("old_grass", (new GDGlitterGrass()).setUnlocalizedName("old_grass"));
    blocks.register("corrupt_grass", (new GDCorruptGrass()).setUnlocalizedName("corrupt_grass"));
    blocks.register("singed_grass", (new GDGlitterGrass()).setUnlocalizedName("singed_grass"));
    blocks.register("frail_glitter_block", (new GDFrailGlitterBlock()).setUnlocalizedName("frail_glitter_block"));
    blocks.register("thick_glitter_block", (new GDThickGlitterBlock()).setUnlocalizedName("thick_glitter_block"));
    blocks.register("crystal_growth", (new GDCrystalGrowth()).setUnlocalizedName("crystal_growth"));
    blocks.register("crystal_bloom", (new GDCrystalBloom()).setUnlocalizedName("crystal_bloom"));
    blocks.register("gaia_sapling", (new GDGaiaSapling()).setUnlocalizedName("gaia_sapling"));
    blocks.register("gaia_leaves", (new GDGaiaLeaves()).setUnlocalizedName("gaia_leaves"));
    blocks.register("special_gaia_leaves", (new GDSpecialLeaves()).setUnlocalizedName("special_gaia_leaves"));
    blocks.register("gaia_log", (new GDGaiaLog()).setUnlocalizedName("gaia_log"));
    blocks.register("special_gaia_log", (new GDSpecialLog()).setUnlocalizedName("special_gaia_log"));
    blocks.register("pink_agate_planks", (new GDAgatePlanks()).setUnlocalizedName("pink_agate_planks"));
    blocks.register("blue_agate_planks", (new GDAgatePlanks()).setUnlocalizedName("blue_agate_planks"));
    blocks.register("green_agate_planks", (new GDAgatePlanks()).setUnlocalizedName("green_agate_planks"));
    blocks.register("purple_agate_planks", (new GDAgatePlanks()).setUnlocalizedName("purple_agate_planks"));
    blocks.register("fossilized_planks", (new GDAgatePlanks()).setUnlocalizedName("fossilized_planks"));
    blocks.register("corrupted_planks", (new GDAgatePlanks()).setUnlocalizedName("corrupted_planks"));
    blocks.register("crusty_planks", (new GDAgatePlanks()).setUnlocalizedName("crusty_planks"));
    blocks.register("heated_planks", (new GDAgatePlanks()).setLightLevel(5).setUnlocalizedName("heated_planks"));
    blocks.register("pink_agate_plank_slab", (new GDAgatePlankSlab(false)).setUnlocalizedName("pink_agate_plank_slab"));
    blocks.register("blue_agate_plank_slab", (new GDAgatePlankSlab(false)).setUnlocalizedName("blue_agate_plank_slab"));
    blocks.register("green_agate_plank_slab", (new GDAgatePlankSlab(false)).setUnlocalizedName("green_agate_plank_slab"));
    blocks.register("purple_agate_plank_slab", (new GDAgatePlankSlab(false)).setUnlocalizedName("purple_agate_plank_slab"));
    blocks.register("fossilized_plank_slab", (new GDAgatePlankSlab(false)).setUnlocalizedName("fossilized_plank_slab"));
    blocks.register("corrupted_plank_slab", (new GDAgatePlankSlab(false)).setUnlocalizedName("corrupted_plank_slab"));
    blocks.register("crusty_plank_slab", (new GDAgatePlankSlab(false)).setUnlocalizedName("crusty_plank_slab"));
    blocks.register("heated_plank_slab", (new GDAgatePlankSlab(false)).setLightLevel(5).setUnlocalizedName("heated_plank_slab"));
    blocks.register("double_pink_agate_plank_slab", (new GDAgatePlankSlab(true)).setUnlocalizedName("double_pink_agate_plank_slab"));
    blocks.register("double_blue_agate_plank_slab", (new GDAgatePlankSlab(true)).setUnlocalizedName("double_blue_agate_plank_slab"));
    blocks.register("double_green_agate_plank_slab", (new GDAgatePlankSlab(true)).setUnlocalizedName("double_green_agate_plank_slab"));
    blocks.register("double_purple_agate_plank_slab", (new GDAgatePlankSlab(true)).setUnlocalizedName("double_purple_agate_plank_slab"));
    blocks.register("double_fossilized_plank_slab", (new GDAgatePlankSlab(true)).setUnlocalizedName("double_fossilized_plank_slab"));
    blocks.register("double_corrupted_plank_slab", (new GDAgatePlankSlab(true)).setUnlocalizedName("double_corrupted_plank_slab"));
    blocks.register("double_crusty_plank_slab", (new GDAgatePlankSlab(true)).setUnlocalizedName("double_crusty_plank_slab"));
    blocks.register("double_heated_plank_slab", (new GDAgatePlankSlab(true)).setLightLevel(5).setUnlocalizedName("double_heated_plank_slab"));
    Block agatePlanks = new GDAgatePlanks();
    blocks.register("pink_agate_plank_stairs", (new GDAgatePlankStairs(agatePlanks.getDefaultState())).setUnlocalizedName("pink_agate_plank_stairs"));
    blocks.register("blue_agate_plank_stairs", (new GDAgatePlankStairs(agatePlanks.getDefaultState())).setUnlocalizedName("blue_agate_plank_stairs"));
    blocks.register("green_agate_plank_stairs", (new GDAgatePlankStairs(agatePlanks.getDefaultState())).setUnlocalizedName("green_agate_plank_stairs"));
    blocks.register("purple_agate_plank_stairs", (new GDAgatePlankStairs(agatePlanks.getDefaultState())).setUnlocalizedName("purple_agate_plank_stairs"));
    blocks.register("fossilized_plank_stairs", (new GDAgatePlankStairs(agatePlanks.getDefaultState())).setUnlocalizedName("fossilized_plank_stairs"));
    blocks.register("corrupted_plank_stairs", (new GDAgatePlankStairs(agatePlanks.getDefaultState())).setUnlocalizedName("corrupted_plank_stairs"));
    blocks.register("crusty_plank_stairs", (new GDAgatePlankStairs(agatePlanks.getDefaultState())).setUnlocalizedName("crusty_plank_stairs"));
    blocks.register("heated_plank_stairs", (new GDAgatePlankStairs(agatePlanks.getDefaultState())).setUnlocalizedName("heated_plank_stairs"));
    blocks.register("salt_block", (new GDSaltBlock()).setUnlocalizedName("salt_block"));
    blocks.register("gaia_stone", (new GDGaiaStone()).setUnlocalizedName("gaia_stone"));
    blocks.register("gaia_cobblestone", (new GDGaiaStone()).setUnlocalizedName("gaia_cobblestone"));
    blocks.register("wasteland_stone", (new GDWastelandStone()).setUnlocalizedName("wasteland_stone"));
    blocks.register("static_stone", (new GDStaticStone()).setUnlocalizedName("static_stone"));
    blocks.register("gaia_stone_bricks", (new GDGaiaStoneBricks()).setUnlocalizedName("gaia_stone_bricks"));
    blocks.register("malachite_bricks", (new GDMalachiteBricks()).setUnlocalizedName("malachite_bricks"));
    blocks.register("malachite_brick_slab", (new GDMalachiteBrickSlab(false)).setUnlocalizedName("malachite_brick_slab"));
    blocks.register("double_malachite_brick_slab", (new GDMalachiteBrickSlab(true)).setUnlocalizedName("double_malachite_brick_slab"));
    blocks.register("malachite_pillar", new GDMalachiteBrickPillar().setUnlocalizedName("malachite_pillar"));
    Block malachiteBricks = new GDMalachiteBricks();
    blocks.register("malachite_brick_stairs", (new GDMalachiteStairs(malachiteBricks.getDefaultState())).setUnlocalizedName("malachite_brick_stairs"));
    blocks.register("malachite_chisel_stairs", (new GDMalachiteStairs(malachiteBricks.getDefaultState())).setUnlocalizedName("malachite_chisel_brick_stairs"));
    blocks.register("malachite_pulsing_brick_stairs", (new GDMalachiteStairs(malachiteBricks.getDefaultState())).setUnlocalizedName("malachite_pulsing_brick_stairs"));
    Block malachitePillar = new GDMalachiteBrickPillar();
    blocks.register("malachite_pillar_stairs", (new GDMalachiteStairs(malachitePillar.getDefaultState())).setUnlocalizedName("malachite_pillar_stairs"));
    blocks.register("malachite_floor_stairs", (new GDMalachiteStairs(malachiteBricks.getDefaultState())).setUnlocalizedName("malachite_floor_stairs"));
    blocks.register("malachite_pulsing_floor_stairs", (new GDMalachiteStairs(malachiteBricks.getDefaultState())).setUnlocalizedName("malachite_pulsing_floor_stairs"));
    blocks.register("volcanic_rock", (new GDVolcanicRock()).setUnlocalizedName("volcanic_rock"));
    blocks.register("hematite_block", (new GDHematiteBlock()).setUnlocalizedName("hematite_block"));
    blocks.register("labradorite_block", (new GDLabradoriteBlock()).setUnlocalizedName("laboradorite_block"));
    blocks.register("opal_block", (new GDOpalBlock()).setUnlocalizedName("opal_block"));
    blocks.register("pyrite_block", (new GDPyriteBlock()).setUnlocalizedName("pyrite_block"));
    blocks.register("moonstone_block", (new GDMoonstoneBlock()).setUnlocalizedName("moonstone_block"));
    blocks.register("cinnabar_block", (new GDCinnabarBlock()).setUnlocalizedName("cinnabar_block"));
    blocks.register("tektite_block", (new GDTektiteBlock()).setUnlocalizedName("tektite_block"));
    blocks.register("hematite_ore", (new GDHematiteOre()).setUnlocalizedName("hematite_ore"));
    blocks.register("pyrite_ore", (new GDPyriteOre()).setUnlocalizedName("pyrite_ore"));
    blocks.register("opal_ore", (new GDOpalOre()).setUnlocalizedName("opal_ore"));
    blocks.register("labradorite_ore", (new GDLabradoriteOre()).setUnlocalizedName("labradorite_ore"));
    blocks.register("moonstone_ore", (new GDMoonstoneOre()).setUnlocalizedName("moonstone_ore"));
    blocks.register("cinnabar_ore", (new GDCinnabarOre()).setUnlocalizedName("cinnabar_ore"));
}
Also used : Block(net.minecraft.block.Block) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 55 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Gaia-Dimension by Andromander.

the class GDBiomesRegister method onRegisterBiomes.

@SuppressWarnings("OverlyCoupledMethod")
@SubscribeEvent
public static void onRegisterBiomes(Register<Biome> event) {
    final BiomeRegistry biomes = new BiomeRegistry(event.getRegistry());
    biomes.register("pink_agate_forest", new GDPinkAgateForest(new BiomeProperties("Pink Agate Forest").setTemperature(0.66F).setRainfall(0).setHeightVariation(0.1F)), Type.FOREST);
    biomes.register("blue_agate_taiga", new GDBlueAgateTaiga(new BiomeProperties("Blue Agate Taiga").setTemperature(0.4F).setRainfall(0).setHeightVariation(0.2F)), Type.CONIFEROUS);
    biomes.register("green_agate_jungle", new GDGreenAgateJungle(new BiomeProperties("Green Agate Jungle").setTemperature(0.75F).setRainfall(0).setHeightVariation(0.2F)), Type.JUNGLE);
    biomes.register("purple_agate_swamp", new GDPurpleAgateSwamp(new BiomeProperties("Purple Agate Swamp").setTemperature(0.7F).setRainDisabled().setBaseHeight(-0.05F).setHeightVariation(0.05F)), Type.SWAMP, Type.MAGICAL);
    biomes.register("fossil_woodland", new GDFossilWoodland(new BiomeProperties("Fossil Woodland").setTemperature(0.66F).setRainfall(0).setHeightVariation(0.05F)), Type.SAVANNA);
    biomes.register("crystal_plains", new GDCrystalPlains(new BiomeProperties("Crystal Plains").setTemperature(0.66F).setRainDisabled().setBaseHeight(0.125F).setHeightVariation(0.05F)), Type.PLAINS);
    biomes.register("volcaniclands", new GDVolcanicLands(new BiomeProperties("Volcaniclands").setTemperature(0.9F).setRainDisabled().setBaseHeight(1F).setHeightVariation(0.7F)), Type.HOT, Type.SPARSE, Type.DRY, Type.MOUNTAIN);
    biomes.register("static_wasteland", new GDStaticWasteland(new BiomeProperties("Static Wasteland").setTemperature(0.4F).setRainDisabled().setBaseHeight(3F).setHeightVariation(0.05F)), Type.WASTELAND, Type.MOUNTAIN);
    biomes.register("goldstonelands", new GDGoldstoneLands(new BiomeProperties("Goldstonelands").setTemperature(0.55F).setRainDisabled().setBaseHeight(0.125F).setHeightVariation(0.05F)), Type.WASTELAND, Type.PLAINS);
    biomes.register("mineral_reservoir", new GDMineralReservoir(new BiomeProperties("Mineral Reservoir").setTemperature(0.66F).setRainfall(0).setBaseHeight(-1.8F).setHeightVariation(0.1F)), Type.OCEAN);
    biomes.register("mineral_river", new GDMineralRiver(new BiomeProperties("Mineral River").setTemperature(0.5F).setRainfall(0).setBaseHeight(-0.5F).setHeightVariation(0)), Type.RIVER);
}
Also used : BiomeProperties(net.minecraft.world.biome.Biome.BiomeProperties) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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