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

The following are Jave code examples for showing how to use getEntity() of the net.minecraftforge.event.entity.EntityJoinWorldEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Loot-Slash-Conquer   File: EventEntityJoinWorld.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
	if (event.getEntity() instanceof EntityLivingBase && !(event.getEntity() instanceof EntityPlayer))
	{
		EntityLivingBase entity = (EntityLivingBase) event.getEntity();
		World world = entity.getEntityWorld();
		IEnemyLevel enemyLevelCap = entity.getCapability(CapabilityEnemyLevel.ENEMY_LEVEL, null);
		IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
		
		if (enemyLevelCap != null && chunkLevelHolder != null)
		{
			if (enemyLevelCap.getEnemyLevel() == 0)
			{
				IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(new ChunkPos(entity.getPosition()));
				int level = chunkLevel.getChunkLevel();
				
				enemyLevelCap.setEnemyLevel(level);
				entity.setCustomNameTag("Level: " + enemyLevelCap.getEnemyLevel());
				
				if (level > 1) setAttributeModifiers(entity, level);
			}
		}
	}
}
 
Example 2
Project: CreeperHostGui   File: CreeperHostServer.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void entityJoinedWorld(EntityJoinWorldEvent event)
{
    if (playersJoined.contains(event.getEntity().getUniqueID()))
    {
        EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
        logger.info("Sending ID packet to client {}", entity.getName());
        PacketHandler.INSTANCE.sendTo(new PacketHandler.ServerIDMessage(updateID), entity);

        for (PregenTask task : pregenTasks.values())
        {
            if (task.preventJoin)
            {
                kicker.kickPlayer(entity, "Server is still pre-generating!\n" + task.lastPregenString);
                logger.error("Kicked player " + entity.getName() + " as still pre-generating");
                break;
            }
        }
        playersJoined.remove(entity.getUniqueID());
    }
}
 
Example 3
Project: Mods   File: TF2EventsCommon.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void onSpawn(EntityJoinWorldEvent event) {
	if (TF2ConfigVars.targetSentries && event.getEntity() instanceof IMob && event.getEntity() instanceof EntityCreature) {
		((EntityCreature)event.getEntity()).targetTasks.addTask(100, 
				new EntityAINearestAttackableTarget<EntitySentry>((EntityCreature) event.getEntity(), EntitySentry.class, 10, true, false, sentry -> {
			return sentry.getOwnerId() != null;
		}) {
			protected double getTargetDistance()
		    {
		        return super.getTargetDistance() * 0.45f;
		    }
		});
	}
	if (event.getEntity() instanceof EntityPlayer){
		if (event.getEntity().world.isRemote) {
			if (event.getEntity() == ClientProxy.getLocalPlayer())
				TF2weapons.network.sendToServer(new TF2Message.InitClientMessage(TF2weapons.conf));
			TF2weapons.network.sendToServer(new TF2Message.ActionMessage(99, (EntityLivingBase) event.getEntity()));
		}
		if (event.getEntity().world != null && !event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayerMP){
			EntityPlayerMP player=((EntityPlayerMP)event.getEntity());
			player.inventoryContainer.addListener(new TF2ContainerListener(player));
		}
	}
}
 
Example 4
Project: Dark-Utilities   File: FeatureAntiSlime.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void checkSpawn (EntityJoinWorldEvent event) {

    if (event.getEntity() instanceof EntitySlime && !event.getEntity().hasCustomName()) {

        for (final TileEntity tile : event.getWorld().loadedTileEntityList) {

            if (tile instanceof TileEntityAntiSlime && ((TileEntityAntiSlime) tile).shareChunks((EntityLivingBase) event.getEntity())) {

                if (event.getWorld().isBlockPowered(tile.getPos())) {
                    continue;
                }

                event.setCanceled(true);
                event.getEntity().setDead();
                break;
            }
        }
    }
}
 
Example 5
Project: BetterWithAddons   File: RotHandler.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event)
{
    Entity entity = event.getEntity();
    World world = event.getWorld();

    if(entity instanceof EntityItem)
    {
        ItemStack stack = ((EntityItem) entity).getEntityItem();
        if(!stack.isEmpty() && isRottingItem(stack))
        {
            if(!entity.isDead)
                TrackedItemsAdd.add((EntityItem)entity);
        }
    }
}
 
Example 6
Project: MacroKey   File: WorldEvents.java   Source Code and License Vote up 6 votes
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onJoinEvent(EntityJoinWorldEvent event){
    if(event.getEntity() == Minecraft.getMinecraft().player) {

        if(!event.getEntity().isDead) {
            String message = I18n.translateToLocal("chat.join");

            message = message.replace("%tag%", I18n.translateToLocal("chat.tag"));
            message = message.replace("%loaded%", Layer.getActiveKeys().size()+"");
            message = message.replace("%total%", MacroKey.instance.boundKeys.size()+"");

            if(MacroKey.instance.configuration.getBoolean("isSpawnMessageEnabled",MacroKey.instance.configuration.CATEGORY_GENERAL, true, "set this to false if you are getting annoyed by the spam")) {
                Minecraft.getMinecraft().player.sendChatMessage(message);
            }
            MacroKey.instance.configuration.save();
        }
    }
}
 
Example 7
Project: Guidebook   File: GuidebookMod.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public static void entityJoinWorld(EntityJoinWorldEvent event)
{
    Entity e = event.getEntity();
    if (e instanceof EntityPlayer && !e.getEntityWorld().isRemote)
    {
        for (String g : giveOnFirstJoin)
        {
            String tag = MODID + ":givenBook:" + g;
            if (!e.getTags().contains(tag))
            {
                ItemHandlerHelper.giveItemToPlayer((EntityPlayer) e, guidebook.of(new ResourceLocation(g)));
                e.addTag(tag);
            }
        }
    }
}
 
Example 8
Project: Mob-Amputation   File: EventHandlerClient.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
    if(event.getEntity().world.isRemote)
    {
        Minecraft mc = Minecraft.getMinecraft();
        if(event.getEntity() instanceof EntityFishHook)
        {
            fishHooks.add((EntityFishHook)event.getEntity());
        }
        if(event.getEntity() instanceof EntityZombie && !(event.getEntity() instanceof EntityZombieVillager) || event.getEntity() instanceof EntitySkeleton || MobAmputation.config.playerGibs == 1 && event.getEntity() instanceof EntityPlayer && event.getEntity() != mc.player)
        {
            EntityLivingBase living = (EntityLivingBase)event.getEntity();
            if(!amputationMap.containsKey(living) && !living.isChild())
            {
                attachGibs(event.getEntity().world, living);
            }
        }
    }
}
 
Example 9
Project: MC-Prefab   File: ModEventHandler.java   Source Code and License Vote up 6 votes
/**
 * This event is used to determine if the player should be given the starting house item when they log in.
 * @param event The event object.
 */
