Jump to content

[1.7.2]CoreMods help.


SSslimer

Recommended Posts

I know that I need to use ASD, but it's my forst contact with coremods and ASM.

To my project I must made own village that will be a bit similar to vanilla, but my own villagecolection need to be add in finishSetup() method and world(...)

Link to comment
Share on other sites

This might still be relevant. Specifically,

VillagerRegistry#registerVillageCreationHandler

.

 

If that is not what you had in mind, there are hooks for adding your own structures to worldgen as well - I don't know them, specifically, but you should definitely not have to tamper with vanilla classes.

Link to comment
Share on other sites

I don't want to add own building yet.But create own village.

Here is what i need to add to World.class

 

public VillageCollection villageCollectionObj;

 

in finishSetup():

        VillageCollection villagecollection = (VillageCollection)this.mapStorage.loadData(VillageCollection.class, "villages");

 

        if (villagecollection == null)

        {

            this.villageCollectionObj = new VillageCollection(this);

            this.mapStorage.setData("villages", this.villageCollectionObj);

        }

        else

        {

            this.villageCollectionObj = villagecollection;

            this.villageCollectionObj.func_82566_a(this);

        }

 

and in world(ISaveHandler p_i45369_1_, String p_i45369_2_, WorldSettings p_i45369_3_, WorldProvider p_i45369_4_, Profiler p_i45369_5_):

        VillageCollection villagecollection = (VillageCollection)this.perWorldStorage.loadData(VillageCollection.class, "villages");

 

        if (villagecollection == null)

        {

            this.villageCollectionObj = new VillageCollection(this);

            this.perWorldStorage.setData("villages", this.villageCollectionObj);

        }

        else

        {

            this.villageCollectionObj = villagecollection;

            this.villageCollectionObj.func_82566_a(this);

        }

 

 

of course all the needed names will be changed

Link to comment
Share on other sites

Please use [ code ] tags for short snippets of code, and gists for larger amounts :)

 

Do you want your village to coexist with other villages? Do you want to use the vanilla buildings in your village?

 

If you would please be a bit more specific about what you need - not just "I need to add this code", but rather "I want this and this result", I think we can find a way around your needs without having to rely on coremods.

 

Also, I believe the general sentiment is, if you don't know how to make a coremod, you shouldn't be making one.

 

There are plenty of resources both on this forum - and on the web - on how to go about making coremods in the general sense. If you can't tailor those guides and instructions to suit your specific needs, you probably should really be looking into how to achieve what you want to do without making a coremod.

 

In fact, you should probably always be very sure you need a coremod before you choose to make one.

 

Your current need sounds like it can be managed without a coremod, so let's approach it from that angle to begin with, shall we?

 

Note: If you end up making a coremod, and you are having specific issues that to your knowledge should work, yet do not seem to, you are more than welcome to ask for advice, here.

 

I don't think anyone will be willing to take you from Goth to Boss on coremods without very serious justification and commitment on your end.

Link to comment
Share on other sites

To brighten the problem:

I don't want buildings.

Code writen higher is needed to make my village setting and anihilating, by checking the door number.

Without that code my village can't appear.

Maybe there is some way to make village collection without editing world.class or using asm, but so far it's only way known to me.

 

Link to comment
Share on other sites

You don't want buildings? What do you want, then?

 

You want your villages (which consists of what?) to appear and disappear based on door numbers? ... But without buildings, there are no doors (probably).

 

What is the village collection supposed to represent, and what will it do?

Link to comment
Share on other sites

Village can be material (structures) and nomaterial(village centred in some point

calculated from doors).My village will apear after generating my own building on world. When it will generate, door will create village and to make that village I need to add that method and villagecollection class.

Sorry for problems with explaining, but english isn't my native language.

Link to comment
Share on other sites

I am absolutely new with events too.

Something I have wrong.

In my load method      MinecraftForge.EVENT_BUS.register(new BetterWorldHandler());

And method in my handler 

 

@SubscribeEvent
public void someEventMethod(WorldEvent event) 
{		
BetterVillageCollection villagecollection = (BetterVillageCollection)this.mapStorage.loadData(BetterVillageCollection.class, "bettervillages");
        
        if (villagecollection == null)
        {
            this.villageCollectionObj = new BetterVillageCollection(world);
            this.mapStorage.setData("bettervillages", this.villageCollectionObj);
        }
        else
        {
            this.villageCollectionObj = villagecollection;
            this.villageCollectionObj.func_82566_a(world);
        }
}

 

And error from Console

 

