Jump to content

[SOLVED] Getting Whether a Block is in a Village


ThunkGames

Recommended Posts

Hello,

I'm new to Minecraft modding (not to Java) and have recently come across a problem checking if a block is in a village using the following code:

 

    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {

 

    Village villageObj;

   

    villageObj = par1World.villageCollectionObj.findNearestVillage(MathHelper.floor_double(par2), MathHelper.floor_double(par3), MathHelper.floor_double(par4), 32);

   

    boolean inVillage;

   

    if (villageObj.getCenter().getDistanceSquared(par2, par3, par4) < (float)(villageObj.getVillageRadius() * villageObj.getVillageRadius())) {

   

    inVillage = true;

   

    } else {

   

    inVillage = false;

   

    }

   

    System.out.println("In village: " + inVillage);

   

    }

 

 

After some trial and error I think the problem is with villageObj.getCenter.

 

Any help is much appreciated. It might help to have my error log  :P

 

---- Minecraft Crash Report ----

// Ouch. That hurt :(

 

Time: 10/19/14 2:36 PM

Description: Unexpected error

 

java.lang.NullPointerException

at net.bizzit.blocks.chestSell.onBlockPlacedBy(chestSell.java:36)

at net.minecraft.item.ItemBlock.placeBlockAt(ItemBlock.java:248)

at net.minecraft.item.ItemBlock.onItemUse(ItemBlock.java:119)

at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:153)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:401)

at net.minecraft.client.Minecraft.clickMouse(Minecraft.java:1390)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1868)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:910)

at net.minecraft.client.Minecraft.run(Minecraft.java:838)

at net.minecraft.client.main.Main.main(Main.java:101)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.bizzit.blocks.chestSell.onBlockPlacedBy(chestSell.java:36)

at net.minecraft.item.ItemBlock.placeBlockAt(ItemBlock.java:248)

at net.minecraft.item.ItemBlock.onItemUse(ItemBlock.java:119)

at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:153)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:401)

at net.minecraft.client.Minecraft.clickMouse(Minecraft.java:1390)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player728'/53, l='MpServer', x=283.05, y=12.62, z=1613.46]]

Chunk stats: MultiplayerChunkCache: 150

Level seed: 0

Level generator: ID 01 - flat, ver 0. Features enabled: false

Level generator options:

Level spawn location: World: (304,4,1735), Chunk: (at 0,0,7 in 19,108; contains blocks 304,0,1728 to 319,255,1743), Region: (0,3; contains chunks 0,96 to 31,127, blocks 0,0,1536 to 511,255,2047)

Level time: 7169 game time, 7169 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 39 total; [EntityVillager['Villager'/1, l='MpServer', x=223.66, y=4.00, z=1575.34], EntityVillager['Villager'/2, l='MpServer', x=222.28, y=4.00, z=1592.59], EntityVillager['Villager'/3, l='MpServer', x=223.75, y=4.00, z=1596.31], EntityVillager['Villager'/4, l='MpServer', x=235.69, y=4.00, z=1571.44], EntityVillager['Villager'/5, l='MpServer', x=231.84, y=4.00, z=1568.50], EntityVillager['Villager'/6, l='MpServer', x=230.38, y=5.00, z=1580.41], EntityVillager['Villager'/7, l='MpServer', x=230.16, y=5.00, z=1577.22], EntityVillager['Villager'/8, l='MpServer', x=228.44, y=5.00, z=1582.72], EntityVillager['Villager'/9, l='MpServer', x=229.56, y=5.00, z=1596.47], EntityVillager['Villager'/10, l='MpServer', x=225.00, y=4.00, z=1589.59], EntityVillager['Villager'/11, l='MpServer', x=227.66, y=5.00, z=1595.78], EntitySlime['Slime'/12, l='MpServer', x=225.38, y=4.02, z=1596.63], EntityVillager['Villager'/13, l='MpServer', x=232.47, y=4.00, z=1588.50], EntityVillager['Villager'/14, l='MpServer', x=235.56, y=4.00, z=1593.84], EntityVillager['Villager'/15, l='MpServer', x=233.31, y=4.00, z=1589.84], EntityVillager['Villager'/17, l='MpServer', x=239.44, y=5.00, z=1605.31], EntityVillager['Villager'/16, l='MpServer', x=231.31, y=5.00, z=1592.31], EntitySheep['Sheep'/19, l='MpServer', x=237.84, y=4.00, z=1642.09], EntityVillager['Villager'/18, l='MpServer', x=239.91, y=5.00, z=1604.22], EntityVillager['Villager'/21, l='MpServer', x=239.96, y=4.00, z=1569.50], EntityVillager['Villager'/20, l='MpServer', x=253.66, y=5.00, z=1567.75], EntityVillager['Villager'/23, l='MpServer', x=242.59, y=5.00, z=1576.69], EntityVillager['Villager'/22, l='MpServer', x=255.50, y=5.00, z=1569.94], EntityVillager['Villager'/25, l='MpServer', x=244.78, y=4.00, z=1577.72], EntityVillager['Villager'/24, l='MpServer', x=250.72, y=4.00, z=1573.47], EntityVillager['Villager'/27, l='MpServer', x=254.78, y=5.00, z=1592.41], EntityVillager['Villager'/26, l='MpServer', x=248.69, y=4.00, z=1577.41], EntityVillager['Villager'/29, l='MpServer', x=241.22, y=5.00, z=1598.50], EntityVillager['Villager'/28, l='MpServer', x=253.34, y=4.00, z=1589.69], EntityVillager['Villager'/31, l='MpServer', x=247.84, y=4.00, z=1600.38], EntityVillager['Villager'/30, l='MpServer', x=243.63, y=4.00, z=1601.34], EntityVillager['Villager'/34, l='MpServer', x=255.50, y=4.00, z=1579.72], EntitySlime['Slime'/35, l='MpServer', x=261.33, y=5.85, z=1589.38], EntitySheep['Sheep'/32, l='MpServer', x=253.66, y=4.00, z=1654.69], EntityBat['Bat'/33, l='MpServer', x=267.75, y=8.10, z=1556.66], EntitySheep['Sheep'/36, l='MpServer', x=267.69, y=4.00, z=1656.78], EntitySheep['Sheep'/37, l='MpServer', x=258.03, y=4.00, z=1649.03], EntityBat['Bat'/40, l='MpServer', x=285.27, y=6.29, z=1622.54], EntityClientPlayerMP['Player728'/53, l='MpServer', x=283.05, y=12.62, z=1613.46]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:440)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2312)

at net.minecraft.client.Minecraft.run(Minecraft.java:863)

at net.minecraft.client.main.Main.main(Main.java:101)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

-- System Details --

Details:

Minecraft Version: 1.6.4

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_60, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 655548960 bytes (625 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 21741 (1217496 bytes; 1 MB) allocated, 4 (224 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v8.11 FML v6.99.19.964 Minecraft Forge 9.11.1.964 4 mods loaded, 4 mods active

mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{6.99.19.964} [Forge Mod Loader] (forge-1.6.4-9.11.1.964-mcp.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{9.11.1.964} [Minecraft Forge] (forge-1.6.4-9.11.1.964-mcp.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Bizzit Ext{Alpha v0.1} [bizzit Ext] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Launched Version: 1.6

LWJGL: 2.9.0

OpenGL: GeForce GTX 650 Ti BOOST/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Pack: Default

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: 496 (27776 bytes; 0 MB) allocated, 16 (896 bytes; 0 MB) used

 

 

Because I'm new to this whole thing, I'm not to sure on what any of that means. Any help is much appreciated.

 

-David

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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