Jump to content

26broadway

Members
  • Posts

    5
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

26broadway's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thanks! I use the block but need to make sure it's the correct type of block. How do I ensure that the block it is looking at is wood, for example? Names are useful for this, I guess ID's would be too if they weren't depreciated. Do you mean to check equality (using the equality operator of the Block class) of some wood Block instance to the block we're looking at?
  2. Still looking for help on this. I would imagine it's pretty straightforward but I can't seem to figure out how to detect wood. Thanks!
  3. Hello, Goal: Find wood (trees) and later navigate to and chop the trees Method: The entity I created implements a custom ai method that extends EntityAIBase. It creates a list of blocks within a certain radius of the entity and finds blocks of interest. I've tried to filter the list of nearby blocks using both the block name and id (deprecated?) then printing the results. Problem: Depending on where I place the entity it only sometimes finds something other than air even if it's standing near dirt, trees, or stone. Question: What is a good way to find wood blocks near the entity? It seems id's and names are useless in this endeavor. Code: A few of the support functions are removed for clarity. package com.dm.gatherer.ai; import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; public class tempAI extends EntityAIBase { private EntityCreature entity; private double xPosition; private double yPosition; private double zPosition; private double speed; private int field_179481_f; private boolean field_179482_g; private static final String __OBFID = "CL_00001608"; int searchRadius = 25; private int harvestID = 17; private boolean navigationSuccessful = false; boolean runonce = false; List<Entity> harvestableEntities; boolean testBool = false; int testInt = 0; BlockPos searchPos; Block searchBlock; int searchID; List<Integer> searchIDs = new ArrayList<Integer>(); /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { if(!testBool){ for(int searchX = (int) (this.entity.posX - searchRadius); searchX < this.entity.posX + searchRadius; searchX++){ for(int searchY = (int) (this.entity.posY - searchRadius); searchY < this.entity.posY + searchRadius; searchY++){ for(int searchZ = (int) (this.entity.posX - searchRadius); searchZ < this.entity.posX + searchRadius; searchZ++){ searchPos = new BlockPos(searchX, searchY, searchZ); searchBlock = Minecraft.getMinecraft().theWorld.getBlockState(searchPos).getBlock(); searchID = searchBlock.getIdFromBlock(Minecraft.getMinecraft().theWorld.getBlockState(searchPos).getBlock()); if(searchID != 0){ searchIDs.add(searchID); } } } } testBool = true; System.out.println("Start printing!"); for(int id: searchIDs){ System.out.println("ID: " + id); } System.out.println("Done printing!"); } } } Thanks for your attention!
  4. Thanks for the reply Ewe. Yes, I have tried it -> "they will move a few blocks (the x offset I provide) then wait before moving again." I duplicated and modified the entity wander ai method so that it simply walks in a straight line instead of randomly. Some of the code is still obfuscated but it doesn't seem to explicitely add a delay; here is what it looks like currently: package com.dm.gatherer.ai; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.RandomPositionGenerator; import net.minecraft.util.Vec3; public class ChopTrees extends EntityAIBase { private EntityCreature entity; private double xPosition; private double yPosition; private double zPosition; private double speed; private int field_179481_f; private boolean field_179482_g; private static final String __OBFID = "CL_00001608"; public ChopTrees(EntityCreature p_i1648_1_, double p_i1648_2_) { this(p_i1648_1_, p_i1648_2_, 120); } public ChopTrees(EntityCreature p_i45887_1_, double p_i45887_2_, int p_i45887_4_) { this.entity = p_i45887_1_; this.speed = p_i45887_2_; this.field_179481_f = p_i45887_4_; this.setMutexBits(1); } /** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { if (!this.field_179482_g) { if (this.entity.getAge() >= 100) { return false; } if (this.entity.getRNG().nextInt(this.field_179481_f) != 0) { return false; } } Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7); if (vec3 == null) { return false; } else { this.xPosition = vec3.xCoord; this.yPosition = vec3.yCoord; this.zPosition = vec3.zCoord; this.field_179482_g = false; return true; } } /** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean continueExecuting() { return !this.entity.getNavigator().noPath(); } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { //this.entity.moveEntity(3, 0, 0); this.entity.getNavigator().tryMoveToXYZ(this.entity.posX+3, this.entity.posY, this.entity.posZ, this.speed); } public void func_179480_f() { this.field_179482_g = true; } public void func_179479_b(int p_179479_1_) { this.field_179481_f = p_179479_1_; } } The only other ai method added to this particular entity on construction is the swimming ai; this custom ChopTrees ai method is priority 2. I'll try commenting out some of the conditionals in shouldExecute() to see if, perhaps, one of those is sending the false flag periodically. Open to suggestions!
  5. Hello, When I add custom entities to my mod then add ai so that they move in a straight line (goal: continuous movement) they will move a few blocks (the x offset I provide) then wait before moving again. I read somewhere that mobs have a delayed tick. Is there a way around this? How do I add AI entities that have smooth, continuous movement? Thanks!
×
×
  • Create New...

Important Information

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