Java Code Examples for net.minecraftforge.event.entity.EntityEvent

The following are top voted examples for showing how to use net.minecraftforge.event.entity.EntityEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: HealthMod   File: HealthModEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event) {
    if(event.entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entity;
        if(PlayerSymptoms.getForPlayer(player) == null) {
            PlayerSymptoms.addToPlayer(player);

            HealthMod.debug("Adding symptoms");
            PlayerSymptoms.getForPlayer(player).addSymptom(new SymptomFever().instantiate(0));
            PlayerSymptoms.getForPlayer(player).addSymptom(new SymptomNausea().instantiate(2));
        }

        if(PlayerBodyProperties.getForPlayer(player) == null) {
            PlayerBodyProperties.addToPlayer(player);
        }

        if(PlayerDiseases.getForPlayer(player) == null) {
            PlayerDiseases.addToPlayer(player);
        }
    }
}
 
Example 2
Project: ARKCraft-Code   File: ItemsCommonEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event)
{
	if (event.entity instanceof EntityPlayer && ARKPlayer.get((EntityPlayer) event.entity) == null)
	{
		ARKPlayer.register((EntityPlayer) event.entity, event.entity.worldObj);
		if (event.entity.worldObj.isRemote) // On client
		{
			LogHelper.info("ARKPlayerEventHandler: Registered a new ARKPlayer on client.");
		}
		else
		{
			LogHelper.info("ARKPlayerEventHandler: Registered a new ARKPlayer on server.");
		}
	}
}
 
Example 3
Project: ItFellFromTheSky   File: EventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onEnterChunk(EntityEvent.EnteringChunk event)
{
    if(FMLCommonHandler.instance().getEffectiveSide().isServer() && (event.entity instanceof EntityMeteorite || event.entity instanceof EntityPigzilla) && !event.entity.isDead)
    {
        ForgeChunkManager.Ticket ticket = ChunkLoadHandler.tickets.get(event.entity);
        if(ticket == null)
        {
            ticket = ForgeChunkManager.requestTicket(ItFellFromTheSky.instance, event.entity.worldObj, ForgeChunkManager.Type.ENTITY);
            if(ticket != null)
            {
                ticket.bindEntity(event.entity);
                ChunkLoadHandler.addTicket(event.entity, ticket);
            }
        }
        if(ticket != null)
        {
            if(event.oldChunkX != 0 && event.oldChunkZ != 0)
            {
                ForgeChunkManager.unforceChunk(ticket, new ChunkCoordIntPair(event.oldChunkX, event.oldChunkZ));
            }
            ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(event.newChunkX, event.newChunkZ));
        }
    }
}
 
Example 4
Project: R0b0ts   File: PlayerHandler.java   View source code 6 votes vote down vote up
@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());
                }
}
 
Example 5
Project: Soot   File: Attributes.java   View source code 5 votes vote down vote up
@SubscribeEvent
public static void onEntityConstructEvent(EntityEvent.EntityConstructing event)
{
    Entity entity = event.getEntity();
    if(entity instanceof EntityLivingBase) {
        ((EntityLivingBase) entity).getAttributeMap().registerAttribute(PHYSICAL_DAMAGE_RATE);
        ((EntityLivingBase) entity).getAttributeMap().registerAttribute(FIRE_DAMAGE_RATE);
    }
}
 
Example 6
Project: FundamentalChemistry   File: ForgeEventHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void entityConstruct(EntityEvent.EntityConstructing e){
	//add custom properties to players
  if(e.entity instanceof EntityPlayer){
    if(e.entity.getExtendedProperties(PlayerProperties.ID) == null){
      e.entity.registerExtendedProperties(PlayerProperties.ID, new PlayerProperties());
    }
  }
}
 
Example 7
Project: Mods   File: TF2EventsClient.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void entityConstructing(final EntityEvent.EntityConstructing event) {

	if (event.getEntity() instanceof EntityPlayerSP) {
		//System.out.println("Constructing player");
	}
}
 