[13:13:52] [server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Exception getting block type in world
at net.minecraft.world.World.<init>(World.java:316) ~[World.class:?]
at net.minecraft.world.WorldServer.<init>(WorldServer.java:103) ~[WorldServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:63) ~[integratedServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:442) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742) [MinecraftServer$2.class:?]
Caused by: java.lang.NullPointerException
at BetterWorld.BetterWorldHandler.someEventMethod(BetterWorldHandler.java:18) ~[betterWorldHandler.class:?]
at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_BetterWorldHandler_someEventMethod_WorldEvent.invoke(.dynamic) ~[?:?]
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) ~[ASMEventHandler.class:?]
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) ~[EventBus.class:?]
at net.minecraft.world.chunk.Chunk.onChunkLoad(Chunk.java:1014) ~[Chunk.class:?]
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:149) ~[ChunkProviderServer.class:?]
at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:163) ~[ChunkProviderServer.class:?]
at net.minecraft.world.World.getChunkFromChunkCoords(World.java:487) ~[World.class:?]
at net.minecraft.world.World.getBlock(World.java:392) ~[World.class:?]
at net.minecraft.world.World.isAirBlock(World.java:415) ~[World.class:?]
at net.minecraft.world.World.getTopBlock(World.java:376) ~[World.class:?]
at net.minecraft.world.WorldProvider.canCoordinateBeSpawn(WorldProvider.java:97) ~[WorldProvider.class:?]
at net.minecraft.world.WorldServer.createSpawnPosition(WorldServer.java:806) ~[WorldServer.class:?]
at net.minecraft.world.WorldServer.initialize(WorldServer.java:770) ~[WorldServer.class:?]
at net.minecraft.world.World.<init>(World.java:301) ~[World.class:?]

 

 

 

Link to comment
Share on other sites

So what I need to do to make my  villageCollectionObj in  world server???

 

EntityPlayer player = mc.thePlayer;

        WorldServer worldServer = DimensionManager.getWorld(player.dimension);

        if(worldServer == null){

            return null;

        }

        BetterVillageCollection vlgc = worldServer.villageCollectionObj;

        BetterVillage closestVillage = vlgc.findNearestVillage(

                MathHelper.floor_double(player.posX),

                MathHelper.floor_double(player.posY),

                MathHelper.floor_double(player.posZ), 50);

Link to comment
Share on other sites

Stil doesn't work.

Handler class:

public static BetterVillageCollection villageCollectionObj;

@SubscribeEvent
public void someEventMethod(WorldEvent event) 
{	
	BetterVillageCollection villagecollection = (BetterVillageCollection)event.world.mapStorage.loadData(BetterVillageCollection.class, "bettervillages");	

        if (villagecollection == null)
        {
            this.villageCollectionObj = new BetterVillageCollection(event.world);
            event.world.mapStorage.setData("bettervillages", this.villageCollectionObj);
        }
        else
        {
            this.villageCollectionObj = villagecollection;
            this.villageCollectionObj.func_82566_a(event.world);
        }
}

And code for my mod.

     
BetterWorldHandler handler = new BetterWorldHandler();

        BetterVillageCollection vlgc = handler.villageCollectionObj;
        BetterVillage closestVillage = vlgc.findNearestVillage(
                MathHelper.floor_double(player.posX),
                MathHelper.floor_double(player.posY),
                MathHelper.floor_double(player.posZ), 50);
[/cpde]

Link to comment
Share on other sites

It's terrible.I only need to load and set data from world.

Now my code looks like:

public static BetterVillageCollection get(World world)
{
	BetterVillageCollection data = (BetterVillageCollection)world.loadItemData(BetterVillageCollection.class, IDENTIFIER);

	if (data == null)
	{
		data = new BetterVillageCollection(world);
		world.setItemData(IDENTIFIER, data);
	}
        else
        {
            data.func_82566_a(world);
        }

	return data;
}

[code]
        BetterWorldHandler handler = new BetterWorldHandler();

        BetterVillageCollection vlgc = handler.get(worldServer);
        BetterVillage closestVillage = vlgc.findNearestVillage(
                MathHelper.floor_double(player.posX),
                MathHelper.floor_double(player.posY),
                MathHelper.floor_double(player.posZ), 50);

[/code]

Link to comment
Share on other sites

I use bottom code with findNearestVillage() to search village and get from it informations.When I use normall village the code works and in my GUI disply e.g. number of villagers.My code for village is the same, because I need to be sure that village creates.

If the code is the same with necesary changes ,the code for loading and saving data is incorrect.

Link to comment
Share on other sites

  • 2 weeks later...

My village code is the same.

I am not sure is the code working, but it should, because it's the same as vanilla.

I want to make more usefull villages and I don't want to edit base files.

Why should I send Packets if I my mod is for single player?

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.

Announcements



×
×
  • Create New...

Important Information

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