Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Right now, I'm trying to get at least the position of the nearest village, say within a radius of x, which at the moment is 10,000.  I scraped this together, but it's firing a null exception when trying to populate my village variable.  Any pointers?

 

package com.fuzzybat23;


import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.village.Village;
import net.minecraft.village.VillageCollection;
import net.minecraft.world.WorldServer;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@net.minecraftforge.fml.common.Mod(modid = "villageinfo", version = "1.0", clientSideOnly = true, acceptedMinecraftVersions = "[1.12, 1.13]")
public class VillageInfo
{
    @net.minecraftforge.fml.common.Mod.Instance("VillageInfo")
    public static final String MODID = "villageinfo";

    @Mod.Instance
    public static VillageInfo instance;

    public static final Logger logger = LogManager.getLogger();

    @Mod.EventHandler
    @SideOnly(Side.CLIENT)
    public void preInit(FMLPreInitializationEvent event)
    {
        ModMetadata data = event.getModMetadata();
        data.autogenerated = false;
        data.version = "1.0";
        data.name = "Village Info";
        data.description = "Displays nearby village info.";
        data.authorList.add("Fuzzybat23");
        data.url = "https://minecraft.curseforge.com/members/fuzzybat23/projects";
        data.credits = "Bats everywhere.";
        data.logoFile = "assets/logo/logo.png";

        FMLCommonHandler.instance().bus().register(instance);
        MinecraftForge.EVENT_BUS.register(instance);
    }

    @SubscribeEvent
    public void onRenderTextOverlay(RenderGameOverlayEvent.Text event)
    {
        Minecraft mc = Minecraft.getMinecraft();
        EntityPlayer player = mc.player;

        if(mc.gameSettings.showDebugInfo)
            getVillageData(event, player);
    }

    private void getVillageData(RenderGameOverlayEvent.Text event, EntityPlayer player)
    {
        if(player == null)
            return;

        WorldServer worldServer = DimensionManager.getWorld(player.dimension);
        VillageCollection villageCollection = null;

        Village village = villageCollection.getNearestVillage(player.getPosition(),10000);

        event.getLeft().add("Test1: " + worldServer.toString());
        if(village != null)
            event.getLeft().add("Test2: " + village.toString());
    }
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.