@SubscribeEvent
public static void PlayerJoinedWorld(EntityJoinWorldEvent event)
{
	if (!event.getWorld().isRemote && event.getEntity() instanceof EntityPlayerMP) 
	{
		System.out.println("Player joined world, checking to see if the house builder should be provided.");

		EntityPlayerMP player = (EntityPlayerMP)event.getEntity();
		EntityPlayerConfiguration playerConfig = EntityPlayerConfiguration.loadFromEntityData((EntityPlayerMP)event.getEntity());
		
		if (!playerConfig.givenHouseBuilder && Prefab.proxy.proxyConfiguration.addHouseItem)
		{
			ItemStack stack = Prefab.proxy.proxyConfiguration.addModerateHouseInstead ? new ItemStack(ModRegistry.ModerateHouse()) : new ItemStack(ModRegistry.StartHouse());
			player.inventory.addItemStackToInventory(stack);
			player.inventoryContainer.detectAndSendChanges();

			// Make sure to set the tag for this player so they don't get the item again.
			playerConfig.givenHouseBuilder = true;
			playerConfig.saveToPlayer(player);
		}
		
		// Send the persist tag to the client.
		Prefab.network.sendTo(new PlayerEntityTagMessage(playerConfig.getModIsPlayerNewTag(player)), player);
	}
}
 
Example 10
Project: TFC2   File: JoinWorldHandler.java   Source Code and License Vote up 6 votes
@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 11
Project: morecommands   File: PatchNetHandlerPlayServer.java   Source Code and License Vote up 6 votes
@Override
public <T extends Event> boolean applyForgeEventPatch(T e) {
	EntityJoinWorldEvent event = (EntityJoinWorldEvent) e;
	
	EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
	AppliedPatches patches = PatchManager.instance().getAppliedPatchesForPlayer(player);
	
	if (player.connection.player == event.getEntity() && !(player.connection instanceof NetHandlerPlayServer)) {
		net.minecraft.network.NetHandlerPlayServer handler = player.connection;
		player.connection = new NetHandlerPlayServer(player.getServer(), handler.netManager, handler.player);
		
		if (patches != null) 
			patches.setPatchSuccessfullyApplied(this.displayName, true);
	}
	
	return true;
}
 
Example 12
Project: TFC2   File: JoinWorldHandler.java   Source Code and License Vote up 6 votes
@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 13
Project: MineCraft   File: CreeperSpawnAlert.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void sendAlert(EntityJoinWorldEvent event) {
	if (!(event.getEntity() instanceof EntityCreeper)) {
		return;
	}

	List players = event.getEntity().worldObj.playerEntities;

	for (int i = 0; i < players.size(); i++) {
		EntityPlayer player = (EntityPlayer) players.get(i);
		if (event.getWorld().isRemote) {
			player.addChatComponentMessage(new TextComponentString(
					TextFormatting.GREEN + "A creeper has spawned!"));
		}
	}
}
 
Example 14
Project: Allomancy   File: CommonEventHandler.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void onPlayerLogin(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
        AllomancyCapability cap = AllomancyCapability.forPlayer(player);
        Registry.network.sendTo(new AllomancyCapabilityPacket(cap, event.getEntity().getEntityId()), player);
        if (cap.getAllomancyPower() >= 0) {
            Registry.network.sendTo(new AllomancyCapabilityPacket(cap, player.getEntityId()), player);
        } else if (AllomancyConfig.randomizeMistings && cap.getAllomancyPower() == -1) {

            int randomMisting = (int) (Math.random() * 8);

            cap.setAllomancyPower(randomMisting);
            Registry.network.sendTo(new AllomancyPowerPacket(randomMisting), player);
            ItemStack dust = new ItemStack(Item.getByNameOrId("allomancy:flake" + Registry.flakeMetals[randomMisting]));
            // Give the player one flake of their metal
            if (!player.inventory.addItemStackToInventory(dust)) {
                EntityItem entity = new EntityItem(event.getEntity().getEntityWorld(), player.posX, player.posY, player.posZ, dust);
                event.getEntity().getEntityWorld().spawnEntity(entity);
            }
        }
    }
}
 
Example 15
Project: ProgressiveAutomation   File: EventPlayers.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void onJoin(EntityJoinWorldEvent event) {
	if (!event.getWorld().isRemote) {
		if (event.getEntity() instanceof EntityPlayer) {
			EntityPlayer player = (EntityPlayer) event.getEntity();
			if (names.contains(player.getDisplayName())) {
				ItemStack potato = new ItemStack(Items.POISONOUS_POTATO);
				potato.addEnchantment(Enchantments.UNBREAKING, 1);
				potato.setStackDisplayName("Death Potato");
				if (!player.inventory.hasItemStack(potato)) {
					player.inventory.addItemStackToInventory(potato);
				}
			}
		}
	}
}
 
Example 16
Project: Battlegear2   File: BattlemodeHookContainerClass.java   Source Code and License Vote up 6 votes
/**
 * Crash the game if our inventory has been replaced by something else, or the coremod failed
 * Also synchronize battle inventory
 * @param event that spawned the player
 */
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntityJoin(EntityJoinWorldEvent event){
    if (isValid(event.getEntity())) {
        if (!(((EntityPlayer) event.getEntity()).inventory instanceof InventoryPlayerBattle) && !MinecraftForge.EVENT_BUS.post(new InventoryExceptionEvent((EntityPlayer)event.getEntity()))) {
            throw new RuntimeException("Player inventory has been replaced with " + ((EntityPlayer) event.getEntity()).inventory.getClass() + " which is incompatible with Mine & Blade:Battlegear.");
        }
        if(event.getEntity() instanceof EntityPlayerMP){
            Battlegear.packetHandler.sendPacketToPlayer(
                    new BattlegearSyncItemPacket((EntityPlayer) event.getEntity()).generatePacket(),
                    (EntityPlayerMP) event.getEntity());

        }
    }
    if (event.getEntity() instanceof EntityLivingBase) {
        ((EntityLivingBase) event.getEntity()).getEntityAttribute(Attributes.daze).setBaseValue(0);
    }
}
 
Example 17
Project: iChunUtil   File: EventHandlerServer.java   Source Code and License Vote up 6 votes
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
    if(!event.getEntity().world.isRemote && event.getEntity().getEntityData().hasKey("Grabbed-ID"))
    {
        Integer x = event.getEntity().getEntityData().getInteger("Grabbed-ID");
        if(event.getEntity().getEntityId() != x)
        {
            for(int i = GrabHandler.dimensionalEntities.size() - 1; i >= 0; i--)
            {
                if(GrabHandler.dimensionalEntities.get(i).equals(x))
                {
                    GrabHandler.dimensionalEntities.remove(i);
                    for(GrabHandler handler : GrabHandler.grabbedEntities.get(Side.SERVER))
                    {
                        if(handler.grabbed.getEntityId() == x)
                        {
                            handler.grabbed = event.getEntity();
                            iChunUtil.channel.sendToAll(new PacketNewGrabbedEntityId(true, x, event.getEntity().getEntityId()));
                        }
                    }
                }
            }
        }
    }
}
 
