Java Code Examples for cpw.mods.fml.common.eventhandler.EventPriority#LOWEST

The following examples show how to use cpw.mods.fml.common.eventhandler.EventPriority#LOWEST . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TickDynamicMod.java    From TickDynamic with MIT License 6 votes vote down vote up
@SubscribeEvent(priority=EventPriority.LOWEST)
public void tickEventEnd(ServerTickEvent event) {	
	if(event.phase == Phase.END)
	{
  	getTimedGroup("other").endTimer();
  	root.endTick(true);
  	
  	if(debugTimer)
  		System.out.println("Tick time used: " + (root.getTimeUsed()/root.timeMilisecond) + "ms");
  	
  	//After every world is done ticking, re-balance the time slices according
  	//to the data gathered during the tick.
  	root.balanceTime();
  	
  	//Calculate TPS
  	updateTPS();
  	
  	if(saveConfig)
  	{
  		saveConfig = false;
  		config.save();
  	}
	}
}
 
Example 2
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(PlayerInteractEvent e) {
    if (!e.world.isRemote && e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
            && isStickyJar(e.entityPlayer.getHeldItem())) {
        if (interacts == null) {
            interacts = new HashMap<EntityPlayer, Integer>();
        }
        interacts.put(e.entityPlayer, e.face);
    }

    if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
        ItemStack i = e.entityPlayer.getHeldItem();
        if (i != null && (i.getItem() instanceof ItemWandCasting)) {
            WandHandler.handleWandInteract(e.world, e.x, e.y, e.z, e.entityPlayer, i);
        }
    }
}
 
Example 3
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void on(BlockEvent.PlaceEvent e) {
    if (e.isCanceled()) {
        if (interacts != null)
            interacts.remove(e.player);
    } else {
        if (!e.world.isRemote && isStickyJar(e.itemInHand)) {
            TileEntity parent = e.world.getTileEntity(e.x, e.y, e.z);
            if (parent instanceof TileJarFillable) {
                int metadata = e.world.getBlockMetadata(e.x, e.y, e.z);
                e.world.setBlock(e.x, e.y, e.z, RegisteredBlocks.blockStickyJar, metadata, 2);

                TileEntity tile = e.world.getTileEntity(e.x, e.y, e.z);
                if (tile instanceof TileStickyJar) {
                    Integer sideHit = interacts.get(e.player);
                    ((TileStickyJar) tile).init((TileJarFillable) parent, e.placedBlock, metadata,
                            ForgeDirection.getOrientation(sideHit == null ? 1 : sideHit).getOpposite());
                    RegisteredBlocks.blockStickyJar.onBlockPlacedBy(e.world, e.x, e.y, e.z, e.player, e.itemInHand);
                }
            }
        }
    }
}
 
Example 4
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(ItemTooltipEvent event) {
    if(event.itemStack != null) {
        if(event.itemStack.getItem() instanceof ItemGolemPlacer
                || event.itemStack.getItem() instanceof ItemAdditionalGolemPlacer) {
            if(RegisteredGolemStuff.upgradeRunicShield.hasUpgrade(event.itemStack)) {
                event.toolTip.add("\u00a76" + StatCollector.translateToLocal("item.runic.charge") + " +" + RegisteredGolemStuff.upgradeRunicShield.getChargeLimit(event.itemStack));
            }

            AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(event.itemStack);
            if(core != null) {
                String searchStr = StatCollector.translateToLocal("item.ItemGolemCore.name");
                for(int i = 0; i < event.toolTip.size(); i++) {
                    String line = event.toolTip.get(i);
                    if(line.contains(searchStr)) {
                        int index = line.indexOf('\u00a7', searchStr.length()) + 2;
                        event.toolTip.remove(i);
                        event.toolTip.add(i, line.substring(0, index) + StatCollector.translateToLocal(core.getUnlocalizedName()));
                        break;
                    }
                }
            }
        }
    }
}
 
