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

Player rotation pitch and yaw


Asweez
 Share

Recommended Posts

Ok so I know how to get the player's pitch and yaw, but the world can't be remote (!world.isRemote). However, I want to use the players rotation to add velocity, but the player.addVelocity method won't work when the world isn't remote. How would I do this?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

If you absolutely positively can't do it on the server, then you need packets.  Game set match.

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

Ok so I have my packets set up but where would I put the player.addVelocity? Would it be in the handler? And where would the player's rotation amounts be inserted? Would they be a parameter for the packet or calculated during message handling?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

You can also change the player's motionX/Y/Z fields directly on the server, but it is usually better to handle player motion on the client.

 

Correction:

You want to do it on both.

 

If you do it client-side-only then the server will go "hey buddy, you're over here" and rubber band you back.

If you do it server-side-only the client will lag-behind and you'll rubber band the other way.

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

You can also change the player's motionX/Y/Z fields directly on the server, but it is usually better to handle player motion on the client.

 

Correction:

You want to do it on both.

 

If you do it client-side-only then the server will go "hey buddy, you're over here" and rubber band you back.

If you do it server-side-only the client will lag-behind and you'll rubber band the other way.

The rubber-band effect typically happens if you use setPosition type methods on the client, but changing motion actually works just fine. You can still get an 'illegal stance' warning if player's total motion is too high, though, whether or not you set it on the server, the client, or both.

 

Generally it is better to do things on both sides if possible, but in this case I don't think it really matters that much since the client is sending motion updates to the server anyway (see EntityClientPlayerMP#sendMotionUpdates).

Link to comment
Share on other sites

Ya:

 

PacketHandler

 

package 
;

import com.apmods.accupack.AccuPack;

import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;

public class AccuNetwork {
public static SimpleNetworkWrapper network ;
public static void init(){
	network = NetworkRegistry.INSTANCE.newSimpleChannel(AccuPack.MODID);
	registerPackets();
}
public static void registerPackets(){
	network.registerMessage(JetpackFlyPacket.class, JetpackFlyPacket.JetpackFlyMessage.class, 0, Side.SERVER);
	network.registerMessage(JetpackFlyPacket.class, JetpackFlyPacket.JetpackFlyMessage.class, 0, Side.CLIENT);
}
}

 

 

JetpackFlyPacket:

 

 

package com.apmods.accupack.network;

import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

import com.apmods.accupack.network.JetpackFlyPacket.JetpackFlyMessage;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;

public class JetpackFlyPacket implements IMessageHandler<JetpackFlyMessage, IMessage>{

@Override
public IMessage onMessage(JetpackFlyMessage message, MessageContext ctx) {

	return null;
}
public class JetpackFlyMessage implements IMessage{

	public JetpackFlyMessage(){

	}
	@Override
	public void fromBytes(ByteBuf buf) {


	}

	@Override
	public void toBytes(ByteBuf buf) {


	}

}

}

(empty as of now)

 

KeyHandler:

 

 

package com.apmods.accupack;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;

import com.apmods.accupack.network.AccuNetwork;
import com.apmods.accupack.network.JetpackFlyPacket;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;

public class KeyHandler {
@SubscribeEvent
public void keyInput(KeyInputEvent event){
	Minecraft mc = Minecraft.getMinecraft();
	if(KeyBindings.jetpackFly.isPressed()){
		if(mc.inGameHasFocus){
			AccuNetwork.network.sendToServer(new JetpackFlyPacket.JetpackFlyMessage());
			//Error above "No enclosing instance of type JetpackFlyPacket is accessible. 
			// Cont. Must qualify the allocation with an enclosing instance of type JetpackFlyPacket 
			// Cont. (e.g. x.new A() where x is an instance of JetpackFlyPacket)."
		}
	}
}
}

 

 

KeyBindings:

 

package com.apmods.accupack;

import org.lwjgl.input.Keyboard;

import net.minecraft.client.settings.KeyBinding;

public class KeyBindings {
public static final KeyBinding jetpackFly = new KeyBinding("AccuPack Fly Key", Keyboard.KEY_SPACE, "key.categories.accupack");
}

 

 

Init method:

 

@EventHandler
    public void preInit(FMLPreInitializationEvent event){
    	proxy.preInit();
    	AccuNetwork.init();
    }
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	proxy.init();
    	
    }

(edited for the important parts)

 

Tell me if you need anything else

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

So what exactly is it you are wanting to do, fly? KeyInputEvent fires once when a key is pressed and once when it is released, but not at all in between, so you'll need to set some variable somewhere like 'isBoosting' then add player.motionY += 0.15D or whatever each tick if it's true. You could of course just check if the key is still pressed using the keybinding instance, but that is client side only.

Link to comment
Share on other sites

  • 3 years later...
On 31. 12. 2014 at 7:07 PM, Asweez said:

Why do they change the names?

Most likely to make development more user friendly. I believe the original names func_xxx are a result of decompilation, and the new names are user friendly aliases for them. 

