That's why I need the code, as in the code that is not working. You probably just didn't cast the entity properly, as setHealth is not an Entity method, but an EntityLivingBase (and thus also EntityPlayer) method. Post your entire LivingDeath event code.
Ah, sorry. That was the problem.
Unfortunately I just noticed a bigger problem. When I exit the work and re-enter it, the values are messed up.
I'll post the code if you need it.
Problem: When the world reloads, it resets the value of my int to its default and I have it print a message so I know this for sure. Also, I have a block change this value and also print a message. Problem: the block acts as though the value never reset when the world was reloaded.
I had that figured out already , but I'm not sure how I would edit it so that it works. It's just the syncing to the client that is wrong, the server is working fine :/ Ideas?
Only ever load data on the server, and send a packet to the client if you need it to be synchronized - please look through the tutorial or better yet, the example mod on my Github, to see how loading and synchronization should work.
Unfortunately I just noticed a bigger problem. When I exit the work and re-enter it, the values are messed up.
I'll post the code if you need it.
Problem: When the world reloads, it resets the value of my int to its default and I have it print a message so I know this for sure. Also, I have a block change this value and also print a message. Problem: the block acts as though the value never reset when the world was reloaded.
The value is only 'reset' because it gets initialized during construction to your default value, but when the game loads from NBT, the correct value should be loaded - this is why your block is acting as though the value wasn't reset, it is using the server side value, and your print message is probably giving you the client side value which you didn't synchronize, so is using the default value instead.
If you want your value to reset every time, don't save / load it to NBT; if you want your value to persist, do the opposite; if you need your value on the client side, send a packet to the client each time your entity joins the world.
Hmm.. It doesn't give me an error anymore, so that's a + I guess..
Still doesn't sync and I can't seem to find differences in the code.
Probably because I'm blind, but hey
going to give you all code now, warning ( messy code :/ )
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
Very stupid question here but, you see, I am trying to test if the game is in full screen and, if so, change the position of the mana bar. But, it seems like all the methods are not working. Got any idea?
I have tried:
this.mc.isFullScreen()
this.mc.isFullScreen() == true
!this.mc.isFullScreen()
this.mc.gameSettings.fullscreen == true
!this.mc.gameSettings.fullscreen
this.mc.gameSettings.fullscreen
Still doesn't sync and I can't seem to find differences in the code.
You have TWO extended properties classes, but you only save/load/sync ONE of them; which one are you having trouble with? Btw, you've got 'render tick' code inside a PlayerTickEvent - that's not going to work very well, and if you're not careful, could crash your game (player tick runs on both sides).
Very stupid question here but, you see, I am trying to test if the game is in full screen and, if so, change the position of the mana bar. But, it seems like all the methods are not working. Got any idea?
I haven't ever needed to test for full screen before, as I've always kept the position in the same relative position whether the screen was full or windowed. Why, might I ask, do you want to change the position when full screen vs. windowed? Looking at your code, your x and y position are the same anyway in both cases... are you sure it didn't work?
There's no need to have that huge block of code twice, either:
// if (HappyCraftMod.manaBarSwitch)
// if (HappyCraftMod.manaBarSwitch == true)
// those are the same thing... booleans can be used directly without " == true" or " == false"
if (!mc.thePlayer.capabilities.isCreativeMode && HappyCraftMod.manaBarSwitch) {
int xPos, yPos; // not initialized yet, or you could initialize them to one or the other value (full or windowed)
if (mc.isFullScreen()) {
// x and y position for full screen
} else {
// x and y position for windowed mode
}
// all the gui rendering code, just once
}
You could even get fancy if, for example, your position calculations were somewhat intense and you didn't want to run them over and over again every single tick, you can calculate them once and store them in class variables, along with the current screen mode; then, each tick, check if the current screen mode is different from the last screen mode, and only then recalculate the positions. Not really necessary in this case, but it's something to keep in mind.
You have TWO extended properties classes, but you only save/load/sync ONE of them; which one are you having trouble with? Btw, you've got 'render tick' code inside a PlayerTickEvent - that's not going to work very well, and if you're not careful, could crash your game (player tick runs on both sides).
It's the ExtendedPlayerSkills etendedproperties class, the other one uses datawatcher (which I will probably change).
Also for the PlayerTickEvent, I dunno how it got there? lol and it doesn't seem to be enabled anyway
thanks for pointing that out as well
It's the ExtendedPlayerSkills etendedproperties class, the other one uses datawatcher (which I will probably change).
Did you register your SyncPlayerSkillsPacket in the PacketPipeline? It doesn't look like you did. The more precise you can be in describing the problem, the more I will be able to help you.
Did you register your SyncPlayerSkillsPacket in the PacketPipeline? It doesn't look like you did. The more precise you can be in describing the problem, the more I will be able to help you.
omg xD, that was the one thing I forgot to do when I copied the other one thank you!
I am blind sometimes :3
removing the git btw, don't want it to be open source yet :3
Anyway, I need the values on client to check them properly in a render file right?
Yes. You need to send a packet, as I've said previously several times. Please read the wiki tutorial on packets and see the examples I've provided; if you need further help, you are going to have to post some code.
The Meaning of Life, the Universe, and Everything.
Join Date:
12/4/2013
Posts:
45
Minecraft:
bluecube2
Member Details
Okay. Thanks. I'm sorry if I seem so inept, but as I said I'm really new to this.
Anyway, here's the code I'm having trouble with. Sorry for not posting this earlier.
My Extended Player:
package BlueCube.Mods.VoxelDoctor.Entity;
import org.lwjgl.opengl.GL11;
import BlueCube.Mods.VoxelDoctor.Main.Config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.IExtendedEntityProperties;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
public class ExtendedPlayer implements IExtendedEntityProperties
{
public final static String EXT_PROP_NAME = "ExtendedPlayer";
private final EntityPlayer player;
private int currentRegens, maxRegens;
public double playerX, playerY, playerZ;
private int currentDoctor;
public ExtendedPlayer(EntityPlayer player)
{
this.player = player;
this.currentRegens = maxRegens = 1;
this.currentDoctor = 0;
}
public static final void register(EntityPlayer player)
{
player.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer(player));
}
public static final ExtendedPlayer get(EntityPlayer player)
{
return (ExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME);
}
@Override
public void saveNBTData(NBTTagCompound compound)
{
NBTTagCompound properties = new NBTTagCompound();
properties.setInteger("CurrentDoctor", this.currentDoctor);
properties.setInteger("CurrentRegens", this.currentRegens);
properties.setInteger("MaxRegens", this.maxRegens);
properties.setDouble("PlayerX", this.playerX);
properties.setDouble("PlayerY", this.playerY);
properties.setDouble("PlayerZ", this.playerZ);
compound.setTag(EXT_PROP_NAME, properties);
}
@Override
public void loadNBTData(NBTTagCompound compound)
{
NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
this.currentDoctor = properties.getInteger("CurrentDoctor");
this.currentRegens = properties.getInteger("CurrentRegens");
this.maxRegens = properties.getInteger("MaxRegens");
this.playerX = properties.getDouble("PlayerX");
this.playerY = properties.getDouble("PlayerY");
this.playerZ = properties.getDouble("PlayerZ");
System.out.println("[Doctor] Current Regeneration: " + this.currentDoctor);
System.out.println("[Regens] Regen from NBT: " + this.currentRegens + "/" + this.maxRegens);
System.out.println("[ExitX] Exit Coord: x: " + this.playerX + "y: " + this.playerY + "z: " + this.playerZ);
}
@Override
public void init(Entity entity, World world)
{
}
public boolean useRegen(int amount)
{
boolean sufficient = amount <= this.currentRegens;
this.currentRegens -= (amount < this.currentRegens ? amount : this.currentRegens);
return sufficient;
}
public int getCurrentRegens()
{
return this.currentRegens;
}
public void replenishRegens()
{
this.currentRegens = this.maxRegens;
}
public int getCurrentDoctor()
{
return this.currentDoctor;
}
public void changeDoctor()
{
if(this.currentDoctor != 12)
{
this.currentDoctor += 1;
}
else
{
this.currentDoctor = 0;
}
}
}
The block that interacts with the value:
package BlueCube.Mods.VoxelDoctor.Blocks;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import BlueCube.Mods.VoxelDoctor.Entity.ExtendedPlayer;
import BlueCube.Mods.VoxelDoctor.Main.MainClass;
import BlueCube.Mods.VoxelDoctor.Teleporter.TeleporterOverworld;
import BlueCube.Mods.VoxelDoctor.Teleporter.TeleporterTardis;
import BlueCube.Mods.VoxelDoctor.TileEntities.TileEntityMiniTardis;
import BlueCube.Mods.VoxelDoctor.TileEntities.TileEntityTardisLampWhite;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockFence;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class BlockMiniTardis extends BlockContainer
{
public BlockMiniTardis(int par1)
{
super(par1, Material.iron);
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
}
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
ExtendedPlayer props = ExtendedPlayer.get(par5EntityPlayer);
ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem();
if(itemstack == null)
{
generateRandomParticles(par1World, par5EntityPlayer);
if(!par1World.isRemote)
{
if(props.getCurrentDoctor() == 0)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 1st Doctor.");
}
else if(props.getCurrentDoctor() == 1)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 2nd Doctor.");
}
else if(props.getCurrentDoctor() == 2)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 3rd Doctor.");
}
else if(props.getCurrentDoctor() == 3)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 4th Doctor.");
}
else if(props.getCurrentDoctor() == 4)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 5th Doctor.");
}
else if(props.getCurrentDoctor() == 5)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 6th Doctor.");
}
else if(props.getCurrentDoctor() == 6)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 7th Doctor.");
}
else if(props.getCurrentDoctor() == 7)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 8th Doctor.");
}
else if(props.getCurrentDoctor() == 8)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the War Doctor.");
}
else if(props.getCurrentDoctor() == 9)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 9th Doctor.");
}
else if(props.getCurrentDoctor() == 10)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 10th Doctor.");
}
else if(props.getCurrentDoctor() == 11)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 11th Doctor.");
}
else if(props.getCurrentDoctor() == 12)
{
System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor());
((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the yourself.");
}
}
props.changeDoctor();
}
return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
}
public int idPicked(World par1World, int par2, int par3, int par4)
{
return MainClass.AmyTardis.itemID;
}
public int idDropped(int par1, Random par2Random, int par3)
{
return MainClass.AmyTardis.itemID;
}
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
boolean flag = false;
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4)))
{
flag = true;
}
if (flag)
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockToAir(par2, par3, par4);
}
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileEntityMiniTardis();
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);
}
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon("planks_oak");
}
private void generateRandomParticles(World par1World, EntityPlayer par2EntityPlayer)
{
for (int i = 0; i < 60; ++i)
{
par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY, par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 2.22D, 2.22D, 0.0D);
par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY, par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 5.22D, 1.3D, 0.0D);
par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY, par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 2.22D, 2.22D, 0.5D);
par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY - (par1World.rand.nextDouble() - 0.5D), par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 2.22D, 2.22D, 0.0D);
par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY + (par1World.rand.nextDouble() - 0.5D), par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 5.22D, 1.3D, 0.0D);
par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY + (par1World.rand.nextDouble() - 0.5D), par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 2.22D, 2.22D, 0.5D);
}
}
}
Okay. Thanks. I'm sorry if I seem so inept, but as I said I'm really new to this.
Anyway, here's the code I'm having trouble with. Sorry for not posting this earlier.
~snip~
I've done reading up on packets so I'll try that out.
I suppose it could be worse...
public void renderFirstPersonArm(EntityPlayer par1EntityPlayer) {
// don't you have an EntityPlayer right ^^^^^ up there? no need for another one.
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
}
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
ExtendedPlayer props = ExtendedPlayer.get(par5EntityPlayer);
ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem();
Entity touch = par5EntityPlayer; // this is pretty absurd...
Your chained if/elses and some other things could definitely be more compact / efficient, but we'll stick with getting your data to the client; basically, once you figure out how to create and send a packet (see the wiki tutorial), you need to send one from the server to the client whenever the player joins the game (EntityJoinWorld event) and whenever your data changes in your changeDoctor() method. You only need to send a single integer in the packet - look at my mana packet as an example.
The Meaning of Life, the Universe, and Everything.
Join Date:
12/4/2013
Posts:
45
Minecraft:
bluecube2
Member Details
Ugh. Not sure why I had the those extra player methods.
The extra variable in the RenderPlayer (gosh that was supposed to be "prop" >.<) does noting as well...
Thanks for pointing those out and for going through my messy code.
I appreciate the help.
I am trying to make it so that my mana bar refills slowly as you hold a button but right now it just refills all the way instantly when I push the button. I was able to make it refill in small increments every time I tapped the button so I know there is nothing wrong with my ExtendedPlayer class. I tried to used a tick handler but I feel like I'm doing it wrong since it has no effect whatsoever. Here are the parts of my key handler and tick handler that I'm using:
@SideOnly(Side.CLIENT)
public class ClientTickHandler
{
private Minecraft mc;
public ClientTickHandler(Minecraft mc)
{
this.mc = mc;
}
@SubscribeEvent
public static void onChargeTick(ClientTickEvent event)
I am trying to make it so that my mana bar refills slowly as you hold a button but right now it just refills all the way instantly when I push the button. I was able to make it refill in small increments every time I tapped the button so I know there is nothing wrong with my ExtendedPlayer class. I tried to used a tick handler but I feel like I'm doing it wrong since it has no effect whatsoever. Here are the parts of my key handler and tick handler that I'm using:
@SideOnly(Side.CLIENT)
public class ClientTickHandler
{
private Minecraft mc;
public ClientTickHandler(Minecraft mc)
{
this.mc = mc;
}
@SubscribeEvent
public static void onChargeTick(ClientTickEvent event)
1. "new ClientTickEvent(Phase.START)"
Never do that, unless of course you are posting an event, which you are not.
2. Technically you don't even need a key handler for this, but registering a key binding will allow your players to customize the key. That's all you need to do though - no KeyInputEvent is necessary. You can check in your tick handler if the key is down:
// in the client tick:
if (keys[CHARGE_KI].getKeyIsPressed()) {
// send recharge packet
}
3. ExtendedPlayer.replenishKi(ExtendedPlayer.getMaxKi() / 100);
Where is your player variable here? How can you replenish ki when you don't have a player? You are on the client side, so you can use mc.thePlayer -> ExtendedPlayer.get(mc.thePlayer) should return the extended properties for the current player.
4. You are on the client side, so you need to send a packet to the server telling the server that the key is pressed and ki should be regenerating - don't replenish it on the client.
I think I've got most of it figured out but I can't get keys[CHARGE_KI] to work in my tick handler. Thanks for the help.
You need to make your "KeyBinding[] keys" field public or create a getter method for it so you can access it outside of its class. For key bindings, I make mine public, static, and final.
Well I'm back again. My keys are definitely working but for some reason my tick handler isn't running. I put two lines of debugging code in my ClientTickHandler and neither of them showed up. Here is my tick handler with the debugging lines and my client proxy.
@SideOnly
(Side.CLIENT)
public class ClientTickHandler
{
private Minecraft mc;
public ClientTickHandler(Minecraft mc)
{
this.mc = mc;
System.out.println("ClientTick is working.");
}
@SubscribeEvent
public void onChargeTick(ClientTickEvent event)
{
System.out.println("ChargeTick is working.");
if (Keyboard.getEventKey() == MCZKeyHandler.keys[MCZKeyHandler.CHARGE_KI].getKeyCode())
Well I'm back again. My keys are definitely working but for some reason my tick handler isn't running. I put two lines of debugging code in my ClientTickHandler and neither of them showed up. Here is my tick handler with the debugging lines and my client proxy.
In your main class, do you call "proxy.initialize()" ?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Ah, sorry. That was the problem.
Unfortunately I just noticed a bigger problem. When I exit the work and re-enter it, the values are messed up.
I'll post the code if you need it.
Problem: When the world reloads, it resets the value of my int to its default and I have it print a message so I know this for sure. Also, I have a block change this value and also print a message. Problem: the block acts as though the value never reset when the world was reloaded.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumOnly ever load data on the server, and send a packet to the client if you need it to be synchronized - please look through the tutorial or better yet, the example mod on my Github, to see how loading and synchronization should work.
The value is only 'reset' because it gets initialized during construction to your default value, but when the game loads from NBT, the correct value should be loaded - this is why your block is acting as though the value wasn't reset, it is using the server side value, and your print message is probably giving you the client side value which you didn't synchronize, so is using the default value instead.
If you want your value to reset every time, don't save / load it to NBT; if you want your value to persist, do the opposite; if you need your value on the client side, send a packet to the client each time your entity joins the world.
Still doesn't sync and I can't seem to find differences in the code.
Probably because I'm blind, but hey
going to give you all code now, warning ( messy code :/ )
https://github.com/xulufworld/derp
if you've got time of course
Art by me: [email protected]
I have tried:
this.mc.isFullScreen()
this.mc.isFullScreen() == true
!this.mc.isFullScreen()
this.mc.gameSettings.fullscreen == true
!this.mc.gameSettings.fullscreen
this.mc.gameSettings.fullscreen
if(!this.mc.thePlayer.capabilities.isCreativeMode && HappyCraftMod.manaBarSwitch == true && !this.mc.isFullScreen()) { int xPos = (event.resolution.getScaledWidth() + 56) / 2 + 5; int yPos = (event.resolution.getScaledHeight() + 9) / 2 + 67; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); this.mc.getTextureManager().bindTexture(texturepath); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_ALPHA_TEST); drawTexturedModalRect(xPos, yPos, 0, 0, 56, 9); int manabarwidth = (int)(((float) props.getCurrentMana() / props.getMaxMana()) * 49); drawTexturedModalRect(xPos + 3, yPos + 3, 0, 9, manabarwidth, 3); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); }else if(!this.mc.thePlayer.capabilities.isCreativeMode && HappyCraftMod.manaBarSwitch == true && this.mc.isFullScreen()) { int xPos = (event.resolution.getScaledWidth() + 56) / 2 + 5; int yPos = (event.resolution.getScaledHeight() + 9) / 2 + 67; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); this.mc.getTextureManager().bindTexture(texturepath); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_ALPHA_TEST); drawTexturedModalRect(xPos, yPos, 0, 0, 56, 9); int manabarwidth = (int)(((float) props.getCurrentMana() / props.getMaxMana()) * 49); drawTexturedModalRect(xPos + 3, yPos + 3, 0, 9, manabarwidth, 3); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); }else { return; }I would love any suggestions you got.
I have this value checked in a render file so it needs to be client.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYou have TWO extended properties classes, but you only save/load/sync ONE of them; which one are you having trouble with? Btw, you've got 'render tick' code inside a PlayerTickEvent - that's not going to work very well, and if you're not careful, could crash your game (player tick runs on both sides).
I haven't ever needed to test for full screen before, as I've always kept the position in the same relative position whether the screen was full or windowed. Why, might I ask, do you want to change the position when full screen vs. windowed? Looking at your code, your x and y position are the same anyway in both cases... are you sure it didn't work?
There's no need to have that huge block of code twice, either:
// if (HappyCraftMod.manaBarSwitch) // if (HappyCraftMod.manaBarSwitch == true) // those are the same thing... booleans can be used directly without " == true" or " == false" if (!mc.thePlayer.capabilities.isCreativeMode && HappyCraftMod.manaBarSwitch) { int xPos, yPos; // not initialized yet, or you could initialize them to one or the other value (full or windowed) if (mc.isFullScreen()) { // x and y position for full screen } else { // x and y position for windowed mode } // all the gui rendering code, just once }You could even get fancy if, for example, your position calculations were somewhat intense and you didn't want to run them over and over again every single tick, you can calculate them once and store them in class variables, along with the current screen mode; then, each tick, check if the current screen mode is different from the last screen mode, and only then recalculate the positions. Not really necessary in this case, but it's something to keep in mind.
No, I'm saying if you need the value on the client side, you need to send packets.
Grammar tip: "your" is possessive, along with "my", etc. "my saying" - I don't have a saying... "you're" would be correct here: "you are saying..."
It's the ExtendedPlayerSkills etendedproperties class, the other one uses datawatcher (which I will probably change).
Also for the PlayerTickEvent, I dunno how it got there? lol and it doesn't seem to be enabled anyway
thanks for pointing that out as well
Art by me: [email protected]
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumDid you register your SyncPlayerSkillsPacket in the PacketPipeline? It doesn't look like you did. The more precise you can be in describing the problem, the more I will be able to help you.
omg xD, that was the one thing I forgot to do when I copied the other one
I am blind sometimes :3
removing the git btw, don't want it to be open source yet :3
Art by me: [email protected]
Anyway, I need the values on client to check them properly in a render file right?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumIt's an easy step to miss, and thankfully just as easy to remedy
Yes. You need to send a packet, as I've said previously several times. Please read the wiki tutorial on packets and see the examples I've provided; if you need further help, you are going to have to post some code.
Anyway, here's the code I'm having trouble with. Sorry for not posting this earlier.
My Extended Player:
package BlueCube.Mods.VoxelDoctor.Entity; import org.lwjgl.opengl.GL11; import BlueCube.Mods.VoxelDoctor.Main.Config; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.common.IExtendedEntityProperties; import net.minecraftforge.event.entity.living.LivingDeathEvent; public class ExtendedPlayer implements IExtendedEntityProperties { public final static String EXT_PROP_NAME = "ExtendedPlayer"; private final EntityPlayer player; private int currentRegens, maxRegens; public double playerX, playerY, playerZ; private int currentDoctor; public ExtendedPlayer(EntityPlayer player) { this.player = player; this.currentRegens = maxRegens = 1; this.currentDoctor = 0; } public static final void register(EntityPlayer player) { player.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer(player)); } public static final ExtendedPlayer get(EntityPlayer player) { return (ExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME); } @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); properties.setInteger("CurrentDoctor", this.currentDoctor); properties.setInteger("CurrentRegens", this.currentRegens); properties.setInteger("MaxRegens", this.maxRegens); properties.setDouble("PlayerX", this.playerX); properties.setDouble("PlayerY", this.playerY); properties.setDouble("PlayerZ", this.playerZ); compound.setTag(EXT_PROP_NAME, properties); } @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); this.currentDoctor = properties.getInteger("CurrentDoctor"); this.currentRegens = properties.getInteger("CurrentRegens"); this.maxRegens = properties.getInteger("MaxRegens"); this.playerX = properties.getDouble("PlayerX"); this.playerY = properties.getDouble("PlayerY"); this.playerZ = properties.getDouble("PlayerZ"); System.out.println("[Doctor] Current Regeneration: " + this.currentDoctor); System.out.println("[Regens] Regen from NBT: " + this.currentRegens + "/" + this.maxRegens); System.out.println("[ExitX] Exit Coord: x: " + this.playerX + "y: " + this.playerY + "z: " + this.playerZ); } @Override public void init(Entity entity, World world) { } public boolean useRegen(int amount) { boolean sufficient = amount <= this.currentRegens; this.currentRegens -= (amount < this.currentRegens ? amount : this.currentRegens); return sufficient; } public int getCurrentRegens() { return this.currentRegens; } public void replenishRegens() { this.currentRegens = this.maxRegens; } public int getCurrentDoctor() { return this.currentDoctor; } public void changeDoctor() { if(this.currentDoctor != 12) { this.currentDoctor += 1; } else { this.currentDoctor = 0; } } }The block that interacts with the value:
package BlueCube.Mods.VoxelDoctor.Blocks; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import BlueCube.Mods.VoxelDoctor.Entity.ExtendedPlayer; import BlueCube.Mods.VoxelDoctor.Main.MainClass; import BlueCube.Mods.VoxelDoctor.Teleporter.TeleporterOverworld; import BlueCube.Mods.VoxelDoctor.Teleporter.TeleporterTardis; import BlueCube.Mods.VoxelDoctor.TileEntities.TileEntityMiniTardis; import BlueCube.Mods.VoxelDoctor.TileEntities.TileEntityTardisLampWhite; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockFence; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; public class BlockMiniTardis extends BlockContainer { public BlockMiniTardis(int par1) { super(par1, Material.iron); this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F); } public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { ExtendedPlayer props = ExtendedPlayer.get(par5EntityPlayer); ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem(); if(itemstack == null) { generateRandomParticles(par1World, par5EntityPlayer); if(!par1World.isRemote) { if(props.getCurrentDoctor() == 0) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 1st Doctor."); } else if(props.getCurrentDoctor() == 1) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 2nd Doctor."); } else if(props.getCurrentDoctor() == 2) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 3rd Doctor."); } else if(props.getCurrentDoctor() == 3) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 4th Doctor."); } else if(props.getCurrentDoctor() == 4) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 5th Doctor."); } else if(props.getCurrentDoctor() == 5) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 6th Doctor."); } else if(props.getCurrentDoctor() == 6) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 7th Doctor."); } else if(props.getCurrentDoctor() == 7) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 8th Doctor."); } else if(props.getCurrentDoctor() == 8) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the War Doctor."); } else if(props.getCurrentDoctor() == 9) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 9th Doctor."); } else if(props.getCurrentDoctor() == 10) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 10th Doctor."); } else if(props.getCurrentDoctor() == 11) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the 11th Doctor."); } else if(props.getCurrentDoctor() == 12) { System.out.println("[Doctor] Current Regeneration: " + props.getCurrentDoctor()); ((EntityPlayer) touch).addChatMessage("\u00a76You regenerate into the yourself."); } } props.changeDoctor(); } return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9); } public int idPicked(World par1World, int par2, int par3, int par4) { return MainClass.AmyTardis.itemID; } public int idDropped(int par1, Random par2Random, int par3) { return MainClass.AmyTardis.itemID; } public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { boolean flag = false; if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4))) { flag = true; } if (flag) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); } } @Override public int getRenderType() { return -1; } @Override public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityMiniTardis(); } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2); } public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("planks_oak"); } private void generateRandomParticles(World par1World, EntityPlayer par2EntityPlayer) { for (int i = 0; i < 60; ++i) { par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY, par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 2.22D, 2.22D, 0.0D); par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY, par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 5.22D, 1.3D, 0.0D); par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY, par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 2.22D, 2.22D, 0.5D); par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY - (par1World.rand.nextDouble() - 0.5D), par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 2.22D, 2.22D, 0.0D); par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY + (par1World.rand.nextDouble() - 0.5D), par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 5.22D, 1.3D, 0.0D); par1World.spawnParticle("reddust", par2EntityPlayer.posX + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, par2EntityPlayer.posY + (par1World.rand.nextDouble() - 0.5D), par2EntityPlayer.posZ + (par1World.rand.nextDouble() - 0.5D) * par2EntityPlayer.width, 2.22D, 2.22D, 0.5D); } } }And my Extended Render Player:
package BlueCube.Mods.VoxelDoctor.Render.Player; import org.lwjgl.opengl.GL11; import BlueCube.Mods.VoxelDoctor.Entity.ExtendedPlayer; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; public class RenderNewPlayer extends RenderPlayer { private boolean prop = false; private static final ResourceLocation firstDoctor = new ResourceLocation("doctors/tex_doctor_one.png"); private static final ResourceLocation secondDoctor = new ResourceLocation("doctors/tex_doctor_two.png"); private static final ResourceLocation thirdDoctor = new ResourceLocation("doctors/tex_doctor_three.png"); private static final ResourceLocation fourthDoctor = new ResourceLocation("doctors/tex_doctor_four.png"); private static final ResourceLocation fifthDoctor = new ResourceLocation("doctors/tex_doctor_five.png"); private static final ResourceLocation sixthDoctor = new ResourceLocation("doctors/tex_doctor_six.png"); private static final ResourceLocation seventhDoctor = new ResourceLocation("doctors/tex_doctor_seven.png"); private static final ResourceLocation eighthDoctor = new ResourceLocation("doctors/tex_doctor_eight.png"); private static final ResourceLocation warDoctor = new ResourceLocation("doctors/tex_doctor_war.png"); private static final ResourceLocation ninthDoctor = new ResourceLocation("doctors/tex_doctor_nine.png"); private static final ResourceLocation tenthDoctor = new ResourceLocation("doctors/tex_doctor_ten.png"); private static final ResourceLocation eleventhDoctor = new ResourceLocation("doctors/tex_doctor_eleven.png"); private ModelBiped modelBipedMain; private ModelBiped modelArmorChestplate; private ModelBiped modelArmor; public RenderNewPlayer() { this.modelBipedMain = (ModelBiped)this.mainModel; this.modelArmorChestplate = new ModelBiped(1.0F); this.modelArmor = new ModelBiped(0.5F); } protected ResourceLocation getEntityTexture(AbstractClientNewPlayer par1AbstractClientPlayer) { return par1AbstractClientPlayer.getLocationSkin(); } protected ResourceLocation defaultSkin(Entity entity) { return null; } protected ResourceLocation getEntityTexture(Entity par1Entity) { EntityPlayer player = Minecraft.getMinecraft.thePlayer(); ExtendedPlayer props = ExtendedPlayer.get(player); if(props.getCurrentDoctor() == 1) { return firstDoctor; } if(props.getCurrentDoctor() == 2) { return secondDoctor; } if(props.getCurrentDoctor() == 3) { return thirdDoctor; } if(props.getCurrentDoctor() == 4) { return fourthDoctor; } if(props.getCurrentDoctor() == 5) { return fifthDoctor; } if(props.getCurrentDoctor() == 6) { return sixthDoctor; } if(props.getCurrentDoctor() == 7) { return seventhDoctor; } if(props.getCurrentDoctor() == 8) { return eighthDoctor; } if(props.getCurrentDoctor() == 9) { return warDoctor; } if(props.getCurrentDoctor() == 10) { return ninthDoctor; } if(props.getCurrentDoctor() == 11) { return tenthDoctor; } if(props.getCurrentDoctor() == 12) { return eleventhDoctor; } return this.func_110817_a((AbstractClientPlayer)par1Entity); } public void renderFirstPersonArm(EntityPlayer par1EntityPlayer) { float f = 1.0F; GL11.glColor3f(f, f, f); this.modelBipedMain.onGround = 0.0F; this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); EntityPlayer player = Minecraft.getMinecraft().thePlayer; ExtendedPlayer props = ExtendedPlayer.get(player); if(props.getCurrentDoctor() == 1) { Minecraft.getMinecraft().getTextureManager().bindTexture(firstDoctor); } if(props.getCurrentDoctor() == 2) { Minecraft.getMinecraft().getTextureManager().bindTexture(secondDoctor); } if(props.getCurrentDoctor() == 3) { Minecraft.getMinecraft().getTextureManager().bindTexture(thirdDoctor); } if(props.getCurrentDoctor() == 4) { Minecraft.getMinecraft().getTextureManager().bindTexture(fourthDoctor); } if(props.getCurrentDoctor() == 5) { Minecraft.getMinecraft().getTextureManager().bindTexture(fifthDoctor); } if(props.getCurrentDoctor() == 6) { Minecraft.getMinecraft().getTextureManager().bindTexture(sixthDoctor); } if(props.getCurrentDoctor() == 7) { Minecraft.getMinecraft().getTextureManager().bindTexture(seventhDoctor); } if(props.getCurrentDoctor() == 8) { Minecraft.getMinecraft().getTextureManager().bindTexture(eighthDoctor); } if(props.getCurrentDoctor() == 9) { Minecraft.getMinecraft().getTextureManager().bindTexture(warDoctor); } if(props.getCurrentDoctor() == 10) { Minecraft.getMinecraft().getTextureManager().bindTexture(ninthDoctor); } if(props.getCurrentDoctor() == 11) { Minecraft.getMinecraft().getTextureManager().bindTexture(tenthDoctor); } if(props.getCurrentDoctor() == 12) { Minecraft.getMinecraft().getTextureManager().bindTexture(eleventhDoctor); } this.modelBipedMain.bipedRightArm.render(0.0625F); } }I've done reading up on packets so I'll try that out.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI suppose it could be worse...
public void renderFirstPersonArm(EntityPlayer par1EntityPlayer) { // don't you have an EntityPlayer right ^^^^^ up there? no need for another one. EntityPlayer player = Minecraft.getMinecraft().thePlayer; } public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { ExtendedPlayer props = ExtendedPlayer.get(par5EntityPlayer); ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem(); Entity touch = par5EntityPlayer; // this is pretty absurd...Your chained if/elses and some other things could definitely be more compact / efficient, but we'll stick with getting your data to the client; basically, once you figure out how to create and send a packet (see the wiki tutorial), you need to send one from the server to the client whenever the player joins the game (EntityJoinWorld event) and whenever your data changes in your changeDoctor() method. You only need to send a single integer in the packet - look at my mana packet as an example.
The extra variable in the RenderPlayer (gosh that was supposed to be "prop" >.<) does noting as well...
Thanks for pointing those out and for going through my messy code.
I appreciate the help.
@SideOnly(Side.CLIENT)
public class ClientTickHandler
{
private Minecraft mc;
public ClientTickHandler(Minecraft mc)
{
this.mc = mc;
}
@SubscribeEvent
public static void onChargeTick(ClientTickEvent event)
{
if (event.phase == Phase.START)
{
ExtendedPlayer.replenishKi(ExtendedPlayer.getMaxKi() / 100);
}
}
}
@SubscribeEvent
public void onKeyInput(KeyInputEvent event)
{
while (ExtendedPlayer.getCurrentKi() < ExtendedPlayer.getMaxKi())
{
int kb = Keyboard.getEventKey();
boolean isDown = Keyboard.getEventKeyState();
if ((isDown) && (kb == keys[CHARGE_KI].getKeyCode()))
{
ClientTickHandler.onChargeTick(new ClientTickEvent(Phase.START));
}
else
{
break;
}
}
}
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYikes xD
1. "new ClientTickEvent(Phase.START)"
Never do that, unless of course you are posting an event, which you are not.
2. Technically you don't even need a key handler for this, but registering a key binding will allow your players to customize the key. That's all you need to do though - no KeyInputEvent is necessary. You can check in your tick handler if the key is down:
// in the client tick: if (keys[CHARGE_KI].getKeyIsPressed()) { // send recharge packet }3. ExtendedPlayer.replenishKi(ExtendedPlayer.getMaxKi() / 100);
Where is your player variable here? How can you replenish ki when you don't have a player? You are on the client side, so you can use mc.thePlayer -> ExtendedPlayer.get(mc.thePlayer) should return the extended properties for the current player.
4. You are on the client side, so you need to send a packet to the server telling the server that the key is pressed and ki should be regenerating - don't replenish it on the client.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYou need to make your "KeyBinding[] keys" field public or create a getter method for it so you can access it outside of its class. For key bindings, I make mine public, static, and final.
@SideOnly
(Side.CLIENT)
public class ClientTickHandler
{
private Minecraft mc;
public ClientTickHandler(Minecraft mc)
{
this.mc = mc;
System.out.println("ClientTick is working.");
}
@SubscribeEvent
public void onChargeTick(ClientTickEvent event)
{
System.out.println("ChargeTick is working.");
if (Keyboard.getEventKey() == MCZKeyHandler.keys[MCZKeyHandler.CHARGE_KI].getKeyCode())
{
ExtendedPlayer props = ExtendedPlayer.get(mc.thePlayer);
ExtendedPlayer.get(mc.thePlayer).replenishKi(props.getMaxKi() / 100);
}
}
}
public class ClientProxy extends CommonProxy
{
@Override
public void registerRenderers()
{
RenderingRegistry.registerEntityRenderingHandler(EntityKiblast.class, new RenderKiblast(Minecraftz.kiblastItem));
RenderingRegistry.registerEntityRenderingHandler(EntityBigblast.class, new RenderBigblast(Minecraftz.bigblastItem));
MinecraftForge.EVENT_BUS.register(new GuiKiBar(Minecraft.getMinecraft()));
}
@Override
public void initialize()
{
super.initialize();
FMLCommonHandler.instance().bus().register(new ClientTickHandler(Minecraft.getMinecraft()));
}
}
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumIn your main class, do you call "proxy.initialize()" ?