當前位置: 首頁>>代碼示例>>Java>>正文


Java ForgeSubscribe類代碼示例

本文整理匯總了Java中net.minecraftforge.event.ForgeSubscribe的典型用法代碼示例。如果您正苦於以下問題:Java ForgeSubscribe類的具體用法?Java ForgeSubscribe怎麽用?Java ForgeSubscribe使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ForgeSubscribe類屬於net.minecraftforge.event包,在下文中一共展示了ForgeSubscribe類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onAttack

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void onAttack(LivingAttackEvent event)
{
	Entity source = event.source.getSourceOfDamage();
	
	if(source != null && source instanceof EntityLiving && !event.source.isProjectile())
	{
		EntityLiving attacker = (EntityLiving)source;
		
		PotionEffect affliction = attacker.getActivePotionEffect(Potion.confusion);
		
		if(affliction != null)
		{
			Random rand = attacker.getRNG();
			int tier = affliction.getAmplifier();
			
			if(rand.nextInt(5) <= tier)
			{
				event.setCanceled(true);
			}
		}
	}
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:24,代碼來源:EventManagerMF.java

示例2: fertellise

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void fertellise (BonemealEvent event)
{
	World world = event.world;
	EntityPlayer player = event.entityPlayer;
	int x = event.X;
	int y = event.Y;
	int z = event.Z;
	int id = event.ID;
	ItemStack item = player.getHeldItem();
	int meta = world.getBlockMetadata(x, y, z);
	
	if (id == BlockListMF.sapling.blockID)
       {
           if (!world.isRemote)
           {
               if ((double)world.rand.nextFloat() < ((BlockSaplingMF)BlockListMF.sapling).getBonemealChance(meta))
               {
                   ((BlockSaplingMF)BlockListMF.sapling).markOrGrowMarked(world, x, y, z, world.rand);
               }
           }

           event.setResult(Result.ALLOW);
       }
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:26,代碼來源:EventManagerMF.java

示例3: onEntityJoinWorld

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
   public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
	if(event.entity instanceof EntityArrow)
	{
		EntityArrow arrow = (EntityArrow)event.entity;
		if(arrow.shootingEntity != null && arrow.shootingEntity instanceof EntityLiving)
		{
			EntityLiving attacker = (EntityLiving)arrow.shootingEntity;
			
			PotionEffect affliction = attacker.getActivePotionEffect(Potion.confusion);
			
			if(affliction != null)
			{
				Random rand = attacker.getRNG();
				float tier = (float)affliction.getAmplifier()+1*5F;
				
				arrow.motionX *= 1F + ((rand.nextFloat()*0.2F - 0.1F)*tier);
				arrow.motionY *= 1F + ((rand.nextFloat()*0.2F - 0.1F)*tier);
				arrow.motionZ *= 1F + ((rand.nextFloat()*0.2F - 0.1F)*tier);
			}
		}
	}
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:25,代碼來源:EventManagerMF.java

示例4: onEntityLivingDeath

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void onEntityLivingDeath( LivingDeathEvent event )
{
	if( event.entity.worldObj.isRemote )
	{
		return;
	}
	
	if( event.entity instanceof EntityZombie )
	{
		EntityLivingBase living = (EntityLivingBase)event.entity;
		if( (living.isChild() && r.nextInt(20) == 0) ||
		    (!living.isChild() && r.nextInt(100) == 0) )
		{
			event.entity.entityDropItem( new ItemStack( Billund.Items.orderForm, 1 ), 0.0f );
		}
	}
}
 
開發者ID:dan200,項目名稱:Billund,代碼行數:19,代碼來源:BillundProxyCommon.java

示例5: miniPre

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
@ForgeSubscribe(priority = EventPriority.HIGHEST)
public void miniPre(RenderPlayerEvent.Pre event){
	if(((EntityLivingBase) event.entity).isPotionActive(FCraftPotions.miniPot)){
		GL11.glPushMatrix();
		GL11.glScalef(0.2F, 0.2F, 0.2F);
		//GL11.glTranslatef(0, -6.5F, 0);
		if(event.entity instanceof EntityPlayer){
			EntityPlayer player = (EntityPlayer) event.entity;
			player.height = 0.5F;
			player.yOffset = 0.55F;
			mc.thePlayer.eyeHeight = 0.02F;
			player.boundingBox.setBounds(player.posX - (double)player.width/2.0F, player.posY - (double)player.yOffset + (double)player.ySize, player.posZ - (double)player.width/2.0F, player.posX + (double)player.width/2.0F, player.posY - (double)player.yOffset + (double)player.ySize + (double)player.height, player.posZ + (double)player.width/2.0F);
		}
	}
}
 
開發者ID:Unrelentless,項目名稱:FantasyCraft-Mod,代碼行數:17,代碼來源:FCraftEffectsHandler.java

示例6: onEntityJoinWorld

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
	//Only need to synchronize when the world is remote (i.e. we're on the server side)
	if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer){
		FCraftJobCore.get((EntityPlayer) event.entity).sync();
		FCraftJobCore props = FCraftJobCore.get((EntityPlayer) event.entity);
		if(event.entity.dimension==0){
			MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatMessageComponent.createFromText(props.getJob()+" "+event.entity.getEntityName()+" has joined the search for the grimoire."));		
		}else if(event.entity.dimension==-1){
			MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatMessageComponent.createFromText(props.getJob()+" "+event.entity.getEntityName()+" went to hell!"));			
		}else if(event.entity.dimension==DimensionID.WORLD_OF_BALANCE_ID){
			MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatMessageComponent.createFromText(props.getJob()+" "+event.entity.getEntityName()+" entered the World of Balance!"));		
		}
		
		FCraftJobCore playerData = FCraftJobCore.get((EntityPlayer)event.entity);
		NBTTagCompound savedData = CommonProxy.getEntityData(getSaveKey((EntityPlayer)event.entity));

		if(savedData != null) {
		playerData.loadNBTData(savedData);
		}
		playerData.sync();
	}
}
 
