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

The following examples show how to use net.minecraftforge.event.entity.EntityJoinWorldEvent. These examples are extracted from open source projects. 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 Project: SkyblockAddons   Source File: PlayerListener.java    License: 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 Project: Wizardry   Source File: EventHandler.java    License: 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 Project: Cyberware   Source File: CyberwareDataHandler.java    License: 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 4
Source Project: Valkyrien-Skies   Source File: EventsCommon.java    License: 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 5
@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 6
@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 7
@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 8
Source Project: Et-Futurum   Source File: ServerEventHandler.java    License: 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 9
Source Project: TFC2   Source File: JoinWorldHandler.java    License: 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 10
Source Project: bartworks   Source File: ServerEventHandler.java    License: 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 11
Source Project: ToroQuest   Source File: EventHandlers.java    License: 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 12
Source Project: ToroQuest   Source File: EntitySpawning.java    License: 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 13
Source Project: Cyberware   Source File: ItemBoneUpgrade.java    License: 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 14
Source Project: Signals   Source File: EventHandler.java    License: 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 15
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: 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 Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: 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 17
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: 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 18
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: 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 19
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: 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 20
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: 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 21
@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 22
@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 23
@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 24
@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 25
Source Project: MyTown2   Source File: ProtectionHandlers.java    License: 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 26
Source Project: archimedes-ships   Source File: ClientHookContainer.java    License: 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 27
Source Project: wailanbt   Source File: ConfigEvent.java    License: 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 28
@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 29
Source Project: OpenModsLib   Source File: DropCapture.java    License: 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 30
public static boolean onEntityJoinWorld(Entity entity, World world) {
	return MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, world));
}