Example 8
Project: Mods   File: TF2EventsCommon.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void entityConstructing(final EntityEvent.EntityConstructing event) {

	
	if (event.getEntity() instanceof EntityLivingBase) {
		//event.getEntity().getDataManager().register(ENTITY_UBER, false);
		event.getEntity().getDataManager().register(ENTITY_OVERHEAL, 0f);
	}
	
	if (event.getEntity() instanceof EntityPlayer && TF2UdpClient.instance != null) {
		TF2UdpClient.instance.shutdown();
		TF2UdpClient.instance = null;
	}
}
 
Example 9
Project: CraftingParadiseMod   File: EntityHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public void onEntityConstruction(EntityEvent.EntityConstructing event)
{
    Entity entity = event.getEntity();
    if(entity instanceof EntityPlayer)
    {
        if(entity.world != null)
        {
            if(event.getEntity().world.isRemote)
            {
                CraftingParadise.proxy.registerCustomSky();
            }
        }
    }
}
 
Example 10
Project: 4Space-5   File: AsteroidsPlayerHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event)
{
    if (event.entity instanceof EntityPlayerMP && GCPlayerStats.get((EntityPlayerMP) event.entity) == null)
    {
        GCPlayerStats.register((EntityPlayerMP) event.entity);
    }
}
 
Example 11
Project: 4Space-5   File: GCPlayerHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event)
{
    if (event.entity instanceof EntityPlayerMP && GCPlayerStats.get((EntityPlayerMP) event.entity) == null)
    {
        GCPlayerStats.register((EntityPlayerMP) event.entity);
    }

    if (isClient)
    {
        this.onEntityConstructingClient(event);
    }
}
 
Example 12
Project: 4Space-5   File: GCPlayerHandler.java   View source code 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void onEntityConstructingClient(EntityEvent.EntityConstructing event)
{
	if (event.entity instanceof EntityClientPlayerMP)
	{
		if (GCPlayerStatsClient.get((EntityClientPlayerMP) event.entity) == null)
		{
			GCPlayerStatsClient.register((EntityClientPlayerMP) event.entity);          
		}

		Minecraft.getMinecraft().gameSettings.sendSettingsToServer();
	}
}
 
Example 13
Project: ToroQuest   File: CivilizationHandlers.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void handleEnteringProvince(EntityEvent.EnteringChunk event) {
	if (!(event.getEntity() instanceof EntityPlayerMP)) {
		return;
	}
	EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
	PlayerCivilizationCapabilityImpl.get(player).updatePlayerLocation(event.getNewChunkX(), event.getNewChunkZ());
}
 
Example 14
Project: NyaSamaRailway   File: ChunkLoaderHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void entityEnteredChunk(EntityEvent.EnteringChunk event) {
    Entity entity = event.entity;
    if (entity instanceof LocoBase) {
        if (!entity.worldObj.isRemote) {
            ((LocoBase) entity).forceChunkLoading(event.newChunkX, event.newChunkZ);
        } else {
            ((LocoBase) entity).setupChunks(event.newChunkX, event.newChunkZ);
        }
    }
}
 
Example 15
Project: TickDynamic   File: Entity.java   View source code 5 votes vote down vote up
public Entity(World p_i1582_1_)
{
    this.entityId = nextEntityID++;
    this.renderDistanceWeight = 1.0D;
    this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
    this.field_70135_K = true;
    this.width = 0.6F;
    this.height = 1.8F;
    this.nextStepDistance = 1;
    this.rand = new Random();
    this.fireResistance = 1;
    this.firstUpdate = true;
    this.entityUniqueID = UUID.randomUUID();
    this.myEntitySize = Entity.EnumEntitySize.SIZE_2;
    this.worldObj = p_i1582_1_;
    this.setPosition(0.0D, 0.0D, 0.0D);

    if (p_i1582_1_ != null)
    {
        this.dimension = p_i1582_1_.provider.dimensionId;
    }

    this.dataWatcher = new DataWatcher(this);
    this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
    this.dataWatcher.addObject(1, Short.valueOf((short)300));
    this.entityInit();

    extendedProperties = new HashMap<String, IExtendedEntityProperties>();

    MinecraftForge.EVENT_BUS.post(new EntityEvent.EntityConstructing(this));

    for (IExtendedEntityProperties props : this.extendedProperties.values())
    {
        props.init(this, p_i1582_1_);
    }
}
 
