Example usage for net.minecraftforge.event.entity EntityJoinWorldEvent getWorld

List of usage examples for net.minecraftforge.event.entity EntityJoinWorldEvent getWorld

Introduction

In this page you can find the example usage for net.minecraftforge.event.entity EntityJoinWorldEvent getWorld.

Prototype

public World getWorld() 

Source Link

Usage

From source file:com.blogspot.jabelarminecraft.magicbeans.EventHandler.java

License:Open Source License

@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public static void onEvent(EntityJoinWorldEvent event) {
    World world = event.getWorld();
    if (world.isRemote) {
        return;// w w w.ja v  a2 s .c o  m
    }

    Entity theEntity = event.getEntity();
    if (theEntity instanceof EntityCreeper) {
        //          // DEBUG
        //          System.out.println("EntityJoinWorldEvent creeper at height = "+theEntity.posY);
        if (theEntity.posZ > MagicBeans.configMaxStalkHeight) {
            // assumes that must be in castle at this height
            event.setCanceled(true); // creepers would wreck castle
            return;
        }
    }
}

From source file:com.techshroom.ludicroushooks.LudicrousHooks.java

License:MIT License

@SubscribeEvent
public void onPlayerEntitySpawn(EntityJoinWorldEvent event) {
    if (!(event.getEntity() instanceof EntityPlayer)) {
        return;/*www . j a  v a  2s. c o m*/
    }
    Collection<NBTTagCompound> hooks = this.unspawnedHooks.get(event.getEntity().getUniqueID());
    hooks.forEach(h -> {
        Entity hook = EntityList.createEntityFromNBT(h, event.getWorld());
        if (!(hook instanceof EntityHook)) {
            LOGGER.warn("Unspanwed hook created an instance of " + hook.getClass().getName() + " rather than "
                    + EntityHook.class.getName());
        }
        event.getWorld().spawnEntityInWorld(hook);
    });
    hooks.clear();
}

From source file:de.canitzp.rarmor.event.CommonEvents.java

@SubscribeEvent
public void onPlayerJoin(EntityJoinWorldEvent event) {
    if (!event.getWorld().isRemote) {
        Entity entity = event.getEntity();
        if (entity instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entity;

            for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
                ItemStack stack = player.inventory.getStackInSlot(i);
                if (!stack.isEmpty()) {
                    IRarmorData data = RarmorAPI.methodHandler.getDataForStack(player.getEntityWorld(), stack,
                            false);/*from  ww  w.jav a  2s.  co  m*/
                    if (data != null) {
                        data.queueUpdate(true);
                    }
                }
            }
        }
    }
}

From source file:de.sanandrew.mods.turretmod.registry.turret.GuiTcuRegistry.java

License:Creative Commons License

@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP && !event.getWorld().isRemote) {
        PacketRegistry.sendToPlayer(new PacketSyncTcuGuis(), (EntityPlayerMP) event.getEntity());
    }/*  w w w  . j  a  v a2  s.  co  m*/
}

From source file:de.sanandrew.mods.turretmod.util.PlayerList.java

License:Creative Commons License

@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayer && !event.getWorld().isRemote) {
        this.playerMap.put(event.getEntity().getUniqueID(), event.getEntity().getName());
        this.syncList();
        this.markDirty();
    }/*from   w w w  .  j  a v  a  2s .  com*/
}

From source file:jayavery.accesstweaks.Maxbright.java

License:Open Source License

/** Updates the brightness when the player first joins. */
@SubscribeEvent//from   w ww . j a  v  a2 s  .  c o  m
public static void joinWorld(EntityJoinWorldEvent event) {

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

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

}

From source file:mod.rankshank.arbitraria.common.vars.ArbitraryCaps.java

@SubscribeEvent
public static void replaceBobber(EntityJoinWorldEvent event) {
    if (event.getEntity().getClass().equals(EntityFishHook.class)) {
        EntityAdvancedFishingHook adv = new EntityAdvancedFishingHook((EntityFishHook) event.getEntity());
        event.getWorld().spawnEntity(adv);
        event.setCanceled(true);//  www . ja v  a  2 s.  c  o m
    }
}

From source file:org.blockartistry.DynSurround.client.handlers.EnvironStateHandler.java

License:MIT License

/**
 * Hook the entity join world event so we can get the player and world info
 * ASAP.//  w  ww .j a  va2s  . co  m
 */
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onEntityJoin(@Nonnull final EntityJoinWorldEvent event) {
    if (event.getWorld().isRemote && event.getEntity() instanceof EntityPlayerSP) {
        EnvironState.tick(event.getWorld(), (EntityPlayer) event.getEntity());
    }
}

From source file:org.drools.minecraft.adapter.NewAdapter.java

License:Apache License

/**
 * Set up player session, inventory, etc.
 *
 * @param event//from   w w  w  .j av  a  2  s  .  c om
 */
@SubscribeEvent
public void onPlayerJoin(EntityJoinWorldEvent event) {
    if (!event.getWorld().isRemote) {
        if (event.getEntity() instanceof EntityPlayer) {
            PlayerConfiguration playerConfig = new BasePlayerConfigurationImpl(null);
            String name = event.getEntity().getDisplayName().getUnformattedText();
            Player player = new BasePlayerImpl(name);
            game.join(player, playerConfig);
        }
    }
}