Example 5
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(AttackEntityEvent event) {
    ItemStack heldItem = event.entityPlayer.getHeldItem();
    if(heldItem != null && heldItem.getItem() == ConfigItems.itemGolemBell && event.target instanceof EntityGolemBase
            && !event.target.worldObj.isRemote && !event.target.isDead) {
        event.target.captureDrops = true;
        markedGolems.put((EntityGolemBase) event.target, event.entityPlayer);
    }
}
 
Example 6
Source File: EventHandlerPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEnderTeleport(EnderTeleportEvent event){
    if(!HackableEnderman.onEndermanTeleport(event.entity)) {
        event.setCanceled(true);
    } else {
        if(Config.enableEndermanSeedDrop && Math.random() < 0.05D) {
            if(!event.entity.worldObj.isRemote) ItemPlasticPlants.markInactive(event.entity.entityDropItem(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.ENDER_PLANT_DAMAGE), 0));
        }
    }
}
 
Example 7
Source File: FMEventHandler.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onFeelPain(LivingHurtEvent event){
    if(!Config.noLust && event.ammount > 0 && event.entityLiving instanceof EntityPlayer){
        EntityPlayer player = (EntityPlayer)event.entityLiving;
        ItemStack amulet = BaublesApi.getBaubles(player).getStackInSlot(0);
        if(amulet != null && amulet.getItem() == ForbiddenItems.subCollar){
            int doses = 3 * (int)event.ammount;
            if(event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){
                EntityPlayer dom = (EntityPlayer)event.source.getEntity();
                int chance = 1;
                if(dom.getHeldItem() != null && dom.getHeldItem().getItem() instanceof ItemRidingCrop) {
                    doses += 3;
                    chance += 3;
                }
                if(player.worldObj.provider.dimensionId == -1 && randy.nextInt(30) < chance){
                    EntityItem ent = player.entityDropItem(new ItemStack(ForbiddenItems.deadlyShards, 1, 4), 1.0F);
                    ent.motionY += player.worldObj.rand.nextFloat() * 0.05F;
                    ent.motionX += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
                    ent.motionZ += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
                }
            }
            for(int x = 0;x < doses; x++){
                ((ItemSubCollar)ForbiddenItems.subCollar).addVis(amulet, primals[randy.nextInt(6)], 1, true);
            }
        }
    }
}
 