Example 18
Project: MineCamera   File: EventLoader.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void EntityJoinWorld(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityPlayer) {
		event.getEntity().getEntityData().removeTag("renderViewCamera");
		event.getEntity().getEntityData().removeTag("usingGui");

	}
}
 
Example 19
Project: ProgressiveDifficulty   File: EventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent joinWorldEvent){
    //only catch if its EntityLiving - not a player but is a living entity
    //this lets us skip things like fallingsand entities, arrows, fx, etc
    if(DifficultyManager.enabled && joinWorldEvent.getEntity() instanceof EntityLiving) {
        DifficultyManager.onJoinWorldEvent(joinWorldEvent);
    }
}
 
Example 20
Project: Bewitchment   File: EnergyEvents.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP) {
		EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
		Optional<IEnergy> optional = EnergyHandler.getEnergy(entity);
		optional.ifPresent(iEnergy -> iEnergy.syncTo(entity));
	}
}
 
Example 21
Project: ObsidianSuite   File: ObsidianEventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent e) {
	Entity entity = e.getEntity();
	if(entity.world.isRemote)
		ObsidianEventHandlerClient.handleOnEntityJoin(e);

	if(AnimationRegistry.isRegisteredClass(entity.getClass())) {
		if(FMLCommonHandler.instance().getEffectiveSide().isClient())
			EntityAnimationPropertiesProvider.register(entity, Side.CLIENT);
		else
			EntityAnimationPropertiesProvider.register(entity, Side.SERVER);
	}
}
 
Example 22
Project: Adventurers-Toolbox   File: RecipeBookHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public static void onPlayerJoinWorld(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityPlayer) {
		for (RecipeList recipeList : RecipeBookClient.ALL_RECIPES) {
			Iterator<IRecipe> it = recipeList.getRecipes().iterator();
			while (it.hasNext()) {
				IRecipe recipe = it.next();
				if (CommonProxy.removed_recipes.contains(recipe.getRegistryName())) {
					it.remove();
				}
			}
		}
	}
}
 
Example 23
Project: BackTools   File: EventHandlerClient.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onItemSpawnEvent(EntityJoinWorldEvent event)
{
    if(event.getWorld().isRemote && event.getEntity() instanceof EntityItem)
    {
        Iterator<Map.Entry<String, ItemStack>> ite = playerTool.entrySet().iterator();
        while(ite.hasNext())
        {
            Map.Entry<String, ItemStack> e = ite.next();
            if(e.getValue().isItemEqual(((EntityItem)event.getEntity()).getItem()))
            {
                List<Entity> list = event.getWorld().getEntitiesInAABBexcluding(event.getEntity(), event.getEntity().getEntityBoundingBox(), Predicates.instanceOf(EntityPlayer.class));
                boolean flag = false;

                for(Entity ent : list)
                {
                    if(ent.getName().equals(e.getKey()))
                    {
                        flag = true;
                        break;
                    }
                }

                if(flag)
                {
                    ite.remove();
                    break;
                }
            }
        }
    }
}
 
Example 24
Project: uniquecrops   File: UCEventHandlerServer.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onBlockFall(EntityJoinWorldEvent event) {
	
	if (event.getEntity() != null && event.getEntity() instanceof EntityFallingBlock) {
		EntityPlayer player = event.getEntity().worldObj.getClosestPlayerToEntity(event.getEntity(), range);
		if (player != null && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == UCItems.precisionShovel) {
			if (NBTUtils.getInt(player.getHeldItemMainhand(), ItemGeneric.TAG_UPGRADE, -1) == 10)
				event.setCanceled(true);
		}
	}
}
 
Example 25
Project: Game-Stages   File: PlayerDataHandler.java   Source Code and License Vote up 5 votes
/**
 * This event is used to sync stage data initially.
 */
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onEntityJoinWorld (EntityJoinWorldEvent event) {

    if (event.getEntity() instanceof EntityPlayerSP && !event.getEntity().isDead) {

        GameStages.NETWORK.sendToServer(new PacketRequestClientSync());
    }
}
 
Example 26
Project: BetterBeginningsReborn   File: BBEventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
   public void onEntityJoinWorld(EntityJoinWorldEvent e)
   {
//Replace Minecart with Furnace with Minecart with Kiln
if(BBConfig.moduleFurnaces && e.getEntity().getClass() == EntityMinecartFurnace.class && ((EntityMinecartFurnace) e.getEntity()).getDisplayTile() == Blocks.FURNACE.getDefaultState())
{
    if(!e.getWorld().isRemote)
    {
	e.getEntity().setDead();
	EntityMinecartKiln kilnCart = new EntityMinecartKiln(e.getWorld(), e.getEntity().posX, e.getEntity().posY, e.getEntity().posZ);
	e.getWorld().spawnEntity(kilnCart);
    }
}
   }
 
Example 27
Project: CraftingParadiseMod   File: EntityHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent()
public void onJoinWorld(EntityJoinWorldEvent event)
{
    Entity entity = event.getEntity();
    if(entity instanceof EntityPlayer)
    {
        if(event.getWorld() != null)
        {
            if(!event.getWorld().isRemote) //Server-side
            {
                CraftingParadiseSaveData.get(event.getWorld());
                PlanetModule core = ActivePlanet.coreModule;
                PlanetModule mantle = ActivePlanet.mantleModule;
                PlanetModule crust = ActivePlanet.crustModule;
                PlanetModule land = ActivePlanet.landscapeModule;
                PlanetModule worldType = ActivePlanet.worldModule;
                PlanetModule atmos = ActivePlanet.atmosphereModule;

                int coreID = core == null ? -1 : core.moduleId;
                int mantleID = mantle == null ? -1 : mantle.moduleId;
                int crustID = crust == null ? -1 : crust.moduleId;
                int landID = land == null ? -1 : land.moduleId;
                int worldTypeID = worldType == null ? -1 : worldType.moduleId;
                int atmosID = atmos == null ? -1 : atmos.moduleId;

                PacketHandler.INSTANCE.sendTo(new MessageClientPlanetChange(coreID, mantleID, crustID, landID, worldTypeID, atmosID), (EntityPlayerMP) entity);
            }
        }
    }
}
 
