Clarify Factory call and Event Functionality

This commit is contained in:
Tarion 2013-03-19 23:59:28 -03:00 committed by Christian
parent aa202878e2
commit 9b58fb9384
4 changed files with 28 additions and 28 deletions

View File

@ -11,7 +11,7 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.entity.living.LivingMaxCanSpawnEvent;
import net.minecraftforge.event.entity.living.LivingPackSizeEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
@ -69,10 +69,10 @@ public class ForgeEventFactory
return event.list;
}
public static int getMaxSpawnedInChunk(EntityLiving entity)
public static int getMaxSpawnPackSize(EntityLiving entity)
{
LivingMaxCanSpawnEvent maxCanSpawnEvent = new LivingMaxCanSpawnEvent(entity);
LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxSpawnInChunk : entity.getMaxSpawnedInChunk();
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk();
}
}

View File

@ -1,23 +0,0 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.EntityLiving;
import net.minecraftforge.event.Event.HasResult;
@HasResult
public class LivingMaxCanSpawnEvent extends LivingEvent
{
/**
* This event is fired when the spawning system tries to determine the
* maximum amount of the entity can spawn in a chunk.
*
* If you set the result to 'ALLOW', it means that you want to return
* the value of maxSpawnInChunk as the maximum amount allowed in the
* chunk.
*/
public int maxSpawnInChunk;
public LivingMaxCanSpawnEvent(EntityLiving entity)
{
super(entity);
}
}

View File

@ -0,0 +1,23 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.EntityLiving;
import net.minecraftforge.event.Event.HasResult;
@HasResult
public class LivingPackSizeEvent extends LivingEvent
{
/**
* This event is fired when the spawning system determines the
* maximum amount of the selected entity that can spawn at the same
* time.
*
* If you set the result to 'ALLOW', it means that you want to return
* the value of maxPackSize as the maximum pack size for current entity.
*/
public int maxPackSize;
public LivingPackSizeEvent(EntityLiving entity)
{
super(entity);
}
}

View File

@ -46,7 +46,7 @@
creatureSpecificInit(entityliving, par0WorldServer, f, f1, f2);
- if (j2 >= entityliving.getMaxSpawnedInChunk())
+ if (j2 >= ForgeEventFactory.getMaxSpawnedInChunk(entityliving))
+ if (j2 >= ForgeEventFactory.getMaxSpawnPackSize(entityliving))
{
continue label110;
}