-
Posts
642 -
Joined
-
Last visited
Everything posted by TheRPGAdventurer
-
I have a dragon whistle item, i want the whistle to use it for specific tasks such as circling the player coming to the player, following the player while flying etc. I have coded the flight AI now I need an Item, A dragon whistle to trigger them, so i tried putting commands with an ENUM. but when I use it on addInformation() the game crashes with a nullPointerException ItemDragonWhistle: https://pastebin.com/YQ2MMzEF EntityTameableDragon: https://pastebin.com/wBYHLk26 StatCollector: https://pastebin.com/Bud1QeZ8
-
but i still use it for my dragons to classify each breed and return its name, would the dragons despawn without return net.minecraft.util.text.translation.I18n.translateToLocal("entity." + entName + "." + breedName + ".name"); My lang file entity.DragonMount.ice.name=Snow Dragon entity.DragonMount.end.name=Ender Dragon entity.DragonMount.aether.name=Sky Dragon entity.DragonMount.forest.name=Forest Dragon entity.DragonMount.sylphid.name=Water Dragon entity.DragonMount.nether.name=Nether Dragon entity.DragonMount.fire.name=Fire Dragon entity.DragonMount.skeleton.name=Skeleton Dragon entity.DragonMount.wither.name=Wither Dragon entity.DragonMount.enchant.name=Enchantment Dragon entity.DragonMount.sunlight.name=Sunlight Dragon entity.DragonMount.storm.name=Storm Dragon entity.DragonMount.zombie.name=Zombie Dragon entity name is DragonMount
-
So i use Entity#onGround on my dragon flying algorithim to detect if it is on the ground so the dragon can stop flying. But I need to make one with an offset above it. I once used a "while loop" algorithim to detect if the dragon has solid ground below with an offset above it +. but problem is that if the dragon goes to a single piece of y axis without any blocks below or Biome O Plenty's blocks that it cant verify, the game crashes because it cant find any solid block so i ended up using Entity#onGround without any offset. Instead but it too has some problems, like having no offset. In Entity#move() there is this method this.onGround = this.isCollidedVertically && d3 < 0.0D; so i tried replicating it with an offset @Override public void move(MoverType type, double x, double y, double z) { this.onGround = this.isCollidedVertically && y > 5.0D; super.move(type, x, y, z); } but what it does is still making the dragon fly even tho its sticking on the ground it is indicated when it is playing its walking/step sound Without an offset, i ended up with this bug, dragon is stuck it should stop flying rightnow and use the walking algorithim instead of the flying algorithim.
-
@Override public String getName() { // return custom name if set if (hasCustomName()) { return getCustomNameTag(); } // return default breed name otherwise String entName = EntityList.getEntityString(this); String breedName = getBreedType().getName().toLowerCase(); return net.minecraft.util.text.translation.I18n.translateToLocal("entity." + entName + "." + breedName + ".name"); } I used it for my dragon mob here, I once accidentally used the client version but it crashed the game on servers
-
/* ** 2013 July 28 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. */ package com.TheRPGAdventurer.ROTD.server.entity.ai.air; import com.TheRPGAdventurer.ROTD.DragonMountsConfig; import com.TheRPGAdventurer.ROTD.server.entity.EntityTameableDragon; import com.TheRPGAdventurer.ROTD.server.entity.ai.EntityAIDragonBase; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.DimensionType; /** * Dragon AI for instant landing, if left unmounted in air. * * @author Nico Bergemann <barracuda415 at yahoo.de> */ public class EntityAIDragonLandAndCommenceFlyByAttack extends EntityAIDragonBase { private final double speed; private BlockPos landingPos; public EntityAIDragonLandAndCommenceFlyByAttack(EntityTameableDragon dragon, double speed) { super(dragon); this.speed = speed; setMutexBits(1); } public BlockPos findLandingArea(BlockPos pos) { for (int Y = 1; Y <= 2; Y++) { for (int Z = 1; Z <= 2; Z++) { for (int X = 1; X <= 2; X++) { world.getBlockState(new BlockPos(X, Y, Z)).getMaterial().isSolid(); { pos = pos.down(); } } } } return pos; } private boolean findLandingBlock() { // get current entity position landingPos = dragon.getPosition(); // add some variance int followRange = MathHelper.floor(getFollowRange()); int ox = followRange - random.nextInt(followRange) * 2; int oz = followRange - random.nextInt(followRange) * 2; landingPos = landingPos.add(ox, 0, oz); // get ground block if (dragon.world.provider.getDimensionType() == DimensionType.NETHER) { landingPos = findLandingArea(landingPos); } else { landingPos = dragon.world.getHeight(landingPos); } // make sure the block below is solid return world.getBlockState(landingPos.down()).getMaterial().isSolid(); } @Override public boolean shouldExecute() { return !dragon.isInWater() && !dragon.isInLava() && dragon.isFlying() && dragon.getControllingPlayer() == null && findLandingBlock() && dragon.getRevengeTarget() == null; } @Override public boolean shouldContinueExecuting() { return dragon.isFlying() && dragon.getControllingPlayer() == null && !dragon.getNavigator().noPath(); } @Override public void startExecuting() { EntityLivingBase target = dragon.getAttackTarget(); boolean commenceAttackPath = target != null && dragon.getControllingPlayer() == null; boolean commencAttackFlying = commenceAttackPath && !target.onGround; // try to fly to ground block position // if (!tryMoveToBlockPos(landingPos, speed)) { // probably too high, so simply descend vertically // tryMoveToBlockPos(dragon.getPosition().down(4), speed); // } if(!tryToCircleBlockPos(new BlockPos(-8678, 126, 497), speed)) { tryToCircleBlockPos(new BlockPos(-8678, 126, 497), speed); } } } this is where i tried for a test, i used a blockpos where i am close to. protected boolean tryToCircleBlockPos(BlockPos midPoint, double speed) { Vec3d vec1 = dragon.getPositionVector().subtract(midPoint.getX(),midPoint.getY(),midPoint.getZ()); Vec3d vec2 = new Vec3d(0,0,1); // "calculate the angle between these 2 vectors" I hope vec3d is compat with Blockpos Vec3i double a = Math.acos((vec1.dotProduct(vec2)) / (vec1.lengthVector() * vec2.lengthVector())); double r = 12; // radius is now a constant double x = midPoint.getX() + r * Math.cos(a); // x = playerX + r * cos(a) as stated double y = midPoint.getY() + 20; // y = playerY + NUM as stated double z = midPoint.getZ() + r * Math.sin(a); // z = playerZ + r * sin(a) as stated return dragon.getNavigator().tryMoveToXYZ(x + 0.5, y + 0.5, z + 0.5, speed); // no more adding }
-
protected boolean tryToCircleBlockPos(BlockPos midPoint, double speed) { Vec3d vec1 = dragon.getPositionVector().subtract(midPoint.getX(),midPoint.getY(),midPoint.getZ()); Vec3d vec2 = new Vec3d(0,0,1); // "calculate the angle between these 2 vectors" I hope vec3d is compat with Blockpos Vec3i double a = Math.acos((vec1.dotProduct(vec2)) / (vec1.lengthVector() * vec2.lengthVector())); double r = 12; // radius is now a constant double x = midPoint.getX() + r * Math.cos(a); // x = playerX + r * cos(a) as stated double y = midPoint.getY() + 20; // y = playerY + NUM as stated double z = midPoint.getZ() + r * Math.sin(a); // z = playerZ + r * sin(a) as stated return dragon.getNavigator().tryMoveToXYZ(x + 0.5, y + 0.5, z + 0.5, speed); // no more adding } they do go to me, but they dont rotate on a position, am i doing something wrong, does this needs to be a static or a loop?
-
protected boolean tryToCircleBlockPos(BlockPos midPoint, double speed) { Vec3d vec1 = dragon.getPositionVector().subtract(midPoint.getX(),midPoint.getY(),midPoint.getZ()); Vec3d vec2 = dragon.getPositionVector(); // what does unitZ mean double a = Math.acos((vec1.dotProduct(vec2)) / (vec1.lengthVector() * vec2.lengthVector())); double r = 12; // radius is now a constant // double r = dragon.getDistance(midPoint.getX(),midPoint.getY(),midPoint.getZ()); can i use dis? double x = midPoint.getX() + r * Math.cos(a); // x = playerX + r * cos(a) as stated double y = midPoint.getY() + 20; // y = playerY + NUM as stated double z = midPoint.getZ() + r * Math.sin(a); // z = playerZ + r * sin(a) as stated return dragon.getNavigator().tryMoveToXYZ(x + 0.5, y + 0.5, z + 0.5, speed); // no more adding }
-
protected boolean tryToCircleBlockPos(BlockPos midPoint, double speed) { Vec3d vec1 = new Vec3d(midPoint.getX(),midPoint.getY(),midPoint.getZ()); Vec3d vec2 = dragon.getPositionVector(); // "calculate the angle between these 2 vectors" I think this im missing and im bad a t trigonometry double a = Math.acos((vec1.dotProduct(vec2)) / (vec1.lengthVector() * vec2.lengthVector())); double r = dragon.getDistanceSqToCenter(midPoint); // radius is now a double double x = midPoint.getX() + r * Math.cos(a); // x = playerX + r * cos(a) as stated double y = midPoint.getY() + 50; // y = playerY + NUM as stated double z = midPoint.getZ() + r * Math.sin(a); // z = playerZ + r * sin(a) as stated return dragon.getNavigator().tryMoveToXYZ(x, y, z, speed); // no more adding }
-
protected boolean tryToCircleBlockPos(BlockPos midPoint, double speed) { Vec3d vec1 = new Vec3d(midPoint.getX(),midPoint.getY(),midPoint.getZ()); Vec3d vec2 = dragon.getPositionVector(); double a = Math.acos((vec1.dotProduct(vec2)) / (vec1.lengthVector() * vec2.lengthVector())); Vec3d r = vec1.subtract(vec2); double x = midPoint.getX() + r.x * Math.cos(a); double y = midPoint.getY() + 50; double z = midPoint.getZ() + r.z * Math.sin(a); return dragon.getNavigator().tryMoveToXYZ(midPoint.getX() + x, midPoint.getY() + y, midPoint.getZ() + z, speed); }
-
protected boolean tryToCircleBlockPos(BlockPos midPoint, double speed) { Vec3d vec1 = new Vec3d(midPoint.getX(),midPoint.getY(),midPoint.getZ()); Vec3d vec2 = dragon.getPositionVector(); double r = Math.acos((vec1.dotProduct(vec2)) / (vec1.lengthVector() * vec2.lengthVector() ) ); double x = midPoint.getX() + r * Math.cos(dragon.rotationYaw + 90); double y = midPoint.getY() + 50; double z = midPoint.getZ() + r * Math.sin(dragon.rotationYaw + 90); return dragon.getNavigator().tryMoveToXYZ(midPoint.getX() + x, midPoint.getY() + y, midPoint.getZ() + z, speed); } so how'sthis
-
This question is more java mathematics related rather than minecraft related, so i plan to make a dragon whistle item that would command a dragon to either fly towards or circle the player when flying, so is my code for making the dragon circle the player and flying correct? protected boolean tryToCircleBlockPos(BlockPos midPoint, double speed) { // midpoint is gonna be player position dragon.setFlying(true); return dragon.getNavigator().tryMoveToXYZ(midPoint.getX() + 0.5 * Math.PI, midPoint.getY() + 10, midPoint.getZ() + 0.5 * Math.PI, speed); }