Java Code Examples for net.minecraftforge.event.entity.EntityJoinWorldEvent#getEntity()

The following examples show how to use net.minecraftforge.event.entity.EntityJoinWorldEvent#getEntity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventHandler.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void redstoneHandler(EntityJoinWorldEvent event) {
	if (event.getWorld().isRemote) {
		return;
	}

	if (event.getEntity() instanceof EntityItem && !(event.getEntity() instanceof EntityBurnableItem)) {
		EntityItem item = (EntityItem) event.getEntity();
		if (EntityBurnableItem.isBurnable(item.getItem())) {
			EntityBurnableItem newItem = new EntityBurnableItem(event.getWorld(), item.posX, item.posY, item.posZ, item.getItem());
			newItem.motionX = item.motionX;
			newItem.motionY = item.motionY;
			newItem.motionZ = item.motionZ;
			newItem.setPickupDelay(40);
			item.setDead();
			event.getWorld().spawnEntity(newItem);
		}
	}
}
 
Example 2
Source File: CyberwareDataHandler.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent
public void syncCyberwareData(EntityJoinWorldEvent event)
{
	if (!event.getWorld().isRemote)
	{
		Entity e = event.getEntity();
		if (CyberwareAPI.hasCapability(e))
		{
			if (e instanceof EntityPlayer)
			{
				//System.out.println("Sent data for player " + ((EntityPlayer) e).getName() + " to that player's client");
				NBTTagCompound nbt = CyberwareAPI.getCapability(e).serializeNBT();
				CyberwarePacketHandler.INSTANCE.sendTo(new CyberwareSyncPacket(nbt, e.getEntityId()), (EntityPlayerMP) e);
			}
		}
	}
}
 
Example 3
Source File: EventsCommon.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();

    World world = entity.world;
    BlockPos posAt = new BlockPos(entity);

    Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(world, posAt);
    if (!event.getWorld().isRemote && physicsObject.isPresent()
        && !(entity instanceof EntityFallingBlock)) {
        if (entity instanceof EntityArmorStand
            || entity instanceof EntityPig || entity instanceof EntityBoat) {
            EntityMountable entityMountable = new EntityMountable(world,
                entity.getPositionVector(), CoordinateSpaceType.SUBSPACE_COORDINATES, posAt);
            world.spawnEntity(entityMountable);
            entity.startRiding(entityMountable);
        }
        physicsObject.get()
            .getShipTransformationManager()
            .getCurrentTickTransform().transform(entity,
            TransformType.SUBSPACE_TO_GLOBAL);
        // TODO: This should work but it doesn't because of sponge. Instead we have to rely on MixinChunk.preAddEntity() to fix this
        // event.setCanceled(true);
        // event.getWorld().spawnEntity(entity);
    }
}
 
Example 4
Source File: SlimeMerger.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SubscribeEvent
public void slimeConstruct(EntityJoinWorldEvent event)
{
    if (!ConfigManager.SERVER.mergeSlimes.get())
        return;

    Entity entity = event.getEntity();

    if (!(entity instanceof SlimeEntity))
        return;

    SlimeEntity slime = (SlimeEntity) entity;

    slime.goalSelector.addGoal(7, new MergeWithNearbySlimesGoal(slime));
    slime.targetSelector.addGoal(5, new MoveTowardNearestSlimeGoal(slime));
}
 
Example 5
Source File: ItemBreakingTracker.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SubscribeEvent
public void entityJoinWorld(EntityJoinWorldEvent ev)
{
    if (!ConfigManager.SERVER.enableScraping.get())
        return;
    if (ev.getEntity().world.isRemote)
        return;

    if (ev.getEntity() instanceof PlayerEntity)
    {
        PlayerEntity player = (PlayerEntity) ev.getEntity();

        CombatTrackerIntercept interceptTracker = new CombatTrackerIntercept(player);
        ObfuscationReflectionHelper.setPrivateValue(LivingEntity.class, player, interceptTracker, "field_94063_bt");
    }
}
 