Example 8
Source File: ServerEventHandler.java    From bartworks with MIT License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void EntityJoinWorldEvent(EntityJoinWorldEvent event) {
    if (event == null || !(event.entity instanceof EntityPlayerMP) || !SideReference.Side.Server)
        return;
    MainMod.BW_Network_instance.sendToPlayer(new OreDictCachePacket(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity);
    MainMod.BW_Network_instance.sendToPlayer(new ServerJoinedPackage(null),(EntityPlayerMP) event.entity);
}
 
Example 9
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(PlayerInteractEvent e) {
    if(!e.world.isRemote && e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
        ItemStack itemInHand = e.entityPlayer.getHeldItem();
        if(itemInHand != null && (itemInHand.getItem() instanceof ItemGolemPlacer
                || itemInHand.getItem() instanceof ItemAdditionalGolemPlacer)) {
            int entityId = Entity.nextEntityID;
            if(itemInHand.getItem().onItemUseFirst(itemInHand, e.entityPlayer, e.world, e.x, e.y, e.z, e.face, 0, 0, 0)) {
                e.setCanceled(true);
                Entity entity = e.world.getEntityByID(entityId);
                if(entity != null && entity instanceof EntityGolemBase) {
                    EntityGolemBase golem = (EntityGolemBase) entity;

                    //move persistent data to entity
                    golem.getEntityData().setTag(Gadomancy.MODID, NBTHelper.getPersistentData(itemInHand).copy());

                    MinecraftForge.EVENT_BUS.post(new PlacerCreateGolemEvent(e.entityPlayer, golem, itemInHand));

                    ExtendedGolemProperties props = (ExtendedGolemProperties) golem.getExtendedProperties(Gadomancy.MODID);
                    if(props != null) {
                        props.updateGolemCore();
                        props.updateGolem();
                    }

                    //update runic shielding
                    if(RegisteredGolemStuff.upgradeRunicShield.hasUpgrade(golem)) {
                        RegisteredGolemStuff.upgradeRunicShield.getCharge(golem);
                    }
                }
            }
        }
    }
}
 
Example 10
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void on(EntityJoinWorldEvent event) {
    if(!event.entity.worldObj.isRemote && event.entity instanceof EntityGolemBase) {
        EntityGolemBase golem = (EntityGolemBase) event.entity;
        ExtendedGolemProperties props = (ExtendedGolemProperties) golem.getExtendedProperties(Gadomancy.MODID);
        if(props != null) {
            props.setWrapperIfNeeded();
        }
    }

    if (event.entity instanceof EntityItem) {
        EntityItem item = (EntityItem) event.entity;
        ItemStack stack = item.getEntityItem();

        if (stack.getItem() == ConfigItems.itemGolemPlacer) {
            AdditionalGolemType type = GadomancyApi.getAdditionalGolemType(EnumGolemType.getType(stack.getItemDamage()));
            if (type != null) {
                ItemStack fakePlacer = new ItemStack(type.getPlacerItem());
                fakePlacer.setTagCompound(stack.getTagCompound());
                fakePlacer.setItemDamage(stack.getItemDamage());

                item.setEntityItemStack(fakePlacer);
            }
        }
    }

    if(!event.world.isRemote && event.entity instanceof EntityLivingBase) {
        if(((EntityLivingBase) event.entity).isPotionActive(RegisteredPotions.ACHROMATIC)) {
            ((DataAchromatic) SyncDataHolder.getDataServer("AchromaticData")).handleApplication((EntityLivingBase) event.entity);
        }
    }
}
 
Example 11
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(EntityEvent.EntityConstructing e) {
    if(e.entity instanceof EntityGolemBase) {
        EntityGolemBase golem = (EntityGolemBase) e.entity;

        golem.registerExtendedProperties(Gadomancy.MODID, new ExtendedGolemProperties(golem));

        golem.getDataWatcher().addObject(ModConfig.golemDatawatcherId, "");
    }
}
 
Example 12
Source File: IntegrationThaumicHorizions.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(AttackEntityEvent e) {
    EntityPlayer player = e.entityPlayer;
    if(!e.target.worldObj.isRemote && e.target instanceof EntityGolemTH
            && player.isSneaking()) {
        e.setCanceled(true);

        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem().onLeftClickEntity(stack, player, e.target)
                && e.target.isDead) {
            CommonProxy.EVENT_HANDLER_GOLEM.on(new PlaySoundAtEntityEvent(e.target, "thaumcraft:zap", 0.5f, 1.0f));
        }
    }
}
 
Example 13
Source File: RenderEventHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void renderPost(RenderLivingEvent.Post event) {
    if(event.entity instanceof EntityPlayer) {
        EntityPlayer p = (EntityPlayer) event.entity;
        if(armor != null) {
            p.inventory.armorInventory = armor;
        }
    }
}
 
Example 14
Source File: RenderEventHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void renderEntityPre(RenderLivingEvent.Pre event) {
    if(event.entity instanceof EntityPlayer) {
        EntityPlayer p = (EntityPlayer) event.entity;
        if(((DataAchromatic)SyncDataHolder.getDataClient("AchromaticData")).isAchromatic((EntityPlayer) event.entity)) {
            current = p;
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F);
            GL11.glDepthMask(false);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
        }

        armor = p.inventory.armorInventory;
        p.inventory.armorInventory = new ItemStack[armor.length];
        System.arraycopy(armor, 0, p.inventory.armorInventory, 0, armor.length);

        boolean changed = false;
        for(int i = 0; i < armor.length; i++) {
            if(armor[i] != null && NBTHelper.hasPersistentData(armor[i])) {
                NBTTagCompound compound = NBTHelper.getPersistentData(armor[i]);
                if(compound.hasKey("disguise")) {
                    NBTBase base = compound.getTag("disguise");
                    if(base instanceof NBTTagCompound) {
                        p.inventory.armorInventory[i] = ItemStack.loadItemStackFromNBT((NBTTagCompound) base);
                    } else {
                        p.inventory.armorInventory[i] = null;
                    }
                    changed = true;
                }
            }
        }

        if(!changed) {
            p.inventory.armorInventory = armor;
            armor = null;
        }
    }
}
 