Example 16
Project: Thallus   File: PlayerEventHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event)
{
    if (event.entity instanceof EntityPlayer && StatsHelper.get((EntityPlayer) event.entity) == null)
    {
        StatsHelper.register((EntityPlayer) event.entity);
    }
}
 
Example 17
Project: FusionWarfare   File: OnPlayerJoinEvent.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing (EntityEvent.EntityConstructing event) {
		
    if (event.entity instanceof EntityPlayer && FWPlayerStats.get((EntityPlayer) event.entity) == null) {
    	FWPlayerStats.register((EntityPlayer) event.entity);
    }
}
 
Example 18
Project: EventMod   File: EventHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event) {
    Side side = FMLCommonHandler.instance().getEffectiveSide();
    if (side == Side.SERVER) {
        if (event.entity instanceof EntityPlayer) {
            LoreStatusTracker.attachStatusTracker((EntityPlayer) event.entity);
        }
    }
}
 
Example 19
Project: Gadomancy   File: EventHandlerGolem.java   View source code 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(EntityEvent.EntityConstructing e) {
    if(e.entity instanceof EntityGolemBase) {
        EntityGolemBase golem = (EntityGolemBase) e.entity;

        golem.registerExtendedProperties(Gadomancy.MODID, new ExtendedGolemProperties(golem));

        golem.getDataWatcher().addObject(ModConfig.golemDatawatcherId, "");
    }
}
 
Example 20
Project: Gadomancy   File: EventHandlerGolem.java   View source code 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void on(EntityEvent.EnteringChunk event) {
    if(event.entity instanceof EntityGolemBase) {
        EntityGolemBase golem = (EntityGolemBase) event.entity;
        if(GadomancyApi.isAdditionalGolemType(golem.getGolemType())) {
            ExtendedGolemProperties props = (ExtendedGolemProperties)event.entity.getExtendedProperties(Gadomancy.MODID);
            if(props.shouldUpdateHealth()) {
                props.resetUpdateHealth();
                golem.setHealth(props.getHealth());
            }
        }
    }
}
 
Example 21
Project: SecureCraftProtect   File: SCPEntityConstructingHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event) {
    if (event.entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entity;
        if (ExtendedPlayerSCP.get(player) == null) {
            ExtendedPlayerSCP.register(player);
        }
    } else if (event.entity instanceof EntityAnimal) {
        EntityAnimal animal = (EntityAnimal) event.entity;
        if (ExtendedAnimalSCP.get(animal) == null) {
            ExtendedAnimalSCP.register(animal);
        }
    }
}
 
Example 22
Project: sprinkles_for_vanilla   File: PlayerHandlers.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onConstruction(EntityEvent.EntityConstructing event)
{
    if (event.entity instanceof EntityPlayer && event.entity.getExtendedProperties(ModInfo.MOD_NAME) == null && SprinklesForVanilla.isOnServer)
    {
        event.entity.registerExtendedProperties(ModInfo.MOD_NAME, new PlayerProperties());
    }
}
 
Example 23
Project: PeripheralsPlusPlus   File: PropertiesHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstruct(EntityEvent.EntityConstructing event) {
	if (Config.enableNanoBots) {
		if (event.entity.getExtendedProperties(NanoProperties.IDENTIFIER) == null) {
			event.entity.registerExtendedProperties(NanoProperties.IDENTIFIER, new NanoProperties());
		}
	}
}
 
Example 24
Project: AdventureBackpack2   File: PlayerEventHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void registerBackpackProperty(EntityEvent.EntityConstructing event)
{
    if (event.entity instanceof EntityPlayer && BackpackProperty.get((EntityPlayer) event.entity) == null)
    {
        BackpackProperty.register((EntityPlayer) event.entity);
        /*if (!event.entity.worldObj.isRemote)
        {
            AdventureBackpack.proxy.joinPlayer((EntityPlayer)event.entity);
        }*/
    }

}
 
