net.minecraftforge.event.entity.EntityJoinWorldEvent Java Examples

The following examples show how to use net.minecraftforge.event.entity.EntityJoinWorldEvent. 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: PlayerListener.java    From SkyblockAddons with MIT License 6 votes vote down vote up
/**
 * Reset all the timers and stuff when joining a new world.
 */
@SubscribeEvent()
public void onWorldJoin(EntityJoinWorldEvent e) {
    if (e.entity == Minecraft.getMinecraft().thePlayer) {
        lastWorldJoin = System.currentTimeMillis();
        lastBoss = -1;
        magmaTick = 1;
        timerTick = 1;
        main.getInventoryUtils().resetPreviousInventory();
        recentlyLoadedChunks.clear();
        countedEndermen.clear();
        EndstoneProtectorManager.reset();

        IslandWarpGui.Marker doubleWarpMarker = IslandWarpGui.getDoubleWarpMarker();
        if (doubleWarpMarker != null) {
            IslandWarpGui.setDoubleWarpMarker(null);
            Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp "+doubleWarpMarker.getWarpName());
        }
    }
}
 
Example #2
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 #3
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public void on(EntityJoinWorldEvent event) {
    if(!event.world.isRemote && event.entity instanceof EntityItem) {
        ItemStack stack = ((EntityItem) event.entity).getEntityItem();
        if(isDisguised(stack)) {
            long time = event.world.getTotalWorldTime() + event.world.rand.nextInt(60) + 40;
            trackedItems.put((EntityItem) event.entity, time);
        }
        if(stack.getItem() instanceof ItemElement && !(event.entity instanceof EntityItemElement)) {
            event.setCanceled(true);
            EntityItem newItem = new EntityItemElement(event.world,
                    event.entity.posX, event.entity.posY, event.entity.posZ,
                    ((EntityItem) event.entity).getEntityItem());
            newItem.delayBeforeCanPickup = ((EntityItem) event.entity).delayBeforeCanPickup;
            newItem.motionX = event.entity.motionX;
            newItem.motionY = event.entity.motionY;
            newItem.motionZ = event.entity.motionZ;
            event.world.spawnEntityInWorld(newItem);
        }
    }
}
 
Example #4
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
	if (event.entity instanceof EntityPig) {
		EntityPig pig = (EntityPig) event.entity;
		if (EtFuturum.enableBeetroot)
			pig.tasks.addTask(4, new EntityAITempt(pig, 1.2, ModItems.beetroot, false));
	} else if (event.entity instanceof EntityChicken) {
		EntityChicken chicken = (EntityChicken) event.entity;
		if (EtFuturum.enableBeetroot)
			chicken.tasks.addTask(3, new EntityAITempt(chicken, 1.0D, ModItems.beetroot_seeds, false));
	} else if (event.entity instanceof EntityWolf) {
		EntityWolf wolf = (EntityWolf) event.entity;
		if (EtFuturum.enableRabbit)
			wolf.targetTasks.addTask(4, new EntityAITargetNonTamed(wolf, EntityRabbit.class, 200, false));
	} else if (event.entity instanceof EntityVillager) {
		EntityVillager villager = (EntityVillager) event.entity;
		for (Object obj : villager.tasks.taskEntries) {
			EntityAITaskEntry entry = (EntityAITaskEntry) obj;
			if (entry.action instanceof EntityAIOpenDoor) {
				villager.tasks.removeTask(entry.action);
				villager.tasks.addTask(entry.priority, new EntityAIOpenCustomDoor(villager, true));
				break;
			}
		}
	}
}
 
