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


Java LivingSpawnEvent.CheckSpawn方法代碼示例

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


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

示例1: onEntitySpawnEvent

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
    int i = 0;
    for (SpawnRule rule : RulesManager.rules) {
        if (rule.match(event)) {
            Event.Result result = rule.getResult();
            if (debug) {
                InControl.logger.log(Level.INFO, "Rule " + i + ": "+ result
                        + " entity: " + event.getEntity().getName()
                        + " y: " + event.getY()
                        + " biome: " + event.getWorld().getBiome(new BlockPos(event.getX(), event.getY(), event.getZ())).getBiomeName());
            }
            event.setResult(result);
            if (result != Event.Result.DENY) {
                rule.action(event);
            }
            return;
        }
        i++;
    }
}
 
開發者ID:McJty,項目名稱:InControl,代碼行數:22,代碼來源:ForgeEventHandlers.java

示例2: SiegeCheckSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void SiegeCheckSpawn(final LivingSpawnEvent.CheckSpawn event) {
    if (EventHandlerSiege.SiegeParticipants.isEmpty()) {
        return;
    }
    if (event.entity.worldObj.isRemote) {
        return;
    }
    if (event.world.provider.dimensionId != 1) {
        return;
    }
    if (event.entityLiving instanceof EntityMob && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) {
        event.entityLiving.getEntityData().setBoolean("Siege", true);
        event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 7200, 2));
        event.setResult(Event.Result.ALLOW);
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:18,代碼來源:EventHandlerSiege.java

