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


Java EntityJoinWorldEvent.setCanceled方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.EntityJoinWorldEvent.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityJoinWorldEvent.setCanceled方法的具體用法?Java EntityJoinWorldEvent.setCanceled怎麽用?Java EntityJoinWorldEvent.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.EntityJoinWorldEvent的用法示例。


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

示例1: onEntityJoinWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
    int i = 0;
    for (SpawnRule rule : RulesManager.rules) {
        if (rule.isOnJoin() && rule.match(event)) {
            Event.Result result = rule.getResult();
            if (debug) {
                InControl.logger.log(Level.INFO, "Join Rule " + i + ": "+ result
                        + " entity: " + event.getEntity().getName()
                        + " y: " + event.getEntity().getPosition().getY());
            }
            if (result != Event.Result.DENY) {
                rule.action(event);
            } else {
                event.setCanceled(true);
            }
            return;
        }
        i++;
    }
}
 
開發者ID:McJty,項目名稱:InControl,代碼行數:22,代碼來源:ForgeEventHandlers.java

示例2: checkSpawn

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void checkSpawn (EntityJoinWorldEvent event) {

    if (event.getEntity() instanceof EntitySlime && !event.getEntity().hasCustomName()) {

        for (final TileEntity tile : event.getWorld().loadedTileEntityList) {

            if (tile instanceof TileEntityAntiSlime && ((TileEntityAntiSlime) tile).shareChunks((EntityLivingBase) event.getEntity())) {

                if (event.getWorld().isBlockPowered(tile.getPos())) {
                    continue;
                }

                event.setCanceled(true);
                event.getEntity().setDead();
                break;
            }
        }
    }
}
 
開發者ID:Darkhax-Minecraft,項目名稱:Dark-Utilities,代碼行數:21,代碼來源:FeatureAntiSlime.java

示例3: on

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void on(EntityJoinWorldEvent event) {
    if(!event.world.isRemote && event.entity instanceof EntityItem) {
        ItemStack stack = ((EntityItem) event.entity).getEntityItem();
        if(isDisguised(stack)) {
            long time = event.world.getTotalWorldTime() + event.world.rand.nextInt(60) + 40;
            trackedItems.put((EntityItem) event.entity, time);
        }
        if(stack.getItem() instanceof ItemElement && !(event.entity instanceof EntityItemElement)) {
            event.setCanceled(true);
            EntityItem newItem = new EntityItemElement(event.world,
                    event.entity.posX, event.entity.posY, event.entity.posZ,
                    ((EntityItem) event.entity).getEntityItem());
            newItem.delayBeforeCanPickup = ((EntityItem) event.entity).delayBeforeCanPickup;
            newItem.motionX = event.entity.motionX;
            newItem.motionY = event.entity.motionY;
            newItem.motionZ = event.entity.motionZ;
            event.world.spawnEntityInWorld(newItem);
        }
    }
}
 
開發者ID:makeoo,項目名稱:Gadomancy,代碼行數:22,代碼來源:EventHandlerWorld.java

示例4: onEntitySpawn

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntitySpawn(EntityJoinWorldEvent event)
{
    if(event.entity.worldObj.isRemote && event.entity instanceof EntityMeteorite && FMLCommonHandler.instance().getEffectiveSide().isClient() && !event.entity.isDead)
    {
        event.setCanceled(true);
        if(!event.entity.worldObj.weatherEffects.contains(event.entity))
        {
            boolean has = false;
            for(int i = 0; i < event.entity.worldObj.weatherEffects.size(); i++)
            {
                Entity ent = (Entity)event.entity.worldObj.weatherEffects.get(i);
                if(ent instanceof EntityMeteorite && ent.getEntityId() == event.entity.getEntityId())
                {
                    has = true;
                    ent.setLocationAndAngles(event.entity.posX, event.entity.posY, event.entity.posZ, 0F, 0F);
                    break;
                }
            }
            if(!has)
            {
                event.entity.worldObj.weatherEffects.add(event.entity);
            }
        }
    }
}
 
開發者ID:iChun,項目名稱:ItFellFromTheSky,代碼行數:27,代碼來源:EventHandler.java