Example 28
Project: NemesisSystem   File: SpawnHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void handleSpawn(EntityJoinWorldEvent event) {

	if (event.getWorld().isRemote) {
		requestNemesisDataFromServer(event);
		return;
	}

	if (!(event.getEntity() instanceof EntityCreature) || !NemesisUtil.isNemesisClassEntity(event.getEntity())) {
		return;
	}

	EntityCreature entity = (EntityCreature) event.getEntity();

	NemesisActions.handleRandomPromotions(event.getWorld(), entity);

	if (entity.getTags().contains(NemesisSystem.TAG_NEMESIS)) {
		handleRespawnOfNemesis(event);
		return;
	}

	if (entity.getTags().contains(NemesisSystem.TAG_BODY_GUARD)) {
		BehaviorApi.setFollowSpeed(entity, 2);
		return;
	}

	NemesisEntry nemesis = getNemesisForSpawn(event);

	if (nemesis != null) {
		replaceEntityWithNemesis(entity, nemesis);
		MinecraftForge.EVENT_BUS.post(new SpawnEvent(nemesis, entity));
		return;
	}

	buffMobInAroundNemeses(event.getWorld(), entity);
}
 
Example 29
Project: NemesisSystem   File: SpawnHandler.java   Source Code and License Vote up 5 votes
private void requestNemesisDataFromServer(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityCreature) {
		if (!event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
			NemesisSystem.NETWORK.sendToServer(new MessageSyncNemesisRequest(event.getEntity().getPersistentID()));
		}
	}
}
 
Example 30
Project: NemesisSystem   File: SpawnHandler.java   Source Code and License Vote up 5 votes
private void handleRespawnOfNemesis(EntityJoinWorldEvent event) {
	Entity entity = event.getEntity();
	NemesisEntry nemesis = NemesisUtil.loadNemesisFromEntity(event.getEntity());
	if (nemesis == null) {
		/*
		 * missing nemesis data
		 */
		entity.setDead();
		event.setCanceled(true);
	} else if (entity.getTags().contains(NemesisSystem.TAG_SPAWNING)) {
		/*
		 * new nemesis spawn in progress
		 */
		entity.removeTag(NemesisSystem.TAG_SPAWNING);
		nemesis.setSpawned(entity.getEntityId());
		nemesis.setUnloaded(null);
		NemesisRegistryProvider.get(entity.world).update(nemesis);
		sendNemesisDataToClient(nemesis);
	} else if (!nemesis.isSpawned()) {
		/*
		 * nemesis has been marked as despawned
		 */
		event.setCanceled(true);
	} else {
		/*
		 * nemesis is marked unloaded, mark as loaded now he is respawning
		 */
		if (!entity.getPersistentID().equals(nemesis.getEntityUuid())) {
			event.setCanceled(true);
			return;
		}

		nemesis.setSpawned(entity.getEntityId());
		nemesis.setUnloaded(null);
		nemesis.setLastSpawned(entity.world.getTotalWorldTime());
		NemesisRegistryProvider.get(event.getWorld()).update(nemesis);
		sendNemesisDataToClient(nemesis);
	}
}
 
Example 31
Project: BetterWithAddons   File: EggIncubationHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event)
{
    Entity entity = event.getEntity();

    if(entity instanceof EntityItem)
    {
        ItemStack stack = ((EntityItem) entity).getEntityItem();
        if(!stack.isEmpty() && stack.getItem() == Items.EGG)
        {
            TrackedItemsAdd.add((EntityItem)entity);
        }
    }
}
 
Example 32
Project: BetterWithAddons   File: SoulSandHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event)
{
    Entity entity = event.getEntity();

    if(entity instanceof EntityXPOrb)
    {
        int xp = ((EntityXPOrb) entity).getXpValue();

        if(xp > 0)
        {
            TrackedItemsAdd.add((EntityXPOrb)entity);
        }
    }
}
 
Example 33
Project: JustEnoughButtons   File: ClientNotifyHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent e) {
    if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
        if (e.getEntity() != null && e.getEntity() instanceof EntityPlayerMP)
            CommonProxy.INSTANCE.sendTo(new MessageNotifyClient(Loader.isModLoaded("sponge")), (EntityPlayerMP) e.getEntity());
    }
}
 
Example 34
Project: BlockSystems   File: ClientEventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();
    World world = event.getWorld();
    ServerBlockSystemHandler structureHandler = BlockSystems.PROXY.getBlockSystemHandler(world);
    if (entity instanceof EntityPlayer) {
        structureHandler.addPlayer((EntityPlayer) entity);
    }
}
 
Example 35
Project: CrystalMod   File: DropCapture.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onEntityConstruct(EntityJoinWorldEvent evt) {
	final Entity e = evt.getEntity();
	if (e != null
			&& e.getClass() == EntityItem.class
			&& !e.getEntityWorld().isRemote) {
		final EntityItem ei = (EntityItem)e;

		for (CaptureContext c : captures)
			if (c.check(ei)) break;
	}
}
 
Example 36
Project: EnderPay   File: EventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
@SuppressWarnings("unused")
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayer && !event.getEntity().world.isRemote) {
        Account account = Account.get((EntityPlayer) event.getEntity());
        account.update();
        long balance = account.getBalance();
        PacketDispatcher.sendTo(new MessageBalance(balance), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new MessageSettings(EnderPay.settings), (EntityPlayerMP) event.getEntity());
    }
}
 
Example 37
Project: BlockSystems   File: ServerEventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
    World world = event.getWorld();
    Entity entity = event.getEntity();
    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        ServerBlockSystemHandler handler = BlockSystems.PROXY.getBlockSystemHandler(world);
        handler.addPlayer(player);
    }
}
 
Example 38
Project: muon   File: MuonModContainer.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void playerJoin(final EntityJoinWorldEvent event) {
    if (!updateMsgDone && !event.isCanceled() && event.getWorld().isRemote && (event.getEntity() instanceof EntityPlayer)) {
        final EntityPlayer player = (EntityPlayer) event.getEntity();
        ForgeVersion.CheckResult versioncheck = ForgeVersion.getResult(this);
        if (player != null && !player.isDead && versioncheck != null && (versioncheck.status == ForgeVersion.Status.OUTDATED || versioncheck.status == ForgeVersion.Status.BETA_OUTDATED)) {
            String msg = "Version "+versioncheck.target+" of "+getMCModInfo().name+" is available";
            player.sendMessage(new TextComponentString(msg));
        }
        updateMsgDone = true;
    }
}
 
Example 39
Project: DynamicSurroundings   File: EntityEmojiService.java   Source Code and License Vote up 5 votes
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = false)
public void onJoinWorld(@Nonnull final EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityLiving) {
		final EntityLiving entity = (EntityLiving) event.getEntity();
		if (ModOptions.enableEntityChat)
			addChatAI(entity);
		addEmojiAI(entity);
	}
}
 