Example 25
Project: mcplus_mods   File: EventHandlerOvergrowth.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityItemUpdate(EntityEvent.EnteringChunk parEvent)
{
	if (!REFORESTATION) return;
	if (!(parEvent.entity instanceof EntityItem)) return;

	EntityItem entityitem = (EntityItem) parEvent.entity;
	ItemStack itemstack = entityitem.getDataWatcher().getWatchableObjectItemStack(10);
	if (itemstack == null || !(Block.getBlockFromItem(itemstack.getItem()) instanceof BlockSapling)) return;
	entityitem.lifespan = REFOREST_AGE;
}
 
Example 26
Project: balkons-weaponmod   File: WMCommonEventHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructed(EntityEvent.EntityConstructing event)
{
	if (event.entity instanceof EntityPlayer)
	{
		PlayerWeaponData.initPlayerWeaponData((EntityPlayer) event.entity);
	}
}
 
Example 27
Project: NausicaaMod   File: NPlayerHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing (EntityEvent.EntityConstructing event)
{
	if (event.entity instanceof EntityPlayer && NPlayerStats.get((EntityPlayer) event.entity) == null)
	{
		NPlayerStats.register((EntityPlayer) event.entity);
	}
}
 
Example 28
Project: Quantum-Anomalies   File: BiomeListener.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void enterChunk(EntityEvent.EnteringChunk event) {
    if (event.entity instanceof EntityPlayer) {
        BiomeGenBase biome = event.entity.worldObj.getBiomeGenForCoords(event.newChunkX * 16, event.newChunkZ * 16);

        if (biome instanceof IBiomeAnomaly)
            NetworkHandler.wrapper.sendToServer(new MessageDiscoveryItem(QADiscoveries.Item.BIOME.get().getKey()));

        if (biome.equals(BiomeGenBase.sky))
            NetworkHandler.wrapper.sendToServer(new MessageDiscoveryItem(QADiscoveries.Item.CHAOS.get().getKey()));

    }
}
 
Example 29
Project: Cauldron   File: Chunk.java   View source code 5 votes vote down vote up
public void addEntity(Entity p_76612_1_)
{
    this.hasEntities = true;
    int i = MathHelper.floor_double(p_76612_1_.posX / 16.0D);
    int j = MathHelper.floor_double(p_76612_1_.posZ / 16.0D);

    if (i != this.xPosition || j != this.zPosition)
    {
        logger.warn("Wrong location! " + p_76612_1_ + " (at " + i + ", " + j + " instead of " + this.xPosition + ", " + this.zPosition + ")");
        Thread.dumpStack();
    }

    int k = MathHelper.floor_double(p_76612_1_.posY / 16.0D);

    if (k < 0)
    {
        k = 0;
    }

    if (k >= this.entityLists.length)
    {
        k = this.entityLists.length - 1;
    }

    MinecraftForge.EVENT_BUS.post(new EntityEvent.EnteringChunk(p_76612_1_, this.xPosition, this.zPosition, p_76612_1_.chunkCoordX, p_76612_1_.chunkCoordZ));
    p_76612_1_.addedToChunk = true;
    p_76612_1_.chunkCoordX = this.xPosition;
    p_76612_1_.chunkCoordY = k;
    p_76612_1_.chunkCoordZ = this.zPosition;
    this.entityLists[k].add(p_76612_1_);
}
 
Example 30
Project: Cauldron   File: Entity.java   View source code 5 votes vote down vote up
public Entity(World p_i1582_1_)
{
    this.entityId = nextEntityID++;
    this.renderDistanceWeight = 1.0D;
    this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
    this.field_70135_K = true;
    this.width = 0.6F;
    this.height = 1.8F;
    this.nextStepDistance = 1;
    this.rand = new Random();
    this.fireResistance = 1;
    this.firstUpdate = true;
    this.entityUniqueID = UUID.randomUUID();
    this.myEntitySize = Entity.EnumEntitySize.SIZE_2;
    this.worldObj = p_i1582_1_;
    this.setPosition(0.0D, 0.0D, 0.0D);

    if (p_i1582_1_ != null)
    {
        this.dimension = p_i1582_1_.provider.dimensionId;
    }

    this.dataWatcher = new DataWatcher(this);
    this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
    this.dataWatcher.addObject(1, Short.valueOf((short)300));
    this.entityInit();

    extendedProperties = new HashMap<String, IExtendedEntityProperties>();

    MinecraftForge.EVENT_BUS.post(new EntityEvent.EntityConstructing(this));

    for (IExtendedEntityProperties props : this.extendedProperties.values())
    {
        props.init(this, p_i1582_1_);
    }
}
 
