Java 类net.minecraftforge.fml.common.eventhandler.SubscribeEvent 实例源码

项目:Melodium    文件:ItemCompositionPaper.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void handleHearingSounds(PlaySoundEvent event) {
    EntityPlayer p = Minecraft.getMinecraft().player;
    if (p != null)
    {
        Tuple<SoundType, Double> result = getTypeFromSound(event.getName(), event.getSound());
        if (p.getHeldItemMainhand().getItem() == this)
        {
            if (addSound(p.getHeldItemMainhand(), result.getFirst(), result.getSecond())){
                PacketHandler.INSTANCE.sendToServer(new MessageCompositionUpdate(p.getUniqueID(),p.getHeldItemMainhand().getTagCompound(),true));
            }
        } else if (p.getHeldItemOffhand().getItem() == this) {
            if (addSound(p.getHeldItemOffhand(), result.getFirst(), result.getSecond())){
                PacketHandler.INSTANCE.sendToServer(new MessageCompositionUpdate(p.getUniqueID(),p.getHeldItemOffhand().getTagCompound(),false));
            }
        }
    }
}
项目:Loot-Slash-Conquer    文件:GuiMana.java   
@SubscribeEvent
public void onRenderOverlayText(RenderGameOverlayEvent.Text event)
{
    ScaledResolution sr = event.getResolution();
    EntityPlayer player = Minecraft.getMinecraft().player;
    Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);

    if (!player.capabilities.isCreativeMode && statsCap != null)
    {
        String mana = statsCap.getMana() + " / " + statsCap.getMaxMana();

        GL11.glPushMatrix();
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(mana, (sr.getScaledWidth() / 2 + 37) * 2, (sr.getScaledHeight() - 37) * 2, 0xFFFFFF);
        GL11.glPopMatrix();
    }
}
项目:Defier    文件:CommonProxy.java   
@SubscribeEvent
public static void itemRegistry(RegistryEvent.Register<Item> e) {
    IForgeRegistry<Item> reg = e.getRegistry();
    registerItemBlock(reg, ModItems.compressor);
    registerItemBlock(reg, ModItems.defier);
    registerItemBlock(reg, ModItems.patternmolder);
    registerItemBlock(reg, ModItems.energyprovider);

    reg.register(new DefierItem("largemass"));
    reg.register(new DefierItem("defiercore"));
    reg.register(new DefierItem("defierstar"));
    reg.register(new EnergyStarItem());
    reg.register(new DefierItem("strongstar"));
    reg.register(new DefierItem("speedstar"));
    reg.register(new PatternItem());
}
项目:DebugServerInfo    文件:ServerHelper.java   
@SubscribeEvent
public void onTickPlayerTick(TickEvent.PlayerTickEvent event)
{
    if (event.side.isClient() || event.phase != TickEvent.Phase.START || !hasPermission(event.player)) return;
    int count = event.player.getEntityData().getInteger(NBT_COUNTER);
    if (count <= 0) return;
    event.player.getEntityData().setInteger(NBT_COUNTER, count - 1);
    Data data = ServerHelper.getData();
    if (data != null)
    {
        try
        {
            DebugServerInfo.getSnw().sendTo(data, (EntityPlayerMP) event.player);
        }
        catch (Exception e)
        {
            getLogger().info("Caught error in sendTo. {} ({})", e.getMessage(), e.getClass().getName());
        }
    }
}
项目:pnc-repressurized    文件:EventHandlerPneumaticCraft.java   
@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event) {
    if (ConfigHandler.general.enableDungeonLoot) {
        String prefix = "minecraft:chests/";
        String name = event.getName().toString();
        if (name.startsWith(prefix)) {
            String file = name.substring(name.indexOf(prefix) + prefix.length());
            switch (file) {
                case "abandoned_mineshaft":
                case "desert_pyramid":
                case "jungle_temple":
                case "simple_dungeon":
                case "spawn_bonus_chest":
                case "stronghold_corridor":
                case "village_blacksmith":
                    LootEntry entry = new LootEntryTable(RL("inject/simple_dungeon_loot"), 1, 0,  new LootCondition[0], "pneumaticcraft_inject_entry");
                    LootPool pool = new LootPool(new LootEntry[]{entry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "pneumaticcraft_inject_pool");
                    event.getTable().addPool(pool);
                    break;
                default:
                    break;
            }
        }
    }
}
项目:minecraft-territorialdealings    文件:EventListener.java   
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event)
{
    if (event.player.worldObj.isRemote) { return; } // Server side only

    if (event.crafting.getItem() instanceof LeaderRequiredItem) // Only leaders can craft this item
    {
        if (TerritoryHandler.getFactionPlayerIsLeaderOf(event.player) == null)
        {
            Main.console("Item is leader-only, but the player is not a leader. Removing the item.");
            event.crafting.stackSize = 0;   // Not having it

            //event.setCanceled(true);  // That event cannot be cancelled. How do I reliably stop the creation of this item? Setting the stack size itself seems to be delayed until the metadata changes,
                                        // or some time passes and a sync is started
            //TODO: Refund the items used?
        }
        // else, is leader of at least one faction. Checks out.
    }
}
项目:Mods    文件:TF2EventsClient.java   
@SubscribeEvent
public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) {
    if (Minecraft.getMinecraft().player != null) {
        if ((event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative || event.getGui() instanceof GuiWearables)
                && !Minecraft.getMinecraft().player.getCapability(TF2weapons.INVENTORY_CAP, null).isEmpty()) {
            // GuiContainer gui = (GuiContainer) event.getGui();
            event.getButtonList().add(new GuiButton(97535627, event.getGui().width / 2 - 10, event.getGui().height / 2 + 95, 20, 20, "W"));
        }

        if (event.getGui() instanceof GuiMerchant)
            if (((GuiMerchant) event.getGui()).getMerchant().getDisplayName().getUnformattedText().equals(I18n.format("entity.hale.name"))) {
                event.getButtonList().add(new GuiButton(7578, event.getGui().width / 2 - 100, event.getGui().height / 2 - 110, 100, 20, "Change Team"));
                event.getButtonList().add(new GuiButton(7579, event.getGui().width / 2, event.getGui().height / 2 - 110, 100, 20, "Recover Lost Items"));
            }
        Minecraft.getMinecraft().player.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 8;
    }
}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void craftItem(net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent event) {
    ItemStack withPattern=ItemStack.EMPTY;
    ItemStack noPattern=ItemStack.EMPTY;
    for(int i=0; i<event.craftMatrix.getSizeInventory();i++){
        ItemStack stack=event.craftMatrix.getStackInSlot(i);
        if(!stack.isEmpty() && stack.getItem() instanceof ItemBanner){
            if(TileEntityBanner.getPatterns(stack)>0){
                withPattern=stack;
            }
            else{
                noPattern=stack;
            }
            if(!withPattern.isEmpty()&&!noPattern.isEmpty()){
                withPattern.shrink(1);
            }
        }
    }
}
项目:uniquecrops    文件:UCEventHandlerServer.java   
@SubscribeEvent
public void checkPlayerNBT(PlayerEvent.Clone event) {

    if (!event.isWasDeath())
        return;

    EntityPlayer old = event.getOriginal();
    EntityPlayer player = event.getEntityPlayer();

    NBTTagCompound oldtag = old.getEntityData();
    NBTTagCompound tag = player.getEntityData();
    if (oldtag.hasKey(GrowthSteps.TAG_GROWTHSTAGES)) {
        tag.setTag(GrowthSteps.TAG_GROWTHSTAGES, oldtag.getTagList(GrowthSteps.TAG_GROWTHSTAGES, 10).copy());
    }
    if (oldtag.hasKey("hasSacrificed"))
        tag.setBoolean("hasSacrificed", oldtag.getBoolean("hasSacrificed"));
    if (oldtag.hasKey(SeedBehavior.TAG_ABSTRACT))
        tag.setInteger(SeedBehavior.TAG_ABSTRACT, oldtag.getInteger(SeedBehavior.TAG_ABSTRACT));
}
项目:ForgeHax    文件:XrayMod.java   
@SubscribeEvent
public void onPreRenderBlockLayer(RenderBlockLayerEvent.Pre event) {
    if(!isInternalCall) {
        if (!event.getRenderLayer().equals(BlockRenderLayer.TRANSLUCENT)) {
            event.setCanceled(true);
        } else if (event.getRenderLayer().equals(BlockRenderLayer.TRANSLUCENT)) {
            isInternalCall = true;
            Entity renderEntity = MC.getRenderViewEntity();
            GlStateManager.disableAlpha();
            MC.renderGlobal.renderBlockLayer(BlockRenderLayer.SOLID, event.getPartialTicks(), 0, renderEntity);
            GlStateManager.enableAlpha();
            MC.renderGlobal.renderBlockLayer(BlockRenderLayer.CUTOUT_MIPPED, event.getPartialTicks(), 0, renderEntity);
            MC.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
            MC.renderGlobal.renderBlockLayer(BlockRenderLayer.CUTOUT, event.getPartialTicks(), 0, renderEntity);
            MC.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
            GlStateManager.disableAlpha();
            isInternalCall = false;
        }
    }
}
项目:BetterThanWeagles    文件:LootTableInjector.java   
@SubscribeEvent
public void lootTableLoaded(LootTableLoadEvent event)
{
    ResourceLocation poolName = event.getName();

    String injectTablePath = "inject/" + poolName.getResourceDomain() + "/" + poolName.getResourcePath();

    if (!LootTableInjector.INJECTED_LOOT_TABLES.contains(injectTablePath))
    {
        return;
    }

    LootTable injectTable = event.getLootTableManager().getLootTableFromLocation(new ResourceLocation(BetterThanWeagles.MODID, injectTablePath));
    for (int i = 0; i < LootTableInjector.MAX_POOLS; i++)
    {
        LootPool pool = injectTable.getPool(String.format("inject%d", i));
        if (pool != null)
        {
            event.getTable().addPool(pool);
        }
    }
}
项目:craftsman    文件:Turtle.java   
@SubscribeEvent
public void track(PlayerTickEvent event) {
    EntityPlayer player = event.player;

    Item heldItem = player.getHeldItemMainhand().getItem();
    if (!(heldItem instanceof ItemBlock)) {
        return;
    }    

    IBlockState heldBlockState = Block.getBlockFromItem(heldItem).getDefaultState();
    BlockPos basePos = player.getPosition().add(0, -1, 0);
    IBlockState baseState = player.getEntityWorld().getBlockState(basePos);

    if (heldBlockState.equals(baseState)) {
        return;
    }

    player.getEntityWorld().setBlockState(basePos, heldBlockState);
}
项目:ModularMachinery    文件:ClientScheduler.java   
@SubscribeEvent
public void tick(TickEvent.ClientTickEvent event) {
    clientTick++;
    ClientProxy.renderHelper.tick();

    inTick = true;
    synchronized (lock) {
        inTick = true;
        Iterator<Runnable> iterator = queuedRunnables.keySet().iterator();
        while (iterator.hasNext()) {
            Runnable r = iterator.next();
            Counter delay = queuedRunnables.get(r);
            delay.decrement();
            if(delay.value <= 0) {
                r.run();
                iterator.remove();
            }
        }
        inTick = false;
        for (Map.Entry<Runnable, Integer> waiting : waitingRunnables.entrySet()) {
            queuedRunnables.put(waiting.getKey(), new Counter(waiting.getValue()));
        }
    }
    waitingRunnables.clear();
}
项目:uniquecrops    文件:UCEventHandlerServer.java   
@SubscribeEvent
public void setUpgradeChance(AnvilRepairEvent event) {

    ItemStack output = event.getItemResult();
    EntityPlayer player = event.getEntityPlayer();
    if (output == null)
        return;
    if (player == null)
        return;

    if (player.worldObj.isRemote)
        return;

    if (output.getItem() instanceof IBookUpgradeable) {
        int upgradelevel = NBTUtils.getInt(output, ItemGeneric.TAG_UPGRADE, -1);
        if (upgradelevel == 10) {
            Random rand = new Random();
            if (rand.nextBoolean() == false && !player.worldObj.isRemote) {
                player.addChatMessage(new TextComponentString(TextFormatting.RED + "You attempt to refine this item, but it breaks.."));
                output.stackSize = 0;
            }
        }
    }
}
项目:PurificatiMagicae    文件:BlockRegistry.java   
@SubscribeEvent
public static void onRegisterBlocks(RegistryEvent.Register<Block> e)
{
    IForgeRegistry<Block> reg = e.getRegistry();
    register(new BlockCrystal(), reg);
    register(new BlockCrystalGlass(), reg);
    Block ore_crysagnetite = new BlockBase("ore_crysagnetite", Material.ROCK).setHardness(3).setLightLevel(0.1f);
    ore_crysagnetite.setHarvestLevel("pickaxe", 2);
    register(ore_crysagnetite, reg);
    register(new BlockTranslationDesk(), reg);
    register(new BlockCrystalSmall(), reg);
    register(new BlockWallIfTablet(), reg);
    register(new BlockBrokenWallIfTablet(), reg);
    register(new BlockMicroscope(), reg);
    register(new BlockLuminousCrystalGlass(), reg);
    register(new BlockTest(), reg);
    register(new BlockBrulantaFlower(), reg);
    register(new BlockCodeStorage(), reg);
    register(new BlockMagibench(), reg);
    register(new BlockRopeCoil(), reg);
    register(new BlockStoneCrusher(), reg);
}
项目:CreeperHostGui    文件:EventHandler.java   
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs)
{
    if (!CreeperHost.MOD_ID.equals(eventArgs.getModID()))
    {
        return;
    }

    CreeperHost.instance.saveConfig();
}
项目:FirstAid    文件:EventHandler.java   
@SubscribeEvent
public static void onItemCraft(PlayerEvent.ItemCraftedEvent event) {
    ItemStack stack = event.crafting;
    if (stack.getItem() == FirstAidItems.BANDAGE) {
        String username = event.player.getName();
        if (username.equalsIgnoreCase("ichun"))
            stack.setStackDisplayName("MediChun's Healthkit"); //Yup, I *had* to do this
    }
}
项目:TheOink    文件:OinkEntityEvents.java   
@SubscribeEvent
public static void applyEffectSausage(LivingEvent.LivingUpdateEvent e) {
    if (e.getEntity() instanceof OinkSausage) {
        OinkSausage piggy = (OinkSausage) e.getEntity();
        if (sausageGlow) {
            piggy.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 5, 10, false, false));
        }
    }
}
项目:harshencastle    文件:HandlerHarshenInventory.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event)
{
    if(stackMap.containsKey(event.player.getUniqueID()))
    {
        event.player.getEntityData().setTag("harshenInventory", stackMap.get(event.player.getUniqueID()).serializeNBT());
        for(int i = 0; i < stackMap.get(event.player.getUniqueID()).getSlots(); i++)
            if(stackMap.get(event.player.getUniqueID()).getStackInSlot(i).getItem() instanceof IHarshenProvider)
                ((IHarshenProvider)stackMap.get(event.player.getUniqueID()).getStackInSlot(i).getItem()).onAdd(event.player, i);

    }
}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent
public void stopUsing(PlayerInteractEvent.LeftClickBlock event) {
    if (!TF2Util.canInteract(event.getEntityLiving())) {
        event.setCanceled(true);
    }
    event.getEntityPlayer().removePotionEffect(TF2weapons.charging);
}
项目:CraftingParadiseMod    文件:EntityHandler.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onEntityConstruction(EntityEvent.EntityConstructing event)
{
    Entity entity = event.getEntity();
    if(entity instanceof EntityPlayer)
    {
        if(entity.world != null)
        {
            if(event.getEntity().world.isRemote)
            {
                CraftingParadise.proxy.registerCustomSky();
            }
        }
    }
}
项目:FundamentalChemistry    文件:ForgeEventHandler.java   
@SubscribeEvent
public void entityConstruct(EntityEvent.EntityConstructing e){
    //add custom properties to players
  if(e.entity instanceof EntityPlayer){
    if(e.entity.getExtendedProperties(PlayerProperties.ID) == null){
      e.entity.registerExtendedProperties(PlayerProperties.ID, new PlayerProperties());
    }
  }
}
项目:TheOink    文件:OinkEntityEvents.java   
@SubscribeEvent
public static void applyEffectBacon(LivingEvent.LivingUpdateEvent e) {
    if (e.getEntity() instanceof OinkBacon) {
        OinkBacon piggy = (OinkBacon) e.getEntity();
        if (baconGlow) {
            piggy.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 5, 10, false, false));
        }
    }

}
项目:harshencastle    文件:HandlerFlatPlateRenderer.java   
@SubscribeEvent
public void lastRender(RenderWorldLastEvent event)
{
    if(!Minecraft.getMinecraft().player.capabilities.isCreativeMode && !Minecraft.getMinecraft().player.isSpectator())
        return;
    ArrayList<BlockPos> nonRemovedPlates = new ArrayList<>();
    int time = platePositions.size();
    for(int i = 0; i < time; i++)
        if(Minecraft.getMinecraft().world.getBlockState(platePositions.get(i)).getBlock() instanceof HarshenDimensionalFlatPlate)
            nonRemovedPlates.add(renderAt(platePositions.get(i), event.getPartialTicks()));
    platePositions = nonRemovedPlates;
}
项目:ForgeHax    文件:AntiOverlayMod.java   
@SubscribeEvent
public void onRender(RenderEvent event) {
    ItemStack item = FastReflection.Fields.EntityRenderer_itemActivationItem.get(MC.entityRenderer);

    if (item != null && item.getItem() == Items.TOTEM_OF_UNDYING) {
        FastReflection.Fields.EntityRenderer_itemActivationItem.set(MC.entityRenderer, null);
    }
}
项目:ForgeHax    文件:SpawnerEspMod.java   
@SubscribeEvent
public void onRender(RenderEvent event) {
    event.getBuffer().begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);

    for(TileEntity tileEntity : getWorld().loadedTileEntityList) {
        if(tileEntity instanceof TileEntityMobSpawner) {
            BlockPos pos = tileEntity.getPos();
            GeometryTessellator.drawCuboid(event.getBuffer(), pos, GeometryMasks.Line.ALL, Utils.Colors.RED);
        }
    }

    event.getTessellator().draw();
}
项目:Anima-Mundi    文件:ParticleManager.java   
@SubscribeEvent
public static void registerParticles(TextureStitchEvent.Pre event)
{
    stitchParticle("particle/glow_par", event.getMap());
    stitchParticle("items/sword_glow_top", event.getMap());
    stitchParticle("items/sword_glow_bottom", event.getMap());
}
项目:harshencastle    文件:HandlerKeyBinding.java   
@SubscribeEvent
public void onKeyInput(KeyInputEvent event)
{
    for(KeyBinding key : ringEvents)
        if(key.isPressed())
            sendRingEvent(ringEvents.indexOf(key));
    if(openInventory.isPressed())
        HarshenClientUtils.openInventory();
}
项目:Teleporting-XP    文件:ModConfig.java   
@SubscribeEvent
public static void configChanged(ConfigChangedEvent.OnConfigChangedEvent event)
{
    if(event.getModID().equals(Reference.MOD_ID))
    {
        ConfigManager.sync(Reference.MOD_ID, Config.Type.INSTANCE);
    }
}
项目:Loot-Slash-Conquer    文件:EventInput.java   
@SubscribeEvent
public void onInput(InputEvent event)
{
    KeyBinding p = ClientProxy.bindingP;
    EntityPlayer player = Minecraft.getMinecraft().player;

    if (player != null && p.isPressed())
    {
        player.openGui(LootSlashConquer.instance, GuiHandler.PLAYER_INFORMATION, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
    }

    // if ability key is pressed.
    // send server packet calling ability start.
}
项目:Proyecto-DASI    文件:ScreenHelper.java   
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    purgeExpiredFragments(null);
    if (Minecraft.getMinecraft().currentScreen != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu))
        return;

    int displayWidth = Minecraft.getMinecraft().displayWidth;
    int displayHeight = Minecraft.getMinecraft().displayHeight;
    ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft(), displayWidth, displayHeight);
    int width = res.getScaledWidth();
    int height = res.getScaledHeight();
    float rx = (float) width / 1000f;
    float ry = (float) height / 1000f;

    synchronized(this.fragments)
    {
        for (TextCategory cat : TextCategory.values())
        {
            TextCategoryAttributes atts = this.attributes.get(cat);
            if (atts != null && (!atts.flashing || ((System.currentTimeMillis() / 500) % 3 != 0)) && shouldDisplay(atts.displayLevel))
            {
                int x = Math.round(rx * (float) atts.xOrg);
                int y = Math.round(ry * (float) atts.yOrg);
                ArrayList<TextFragment> frags = this.fragments.get(cat);
                if (frags != null && !frags.isEmpty())
                {
                    for (TextFragment frag : frags)
                    {
                        drawText(frag.text, x, y, atts.colour);
                        y += 10;
                    }
                }
            }
        }
    }
}
项目:refinedstorageaddons    文件:ProxyCommon.java   
@SubscribeEvent
public void onPickupItem(EntityItemPickupEvent e) {
    if (!e.getEntityPlayer().world.isRemote) {
        for (int i = 0; i < 9 * 4; ++i) {
            ItemStack stack = e.getEntityPlayer().inventory.getStackInSlot(i);

            if (stack.getItem() == RSAddonsItems.NETWORK_BAG) {
                ((ItemNetworkBag) stack.getItem()).onPlayerPickup(e, stack);

                break;
            }
        }
    }
}
项目:Proyecto-DASI    文件:RewardForDiscardingItemImplementation.java   
@SubscribeEvent
public void onLoseItem(LoseItemEvent event)
{
    if (event.stack != null)
    {
        accumulateReward(this.params.getDimension(), event.stack);
    }
}
项目:Proyecto-DASI    文件:BuildBattleDecoratorImplementation.java   
@SubscribeEvent
public void onPlaceBlock(PlaceEvent event)
{
    if (blockInBounds(event.pos,this.destBounds))
    {
        this.valid = false;
        this.dest.set(blockPosToIndex(event.pos, this.destBounds), event.state);
    }
}
项目:HardcoreRevival    文件:RestrictionHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    if (player != null && player.getHealth() <= 0f) {
        if (!(event instanceof PlayerInteractEvent.RightClickEmpty || event instanceof PlayerInteractEvent.LeftClickEmpty)) {
            event.setCanceled(true);
        }
    }
}
项目:PurificatiMagicae    文件:SifEvents.java   
@SubscribeEvent
public static void onChunkWatch(ChunkWatchEvent.Watch e)
{
    try
    {
        GlobalChunkPos pos = new GlobalChunkPos(e.getChunk().x, e.getChunk().z, e.getPlayer().dimension);
        NetworkManager.sendTo(new CPacketSyncSif(pos, PurMag.INSTANCE.sif_storage.get(pos)), e.getPlayer());
    }
    catch (Exception ex)
    {
        PurMag.INSTANCE.log.error("Can't sync the SIF chunk data with player!", ex);
    }
}
项目:Adventurers-Toolbox    文件:SpecialToolAbilityHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEndRodToolHarvestEvent(BlockEvent.HarvestDropsEvent event) {
    if (event.getHarvester() == null) {
        return;
    }

    ItemStack stack = event.getHarvester().getHeldItemMainhand();

    boolean flag = false;

    if (stack.getItem() instanceof IHaftTool) {
        if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_END_ROD) {
            flag = true;
        }
    }

    if (flag) {
        if (!event.getWorld().isRemote) {
            BlockPos pos = event.getPos();
            for (ItemStack itemstack : event.getDrops()) {
                if (rand.nextFloat() < event.getDropChance()) {
                    EntityItem entity = new EntityItem(event.getWorld(), pos.getX() + 0.5, pos.getY() + 0.25,
                            pos.getZ() + 0.5, itemstack);
                    entity.setNoGravity(true);
                    entity.motionX = 0;
                    entity.motionY = 0;
                    entity.motionZ = 0;
                    entity.velocityChanged = true;
                    event.getWorld().spawnEntity(entity);
                }
            }
        }
        event.getDrops().clear();
    }
}
项目:Bewitchment    文件:BrewEvents.java   
@SubscribeEvent
public void onBlockDestroy(LivingDestroyBlockEvent event) {
    Collection<BrewEffect> effects = BrewStorageHandler.getBrewEffects(event.getEntityLiving());
    effects.stream().filter(effect -> effect.getBrew() instanceof IBrewBlockDestroy).forEach(effect -> {
        if (event.isCanceled()) return;
        ((IBrewBlockDestroy) effect.getBrew()).onBlockDestroy(event, event.getEntityLiving(), effect.getAmplifier());
    });
}
项目:Lanolin    文件:EventHandlerCommon.java   
@SubscribeEvent
public void updateEntity(LivingEvent.LivingUpdateEvent event){
    if(event.getEntity() instanceof EntityPlayer && event.getEntity().getAir() <= 300 - Config.ARMOR_TICKS_PER_LANOLIN){
        // The entity is a player and is not at full air
        if(event.getEntity().isInsideOfMaterial(Material.WATER)){
            for(int i = 0; i < 4; i++){
                ItemStack armorPiece = ((EntityPlayer) event.getEntity()).inventory.armorInventory.get(i);
                if(armorPiece != ItemStack.EMPTY){
                    NBTTagCompound tags = armorPiece.getTagCompound();
                    if(tags != null && tags.hasKey("lanolin")){
                        // Found armor with lanolin. Reset air and remove a piece of lanolin.
                        event.getEntity().setAir(300);
                        if(tags.getInteger("lanolin") == 1){
                            // No more lanolin on this item, remove the tag
                            tags.removeTag("lanolin");
                        }
                        else{
                            tags.setInteger("lanolin", tags.getInteger("lanolin")-1);
                        }
                        armorPiece.setTagCompound(tags);
                        ((EntityPlayer) event.getEntity()).inventory.armorInventory.set(i, armorPiece);
                        break;
                    }
                }
            }
        }
    }
}
项目:Thermionics    文件:ClientProxy.java   
@SubscribeEvent
public void onPostRender(RenderWorldLastEvent evt) {
    if (!Loader.isModLoaded("baubles")) return;

    EntityPlayer thePlayer = Minecraft.getMinecraft().player;

    for(EntityPlayer entity : Minecraft.getMinecraft().world.playerEntities) {
        IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(entity);
        ItemStack scarfStack = baubles.getStackInSlot(BAUBLE_AMULET);
        if (scarfStack==null || scarfStack.isEmpty() || scarfStack.getItem()!=ThermionicsItems.SCARF) return;
        Scarf scarf = scarfCache.getIfPresent(entity);
        if (scarf==null) {
            scarf = new Scarf();
            scarfCache.put(entity, scarf);
            scarf.readFromNBT(scarfStack.getTagCompound());
            //System.out.println("Created scarf:"+(scarf.leftScarf.size()+scarf.rightScarf.size())+" nodes.");
        } else {

            scarf.updateFromNBT(scarfStack.getTagCompound());
            //System.out.println("Updated scarf:"+(scarf.leftScarf.size()+scarf.rightScarf.size())+" nodes.");
        }

        double dx = thePlayer.prevPosX + (thePlayer.posX - thePlayer.prevPosX) * evt.getPartialTicks();
        double dy = thePlayer.prevPosY + (thePlayer.posY - thePlayer.prevPosY) * evt.getPartialTicks();
        double dz = thePlayer.prevPosZ + (thePlayer.posZ - thePlayer.prevPosZ) * evt.getPartialTicks();

        LayerScarf.renderScarf(
                dx, dy, dz,
                entity, null, scarf, evt.getPartialTicks(),
                Minecraft.getMinecraft().world);
    }
}