開發者ID:Unrelentless,項目名稱:FantasyCraft-Mod,代碼行數:25,代碼來源:FCraftEntityConsturctionHandler.java

示例7: onLivingDrops

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void onLivingDrops(LivingDropsEvent event)
{
	if (event.entityLiving == null)
	{
		return;
	}
	
	if (event.entityLiving instanceof EntityDragon)
	{
		if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) event.source.getEntity();
			if (!player.worldObj.isRemote)
			{
				EntityItem item = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(Registries.dragonEgg, 1, 0));
	            player.worldObj.spawnEntityInWorld(item);
	            if (!(player instanceof FakePlayer))
	            {
	                item.onCollideWithPlayer(player);
	            }
			}
		}
	}
}
 
開發者ID:Zerokyuuni,項目名稱:Ex-Aliquo,代碼行數:26,代碼來源:AliquoEvents.java

示例8: onEntityPlaceTE

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
@SideOnly(Side.SERVER)
public void onEntityPlaceTE (PlayerInteractEvent event) {
    if (event.entityPlayer.worldObj.getChunkFromBlockCoords(event.x, event.z).chunkTileEntityMap.size() >= Apocalyptic.tePerChunk && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && (event.entityPlayer.worldObj.getBlockTileEntity(event.x, event.y, event.z) == null || event.entityPlayer.isSneaking())) {
        if (event.entityLiving.getHeldItem() != null && (TileEntities.contains(event.entityLiving.getHeldItem().getItem().itemID) || ((event.entityLiving.getHeldItem().getItem().itemID < 4096) && Block.blocksList[event.entityLiving.getHeldItem().getItem().itemID].hasTileEntity()))) {
            event.setCanceled(true);
            event.entityPlayer.addChatMessage("\2474\u0414\u043E\u0441\u0442\u0438\u0433\u043D\u0443\u0442\u043E \u043C\u0430\u043A\u0441. \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E TE \u0432 \u0447\u0430\u043D\u043A\u0435");
        }
    }
    if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && event.entityLiving.getHeldItem() != null) {
        if ((event.entityLiving.getHeldItem().itemID == 1407 || event.entityLiving.getHeldItem().itemID == 223) && (event.entityPlayer.worldObj.provider.dimensionId != 0)) {
            event.setCanceled(true);
            event.entityPlayer.addChatMessage("\2474Невозможно установить устройство!");
        }
        if (event.entityLiving.getHeldItem().itemID == 2007 && event.entityLiving.getHeldItem().getItemDamage() == 2 && event.entityPlayer.worldObj.provider.dimensionId == 4) {
            event.setCanceled(true);
            event.entityPlayer.addChatMessage("\2474Невозможно установить устройство!");
        }
    }
}
 
開發者ID:kunik-ru,項目名稱:Apocalyptic,代碼行數:21,代碼來源:EventPlayerPlaceTE.java

示例9: onArrowLooseEvent

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
  public void onArrowLooseEvent(ArrowLooseEvent event)
  {
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack par1ItemStack = inv.getStackInSlot(inv.currentItem);
if(inv.getCurrentItem().itemID == Item.bow.itemID)
{
	if(mod_Rediscovered.QuickBow)
       {
        boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
        ItemStack itemstack = player.inventory.armorInventory[2];

        if (itemstack != null && itemstack.itemID == mod_Rediscovered.Quiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.LeatherQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.ChainQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.IronQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.GoldQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.DiamondQuiver.itemID)
        {
        	event.setCanceled(true);
        }
       }
}
  }
 
開發者ID:Stormister,項目名稱:Rediscovered-Mod-1.6.4,代碼行數:21,代碼來源:RediscoveredEventHandler.java