Example 6
Source File: JoinWorldHandler.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event)
{
	if (event.getEntity() instanceof EntityPlayer && !event.getEntity().getEntityData().hasKey("hasSpawned"))
	{
		/*if(!(((EntityPlayer)event.getEntity()).inventory instanceof InventoryPlayerTFC))
			((EntityPlayer)event.getEntity()).inventory = Core.getNewInventory((EntityPlayer)event.getEntity());*/

		//((EntityPlayer)event.getEntity()).getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1000);
		//((EntityPlayer)event.getEntity()).setHealth(1000);
		event.getEntity().getEntityData().setBoolean("hasSpawned", true);
	}

	if (event.getEntity() instanceof EntityPlayer)
	{
		/*if(!(((EntityPlayer)event.getEntity()).inventory instanceof InventoryPlayerTFC))
			((EntityPlayer)event.getEntity()).inventory = Core.getNewInventory((EntityPlayer)event.getEntity());*/

		((EntityPlayer)event.getEntity()).inventoryContainer = new ContainerPlayerTFC(((EntityPlayer)event.getEntity()).inventory, !event.getWorld().isRemote, (EntityPlayer)event.getEntity());
		((EntityPlayer)event.getEntity()).openContainer = ((EntityPlayer)event.getEntity()).inventoryContainer;
		if(!event.getWorld().isRemote)
		{
			TFC.network.sendTo(new CFoodPacket((IFoodStatsTFC)((EntityPlayer)event.getEntity()).getFoodStats()), (EntityPlayerMP)event.getEntity());
		}
	}
}
 
Example 7
Source File: EventHandlers.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void spawnToroWhenCowPackSpawns(EntityJoinWorldEvent event) {
	if (event.getWorld().isRemote) {
		return;
	}

	Entity entity = event.getEntity();
	if (entity == null || !(entity instanceof EntityCow)) {
		return;
	}

	if (entity.getEntityData().getBoolean("AddedToWorld")) {
		return;
	}

	entity.getEntityData().setBoolean("AddedToWorld", true);
	
	World world = event.getWorld();

	if (world.rand.nextInt(8) != 0) {
		return;
	}

	BlockPos spawnPoint = findSurface(world, entity.getPosition());

	if (spawnPoint == null) {
		return;
	}
	
	
	Entity toro = new EntityToro(world);

	toro.setPosition(spawnPoint.getX(), spawnPoint.getY() + 1, spawnPoint.getZ());
	world.spawnEntity(toro);
}
 
Example 8
Source File: DropCapture.java    From OpenModsLib with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstruct(EntityJoinWorldEvent evt) {
	final Entity e = evt.getEntity();
	if (e != null
			&& e.getClass() == EntityItem.class
			&& !e.world.isRemote) {
		final EntityItem ei = (EntityItem)e;

		for (CaptureContext c : captures)
			if (c.check(ei)) break;
	}
}
 
Example 9
Source File: EntityJoinWorld.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void OnEntityJoinWorld(EntityJoinWorldEvent event) {
	
	World world = event.getWorld();
	if(world.isRemote) return;
	
	Entity entity = event.getEntity();
	
	// slimes do not extend EntityMob for some reason
	if(!(entity instanceof EntityMob || entity instanceof EntitySlime)){
		return;
	}
	
	EntityLiving mob = (EntityLiving) entity;
	
	Collection<?> effects = mob.getActivePotionEffects();
	for(Object buff : effects){
		if(Potion.getIdFromPotion(((PotionEffect) buff).getPotion()) == 4){
			int level = ((PotionEffect) buff).getAmplifier();
			
			IEntity metaEntity = new MetaEntity((Entity)mob);
			MonsterProfile.equip(world, world.rand, level, metaEntity);
			if(entity.isDead) event.setCanceled(true);
			return;
		}
	}
}
 