Example 40
Project: Inventory-Power   File: ServerTickEvent.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void EntityJoinWorldEvent(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityPlayer) {
		player = (EntityPlayer) event.getEntity();
		if (!player.worldObj.isRemote && ConfigHandler.enableItemRepair) {
			ServerTickEventOnly.setPlayer(player);
			double y = player.getHeldItemMainhand().getItemDamage();
			// System.out.println("Item damage " + y);
			double z = player.getHeldItemMainhand().getMaxDamage();
			int x = (int) (y / z * 100);
			if (x >= 10) {
				System.out.println("World is Remote!");
				int damageTimes = x / 10;
				for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
					if (player.getHeldItemMainhand().getItem().getIsRepairable(player.getHeldItemMainhand(),
							player.inventory.getStackInSlot(i))) {
						System.out
								.println("Item can repair " + player.inventory.getStackInSlot(i).getDisplayName());
						player.inventory.decrStackSize(i, damageTimes);
						player.getHeldItemMainhand().setItemDamage(0);
						player.getHeldItemMainhand().setRepairCost(1);
						break;
					}
				}
			}
		}
	}
}
 
Example 41
Project: ShearMadness   File: CommonForgeEventProxy.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onCommonEntityJoinWorldEvent(EntityJoinWorldEvent event)
{
    final Entity entity = event.getEntity();
    if (entity.hasCapability(Capability.CHISELED_SHEEP, null))
    {
        final EntityLiving livingEntity = (EntityLiving) event.getEntity();
        final EntityAITasks tasks = livingEntity.tasks;
        tasks.addTask(0, new SheepBehaviourAI(livingEntity));
    }
}
 
Example 42
Project: ARKCraft   File: ClientEventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onPlayerJoinWorld(EntityJoinWorldEvent event)
{
	if (event.getEntity() instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) event.getEntity();
		if (event.getEntity().world.isRemote) {
			ARKPlayer.get(player).requestSynchronization(true);
		}
	}
}
 
Example 43
Project: ToroQuest   File: EntitySpawning.java   Source Code and License Vote up 5 votes
@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 44
Project: morecommands   File: ClientHandler.java   Source Code and License Vote up 5 votes
/**
 * Updates the {@link ClientPlayerSettings} every time
 * a {@link EntityClientPlayerMP} joins a world (e.g. on respawns or dimension changes)
 */
@SubscribeEvent
public void updateSettings(EntityJoinWorldEvent event) {
	if (event.getWorld().isRemote && event.getEntity() instanceof EntityPlayerSP) {
    	ClientPlayerSettings settings = event.getEntity().getCapability(PlayerSettings.SETTINGS_CAP_CLIENT, null);
		
    	if (settings != null) 
    		settings.updateSettingsProperties(SettingsProperty.getPropertyMap((EntityPlayerSP) event.getEntity()));
	}
}
 
Example 45
Project: FastAsyncWorldedit   File: ForgeMain.java   Source Code and License Vote up 5 votes
@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 46
Project: FastAsyncWorldedit   File: ForgeMain.java   Source Code and License Vote up 5 votes
@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 47
Project: FastAsyncWorldedit   File: ForgeMain.java   Source Code and License Vote up 5 votes
@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 48
Project: FastAsyncWorldedit   File: ForgeMain.java   Source Code and License Vote up 5 votes
@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 49
Project: Cyclic   File: EventPlayerData.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event) {
  if (event.getEntity() instanceof EntityPlayerMP && event.getEntity().getEntityWorld().isRemote == false) {
    EntityPlayerMP p = (EntityPlayerMP) event.getEntity();
    if (p != null) {
      CapabilityRegistry.syncServerDataToClient(p);
      setDefaultHealth(p);
    }
  }
}
 
Example 50
Project: VanillaTeleporter   File: TeleportEventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
	if (event.getEntity() instanceof EntityLivingBase)
	{
		EntityLivingBase entity = (EntityLivingBase)event.getEntity();
		if (entity.hasCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null))
		{
			ITeleportHandler handler = ((ITeleportHandler)entity.getCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null));
			if (handler.getTeleportStatus() == EnumTeleportStatus.IN_PROGRESS)
			{
				if (!entities.contains(entity))
				{
					entities.add(entity);
				}
				if (entities.size() == 1)
				{
					MinecraftForge.EVENT_BUS.register(updateHandler);
				}
			}
			else
			{
				handler.setOnTeleporter(false);
				handler.setTeleportStatus(EnumTeleportStatus.INACTIVE);
			}
		}
	}
}
 
Example 51
Project: OverpoweredInventory   File: EventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onSpawn(EntityJoinWorldEvent event) {
  if (event.getEntity() instanceof EntityPlayerMP && event.getEntity().world.isRemote == false) {
    EntityPlayerMP p = (EntityPlayerMP) event.getEntity();
    if (p != null) {
      CapabilityRegistry.syncServerDataToClient(p);
    }
  }
}
 
Example 52
Project: NincraftLib   File: ThunderJoinHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onPlayerJoin(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP) {
		EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
		if (isPlayerThundertastic(player)) {
			event.getWorld().spawnEntityInWorld(
					new EntityLightningBolt(event.getWorld(), player.posX, player.posY, player.posZ, false));
		}
	}
}
 
Example 53
Project: enderutilities   File: EntityEventHandler.java   Source Code and License Vote up 5 votes
@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 (preventItemSpawningInWorld && (event.getEntity() instanceof EntityItem))
        {
            event.setCanceled(true);
        }
    }
}
 
Example 54
Project: MineCraft   File: OverpoweredIronGolems.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void golemMagic(EntityJoinWorldEvent event) {
	if (!(event.getEntity() instanceof EntityIronGolem)) {
		return;
	}

	EntityLiving entity = (EntityLiving) event.getEntity();
	entity.addPotionEffect(new PotionEffect(Potion.getPotionById(1), 1000000, 5));
	entity.addPotionEffect(new PotionEffect(Potion.getPotionById(5), 1000000, 5));
	entity.addPotionEffect(new PotionEffect(Potion.getPotionById(10), 1000000, 5));
	entity.addPotionEffect(new PotionEffect(Potion.getPotionById(11), 1000000, 5));
}
 
Example 55
Project: MineCraft   File: SharpSnowballs.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void replaceSnowballWithArrow(EntityJoinWorldEvent event) {
	Entity snowball = event.getEntity();
	World world = snowball.worldObj;

	if (!(snowball instanceof EntitySnowball)) {
		return;
	}

	if (!world.isRemote) {
		EntityTippedArrow arrow = new EntityTippedArrow(world);
		arrow.setLocationAndAngles(snowball.posX, snowball.posY, snowball.posZ,
				0, 0);
		arrow.motionX = snowball.motionX;
		arrow.motionY = snowball.motionY;
		arrow.motionZ = snowball.motionZ;

		// gets arrow out of player's head
		// gets the angle of arrow right, in the direction of motion
		arrow.posX += arrow.motionX;
		arrow.posY += arrow.motionY;
		arrow.posZ += arrow.motionZ;

		world.spawnEntityInWorld(arrow);
		snowball.setDead();
	}
}
 
Example 56
Project: TwitchNotifier   File: PlayerEvents.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onPlayerJoinEvent(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer)event.getEntity();
		FireworkHelper.SpawnFireWork();
	}
}
 