Example #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void on(EntityJoinWorldEvent event) {
    if(!event.entity.worldObj.isRemote && event.entity instanceof EntityGolemBase) {
        EntityGolemBase golem = (EntityGolemBase) event.entity;
        ExtendedGolemProperties props = (ExtendedGolemProperties) golem.getExtendedProperties(Gadomancy.MODID);
        if(props != null) {
            props.setWrapperIfNeeded();
        }
    }

    if (event.entity instanceof EntityItem) {
        EntityItem item = (EntityItem) event.entity;
        ItemStack stack = item.getEntityItem();

        if (stack.getItem() == ConfigItems.itemGolemPlacer) {
            AdditionalGolemType type = GadomancyApi.getAdditionalGolemType(EnumGolemType.getType(stack.getItemDamage()));
            if (type != null) {
                ItemStack fakePlacer = new ItemStack(type.getPlacerItem());
                fakePlacer.setTagCompound(stack.getTagCompound());
                fakePlacer.setItemDamage(stack.getItemDamage());

                item.setEntityItemStack(fakePlacer);
            }
        }
    }

    if(!event.world.isRemote && event.entity instanceof EntityLivingBase) {
        if(((EntityLivingBase) event.entity).isPotionActive(RegisteredPotions.ACHROMATIC)) {
            ((DataAchromatic) SyncDataHolder.getDataServer("AchromaticData")).handleApplication((EntityLivingBase) event.entity);
        }
    }
}
 
Example #13
Source File: AdvancedModEventHandler.java    From AdvancedMod with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onCreeperSpawn(EntityJoinWorldEvent event){
    if(event.entity instanceof EntityCreeper) {
        ((EntityCreeper)event.entity).explosionRadius = 0;
        try {
            Field field = ReflectionHelper.findField(EntityCreeper.class, "field_82225_f", "fuseTime");
            field.set(event.entity, 80);
        } catch(Throwable e) {
            Log.warn("Reflection on Creeper fuseTime failed!");
            e.printStackTrace();
        }
    }
}
 
Example #14
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 #15
Source File: ProtectionHandlers.java    From MyTown2 with The Unlicense 5 votes vote down vote up
@SubscribeEvent
public void entityJoinWorld(EntityJoinWorldEvent ev) {
    if(MyTown.instance.datasource == null) {
        return;
    }

    if (!(ev.entity instanceof EntityLiving)) {
        return;
    }

    ProtectionManager.checkExist(ev.entity, true);
}
 
Example #16
Source File: ClientHookContainer.java    From archimedes-ships with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
	if (event.world.isRemote && event.entity instanceof EntityShip)
	{
		if (((EntityShip) event.entity).getShipChunk().chunkTileEntityMap.isEmpty())
		{
			return;
		}
		
		MsgRequestShipData msg = new MsgRequestShipData((EntityShip) event.entity);
		ArchimedesShipMod.instance.pipeline.sendToServer(msg);
	}
}
 
Example #17
Source File: ConfigEvent.java    From wailanbt with MIT License 5 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
@SubscribeEvent
public void onPlayerJoinWorld(EntityJoinWorldEvent event) {
    if(event.entity instanceof EntityClientPlayerMP){
        LogHelper.info("Initializing config");
        config.init(config.modConfigurationDirectory, (EntityPlayer)event.entity);
    }
}
 
Example #18
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 #19
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 #20
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 #21
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.entity;
    if (!(entity instanceof EntityPlayerMP)) {
        return;
    }
    EntityPlayerMP player = (EntityPlayerMP) entity;
    if (player.worldObj.isRemote) {
        return;
    }
}
 
Example #22
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 #23
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.entity;
    if (!(entity instanceof EntityPlayerMP)) {
        return;
    }
    EntityPlayerMP player = (EntityPlayerMP) entity;
    if (player.worldObj.isRemote) {
        return;
    }
}
 
Example #24
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 #25
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 #26
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 #27
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 #28
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 #29
Source File: ServerEventHandler.java    From bartworks with MIT License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void EntityJoinWorldEvent(EntityJoinWorldEvent event) {
    if (event == null || !(event.entity instanceof EntityPlayerMP) || !SideReference.Side.Server)
        return;
    MainMod.BW_Network_instance.sendToPlayer(new OreDictCachePacket(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity);
    MainMod.BW_Network_instance.sendToPlayer(new ServerJoinedPackage(null),(EntityPlayerMP) event.entity);
}
 
Example #30
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);
}