示例10: onPlayerJoinWorld

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void onPlayerJoinWorld(EntityEvent.EntityConstructing event)
{
    if (event.entity != null)
        if (event.entity.worldObj != null)
            if (!event.entity.worldObj.isRemote)
                if (event.entity instanceof EntityPlayer)
                {
                    EntityPlayer player = (EntityPlayer) event.entity;
                    if (player
                            .getExtendedProperties(R0b0tsPlayerProperties.IDENTIFIER) == null)
                        player.registerExtendedProperties(
                                R0b0tsPlayerProperties.IDENTIFIER,
                                new R0b0tsPlayerProperties());
                }
}
 
開發者ID:PaleoCrafter,項目名稱:R0b0ts,代碼行數:17,代碼來源:PlayerHandler.java

示例11: onSoundLoad

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void onSoundLoad(SoundLoadEvent event)
{

    // For each custom sound file we have defined in Sounds
    for (String soundFile : soundFiles)
    {
        // Try to add the custom sound file to the pool of sounds
        try
        {
            event.manager.addSound(soundFile);
        }
        // If we cannot add the custom sound file to the pool, log the exception
        catch (Exception e)
        {
            FMLLog.warning("Failed loading sound file: " + soundFile);
        }
    }
}
 
開發者ID:PaleoCrafter,項目名稱:R0b0ts,代碼行數:20,代碼來源:SoundHandler.java

示例12: handleBonemeal

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void handleBonemeal(BonemealEvent event) {

	if (!Proxies.common.isSimulating(event.world))
		return;

	TileEntity tile = event.world.getBlockTileEntity(event.X, event.Y, event.Z);
	if (tile instanceof TileSapling) {
		if (((TileSapling) tile).tryGrow(true)) {
			event.setResult(Result.ALLOW);
		}
	} else if(tile instanceof IFruitBearer) {
		IFruitBearer bearer = (IFruitBearer)tile;
		if(bearer.getRipeness() <= 1.0f) {
			bearer.addRipeness(1.0f);
			event.setResult(Result.ALLOW);
		}
	}
}
 
開發者ID:ForestryMC,項目名稱:ForestryLegacy,代碼行數:20,代碼來源:EventHandlerArboriculture.java

示例13: onPopulateChunk

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void onPopulateChunk(PopulateChunkEvent.Post event) {
	if (!event.world.isRemote && shopData != null && event.world.villageCollectionObj != null) {
		List<ChunkCoordinates> villageCoords = new ArrayList<ChunkCoordinates>();
		List<Village> villages = event.world.villageCollectionObj.getVillageList();
		for (Village village : villages) {
			ChunkCoordinates coords = village.getCenter();
			if (isVillageVisited(coords)) {
				continue;
			}
			spawnShop(event.world, coords.posX, coords.posZ);
			shopData.visitedVillageCoords.add(village.getCenter());
			shopData.setDirty(true);
		}
	}
}
 
開發者ID:Hunternif,項目名稱:Dota2Items,代碼行數:17,代碼來源:ShopSpawner.java

示例14: playerUpdate

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void playerUpdate(LivingEvent.LivingUpdateEvent event) {
    if (ticks > 16) {
        if (event.entityLiving != null && event.entityLiving instanceof EntityPlayer) {
            if (!event.entityLiving.worldObj.isRemote)
                return;

            EntityPlayer player = (EntityPlayer) event.entityLiving;
            String capeUrl = CapeHandler.getCapeUrl(player.username);
            if (capeUrl != null && !capeUrl.equals(player.cloakUrl)) {
                player.cloakUrl = capeUrl;
                FMLClientHandler.instance().getClient().renderEngine.obtainImageData(player.cloakUrl, null);
            }
        }
    ticks = 0;
    }
    ticks++;
}
 
開發者ID:sct,項目名稱:HexxitGear,代碼行數:19,代碼來源:PlayerEventHandler.java

示例15: onSound

import net.minecraftforge.event.ForgeSubscribe; //導入依賴的package包/類
@ForgeSubscribe
public void onSound(SoundLoadEvent event) {
       try {
       	for (Sound sound : Sound.values()) {
       		if (!sound.isRandom()) {
       			event.manager.soundPoolSounds.addSound(sound.getName()+".ogg");
       		} else {
       			for (int i = 1; i <= sound.randomVariants; i++) {
       				event.manager.soundPoolSounds.addSound(sound.getName()+i+".ogg");
       			}
       		}
       	}
       }
       catch (Exception e) {
       	Dota2Items.logger.warning("Failed to register one or more sounds.");
       }
   }
 
開發者ID:Hunternif,項目名稱:Dota2Items,代碼行數:18,代碼來源:ClientProxy.java


注:本文中的net.minecraftforge.event.ForgeSubscribe類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。