Example 10
Source File: EntityEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 (preventAllEntitySpawningInWorld)
        {
            event.setCanceled(true);
        }
    }
}
 
Example 11
Source File: ClientEventHandler.java    From Better-Sprinting with Mozilla Public License 2.0 5 votes vote down vote up
@SubscribeEvent
public static void onPlayerJoinWorld(EntityJoinWorldEvent e){
	if (stopCheckingNewServer || e.getEntity() != mc.player){
		return;
	}
	
	stopCheckingNewServer = true;
	
	if (!mc.isIntegratedServerRunning() && mc.getCurrentServerData() != null && !ClientSettings.disableMod.get()){
		PacketPipeline.sendToServer(ClientNetwork.writeModNotification(10));
	}
}
 
Example 12
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerChangedWorld(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();
    if (!(entity instanceof EntityPlayerMP)) {
        return;
    }
    EntityPlayerMP player = (EntityPlayerMP) entity;
    if (player.world.isRemote) {
        return;
    }
}
 
Example 13
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerChangedWorld(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();
    if (!(entity instanceof EntityPlayerMP)) {
        return;
    }
    EntityPlayerMP player = (EntityPlayerMP) entity;
    if (player.worldObj.isRemote) {
        return;
    }
}
 
Example 14
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerChangedWorld(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();
    if (!(entity instanceof EntityPlayerMP)) {
        return;
    }
    EntityPlayerMP player = (EntityPlayerMP) entity;
    if (player.world.isRemote) {
        return;
    }
}
 
Example 15
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerChangedWorld(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();
    if (!(entity instanceof EntityPlayerMP)) {
        return;
    }
    EntityPlayerMP player = (EntityPlayerMP) entity;
    if (player.worldObj.isRemote) {
        return;
    }
}
 
Example 16
Source File: EventHandler.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event){
    if(!event.getWorld().isRemote && event.getEntity() instanceof EntityPlayer) {
        RailNetworkManager.getInstance(event.getWorld().isRemote).onPlayerJoin((EntityPlayerMP)event.getEntity());
    }
    if(!event.getWorld().isRemote && event.getEntity() instanceof EntityMinecart) {
        RailNetworkManager.getInstance(event.getWorld().isRemote).onMinecartJoinedWorld((EntityMinecart)event.getEntity());
        CapabilityMinecartDestination cap = event.getEntity().getCapability(CapabilityMinecartDestination.INSTANCE, null);
        if(cap != null) cap.onCartJoinWorld((EntityMinecart)event.getEntity());
    }
}
 
Example 17
Source File: ItemBoneUpgrade.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent
public void handleJoinWorld(EntityJoinWorldEvent event)
{
	Entity e = event.getEntity();
	
	ItemStack test = new ItemStack(this, 1, 0);
	if (e instanceof EntityLivingBase && CyberwareAPI.isCyberwareInstalled(e, test))
	{
		this.onAdded((EntityLivingBase) e, CyberwareAPI.getCyberware(e, test));
	}
	else if (CyberwareAPI.hasCapability(e) && e instanceof EntityLivingBase)
	{
		this.onRemoved((EntityLivingBase) e, test);
	}
}
 
Example 18
Source File: EntitySpawning.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onCreateVillager(EntityJoinWorldEvent event) {
	if (!event.getWorld().isRemote && event.getEntity() instanceof EntityVillager) {

		cleanMap();

		if (handlePossibleConversion((EntityLiving) event.getEntity(), null)) {
			event.getEntity().setDead();
		}
	}
}
 
Example 19
Source File: DelayedEntityLoadManager.java    From OpenModsLib with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onEntityCreate(EntityJoinWorldEvent evt) {
	final Entity entity = evt.getEntity();
	for (IEntityLoadListener callback : delayedLoads.removeAll(entity.getEntityId()))
		callback.onEntityLoaded(entity);
}