Example 31
Project: LoreExpansion_old   File: PlayerSpawnHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event) {
    Side side = FMLCommonHandler.instance().getEffectiveSide();
    if (side == Side.SERVER) {
        if (event.entity instanceof EntityPlayer) {
            PlayerHandler.attach((EntityPlayer) event.entity);
        }
    }
}
 
Example 32
Project: Zombie-Total-Conversion-Craft   File: PlayerManager.java   View source code 5 votes vote down vote up
@SuppressWarnings("unused")
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event) {
    if (EntityPlayer.class.isAssignableFrom(event.entity.getClass())) {
        event.entity.registerExtendedProperties(ZombieTC.MODID, new ZombieTCPlayerProperties());
        EntityPlayer player = (EntityPlayer) event.entity;
    }
}
 
Example 33
Project: RuneCraftery   File: Chunk.java   View source code 5 votes vote down vote up
/**
 * Adds an entity to the chunk. Args: entity
 */
public void addEntity(Entity par1Entity)
{
    this.hasEntities = true;
    int i = MathHelper.floor_double(par1Entity.posX / 16.0D);
    int j = MathHelper.floor_double(par1Entity.posZ / 16.0D);

    if (i != this.xPosition || j != this.zPosition)
    {
        this.worldObj.getWorldLogAgent().logSevere("Wrong location! " + par1Entity);
        Thread.dumpStack();
    }

    int k = MathHelper.floor_double(par1Entity.posY / 16.0D);

    if (k < 0)
    {
        k = 0;
    }

    if (k >= this.entityLists.length)
    {
        k = this.entityLists.length - 1;
    }

    MinecraftForge.EVENT_BUS.post(new EntityEvent.EnteringChunk(par1Entity, this.xPosition, this.zPosition, par1Entity.chunkCoordX, par1Entity.chunkCoordZ));
    par1Entity.addedToChunk = true;
    par1Entity.chunkCoordX = this.xPosition;
    par1Entity.chunkCoordY = k;
    par1Entity.chunkCoordZ = this.zPosition;
    this.entityLists[k].add(par1Entity);
}
 
Example 34
Project: RuneCraftery   File: Entity.java   View source code 5 votes vote down vote up
public Entity(World par1World)
{
    this.entityId = nextEntityID++;
    this.renderDistanceWeight = 1.0D;
    this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
    this.field_70135_K = true;
    this.width = 0.6F;
    this.height = 1.8F;
    this.nextStepDistance = 1;
    this.rand = new Random();
    this.fireResistance = 1;
    this.firstUpdate = true;
    this.dataWatcher = new DataWatcher();
    this.entityUniqueID = UUID.randomUUID();
    this.myEntitySize = EnumEntitySize.SIZE_2;
    this.worldObj = par1World;
    this.setPosition(0.0D, 0.0D, 0.0D);

    if (par1World != null)
    {
        this.dimension = par1World.provider.dimensionId;
    }

    this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
    this.dataWatcher.addObject(1, Short.valueOf((short)300));
    this.entityInit();

    extendedProperties = new HashMap<String, IExtendedEntityProperties>();

    MinecraftForge.EVENT_BUS.post(new EntityEvent.EntityConstructing(this));

    for (IExtendedEntityProperties props : this.extendedProperties.values())
    {
        props.init(this, par1World);
    }
}
 
Example 35
Project: ClockworkPhase   File: EntityHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstruction(EntityEvent.EntityConstructing event)
{
    if(event.entity instanceof EntityPlayer && ExtendedPlayerProperties.get((EntityPlayer) event.entity) == null)
    {
        ExtendedPlayerProperties.register((EntityPlayer) event.entity);
    }
}
 
Example 36
Project: Battlegear2   File: WeaponHookContainerClass.java   View source code 5 votes vote down vote up
/**
 * Register the custom attributes
 */