Example 15
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) {
    if (event.player.worldObj.isRemote) {
        return;
    }
    handleQuit((EntityPlayerMP) event.player);
}
 
Example 16
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(LivingEvent.LivingUpdateEvent e) {
    if(!e.entityLiving.worldObj.isRemote) {
        lastUpdated = e.entityLiving;
    }
}
 
Example 17
Source File: WorldEventHandler.java    From TickDynamic with MIT License 4 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
  public void onDimensionUnload(WorldEvent.Unload event)
  {
  	if(event.world == null || event.world.isRemote)
  		return;
  	
  	if(mod.debug)
  		System.out.println("TickDynamic unloading injected lists for world: " + event.world.provider.getDimensionName());
  	
  	try {
      	CustomProfiler customProfiler = (CustomProfiler)event.world.theProfiler;
	setCustomProfiler(event.world, customProfiler.original);
} catch (Exception e) {
	System.err.println("Failed to revert World Profiler to original");
	e.printStackTrace();
}
  	
  	//Remove all references to the lists and EntityObjects contained(Groups will remain loaded in TickDynamic)
  	ListManager list = entityListManager.remove(event.world);
  	if(list != null)
  		list.clear();
  	
  	list = tileListManager.remove(event.world);
  	if(list != null)
  		list.clear();
  	
  	//Clear loaded groups for world
  	mod.clearWorldEntityGroups(event.world);
  	
  	//Clear timed groups
  	ITimed manager = mod.getWorldTimeManager(event.world);
  	if(manager != null)
  		mod.timedObjects.remove(manager);
  	
  	for(ITimed timed : mod.timedObjects.values())
{
  		if(timed instanceof TimedEntities)
  		{
  			TimedEntities timedGroup = (TimedEntities)timed;
  			if(!timedGroup.getEntityGroup().valid)
  				mod.timedObjects.remove(timedGroup);
  		}
}
  	
  }
 
Example 18
Source File: SkullFireSwordDropFix.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent( priority = EventPriority.LOWEST )
public void onLivingDrops( LivingDropsEvent event )
{
  try
  {
    if( mSkullFireSword == null ) {
        return;
    }

    // MainRegistry.Logger.info( "SkullFireSwordDropFix::onLivingDrops" );
    if( event.recentlyHit && isValidSkeletonEntity( event.entityLiving ) && event.source.getEntity() instanceof EntityPlayer)
    {
      EntityPlayer player = (EntityPlayer) event.source.getEntity();
      if( player.getHeldItem() != null && player.getHeldItem().getItem() == mSkullFireSword.getItem())
      {
        // MainRegistry.Logger.info( "SkullFireSwordDropFix::Perform DropAction" );

        if( event.drops.isEmpty() ) {
            dropWitherHeadsInWorld(event, new ItemStack(Items.skull, 1, 1));
        } else
        {
          int skulls = 0;
          for( int i = 0; i < event.drops.size(); i++ )
          {
            EntityItem drop = event.drops.get( i );
            ItemStack stack = drop.getEntityItem();
            if( stack.getItem() == Items.skull )
            {
              if( stack.getItemDamage() == 1 ) {
                  dropWitherHeadsInWorld(event, new ItemStack(Items.skull, skulls + 1, 1));
              } else if( stack.getItemDamage() == 0 ) {
                  dropWitherHeadsInWorld(event, new ItemStack(Items.skull, 1, 1));
              }
            }
          }
          if( skulls == 0 ) {
              dropWitherHeadsInWorld(event, new ItemStack(Items.skull, 1, 1));
          }
        }
      }
    }
  }
  catch( Exception e )
  {
    e.printStackTrace();
  }
}