Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Issue with direction values (1.16.5)


Recommended Posts

Hi, I'm making an item class that when releasing a right click it'll do a "slam attack". I had it working fine, but one big issue arose. The slam's distance is affected by the Y facing axis, so if the player is looking up or down the slam goes nowhere. I'm trying to find a method to where only the X and Z facing values are used, not the Y. I tried using the player's rotation, which did get rid of the Y issue, but lead to inaccurate slams. Any help is much appreciated!

 

Here's the "slam attack" code: https://pastebin.com/sh1LdNWZ

Edited by Babelincoln1809
Link to comment
Share on other sites

  • Babelincoln1809 changed the title to Issue with direction values (1.16.5)
Quote

Vector3d look = user.getLookAngle();

Gets the normalized vector from player's pitch and yaw, so a simple way would be change the pitch to the horizontal value (I think it is 0), get the angle, and then change it back. Otherwise just do some simple trig...

Link to comment
Share on other sites

18 hours ago, poopoodice said:

Gets the normalized vector from player's pitch and yaw, so a simple way would be change the pitch to the horizontal value (I think it is 0), get the angle, and then change it back. Otherwise just do some simple trig...

So far I have this, but only fires in one direction

Link to comment
Share on other sites

Quote

new Vector3d(x, z, y);

👀

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

No:
Why are you pushing the Z and Y values in the wrong order?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 hour ago, poopoodice said:

pitch = player.pitch

player.pitch = 0

vec = player.getLookVec

player.pitch = pitch 

Or, more sensibly:

vec = player.getLookVec
vec.y = 0

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 hour ago, Draco18s said:

Or, more sensibly:

vec = player.getLookVec
vec.y = 0

But if I understand it correctly, the getLookVec returns the normalized vec, means the value of y will affect the distance of x and z.

Link to comment
Share on other sites

13 hours ago, poopoodice said:

But if I understand it correctly, the getLookVec returns the normalized vec, means the value of y will affect the distance of x and z.

So... renormalize the vector...

https://www.khanacademy.org/computing/computer-programming/programming-natural-simulations/programming-vectors/a/vector-magnitude-normalization

Edited by Draco18s
  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Nevermind, I was able to wrap my mind around https://forge.gemwire.uk/wiki/Capabilities#Accessing_a_Capability , and currently have it working!
    • So I'm nearly finished with a version of my mod and, although I haven't done mapping changes in awhile, I'm confident that I have the correct method name so that an instance of reflection runs properly. However, the new method name isn't recognized during load in the real environment (I'm aware it needs to be changed back to run in dev). I cross-referenced both the output.srg as well as a Discord bot and they tell me that: func_221052_a    in     PointOfInterestType.class       should be       registerBlockStates Attached is the relevant class and log file. Any help is appreciated. Loading Output Log Villager Util class:  
    • Hey, I have an issue where I can't run the Minecraft client on a fresh project. The steps I took to set it up are as follows: - Downloaded the Forge 1.12.2 MDK (version 14.23.5.2855) - Extracted the .zip file to a folder - With a command prompt console within that directory, I ran "gradlew genEclipseRuns" then once that successfully completed, "gradlew eclipse". - Opened that root folder as a Gradle project in Eclipse - Under Gradle Tasks I ran "runClient" then received the following error specifically for ":runClient":   org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk-11.0.11\bin\java.exe'' finished with non-zero exit value 1 at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:395) at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:37) at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:79) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:786) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:753) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101) at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46) at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:273) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:258) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.base/java.lang.Thread.run(Thread.java:834) I'd appreciate any help, and please don't think I'm lazy by asking this, I've honestly been looking for a solution for the past ~6 hours haha. Thanks!
    • Hello! I'm trying to create a capability that reads a player's CompoundTag, and extracts some custom mod data from it to assemble an object, along with being given one of those mod objects and writing it to a Player's nbt. I've hopefully created the capability correctly, but I'm not sure how to go about having a `Player` read/write this data during a world save, and how I can go about retrieving the data from a given `Player` object on world join (I know I'd need to subscribe to the event, but I have no idea what I'd do from there). Additionally, this code results in "Invalid player data" whenever I join a world, and I don't know what's in here causes that (EDIT: Figured out this was due to my own bad serialization code. Does this mean that the NBT is automatically loaded on world join and saved on world leave?). My full repository can be found here: https://github.com/hammy3502/elementalism , and the relevant code snippets are below:   Object with Custom Mod Data (PlayerProgressionData.java): public class PlayerProgressionData implements INBTSerializable<CompoundTag> { public static final String outerTag = "elementalism_data"; public ProgressionInfo.ElementType type; public ProgressionInfo.ElementType type2; public List<ProgressionInfo> powersUnlocked; public PlayerProgressionData() { this.type = ProgressionInfo.ElementType.NONE; this.type2 = ProgressionInfo.ElementType.NONE; this.powersUnlocked = new ArrayList<>(); } @Override public CompoundTag serializeNBT() { CompoundTag toRet = new CompoundTag(); CompoundTag data = new CompoundTag(); StringBuilder powersList = new StringBuilder(); for (int i = 0; i < powersUnlocked.size(); i++) { powersList.append(powersUnlocked.get(i).id); if (i != powersUnlocked.size() - 1) { powersList.append(","); } } data.putString("unlockedPowers", powersList.toString()); data.putString("element1", this.type.id); data.putString("element2", this.type2.id); toRet.put(outerTag, data); return toRet; } @Override public void deserializeNBT(CompoundTag nbt) { if (!nbt.contains(outerTag)) return; this.powersUnlocked.clear(); CompoundTag data = nbt.getCompound(outerTag); this.type = ProgressionInfo.ElementType.getElementById(data.getString("element1")); this.type2 = ProgressionInfo.ElementType.getElementById(data.getString("element2")); String[] powerIds = data.getString("unlockedPowers").split(","); for (String id : powerIds) { ProgressionInfo info = Objects.requireNonNull(ProgressionInfoInit.ALL_PROGRESSION_INFOS.get(id)); this.powersUnlocked.add(info); } } } Capability Registration (Elementalism.java): public void registerCapabilities(RegisterCapabilitiesEvent event) { event.register(PlayerProgressionData.class); }   Capability Attaching (CommonSubscriber.java): @SubscribeEvent public void attachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (!(event.getObject() instanceof Player)) return; PlayerProgressionData progressionData = new PlayerProgressionData(); LazyOptional<PlayerProgressionData> optionalProgressionData = LazyOptional.of(() -> progressionData); ICapabilityProvider provider = new ICapabilitySerializable<CompoundTag>() { @Override public CompoundTag serializeNBT() { return progressionData.serializeNBT(); } @Override public void deserializeNBT(CompoundTag nbt) { progressionData.deserializeNBT(nbt); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == DATA_STORAGE_CAPABILITY) { return optionalProgressionData.cast(); } return LazyOptional.empty(); } }; event.addCapability(new ResourceLocation(Elementalism.MOD_ID, "data_storage"), provider); event.addListener(optionalProgressionData::invalidate); }   Thank you so much for any help!
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.