@SubscribeEvent
public void onLivingConstructor(EntityEvent.EntityConstructing constructing){
    if(constructing.getEntity() instanceof EntityLivingBase){
        AbstractAttributeMap attributeMap = ((EntityLivingBase) constructing.getEntity()).getAttributeMap();
        attributeMap.registerAttribute(Attributes.armourPenetrate);
        attributeMap.registerAttribute(Attributes.daze);
        if(constructing.getEntity() instanceof EntityPlayer){
            attributeMap.registerAttribute(Attributes.extendedReach).setBaseValue(-2.2);//Reduce bare hands range
        }
        attributeMap.registerAttribute(Attributes.attackSpeed);
        attributeMap.registerAttribute(Attributes.mountedBonus);
    }
}
 
Example 37
Project: BetterNutritionMod   File: Chunk.java   View source code 5 votes vote down vote up
/**
 * Adds an entity to the chunk. Args: entity
 */
public void addEntity(Entity par1Entity)
{
    this.hasEntities = true;
    int i = MathHelper.floor_double(par1Entity.posX / 16.0D);
    int j = MathHelper.floor_double(par1Entity.posZ / 16.0D);

    if (i != this.xPosition || j != this.zPosition)
    {
        this.worldObj.getWorldLogAgent().logSevere("Wrong location! " + par1Entity);
        Thread.dumpStack();
    }

    int k = MathHelper.floor_double(par1Entity.posY / 16.0D);

    if (k < 0)
    {
        k = 0;
    }

    if (k >= this.entityLists.length)
    {
        k = this.entityLists.length - 1;
    }

    MinecraftForge.EVENT_BUS.post(new EntityEvent.EnteringChunk(par1Entity, this.xPosition, this.zPosition, par1Entity.chunkCoordX, par1Entity.chunkCoordZ));
    par1Entity.addedToChunk = true;
    par1Entity.chunkCoordX = this.xPosition;
    par1Entity.chunkCoordY = k;
    par1Entity.chunkCoordZ = this.zPosition;
    this.entityLists[k].add(par1Entity);
}
 
Example 38
Project: BetterNutritionMod   File: Entity.java   View source code 5 votes vote down vote up
public Entity(World par1World)
{
    this.entityId = nextEntityID++;
    this.renderDistanceWeight = 1.0D;
    this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
    this.field_70135_K = true;
    this.width = 0.6F;
    this.height = 1.8F;
    this.nextStepDistance = 1;
    this.rand = new Random();
    this.fireResistance = 1;
    this.firstUpdate = true;
    this.dataWatcher = new DataWatcher();
    this.entityUniqueID = UUID.randomUUID();
    this.myEntitySize = EnumEntitySize.SIZE_2;
    this.worldObj = par1World;
    this.setPosition(0.0D, 0.0D, 0.0D);

    if (par1World != null)
    {
        this.dimension = par1World.provider.dimensionId;
    }

    this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
    this.dataWatcher.addObject(1, Short.valueOf((short)300));
    this.entityInit();

    extendedProperties = new HashMap<String, IExtendedEntityProperties>();

    MinecraftForge.EVENT_BUS.post(new EntityEvent.EntityConstructing(this));

    for (IExtendedEntityProperties props : this.extendedProperties.values())
    {
        props.init(this, par1World);
    }
}
 
Example 39
Project: secri   File: EntitySpawning.java   View source code 5 votes vote down vote up
@ForgeSubscribe
public void onSpawnInChunk(EntityEvent.EnteringChunk event) {
	if (event.entity.posX > event.newChunkX * 16 + 16 || event.entity.posX < event.newChunkX * 16 || event.entity.posZ > event.newChunkZ * 16 + 16
			|| event.entity.posZ < event.newChunkZ * 16) {
		if (MaemeConfig.printErrors)
			System.out.println("Fixing entity");
		event.entity.posX = RandomHelper.getRandomNumberBetween(0, 15) + event.newChunkX * 16;
		event.entity.posZ = RandomHelper.getRandomNumberBetween(0, 15) + event.newChunkZ * 16;
	}
}
 
Example 40
Project: Mods   File: SpinToWin.java   View source code 4 votes vote down vote up
@SubscribeEvent
public void entityConstructing(final EntityEvent.EntityConstructing event) {
	if(event.getEntity() instanceof EntityPlayer){
		event.getEntity().getDataManager().register(SPIN_TIME, false);
	}
}