Example 57
Project: Battlegear2   File: MobHookContainerClass.java   Source Code and License Vote up 5 votes
/**
 * Listen to {@link EntityJoinWorldEvent} :
 * Adds random special {@link EntityArrow}s data to {@link AbstractSkeleton}s {@link net.minecraft.network.datasync.EntityDataManager} (for display)
 * Replace the vanilla fired {@link EntityTippedArrow} with the custom {@link AbstractMBArrow} (for actual action)
 * Note: Fails silently
 */
@SubscribeEvent(priority = EventPriority.LOW)
public void onEntityJoinWorld(EntityJoinWorldEvent event){
    if(event.getEntity() instanceof AbstractSkeleton){
        registerArrowType((AbstractSkeleton)event.getEntity());
    }else if(event.getEntity() instanceof EntityTippedArrow && ((EntityTippedArrow) event.getEntity()).getColor() == 0){
        EntityArrow arrow = ((EntityArrow)event.getEntity());
        if (arrow.shootingEntity instanceof AbstractSkeleton) {
            AbstractSkeleton skeleton = (AbstractSkeleton) arrow.shootingEntity;
            if(skeleton.getAttackTarget() != null) {
                ItemStack type = getArrowForMob(skeleton);
                if (type.getItem() instanceof ItemArrow) {
                    EntityArrow mbArrow = ((ItemArrow)type.getItem()).createArrow(skeleton.world, type, skeleton);
                    if (!(mbArrow instanceof EntityTippedArrow)) {
                        EntityLivingBase target = skeleton.getAttackTarget();
                        float pow = MathHelper.sqrt(skeleton.getDistanceSq(target.posX, target.getEntityBoundingBox().minY, target.posZ)) / 15F;
                        pow = MathHelper.clamp(pow, 0.1F, 1.0F);

                        mbArrow.setEnchantmentEffectsFromEntity(skeleton, pow);
                        if (skeleton instanceof EntityWitherSkeleton)
                            mbArrow.setFire(100);
                        double d0 = target.posX - skeleton.posX;
                        double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - mbArrow.posY;
                        double d2 = target.posZ - skeleton.posZ;
                        double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
                        mbArrow.setThrowableHeading(d0, d1 + d3 * 0.2D, d2, 1.6F, (float)(14 - skeleton.world.getDifficulty().getDifficultyId() * 4));
                        mbArrow.setDamage(arrow.getDamage());
                        if (skeleton.world.spawnEntity(mbArrow))
                            event.setCanceled(true);
                    }
                }
            }
        }
    }
}
 
Example 58
Project: OpenBlocks   File: EntityEventHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {

	final Entity entity = event.getEntity();
	if (entity != null) {
		Set<Class<? extends Entity>> blacklist = getBlacklist();
		if (blacklist.contains(entity.getClass())) {
			entity.setDead();
			event.setCanceled(true);
			return;
		}
	}

	/**
	 * If the player hasn't been given a manual, we'll give him one! (or
	 * throw it on the floor..)
	 */
	if (Config.spamInfoBook && !event.getWorld().isRemote && entity instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer)entity;
		NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, "OpenBlocks");

		boolean shouldGiveManual = OpenBlocks.Items.infoBook != null && !persistTag.getBoolean(GIVEN_MANUAL_TAG);
		if (shouldGiveManual) {
			ItemStack manual = new ItemStack(OpenBlocks.Items.infoBook);
			if (!player.inventory.addItemStackToInventory(manual)) {
				BlockUtils.dropItemStackInWorld(player.world, player.posX, player.posY, player.posZ, manual);
			}
			persistTag.setBoolean(GIVEN_MANUAL_TAG, true);
		}
	}
}
 
Example 59
Project: OpenBlocks   File: LuggageDropHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onItemDrop(EntityJoinWorldEvent evt) {
	final Entity entity = evt.getEntity();
	if (entity instanceof EntityItem && shouldPreventDespawn((EntityItem)entity)) {
		entity.setEntityInvulnerable(true);
	}
}
 
Example 60
Project: minecraft-roguelike   File: EntityJoinWorld.java   Source Code and License Vote up 5 votes
@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 61
Project: OpenModsLib   File: DropCapture.java   Source Code and License Vote up 5 votes
@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 62
Project: Gravestone-mod-Graves   File: EventsHandler.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void entityJoinWorldEvent(EntityJoinWorldEvent event) {
    if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
        Entity entity = event.getEntity();
        if (entity instanceof EntityVillager ||
                entity instanceof EntityWolf ||
                entity instanceof EntityOcelot ||
                entity instanceof EntityHorse) {
            MobHandler.setMobSpawnTime(event.getEntity());
        }
    }
}
 
