Jump to content

Recommended Posts

Posted

I solved my issue with "CommonTickHandler" big thanks to guy, who help me... Current issue with thePlayer.motionY(it's not working or i do something wrong)

My code

//thePlayer - instance of EntityPlayerMP
thePlayer.capabilities.allowFlying = true;
thePlayer.motionY *= 3.0; // Only for test
thePlayer.capabilities.isFlying = true;
thePlayer.fallDistance = 0;  

Player motionY doent's changed, but fallDistance work...

P.S. Sorry for bad english...

Posted

I tried "System.out.println(thePlayer.motionY)" it's print "-0.078.....". Also if i run across world nothing changed motionY ignored...

P.S. Changed motionY *= 3.0 to motionY += 3.0. Nothing changed...

Current code:

        thePlayer.capabilities.allowFlying = true;
thePlayer.capabilities.isFlying = true;
thePlayer.motionY += 3.0; // Only for test
thePlayer.fallDistance = 0;  

Posted

TickHandler(server)

package (mod package);

import java.util.EnumSet;
import java.util.ArrayList;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.network.packet.Packet3Chat; // Will removed
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.server.FMLServerHandler;
import (mod package).*;

public class TickHandler implements ITickHandler 
{		
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) 
{
if(type.equals(EnumSet.of(TickType.PLAYER)))
{
ArrayList players = (ArrayList) MinecraftServer.getServer().getConfigurationManager().playerEntityList; // Wlll replace with FMLServerHandler
Iterator parray = players.iterator();
// Players armor check!
while(parray.hasNext()) {
    EntityPlayerMP thePlayer = (EntityPlayerMP) parray.next();	
ItemStack helmet = thePlayer.inventory.armorItemInSlot(3);
ItemStack body = thePlayer.inventory.armorItemInSlot(2);
ItemStack legs = thePlayer.inventory.armorItemInSlot(1);
ItemStack boots = thePlayer.inventory.armorItemInSlot(0);
if(helmet != null) {
// do something...
}

if(body != null) {
// do something...
}

if(legs != null) {
// do something...
}

if(boots != null) {
if(boots.itemID == (main mod class).bootsPremium.shiftedIndex) {
System.out.println("Player has boots");
    thePlayer.capabilities.allowFlying = true;
thePlayer.capabilities.isFlying = true;
thePlayer.motionY = 10.0; // Only for test
thePlayer.fallDistance = 0;  
//System.out.println(thePlayer.motionY);
}
}

}
}
// End Players armor check!
}

@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) 
{

}

@Override
public EnumSet<TickType> ticks() 
{
	return EnumSet.of(TickType.PLAYER);
}

@Override
public String getLabel() 
{
	return null;
}

}

Also in main mod class

TickRegistry.registerTickHandler(new TickHandler(), Side.SERVER);

Posted

I'm guessing this is in a tick handler, i'm having the same problem, it will update the velocity if the player takes damage it seems, so it could be that the velocity isn't updated through this method without something else happening to the player. Not sure how to do this

 

 

Here is the tick handler as i have it (i'm guessing his is similar)

 

  Reveal hidden contents

 

 

[edit]

whoops looks like he updated the thread whilst i was typing this

Posted
  On 2/12/2013 at 6:03 PM, Yagoki said:

I'm guessing this is in a tick handler, i'm having the same problem, it will update the velocity if the player takes damage it seems, so it could be that the velocity isn't updated through this method without something else happening to the player. Not sure how to do this

 

 

Here is the tick handler as i have it (i'm guessing his is similar)

 

  Reveal hidden contents

 

 

[edit]

whoops looks like he updated the thread whilst i was typing this

I think this ticker dont work on server side because:

 @Override
public EnumSet<TickType> ticks()
{
  return EnumSet.of(TickType.PLAYER, TickType.CLIENT);
}

Posted

i've tried with both, it seems to work the same both way, it's just i didn't bother changing it before posting as i was changing it to see whether it was the tick type that was the problem

[edit]

i just realised what you meant, yeah that's probably true, not got a way to try it though

Posted

just found something else that's odd.

I told it to print the motionY before and after setting it to 1. oddly the speed it was saying before was not equal to 0 whilst standing still, instead it was a bit lower than what i was setting it to. (told it to set it to 1, and it said the initial velocity was 0.907....    told it to set it to 2 and it said it started at 1.8.....) this is odd and may shine some light on our problem.

 

[EDIT]

after my player.motionY=2, it seems that it is normally at -0.0784000015258789 whilst stationary. guess this is gravity or something

Posted

Just had the brilliant idea of scrolling through github to see if there were any open source mods which had done this.

Looking in the source for MachineMuse modular power suits (Epic mod, try it out) In the tick data they only specified TickType.PLAYER. not player and server. not tried it yet, and it may be a while before i can, but give this a go and see what you can do (tell me what you manage so i know if it works when i get round to doing this)

 

I'll post a link to the source so you can look yourself and see what you think

https://github.com/MachineMuse/MachineMusePowersuits/blob/master/src/minecraft/net/machinemuse/powersuits/tick/PlayerTickHandler.java

Posted

I GOT IT WORKING!!!!!!!!!!

just had to register it in the client proxy aswell :)

 

the code is now just the same (player.motionY += number in tick handler) with it regesterd as

TickRegistry.registerTickHandler(new TickHandler(), Side.SERVER);

in common proxy and

TickRegistry.registerTickHandler(new AAPlayerTickHandler(), Side.CLIENT);

in the client proxy :)

YAY IT WORKS

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You will find the crash-report or log in your minecraft directory (crash-report or logs folder)
    • Use a modpack which is using these 2 mods as working base:   https://www.curseforge.com/minecraft/modpacks/life-in-the-village-3
    • inicie un mundo donde instale Croptopia y Farmer's Delight, entonces instale el addon Croptopia Delight pero no funciona. es la version 1.18.2
    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.