示例3: noMobs

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void noMobs(final LivingSpawnEvent.CheckSpawn event) {
    if (event.getResult() == Event.Result.DEFAULT && event.world.provider.dimensionId == ExtraUtils.underdarkDimID && event.entity instanceof EntityMob) {
        if (EventHandlerUnderdark.rand.nextDouble() < Math.min(0.95, event.entity.posY / 80.0)) {
            event.setResult(Event.Result.DENY);
        }
        else {
            IAttributeInstance t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.maxHealth);
            t.setBaseValue(t.getBaseValue() * 2.0);
            ((EntityMob)event.entity).heal((float)t.getAttributeValue());
            t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.attackDamage);
            t.setBaseValue(t.getBaseValue() * 2.0);
            if (!EventHandlerServer.isInRangeOfTorch(event.entity) && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) {
                event.setResult(Event.Result.ALLOW);
            }
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:19,代碼來源:EventHandlerUnderdark.java

示例4: onCheckSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onCheckSpawn(LivingSpawnEvent.CheckSpawn event) {
    double distanceMin = Double.MAX_VALUE;

    for (int i = -31; i <= 32; ++i) {
        for (int j = -31; j <= 32; ++j) {
            for (int k = -31; k <= 32; ++k) {
                BlockPos pos = new BlockPos(event.getX() + i, event.getY() + j, event.getZ() + k);
                IBlockState state = event.getWorld().getBlockState(pos);
                if (state.getBlock() instanceof BlockSourceLight && state.getValue(IWTechBlocks.WORKING)) {
                    distanceMin = Math.min(distanceMin, MathHelper.sqrt_double(i * i + j * j + k * k));
                }
            }
        }
    }

    if (event.getWorld().rand.nextDouble() * 32.0D > distanceMin) {
        event.setResult(Event.Result.DENY);
    }
}
 
開發者ID:InfinityStudio,項目名稱:InspiringWorld,代碼行數:21,代碼來源:BlockSourceLight.java

示例5: onEntityCheckSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityCheckSpawn(LivingSpawnEvent.CheckSpawn event)
{
	if(event.getResult() == Event.Result.ALLOW) return;
	if(TorchmasterConfig.MegaTorchAllowVanillaSpawners && event.isSpawner()) return;

	if(TorchMasterMod.MegaTorchFilterRegistry.containsEntity(event.getEntity()))
	{
		if(TorchRegistry.getMegaTorchRegistry().isInRangeOfTorch(event.getWorld(), event.getEntity().getPosition()))
		{
			event.setResult(Event.Result.DENY);
		}
	}
	else if(TorchMasterMod.DreadLampFilterRegistry.containsEntity(event.getEntity()))
	{
		if(TorchRegistry.getDreadLampRegistry().isInRangeOfTorch(event.getWorld(), event.getEntity().getPosition()))
		{
			event.setResult(Event.Result.DENY);
		}
	}
}
 
開發者ID:Xalcon,項目名稱:TorchMaster,代碼行數:22,代碼來源:EventHandlerServer.java

示例6: spawnHandler

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void spawnHandler(LivingSpawnEvent.CheckSpawn event)
{
	if((!(event.getEntity() instanceof EntityPlayer))&&(!(event.getWorld().isRemote)))
	{
		if(ScarecrowTracking.get(event.getWorld()).inRange(event.getEntity()))
		{
			if(event.getWorld().getBlockState(event.getEntity().getPosition()).getBlock()==Blocks.FARMLAND)
			{
				event.setResult(Result.DENY);
			}
			if(event.getEntity() instanceof EntityBat)
			{
				event.setResult(Result.DENY);
				// I hate bats
			}
		}
	}
}
 
開發者ID:theishiopian,項目名稱:ForageCraft,代碼行數:20,代碼來源:SpawnHandler.java

示例7: BlockSpawnEvent

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void BlockSpawnEvent(LivingSpawnEvent.CheckSpawn event){
    List<MobInhibitorReference> RefList;
    if (event.getResult() != Event.Result.DEFAULT){ return;} // If the event is already forced Allow or Deny, let it through
    if (event.entity.isCreatureType(EnumCreatureType.monster,false)){ //decide which list to use.
        RefList = MobInhibitor.HostileInhibitors;
    } else if (event.entity.isCreatureType(EnumCreatureType.waterCreature,false)){
        RefList = MobInhibitor.AquaInhibitors;
    } else { // this will also catch ambient creatures like bats.
        if (!ConfigurationHandler.InhibitAmbient && event.entity.isCreatureType(EnumCreatureType.ambient,false)){
            return; //If the InhibitAmbient config is not set, and the creature type is ambient, don't do anything.
            //If the config is set, fall through. The remaining category is Creature, which includes passives.
        }
        RefList = MobInhibitor.PassiveInhibitors;
    }
    for (MobInhibitorReference Ref : RefList){
        if (TestRange(Ref, event.entity.posX, event.entity.posY, event.entity.posZ, event.world.provider.dimensionId)) {
            event.setResult(Event.Result.DENY);
            LogHelper.debug("Blocked a spawn based on inhibitor at:"+Ref.i+", "+Ref.j+", "+Ref.k);
            return;
        }
    }
}
 
開發者ID:yarrim,項目名稱:MobInhibitor,代碼行數:24,代碼來源:ServerEventHandler.java

示例8: onEntitySpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntitySpawn(LivingSpawnEvent.CheckSpawn evt) {
  if (evt.getResult() == Result.DENY) {
    return;
  }
  
  if(Config.spawnGuardStopAllSlimesDebug && evt.getEntity() instanceof EntitySlime) {
    evt.setResult(Result.DENY);
    return;
  }
  if(Config.spawnGuardStopAllSquidSpawning && evt.getEntity().getClass() == EntitySquid.class) {
    evt.setResult(Result.DENY);
    return;
  }
  
  Map<BlockPos, ISpawnCallback> guards = getGuardsForWorld(evt.getWorld());
  for (ISpawnCallback guard : guards.values()) {
    ISpawnCallback.Result result = guard.isSpawnPrevented(evt.getEntityLiving());
    if (result == ISpawnCallback.Result.DENY) {
      evt.setResult(Result.DENY);
      return;
    } else if (result == ISpawnCallback.Result.DONE) {
      return;
    }
  }    
}
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:27,代碼來源:SpawningObeliskController.java

示例9: onCheckSpawnEvent

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
public static void onCheckSpawnEvent(LivingSpawnEvent.CheckSpawn checkSpawnEvent) {
    if(enabled) {
        SpawnEventDetails details = new SpawnEventDetails();
        details.entity = (EntityLiving) checkSpawnEvent.getEntityLiving();
        details.fromSpawner = checkSpawnEvent.isSpawner();
        eventsThisTickByDimension.computeIfAbsent(details.entity.world.provider.getDimension(), thing -> new HashMap<>()).put(details.entity, details);

    }
}
 
開發者ID:talandar,項目名稱:ProgressiveDifficulty,代碼行數:10,代碼來源:DifficultyManager.java

示例10: onCreatureSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onCreatureSpawn(LivingSpawnEvent.CheckSpawn event)
{
    if ( isInsideBorder(event) )
        return;

    // CheckSpawn uses event result instead of cancellation
    event.setResult(LivingSpawnEvent.Result.DENY);
}
 
開發者ID:abused,項目名稱:World-Border,代碼行數:10,代碼來源:MobSpawnListener.java

示例11: canEntitySpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
public static Result canEntitySpawn(EntityLiving entity, World world, float x, float y, float z)
{
    if (entity == null)
        return Result.DEFAULT;
    LivingSpawnEvent.CheckSpawn event = new LivingSpawnEvent.CheckSpawn(entity, world, x, y, z);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResult();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:9,代碼來源:ForgeEventFactory.java

示例12: magnumTorchDenySpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void magnumTorchDenySpawn(final LivingSpawnEvent.CheckSpawn event) {
    if (event.getResult() == Event.Result.ALLOW) {
        return;
    }
    if (event.entityLiving.isCreatureType(EnumCreatureType.monster, false) && isInRangeOfTorch(event.entity)) {
        event.setResult(Event.Result.DENY);
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:10,代碼來源:EventHandlerServer.java

示例13: spawnLiving

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void spawnLiving(LivingSpawnEvent.CheckSpawn spawnEvent)
{
    World world = spawnEvent.getWorld();
    EntityLivingBase entity = spawnEvent.getEntityLiving();
    Chunk chunk = world.getChunkFromBlockCoords(new BlockPos(spawnEvent.getX(),spawnEvent.getY(),spawnEvent.getZ()));

    if(!chunk.isLoaded())
        return;

    if(entity instanceof EntityZombie || entity instanceof EntitySkeleton || entity instanceof EntityCreeper)
        spawnEvent.setResult(Event.Result.DENY);
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:14,代碼來源:TerratorialHandler.java

示例14: onCheckSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onCheckSpawn(LivingSpawnEvent.CheckSpawn event) {
    // Check if there is nearby ender leaves.
    for (int i = -4; i <= 4; ++i)
        for (int j = -4; j <= 4; ++j)
            for (int k = -4; k <= 4; ++k)
                if (event.getWorld().getBlockState(
                    new BlockPos(event.getX() + i, event.getY() + j, event.getZ() + k)).getBlock()
                    .equals(IWTechBlocks.BLOCK_ENDER_LEAVES))
                    return;
    // Without nearby ender leaves, 50% chance to cancel it.
    if (event.getWorld().rand.nextBoolean()) {
        event.setResult(Event.Result.DENY);
    }
}
 
開發者ID:InfinityStudio,項目名稱:InspiringWorld,代碼行數:16,代碼來源:BlockEnderLeaves.java

示例15: onMobSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMobSpawn(final LivingSpawnEvent.CheckSpawn event) {
	if (!BLOCK_MOB_TREE_SPAWNING)
		return;
	final BlockPos pos = new BlockPos(event.x, event.y - 1, event.z);
	final Block block = event.world.getBlockState(pos).getBlock();
	if (block.canSustainLeaves(event.world, pos))
		event.setResult(Result.DENY);
}
 
開發者ID:OreCruncher,項目名稱:Restructured,代碼行數:10,代碼來源:MobControl.java


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