Everything posted by Wulfre
-
[1.9.4][SOLVED] Levitate entity.
I was using some of the variables for tick calculations in some other class and never set them back. Thank you for reminding me. Would you mind explaining to me how to make things run server side? I took some recommendations from a friend while writing this -- mostly on checking if the world is remote, which is what I am assuming is the issue. EDIT: I changed world.isRemote to !world.isRemote and everything works as intended now.
-
[1.9.4][SOLVED] Levitate entity.
I realized that after following the usages in the potion class. Thank you.
-
[1.9.4][SOLVED] Levitate entity.
I tried looking for that, but I could not find the class for it in the vanilla library.
-
[1.9.4][SOLVED] Levitate entity.
I am trying to levitate entities that are within a radius from the player when a related item is right clicked with (not yet implemented -- currently tries to levitate as soon as a mob is within the radius). The idea is to gradually move them into a position that is two blocks above the player, but no mobs seem to be reacting to EntityMob#motionY. If I use EntityMob#setPositionAndUpdate they will jerk between their original location and the new location every time the AI tries to preform a task. Another implementation I am planning is to have any mobs that are being levitated to move synchronously with the player, if anyone has insight on that. Not necessarily the actual code, but a rough idea on how to accomplish it. public class ItemFissuredLimiter extends Item { public ItemFissuredLimiter() { setMaxStackSize(1); setCreativeTab(KinesisReference.KINESIS_TAB); } public static int grabRadius = 5; // Blocks. public static int grabLimit = 5; // Mobs. public static int grabDuration = 10; // Seconds. @Override public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand); } @Override public void onUpdate(ItemStack itemStackIn, World worldIn, Entity entity, int someInt, boolean someBoolean) { EntityPlayer playerIn = (EntityPlayer) entity; if(worldIn.isRemote && playerIn.getHeldItemMainhand() == itemStackIn) { // Create bounds around the player, based on the grab radius of the limiter, to check for entities in. double playerX = playerIn.getPosition().getX(); double playerY = playerIn.getPosition().getY(); double playerZ = playerIn.getPosition().getZ(); int radiusHeightDifference = grabRadius - KinesisReference.PLAYER_HEIGHT; BlockPos posMin = new BlockPos(playerX - grabRadius, playerY - grabRadius, playerZ - grabRadius); BlockPos posMax = new BlockPos(playerX + grabRadius, playerY + radiusHeightDifference, playerZ + grabRadius); AxisAlignedBB radiusBox = new AxisAlignedBB(posMin, posMax); // Check for entities that are both in the grab radius and are mobs. List<EntityMob> mobsInRadius = worldIn.getEntitiesWithinAABB(EntityMob.class, radiusBox); // Levitate entities that are within the required radius while restrictions are not yet met. for(EntityMob mob : mobsInRadius) { // Don't levitate boss mobs, that is silly. if(mob.isNonBoss()) { double mobX = mob.getPosition().getX(); double mobY = mob.getPosition().getY(); double mobZ = mob.getPosition().getZ(); System.out.println(mob); System.out.println(mob.motionY); mob.fallDistance = 0; if(mobY < playerY + 2) { mob.motionY = 0.2; } if(mobY > playerY + 2) { mob.motionY = -0.2; } } } } } }
IPS spam blocked by CleanTalk.