Everything posted by FlamingVikingGoat
-
[1.10] Help Moving Living Entities Asymmetrically
I'm not 100% sure of what you mean. Do you mean doing something like entity.motionX = scaledSideB * Math.cos(Math.acos(startSideA/startHyp));
-
[1.10] Help Moving Living Entities Asymmetrically
I'm working on an item that, when right-clicked, pushes back entities in a circle around the player. However, I want the entity to be pushed back following the same line; right now, the entities are pushed back into the closest corner. Additionally, I don't want the item to push entities through walls(so setting entity.posX/entity.posY directly or using entity::moveTo won't work). Here's the code that I have now: @Override public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { AxisAlignedBB aabb = playerIn.getEntityBoundingBox().expand(playerIn.posX + range, playerIn.posY + range, playerIn.posZ + range); List<Entity> entityList = worldIn.getEntitiesWithinAABBExcludingEntity(playerIn, aabb); for (Entity entity : entityList){ if (entity instanceof EntityLiving){ rebukeEntityFromPlayer((EntityLiving) entity, playerIn); } } return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand); } private void rebukeEntityFromPlayer(EntityLiving entity, EntityPlayer player){ //Creates xy plane with player at center by getting the directional distance between the coords of the entity and the player double adjX = entity.posX - player.posX; double adjZ = entity.posZ - player.posZ; //Creates a triangle to describe the distance between the entity and player double startSideA = adjX; double startSideB = adjZ; double startHyp = Math.sqrt((Math.pow(startSideA, 2) + Math.pow(startSideB, 2))); //Scales the triangle to get the point the entity should be pushed to double scaleFactor = range/startHyp; if(scaleFactor <= 1){return;}//stops spell if entity is already out of target area. double scaledSideA = startSideA*scaleFactor; double scaledSideB = startSideB*scaleFactor; double desiredPosX = adjX + (scaledSideA - startSideA); double desiredPosZ = adjZ + (scaledSideB - startSideB); if(Math.abs(adjX) < Math.abs(desiredPosX)){ if(desiredPosX >= 0){ entity.motionX = 3; } else if(desiredPosX < 0){ entity.motionX = -3; } } if(Math.abs(adjZ) < Math.abs(desiredPosZ)){ if(desiredPosZ >= 0){ entity.motionZ = 3; } else if(desiredPosZ < 0){ entity.motionZ = -3; } } } Additionally, here are some images to help convey my problem: Ideal Scenario, Current scenario
-
[1.10] How to give a GuiScreen player capability data
I would think I could do this with a packet, but the task added with addScheduledTask doesn't run until after the gui is created(and the game crashes before this can happen). I'd imagine that it could be used with GuiHandler.getServerGuiElement, but I don't know how.
-
[1.12.2] [SOLVED] Getting the ItemStack stackSize?
To help in future cases: When Obj::field stops working, it's usually because the field has been encapsulated and can only be accessed/changed with accessor/mutator(getter/setter) functions. That is, it typically becomes either Obj::getField/Obj::setField, or something similar if the field name changes(if you're using an IDE, you'll typically find it in the lookup). If you're still having trouble, you can usually find it by skimming the source files(some IDEs allow you to jump to a referenced class if you highlight it and right-click/use a keybind).
-
[1.8] Disable sleep
In the PlayerSleepInBed event, there is a public field(for 1.8) result, an EnumStatus(which is used to determine whether or not a player can sleep). You can cancel sleep with an event like this: Note: In later versions, the result field is private with the setter setResult. Keep this in mind if you plan to upgrade.
-
[1.8] Cannot change ExtendedPlayer fields.
I'm trying to add mana values for players, but I can't seem to change them. I have an item that should change the max value for mana when I right click it, but it doesn't seem to work; I have println's for debugging and they keep displaying that my max mana is 0. ExtendedPlayer code: ItemModSword(contains the code for the item mentioned above):
IPS spam blocked by CleanTalk.