本文整理匯總了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++;
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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
}
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}