Java Code Examples for net.minecraft.world.WorldProviderEnd

The following examples show how to use net.minecraft.world.WorldProviderEnd. 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
@Override
public void update() {
    super.update();
    if (getWorld().isRemote)
        return;
    if (!(getWorld().provider instanceof WorldProviderEnd)) {
        return; //don't try to do anything outside end dimension
    }
    if (getTimer() % 20 == 0) {
        updateDragonEggStatus();
    }
    if (getTimer() % 200 == 0) {
        updateConnectedCrystals();
    }
    int totalEnergyGeneration = 0;
    for (int connectedCrystalId : connectedCrystalsIds.toArray()) {
        //since we don't check quite often, check twice before outputting energy
        if (getWorld().getEntityByID(connectedCrystalId) instanceof EntityEnderCrystal) {
            totalEnergyGeneration += hasDragonEggAmplifier ? 128 : 32;
        }
    }
    if (totalEnergyGeneration > 0) {
        energyContainer.changeEnergy(totalEnergyGeneration);
    }
    setActive(totalEnergyGeneration > 0);
}
 
Example 2
private static void removeDragonBossBarHack(EntityPlayerMP player, WorldProviderEnd provider)
{
    // Somewhat ugly way to clear the Boss Info stuff when teleporting FROM The End
    DragonFightManager manager = provider.getDragonFightManager();

    if (manager != null)
    {
        try
        {
            BossInfoServer bossInfo = ObfuscationReflectionHelper.getPrivateValue(DragonFightManager.class, manager, "field_186109_c");

            if (bossInfo != null)
            {
                bossInfo.removePlayer(player);
            }
        }
        catch (Exception e)
        {
            EnderUtilities.logger.warn("TP: Failed to get DragonFightManager#bossInfo");
        }
    }
}
 
Example 3
public static boolean isEndDimension(World world)
{
    return world.provider instanceof WorldProviderEnd ||
           world.provider.getDimensionType().getId() == 1 ||
           CUSTOM_END_DIMENSIONS.contains(world.provider.getDimension());
           
}
 
Example 4
private static Entity teleportEntityToDimension(Entity entity, double x, double y, double z, int dimDst)
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    WorldServer worldDst = server.getWorld(dimDst);

    teleportInProgress = true;

    if (worldDst == null || ForgeHooks.onTravelToDimension(entity, dimDst) == false)
    {
        teleportInProgress = false;
        return null;
    }

    teleportInProgress = false;

    // Load the chunk first
    int chunkX = (int) Math.floor(x / 16D);
    int chunkZ = (int) Math.floor(z / 16D);
    ChunkLoading.getInstance().loadChunkForcedWithModTicket(dimDst, chunkX, chunkZ, 10);

    if (entity instanceof EntityPlayerMP)
    {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        World worldOld = player.getEntityWorld();
        DummyTeleporter teleporter = new DummyTeleporter(worldDst);

        player.setLocationAndAngles(x, y, z, player.rotationYaw, player.rotationPitch);
        server.getPlayerList().transferPlayerToDimension(player, dimDst, teleporter);

        // Teleporting FROM The End, remove the boss bar that would otherwise get stuck on
        if (worldOld.provider instanceof WorldProviderEnd)
        {
            removeDragonBossBarHack(player, (WorldProviderEnd) worldOld.provider);
        }

        player.setPositionAndUpdate(x, y, z);
        worldDst.updateEntityWithOptionalForce(player, false);
        player.addExperienceLevel(0);
        player.setPlayerHealthUpdated();
        // TODO update food level?
    }
    else
    {
        WorldServer worldSrc = (WorldServer) entity.getEntityWorld();

        // FIXME ugly special case to prevent the chest minecart etc from duping items
        if (entity instanceof EntityMinecartContainer)
        {
            ((EntityMinecartContainer) entity).setDropItemsWhenDead(false);
        }

        Entity entityNew = EntityList.newEntity(entity.getClass(), worldDst);

        if (entityNew != null)
        {
            EntityUtils.copyDataFromOld(entityNew, entity);
            entityNew.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);

            boolean flag = entityNew.forceSpawn;
            entityNew.forceSpawn = true;
            worldDst.spawnEntity(entityNew);
            entityNew.forceSpawn = flag;

            worldDst.updateEntityWithOptionalForce(entityNew, false);
            entity.isDead = true;

            worldSrc.removeEntity(entity);
            worldSrc.updateEntityWithOptionalForce(entity, false);

            worldSrc.resetUpdateEntityTick();
            worldDst.resetUpdateEntityTick();
        }

        entity = entityNew;
    }

    return entity;
}