Edited by DeadPix
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hi, So as the title says it seems im the only one with this issue, it was working fine yesterday. basically the server just keeps saying Pinging.... and doesn't load, i added a vanilla server to see if all servers would behave the same but no, my modded server was the only one. i asked some of my friends to try connecting and no problem so it seems on my end. I tried connecting even when it says pinging and it just stuck on Encrypting and then timed out Client log https://gist.github.com/thekingtoonboy/1c53875b856e0563b9313a8cc060a4a0.js latest Server log [19Sep2021 06:06:35.440] [Netty Epoll Server IO #2/INFO] [codechicken.lib.config.ConfigSyncManager/]: Skipping config sync, No mods have registered a syncable config. [19Sep2021 06:06:35.529] [Netty Epoll Server IO #2/WARN] [com.connectivity.Connectivity/]: Login payload for Registry minecraft:item is using 111.6286% of max allowed size and will cause errors during login if connectivity is not present on client side. [19Sep2021 06:06:35.543] [Netty Epoll Server IO #2/WARN] [com.connectivity.Connectivity/]: Login payload for Registry minecraft:block is using 87.6082% of max allowed size [19Sep2021 06:06:37.491] [User Authenticator #1/INFO] [net.minecraft.network.login.ServerLoginNetHandler/]: UUID of player KiingSultan is e69dbe58-dd8d-4d26-9317-a643a0ffde12 [19Sep2021 06:08:37.721] [Server thread/INFO] [net.minecraft.network.login.ServerLoginNetHandler/]: com.mojang.authlib.GameProfile@1b416c43[id=e69dbe58-dd8d-4d26-9317-a643a0ffde12,name=KiingSultan,properties={textures=[com.mojang.authlib.properties.Property@38939441]},legacy=false] (/5.193.109.22:50035) lost connection: Timed out [19Sep2021 06:13:10.808] [Netty Epoll Server IO #0/INFO] [codechicken.lib.config.ConfigSyncManager/]: Skipping config sync, No mods have registered a syncable config. [19Sep2021 06:13:10.867] [Netty Epoll Server IO #0/WARN] [com.connectivity.Connectivity/]: Login payload for Registry minecraft:item is using 111.6286% of max allowed size and will cause errors during login if connectivity is not present on client side. [19Sep2021 06:13:10.880] [Netty Epoll Server IO #0/WARN] [com.connectivity.Connectivity/]: Login payload for Registry minecraft:block is using 87.6082% of max allowed size [19Sep2021 06:13:18.792] [User Authenticator #2/INFO] [net.minecraft.network.login.ServerLoginNetHandler/]: UUID of player KiingSultan is e69dbe58-dd8d-4d26-9317-a643a0ffde12 [19Sep2021 06:15:19.013] [Server thread/INFO] [net.minecraft.network.login.ServerLoginNetHandler/]: com.mojang.authlib.GameProfile@28a892fa[id=e69dbe58-dd8d-4d26-9317-a643a0ffde12,name=KiingSultan,properties={textures=[com.mojang.authlib.properties.Property@53a47b26]},legacy=false] (/5.193.109.22:50239) lost connection: Timed out Thanks in advance.
    • This isn't something we can fix (or even work around) without someone on the Dev team having an M1 Mac. For context, this is not a Forge issue, Apple being Apple they decided M1's didn't need backwards compatiblity with their old graphics API when they made the new one and the update to GLFW to accomodate the change hasn't made its way through LWJGL as of this writing
    • Hello. I am trying to add custom ores. Everything seems to be called and executed (when print statements are added), but nothing changes in game. I had it working in 1.16, but not in 1.17. I changed some of it to work with the new forge version, and it compiles without errors, but nothing changes in game. Any help figuring this out is appreciated.   Code: @Mod.EventBusSubscriber public class OreGeneration { public static ImmutableList<TargetBlockState> ORE_TARGET_LIST; public static final ArrayList<ConfiguredFeature<?, ?>> overworldOres = new ArrayList<ConfiguredFeature<?, ?>>(); public static void registerOres(){ ORE_TARGET_LIST = ImmutableList.of(OreConfiguration.target(Predicates.NATURAL_STONE, Blocks.STONE.defaultBlockState())); overworldOres.add(register("tin_ore_block", Feature.ORE.configured(new OreConfiguration(ORE_TARGET_LIST, 5)) .rangeUniform(VerticalAnchor.absolute(0), VerticalAnchor.absolute(48)) .squared() .count(20) )); } private static <FC extends FeatureConfiguration> ConfiguredFeature<FC, ?> register(String name, ConfiguredFeature<FC, ?> configuredFeature) { return Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(Extras.MODID, name), configuredFeature); } @SubscribeEvent(priority = EventPriority.HIGHEST) public static void registerBiomeModification(BiomeLoadingEvent event) { BiomeGenerationSettingsBuilder generation = event.getGeneration(); for(ConfiguredFeature<?, ?> ore : overworldOres){ if (ore != null) { generation.getFeatures(Decoration.UNDERGROUND_ORES).add(() -> { return ore; }); } } } }
    • you haven't, you still store the ModEventBus in a static Field and you register the Renderer of your Entity in FMLCommonSetupEvent and not in FMLClientSetupEvent Edit: you still use static initializer for your EntityTypes, I would recommend you to look again at the basics for the Registry System: FCW or the Forge doc
    • post debug log, if you use java 17 downgrade to java 16, since at the moment not supported by Forge
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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