示例5: onEntityJoinWorldEvent

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityJoinWorldEvent(EntityJoinWorldEvent e) {
    if (!e.getWorld().isRemote) {
        List<TileEntity> loadedTileEntityList = e.getWorld().loadedTileEntityList;

        for (int i = loadedTileEntityList.size() - 1; i >= 0; i--) {
            TileEntity tileEntity = loadedTileEntityList.get(i);
            if (tileEntity instanceof OfferingBoxTileEntity) {
                if (((OfferingBoxTileEntity) tileEntity).getChargeLevel() > 0) {
                    if (TotemHelper.hasTotemType((OfferingBoxTileEntity) tileEntity, TotemType.COW)) {
                        Modifiers mods = TotemHelper.getModifiers(e.getWorld(), (OfferingBoxTileEntity) tileEntity);
                        int radius = TotemHelper.DEFAULT_RADIUS + (int) (TotemHelper.RANGE_BOOST * mods.range);

                        if (!canSpawnMobHere(tileEntity.getPos(), e.getEntity(), radius)) {
                            //FMLLog.log(Level.ERROR, "Stopped mob from spawning with radius: " + radius);
                            e.setCanceled(true);
                            break;
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:CorwinJV,項目名稱:MobTotems,代碼行數:25,代碼來源:CowLogic.java

示例6: onEntityJoinWorldEvent

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityJoinWorldEvent(EntityJoinWorldEvent e) {
    if (!e.getWorld().isRemote) {
        List<TileEntity> loadedTileEntityList = new ArrayList<>(e.getWorld().loadedTileEntityList);

        for (TileEntity tileEntity : loadedTileEntityList) {
            if (tileEntity instanceof OfferingBoxTileEntity) {
                if (((OfferingBoxTileEntity) tileEntity).getChargeLevel() > 0) {
                    if (TotemHelper.hasTotemType((OfferingBoxTileEntity) tileEntity, TotemType.CREEPER)) {
                        Modifiers mods = TotemHelper.getModifiers(e.getWorld(), (OfferingBoxTileEntity) tileEntity);
                        int radius = TotemHelper.DEFAULT_RADIUS + (int) (TotemHelper.RANGE_BOOST * mods.range);
                        if (!canSpawnMobHere(tileEntity.getPos(), e.getEntity(), radius)) {
                            //FMLLog.log(Level.ERROR, "Stopped mob from spawning with radius: " + radius);
                            e.setCanceled(true);
                            break;
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:CorwinJV,項目名稱:MobTotems,代碼行數:23,代碼來源:CreeperLogic.java

示例7: onBlockFall

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockFall(EntityJoinWorldEvent event) {
	
	if (event.getEntity() != null && event.getEntity() instanceof EntityFallingBlock) {
		EntityPlayer player = event.getEntity().worldObj.getClosestPlayerToEntity(event.getEntity(), range);
		if (player != null && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == UCItems.precisionShovel) {
			if (NBTUtils.getInt(player.getHeldItemMainhand(), ItemGeneric.TAG_UPGRADE, -1) == 10)
				event.setCanceled(true);
		}
	}
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:12,代碼來源:UCEventHandlerServer.java

示例8: handleRespawnOfNemesis

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
private void handleRespawnOfNemesis(EntityJoinWorldEvent event) {
	Entity entity = event.getEntity();
	NemesisEntry nemesis = NemesisUtil.loadNemesisFromEntity(event.getEntity());
	if (nemesis == null) {
		/*
		 * missing nemesis data
		 */
		entity.setDead();
		event.setCanceled(true);
	} else if (entity.getTags().contains(NemesisSystem.TAG_SPAWNING)) {
		/*
		 * new nemesis spawn in progress
		 */
		entity.removeTag(NemesisSystem.TAG_SPAWNING);
		nemesis.setSpawned(entity.getEntityId());
		nemesis.setUnloaded(null);
		NemesisRegistryProvider.get(entity.world).update(nemesis);
		sendNemesisDataToClient(nemesis);
	} else if (!nemesis.isSpawned()) {
		/*
		 * nemesis has been marked as despawned
		 */
		event.setCanceled(true);
	} else {
		/*
		 * nemesis is marked unloaded, mark as loaded now he is respawning
		 */
		if (!entity.getPersistentID().equals(nemesis.getEntityUuid())) {
			event.setCanceled(true);
			return;
		}

		nemesis.setSpawned(entity.getEntityId());
		nemesis.setUnloaded(null);
		nemesis.setLastSpawned(entity.world.getTotalWorldTime());
		NemesisRegistryProvider.get(event.getWorld()).update(nemesis);
		sendNemesisDataToClient(nemesis);
	}
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:40,代碼來源:SpawnHandler.java

示例9: onEntityCreation

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityCreation(EntityJoinWorldEvent event){
	if(Config.lockedTimeFalling && (event.getEntity() instanceof EntityFallingBlock)){
		if(LockedTimeData.get(event.getWorld()).getNumRunes()>0){
			EntityFallingBlock fb = (EntityFallingBlock)event.getEntity();
			IBlockState state = fb.getBlock();
			fb.setDead();
			event.getWorld().setBlockState(fb.getPosition(), state);
			event.setCanceled(true);
		}
	}
}
 
開發者ID:Xilef11,項目名稱:runesofwizardry-classics,代碼行數:13,代碼來源:RuneLockedTime.java

示例10: entitySpawn

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void entitySpawn(EntityJoinWorldEvent event){
	if(ConfigValues.XPOVERRIDE && !event.getWorld().isRemote && event.getEntity().getClass() == EntityXPOrb.class){
		event.setCanceled(true);
		EntityXPOrb xp = (EntityXPOrb) event.getEntity();
		EntityCustomXPOrb newXP = new EntityCustomXPOrb(xp.world, xp.posX, xp.posY, xp.posZ, xp.xpValue);
		event.getWorld().spawnEntity(newXP);
	}
}
 
開發者ID:The-Fireplace-Minecraft-Mods,項目名稱:Overlord,代碼行數:10,代碼來源:CommonEvents.java

示例11: entityJoinWorldEvent

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void entityJoinWorldEvent(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();

    if (ExtendedConfig.overrideVanillaFishing && entity instanceof EntityFishHook && entity.getClass().equals(EntityFishHook.class)) {
        World world = event.getWorld();
        if (!world.isRemote) {
            EntityPlayer player = ((EntityFishHook) entity).getAngler();
            ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
            if (stack.getItem() != Items.FISHING_ROD) {
                stack = player.getHeldItem(EnumHand.OFF_HAND);
            }
            entity.setDead();

            EntityCustomFishHook hook = new EntityCustomFishHook(world, player);

            int speed = EnchantmentHelper.getFishingSpeedBonus(stack);
            if (speed > 0) {
                hook.setLureSpeed(speed);
            }
            int luck = EnchantmentHelper.getFishingLuckBonus(stack);
            if (luck > 0) {
                hook.setLuck(luck);
            }

            world.spawnEntity(hook);
        }

        event.setCanceled(true);
    }
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:32,代碼來源:GSEventsHandler.java

示例12: onEntitySpawn

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
	if(event.entity instanceof EntityItem && isMonitoring)
	{
		event.setCanceled(true);
	}
}
 
開發者ID:Microsoft,項目名稱:vsminecraft,代碼行數:9,代碼來源:ItemBlockCardboardBox.java

示例13: onEntityJoin

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event)
{
    Entity entity = event.entity;
    Class<?> entityClass = entity.getClass();
    if (blockedMobClasses.containsValue(entityClass) && SprinklesForVanilla.isOnServer)
    {
        if (entityClass == EntityZombie.class)
        {
            if (blockedMobClasses.containsKey("zombieVillager") && ((EntityZombie) entity).isVillager())
            {
                event.setCanceled(true);
            }
            else if (blockedMobClasses.containsKey("zombie") && !((EntityZombie) entity).isVillager())
            {
                event.setCanceled(true);
            }
        }
        else if (entityClass == EntitySkeleton.class)
        {
            if (blockedMobClasses.containsKey("skeleton") && ((EntitySkeleton) entity).getSkeletonType() == 0)
            {
                event.setCanceled(true);
            }
            else if (blockedMobClasses.containsKey("witherSkeleton") && ((EntitySkeleton) entity).getSkeletonType() == 1)
            {
                event.setCanceled(true);
            }
        }
        else
        {
            event.setCanceled(true);
        }
    }
}
 
開發者ID:VikeStep,項目名稱:sprinkles_for_vanilla,代碼行數:36,代碼來源:EntityHandlers.java

示例14: entityJoin

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
  public void entityJoin(EntityJoinWorldEvent evt) {
if (!evt.world.isRemote && evt.entity instanceof EntityPlayerMP) {
	
	packetPipeline.sendTo(new WorldDataPacket(evt.world.getSeed()), (EntityPlayerMP)evt.entity);
}

if (evt.entity instanceof EntityZombie) {
	if (((EntityZombie)evt.entity).isChild()) {
		((EntityZombie)evt.entity).setChild(false);
		evt.setCanceled(true);
	}
}
  }
 
開發者ID:tyronx,項目名稱:vintagecraft,代碼行數:15,代碼來源:VintageCraft.java

示例15: onJoinWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event)
{
    if (event.getWorld().isRemote == false)
    {
        if ((event.getEntity() instanceof EntityLiving) && event.getEntity().getTags().contains(ItemSyringe.TAG_PASSIFIED))
        {
            ItemSyringe.passifyEntity((EntityLiving) event.getEntity());
        }
        else if (preventItemSpawningInWorld && (event.getEntity() instanceof EntityItem))
        {
            event.setCanceled(true);
        }
    }
}
 
開發者ID:maruohon,項目名稱:enderutilities,代碼行數:16,代碼來源:EntityEventHandler.java


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