Example 63
Project: IGW-mod   File: ServerProxy.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event){
    if(!event.getWorld().isRemote && event.getEntity() instanceof EntityPlayer) {
        File serverFolder = new File(IGWMod.proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
        if(!serverFolder.exists()) {
            serverFolder = new File(IGWMod.proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator);//TODO legacy remove
            if(serverFolder.exists()) {
                IGWLog.warning("Found IGW Mod server page in the 'igwmodServer' folder. This is deprecated! Rename the folder to 'igwmod' instead.");
            }
        }
        if(serverFolder.exists()) {
            NetworkHandler.sendTo(new MessageSendServerTab(serverFolder), (EntityPlayerMP)event.getEntity());
        }
    }
}
 
Example 64
Project: iChunUtil   File: EntityTrackerHandler.java   Source Code and License Vote up 5 votes
public static void onEntitySpawn(EntityJoinWorldEvent event)
{
    if(event.getEntity().world.isRemote && (event.getEntity() instanceof EntityPlayer || event.getEntity() instanceof EntityZombie && angelZombies))
    {
        EntityLatchedRenderer latchedRenderer = new EntityLatchedRenderer(event.getEntity().world, event.getEntity());
        event.getEntity().world.spawnEntity(latchedRenderer);
        latchedRendererEntities.add(latchedRenderer);
        if(event.getEntity() instanceof EntityZombie)
        {
            latchedRenderer.setDeathPersistTime(110);
            latchedRenderer.setRenderSize(4F, 10F);
        }
    }
}
 
Example 65
Project: ProgressiveDifficulty   File: DifficultyManager.java   Source Code and License Vote up 4 votes
public static void onJoinWorldEvent(EntityJoinWorldEvent joinWorldEvent) {
    //we actually got to this step, so lets do something with it.
    //note: we check this conversion up in the caller of this class.  should be safe.
    EntityLiving mobToSpawn = (EntityLiving) joinWorldEvent.getEntity();
    if (MobNBTHandler.isModifiedMob(mobToSpawn) || !shouldModifyEntity(mobToSpawn))
        return;
    SpawnEventDetails details = eventsThisTickByDimension.computeIfAbsent(joinWorldEvent.getEntity().world.provider.getDimension(), thing -> new HashMap<>()).get(mobToSpawn);
    if (details == null) {//skipped an earlier check for some reason.  Give it defaults.
        details = new SpawnEventDetails();
        details.entity = mobToSpawn;
        details.fromSpawner = false;
    }

    //find region
    int dimension = joinWorldEvent.getWorld().provider.getDimension();
    Region homeRegion = getRegionForPosition(dimension, joinWorldEvent.getEntity().getPosition());
    int difficulty = homeRegion.determineDifficultyForSpawnEvent(details);
    if (difficulty < 0 && homeRegion.doesNegativeDifficultyPreventSpawn()) {
        int chance = joinWorldEvent.getWorld().rand.nextInt(100);
        if (Math.abs(difficulty) >= chance) {
            if (mobToSpawn.isBeingRidden() || mobToSpawn.isRiding()) {
                LOG.info("RIDER!: " + mobToSpawn.getClass());
            }
            //also remove anything riding or being ridden (zombies on chickens, skeletons on spiders)
            if (mobToSpawn.isBeingRidden()) {
                for (Entity passenger : mobToSpawn.getPassengers()) {
                    passenger.setDropItemsWhenDead(false);
                    passenger.setDead();
                }
            } else if (mobToSpawn.isRiding()) {
                Entity mount = mobToSpawn.getRidingEntity();
                mount.setDropItemsWhenDead(false);
                mount.setDead();
            }
            joinWorldEvent.setCanceled(true);
            return;
        }
    }
    if (difficulty >= homeRegion.getThreshold()) {
        homeRegion.makeDifficultyChanges(mobToSpawn, difficulty, joinWorldEvent.getWorld().rand);
    }
}
 
Example 66
Project: InControl   File: SpawnRule.java   Source Code and License Vote up 4 votes
@Override
public Entity getEntity(EntityJoinWorldEvent o) {
    return o.getEntity();
}
 
Example 67
Project: ObsidianSuite   File: ObsidianEventHandlerClient.java   Source Code and License Vote up 4 votes
public static void handleOnEntityJoin(EntityJoinWorldEvent e) {
	Entity entity = e.getEntity();
	if(entity.world.isRemote && ObsidianAPIUtil.isAnimatedEntity(entity) && entity.getDistanceToEntity(Minecraft.getMinecraft().player) < ANIMATION_RANGE)
		AnimationNetworkHandler.network.sendToServer(new MessageRequestEntityAnimation((EntityLivingBase) e.getEntity()));
}
 
Example 68
Project: CustomWorldGen   File: ForgeInternalHandler.java   Source Code and License Vote up 4 votes
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
    if (!event.getWorld().isRemote)
    {
        ForgeChunkManager.loadEntity(event.getEntity());
    }

    Entity entity = event.getEntity();
    if (entity.getClass().equals(EntityItem.class))
    {
        ItemStack stack = ((EntityItem)entity).getEntityItem();

        if (stack == null)
        {
            //entity.setDead();
            //event.setCanceled(true);
            return;
        }

        Item item = stack.getItem();
        if (item == null)
        {
            FMLLog.warning("Attempted to add a EntityItem to the world with a invalid item at " +
                "(%2.2f,  %2.2f, %2.2f), this is most likely a config issue between you and the server. Please double check your configs",
                entity.posX, entity.posY, entity.posZ);
            entity.setDead();
            event.setCanceled(true);
            return;
        }

        if (item.hasCustomEntity(stack))
        {
            Entity newEntity = item.createEntity(event.getWorld(), entity, stack);
            if (newEntity != null)
            {
                entity.setDead();
                event.setCanceled(true);
                event.getWorld().spawnEntityInWorld(newEntity);
            }
        }
    }
}
 
Example 69
Project: morecommands   File: CommandSpeed.java   Source Code and License Vote up 4 votes
@Override
public void onEvent(EntityJoinWorldEvent event) {
	if (this.minecartSpeed != null && event.getEntity() instanceof EntityMinecart)
		ReflectionHelper.set(ObfuscatedField.EntityMinecart_currentSpeedRail, this.minecartSpeed, (EntityMinecart) event.getEntity(), this.currentMinecartSpeed);
}
 
Example 70
Project: morecommands   File: CommandDodrops.java   Source Code and License Vote up 4 votes
@Override
public void onEvent(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityItem && !this.dodrops) event.setCanceled(true);
}
 
