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

I have little to no knowledge of world generation (besides basic ore generation), and making a new village home seemed like a good place to start.

 

This is what I have so far

 

VillageHandler:

package enlistment.village;

import java.util.ArrayList;
import java.util.Random;

import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraftforge.fml.common.registry.VillagerRegistry;

public class VillageHandler {
public static void init() {
	ArrayList<StructureVillagePieces.PieceWeight> pieces = new ArrayList<StructureVillagePieces.PieceWeight>();

	pieces.add(new StructureVillagePieces.PieceWeight(VillageTroopHome.class, 100, 100));

	VillagerRegistry.addExtraVillageComponents(pieces, new Random(), 100);
}
}

 

VIllageTroopHome:

package enlistment.village;

import java.util.Random;

import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureVillagePieces;

public class VillageTroopHome extends StructureVillagePieces.Village {
public VillageTroopHome(StructureVillagePieces.Start start, int type, Random random, StructureBoundingBox bb, EnumFacing direction) {
	super(start, type);

	this.coordBaseMode = direction;
	this.boundingBox = bb;
}

@Override
public boolean addComponentParts(World world, Random random, StructureBoundingBox bb) {
	System.out.println("HI");

	if(this.field_143015_k < 0) {
		this.field_143015_k = this.getAverageGroundLevel(world, bb);

		if(this.field_143015_k < 0) {
			return true;
		}

		this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 12 - 1, 0);
	}

	this.fillWithBlocks(world, bb, 1, 1, 1, 3, 3, 3, Blocks.cobblestone.getDefaultState(), Blocks.cobblestone.getDefaultState(), false);
	this.fillWithBlocks(world, bb, 2, 2, 2, 2, 100, 2, Blocks.glass.getDefaultState(), Blocks.glass.getDefaultState(), false);

	this.spawnVillagers(world, bb, 2, 1, 2, 1);

	return true;
}
}

 

Looking through the source code of Minecraft, I haven't been able to decipher what the cryptic integers in the VIllagerRegistry#addExtraVillageComponents method does, so I set them to 100 for testing purposes. Also I set the integers in the StructureVillagePieces#PieceWeight constructor to 100 for the same reason.

 

The questions I have besides the integers are if I'm using the correct methods, extending the right classes, and passing the right objects.

Kain

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.