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.

TheExceptionist

Members
  • Joined

  • Last visited

  1. I registered it into the "MinecraftForge.EVENT_BUS", yet it still isn't working.
  2. I been trying for a couple of days now to get a village guard-like mob to spawn in a village that generates in the game. I started by using a forge event "PopulateChunkEvent", but it doesn't seem to be working right. ' @SubscribeEvent public void onPopulateChunk(PopulateChunkEvent.Populate event){ FMLLog.getLogger().info("Spawn Watch"); if(event.hasVillageGenerated){ EntityVillageWatch.spawnWatch(event.world); } } ' Registering the class into the forge EVENTBUS: ' @EventHandler public void preInit(FMLPreInitializationEvent event){ CivItems.init(); CivBlocks.init(); CivItems.register(); CivBlocks.register(); //EntityRegisterCiv.addSpawns(); MinecraftForge.EVENT_BUS.register(new spawnWatch()); } ' My spawnWatch function: ' public EntityVillageWatch(World worldIn, int x, int y, int z) { super(worldIn); this.posX = x; this.posY = y; this.posZ = z; this.setSize(1.4F, 2.9F); ((PathNavigateGround)this.getNavigator()).func_179690_a(true); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); this.tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true)); this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(6, new EntityAIWander(this, 0.6D)); this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIGuardVillage(this)); this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false, new Class[0])); this.targetTasks.addTask(3, new EntityVillageWatch.AINearestAttackableTargetNonCreeper(this, EntityLiving.class, 10, false, true, IMob.field_175450_e)); } public static void spawnWatch(World worldIn){ int i = 0; int numWatch = r.nextInt(20)+21; List villages = worldIn.getVillageCollection().getVillageList(); while(villages.iterator().hasNext()){ int numWatchSpawned = 0; Village village = (Village) villages.get(i); BlockPos center = village.getCenter(); int radius = village.getVillageRadius(); while(numWatchSpawned < numWatch){ worldIn.spawnEntityInWorld(new EntityVillageWatch(worldIn, center.getX() + r.nextInt(radius), center.getY()+r.nextInt(radius), center.getZ()+r.nextInt(radius))); numWatchSpawned++; } i++; } } ' Any suggestions or problems you see with this code? Any help is greatly appreciated.

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.