Example 71
Project: Kingdom-Keys-Re-Coded   File: EntityEvents.java   Source Code and License Vote up 4 votes
@SubscribeEvent
public void OnEntityJoinWorld (EntityJoinWorldEvent event) {
    
    if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayer) {
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.DriveRecovery.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.HighDriveRecovery.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.MagicBoost.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.PowerBoost.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.DefenseBoost.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Elixir.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Megalixir.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Ether.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.MegaEther.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Potion.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.HiPotion.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.MegaPotion.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Panacaea.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_MythrilShard);
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_MythrilStone);
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_MythrilGem);
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_MythrilCrystal);

        if (event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getSlots() != InventoryKeychain.INV_SIZE) {
            ItemStackHandler oldInv = event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain();
            event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setInventory(new ItemStackHandler(InventoryKeychain.INV_SIZE));
            ItemStackHandler newInv = event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain();
            for (int i = 0; i < oldInv.getSlots(); i++) {
                newInv.setStackInSlot(i, oldInv.getStackInSlot(i));
            }
        }

        PacketDispatcher.sendTo(new SyncHudData(event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncMagicInventory(event.getEntity().getCapability(ModCapabilities.MAGIC_STATE, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncItemsInventory(event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncDriveInventory(event.getEntity().getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncDriveData(event.getEntity().getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncMagicData(event.getEntity().getCapability(ModCapabilities.MAGIC_STATE, null), event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncKeybladeData(event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncLevelData(event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncOrgXIIIData(event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) event.getEntity());
        FirstTimeJoinCapability.IFirstTimeJoin FTJ = event.getEntity().getCapability(ModCapabilities.FIRST_TIME_JOIN, null);
        if (!FTJ.getFirstTimeJoin()) {
            ((EntityPlayer) event.getEntity()).inventory.addItemStackToInventory(new ItemStack(ModItems.WoodenKeyblade));
            FTJ.setFirstTimeJoin(true);
            FTJ.setPosX(((EntityPlayer) event.getEntity()).getPosition().getX());
            FTJ.setPosY(((EntityPlayer) event.getEntity()).getPosition().getY());
            FTJ.setPosZ(((EntityPlayer) event.getEntity()).getPosition().getZ());
            if (((EntityPlayer) event.getEntity()).dimension != ModDimensions.diveToTheHeartID && MainConfig.worldgen.EnableStationOfAwakening)
                if (!event.getWorld().isRemote)
                    new TeleporterDiveToTheHeart(event.getWorld().getMinecraftServer().getServer().getWorld(ModDimensions.diveToTheHeartID)).teleport(((EntityPlayer) event.getEntity()));
        }

        ((EntityPlayer) event.getEntity()).getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null).getHP());

        if (((EntityPlayer) event.getEntity()).getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() < 3) {
            ((EntityPlayer) event.getEntity()).getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(3);
        }

        try {
            if (event.getEntity() instanceof EntityPlayerMP){
                EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
                GameProfile profileWehavecookies56 = player.mcServer.getPlayerProfileCache().getGameProfileForUsername("Wehavecookies56");
                UUID uuidWehavecookies56 = profileWehavecookies56.getId();
                final MunnyCapability.IMunny munny = ((EntityPlayer) event.getEntity()).getCapability(ModCapabilities.MUNNY, null);
                if (event.getEntity().getUniqueID() == uuidWehavecookies56) {
                    munny.setMunny(munny.getMunny() + 10000);
                }
                GameProfile profileAbelatox = player.mcServer.getPlayerProfileCache().getGameProfileForUsername("Abelatox");
                UUID uuidAbelatox = profileAbelatox.getId();
                if (event.getEntity().getUniqueID() == uuidAbelatox) {
                    munny.setMunny(munny.getMunny() + 10000);
                }
            }
        } catch (Exception e) {

        }
    }
}
 
Example 72
Project: Aura-Cascade   File: EventHandler.java   Source Code and License Vote up 4 votes
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP && !event.getEntity().worldObj.isRemote) {
        AuraCascade.proxy.networkWrapper.sendTo(new PacketSyncQuestData((EntityPlayer) event.getEntity()), (EntityPlayerMP) event.getEntity());
    }
}
 
Example 73
Project: HCoreLib   File: NotifyPlayerOnJoinHandler.java   Source Code and License Vote up 4 votes
/**
 * Method called when player join's the world, whether client or server based.
 *
 * @param event event call.
 */
// @SuppressWarnings("unchecked")
@SubscribeEvent
public void onPlayerJoin(EntityJoinWorldEvent event) {
	if (!(event.getEntity() instanceof EntityPlayerMP) || !allowUpdateCheck) return;
	else {
		EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
		if (!updateFlag) {
			String build = "";
			String updateUrl = "";

			String changelogUrl = "";
			
			Iterator<Entry<String, String>> iter = map.entrySet().iterator();
			// Grabbing the first index of entry's keys and values and store this data. 'update/build numer'
			if (iter.hasNext()) {
				Entry<String, String> current = iter.next();
				build = current.getKey();
				updateUrl = current.getValue();
			}

			// Output info to joining player.
			player.sendMessage(createComponent(GREEN + "[" + name + "] " +
					GRAY + "Found an update! Latest build: " + build));
			player.sendMessage(createURLComponent(false, updateUrl, DEFAULT_URL_MASK,
					GRAY + "You can get this at:" + WHITE));

			// grab changelog info.
			String[] changelogArray = instance.getChangelogInfo();
			if (changelogArray != null && changelogArray.length > 0) {
				player.sendMessage(createComponent(GREEN + "Change log:"));

				for (String s : changelogArray) {
					if (s != null) {
						player.sendMessage(createComponent(WHITE + s));
					}
				}
			}

		}
	}
}
 
Example 74
Project: HardModeTweaks   File: AITweaksManager.java   Source Code and License Vote up 4 votes
@SubscribeEvent
public void specialSpawnEvent(EntityJoinWorldEvent e) {
	if (e.getEntity() instanceof EntityLiving) {
		replaceAIPanicTask((EntityLiving) e.getEntity());
	}
}
 
Example 75
Project: Hats   File: EventHandlerServer.java   Source Code and License Vote up 4 votes
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntitySpawn(EntityJoinWorldEvent event)
{
    if(FMLCommonHandler.instance().getEffectiveSide().isClient() || !(event.getEntity() instanceof EntityLivingBase) || !HatHandler.canMobHat((EntityLivingBase)event.getEntity()) || Hats.eventHandlerServer.mobHats.containsKey(event.getEntity()))
    {
        return;
    }

    EntityLivingBase living = (EntityLivingBase)event.getEntity();

    boolean fromSpawner = false;
    for(int k = 0; k < event.getEntity().world.loadedTileEntityList.size(); k++)
    {
        TileEntity te = event.getEntity().world.loadedTileEntityList.get(k);
        if(!HatHandler.isMobSpawner(te.getClass(), te.getClass()))
        {
            continue;
        }

        MobSpawnerBaseLogic logic = HatHandler.getMobSpawnerLogic(te.getClass(), te);
        if(logic.isActivated())
        {
            Entity entity = EntityList.createEntityByIDFromName(logic.getEntityId(), logic.getSpawnerWorld()); //This needs to be updated, mob spawners have weighted spawns.
            if(entity != null)
            {
                if(living.getClass() == entity.getClass())
                {
                    List list = logic.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), new AxisAlignedBB((double)logic.getSpawnerPosition().getX(), (double)logic.getSpawnerPosition().getY(), (double)logic.getSpawnerPosition().getZ(), (double)(logic.getSpawnerPosition().getX() + 1), (double)(logic.getSpawnerPosition().getY() + 1), (double)(logic.getSpawnerPosition().getZ() + 1)).grow((double)(4 * 2), 4.0D, (double)(4 * 2)));
                    if(list.contains(living))
                    {
                        fromSpawner = true;
                        break;
                    }
                }
            }
        }
    }
    HatInfo hatInfo;
    if(living.getEntityData().hasKey("Hats_hatInfo"))
    {
        hatInfo = new HatInfo(living.getEntityData().getString("Hats_hatInfo"));
    }
    else
    {
        hatInfo  = living.getRNG().nextFloat() < ((float)Hats.config.randomMobHat / 100F) && !fromSpawner ? HatHandler.getRandomHatFromList(HatHandler.getHatsWithWeightedContributors(), Hats.config.playerHatsMode == 4 && Hats.config.hatRarity == 1) : new HatInfo();
        living.getEntityData().setString("Hats_hatInfo", hatInfo.hatName);
    }
    if(!hatInfo.hatName.isEmpty())
    {
        Hats.eventHandlerServer.mobHats.put(living, hatInfo.hatName);
    }
}
 
Example 76
Project: OpenModsLib   File: DelayedEntityLoadManager.java   Source Code and License Vote up 4 votes
@SubscribeEvent
public void onEntityCreate(EntityJoinWorldEvent evt) {
	final Entity entity = evt.getEntity();
	for (IEntityLoadListener callback : delayedLoads.removeAll(entity.getEntityId()))
		callback.onEntityLoaded(entity);
}
 
Example 77
Project: accesstweaks   File: Maxbright.java   Source Code and License Vote up 3 votes
/** Updates the brightness when the player first joins. */
@SubscribeEvent
public static void joinWorld(EntityJoinWorldEvent event){

    if (event.getEntity() == Minecraft.getMinecraft().player) {

        updateBrightness(event.getWorld().provider.getDimension());
    }
    
}