Hey, I'm having a bit of trouble with things not syncing properly when traveling from the End back to the Overworld. Relogging, syncs everything but it would be nice if I could get that fixed. Any suggestions? Thanks in advance.
Coming back from the End is like dying - have you followed the section on persisting your data through death, i.e. using the Clone event? That should solve your problem.
Coming back from the End is like dying - have you followed the section on persisting your data through death, i.e. using the Clone event? That should solve your problem.
Dying (by environment, mobs, players, void, and /kill), going to the Nether, leaving the Nether, and going to the End all work perfectly fine. It's only when I leave the End that things don't work. Custom inventory stuff stay like it should but integers are reset to their defaults.
Rollback Post to RevisionRollBack
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
Dying (by environment, mobs, players, void, and /kill), going to the Nether, leaving the Nether, and going to the End all work perfectly fine. It's only when I leave the End that things don't work. Custom inventory stuff stay like it should but integers are reset to their defaults.
Show your code, then, as it sounds like you are either not copying the data correctly to the new player instance, or you are not sending all of your data to the client so it 'looks' like your data is reset when it actually is not (which would explain why logging out and back in fixes it, as you probably send all your IEEP data to the client at that time).
Show your code, then, as it sounds like you are either not copying the data correctly to the new player instance, or you are not sending all of your data to the client so it 'looks' like your data is reset when it actually is not (which would explain why logging out and back in fixes it, as you probably send all your IEEP data to the client at that time).
Finally got around to getting this. Hope you can help. Thanks again
From Event Handler:
@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{
if (event.entity instanceof EntityPlayer)
{
if (ExtendedPlayer.get((EntityPlayer) event.entity) == null)
{
ExtendedPlayer.register((EntityPlayer) event.entity);
}
}
}
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote)
{
HeroSuitsPacketHandler.INSTANCE.sendTo(new SyncExtendedPlayer((EntityPlayer)event.entity), (EntityPlayerMP)event.entity);
}
}
@SubscribeEvent
public void onClonePlayer(PlayerEvent.Clone event)
{
ExtendedPlayer.get(event.entityPlayer).copy(ExtendedPlayer.get(event.original));
}
Extended Player:
[/p]
[p]package jx.herosuits.player;[/p]
[p]import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;[/p]
[p]public class ExtendedPlayer implements IExtendedEntityProperties
{
public final static String EXT_PLAYER = "ExtendedPlayer";
private final EntityPlayer player;
private int maxEnergy;
public final InventoryPlayerAccessories inventory = new InventoryPlayerAccessories();
public static final int ENERGY_WATCHER = 20;
public static final int POINT_WATCHER = 21;
public ExtendedPlayer(EntityPlayer player)
{
this.player = player;
this.maxEnergy = 1000;
this.player.getDataWatcher().addObject(ENERGY_WATCHER, this.maxEnergy);
this.player.getDataWatcher().addObject(POINT_WATCHER, 0);
}
public static final void register(EntityPlayer player)
{
player.registerExtendedProperties(ExtendedPlayer.EXT_PLAYER, new ExtendedPlayer(player));
}
public static final ExtendedPlayer get(EntityPlayer player)
{
return (ExtendedPlayer) player.getExtendedProperties(EXT_PLAYER);
}
public void copy(ExtendedPlayer props)
{
inventory.copy(props.inventory);
player.getDataWatcher().updateObject(ENERGY_WATCHER, props.getCurrentEnergy());
maxEnergy = props.maxEnergy;
player.getDataWatcher().updateObject(POINT_WATCHER, props.getPlayerPoints());
}
@Override
public void saveNBTData(NBTTagCompound compound)
{
NBTTagCompound properties = new NBTTagCompound();
inventory.writeToNBT(properties);
properties.setInteger("CurrentEnergy", player.getDataWatcher().getWatchableObjectInt(ENERGY_WATCHER));
properties.setInteger("MaxEnergy", maxEnergy);
properties.setInteger("CurrentPoints", player.getDataWatcher().getWatchableObjectInt(POINT_WATCHER));
compound.setTag(EXT_PLAYER, properties);
}[/p]
[p]@Override
public void loadNBTData(NBTTagCompound compound)
{
NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PLAYER);
inventory.readFromNBT(properties);
player.getDataWatcher().updateObject(ENERGY_WATCHER, properties.getInteger("CurrentEnergy"));
maxEnergy = properties.getInteger("MaxEnergy");
player.getDataWatcher().updateObject(POINT_WATCHER, properties.getInteger("CurrentPoints"));
}[/p]
[p]@Override
public void init(Entity entity, World world) {}
public void onUpdate()
{
if (!player.worldObj.isRemote)
{
if (getCurrentEnergy() < getMaxEnergy())
{
replenishEnergy(2);
}
}
}
public final void replenishEnergy(int amount)
{
setCurrentEnergy(getCurrentEnergy() + amount);
}
public final boolean useEnergy(int amount)
{
boolean hasEnough = amount <= getCurrentEnergy();
setCurrentEnergy(getCurrentEnergy() - amount);
return hasEnough;
}
public final void setEnergyToMax()
{
this.player.getDataWatcher().updateObject(ENERGY_WATCHER, this.maxEnergy);
}
public final int getCurrentEnergy()
{
return player.getDataWatcher().getWatchableObjectInt(ENERGY_WATCHER);
}
public final void setCurrentEnergy(int amount)
{
player.getDataWatcher().updateObject(ENERGY_WATCHER, amount > 0 ? (amount < maxEnergy ? amount : maxEnergy) : 0);
}
public final int getMaxEnergy()
{
return maxEnergy;
}
public int getPlayerPoints()
{
return player.getDataWatcher().getWatchableObjectInt(POINT_WATCHER);
}[/p]
[p]public void setPlayerPoints(int amount)
{
player.getDataWatcher().updateObject(POINT_WATCHER, amount);
}[/p]
[p]public void addPlayerPoints(int amount)
{
int added = getPlayerPoints() + amount;
player.getDataWatcher().updateObject(POINT_WATCHER, added);
}[/p]
[p]public void spendPlayerPoints(int amount)
{
int points = player.getDataWatcher().getWatchableObjectInt(POINT_WATCHER);[/p]
[p]boolean hasEnough = amount <= points;
int spent = getPlayerPoints() - amount;
if (hasEnough)
{
player.getDataWatcher().updateObject(POINT_WATCHER, spent);
}
}
}[/p]
[p]
Sync Packet:
package jx.herosuits.network;
import java.io.IOException;
import jx.herosuits.network.AbstractPacket.AbstractClientMessage;
import jx.herosuits.player.ExtendedPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import cpw.mods.fml.relauncher.Side;
public class SyncExtendedPlayer extends AbstractClientMessage<SyncExtendedPlayer>
{
private NBTTagCompound data;
public SyncExtendedPlayer() {}
public SyncExtendedPlayer(EntityPlayer player)
{
this.data = new NBTTagCompound();
ExtendedPlayer.get(player).saveNBTData(data);
}
@Override
protected void read(PacketBuffer buffer) throws IOException
{
data = buffer.readNBTTagCompoundFromBuffer();
}
@Override
protected void write(PacketBuffer buffer) throws IOException
{
buffer.writeNBTTagCompoundToBuffer(data);
}
@Override
public void process(EntityPlayer player, Side side)
{
System.out.println("Did it!");
ExtendedPlayer.get(player).loadNBTData(data);
}
}
Rollback Post to RevisionRollBack
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
That's interesting... hm. It looks like your code is all set up correctly, and the only thing different is that your 'int' fields are stored in DataWatcher rather than as class fields.
What I do in situations like this is start printing out values like it's going out of style, with information about where that value was printed from, and then run my code and see what I get. More often than not, this pinpoints the location where my expectations and reality diverge.
Initial points of interest would be #copy and #loadNBTData. Be sure to also include the current side (e.g. "Is client? " + player.worldObj.isRemote) so you know which side it's on - only time it will be client is when you receive the sync packet.
Btw, you likely have a bug in your spendPlayerPoints method, as it only spends the points if there are enough, but doesn't return 'true' or 'false' to notify whatever code called it of its success or failure. I'm not really sure what the point of the method as written should be.
That's interesting... hm. It looks like your code is all set up correctly, and the only thing different is that your 'int' fields are stored in DataWatcher rather than as class fields.
What I do in situations like this is start printing out values like it's going out of style, with information about where that value was printed from, and then run my code and see what I get. More often than not, this pinpoints the location where my expectations and reality diverge.
Initial points of interest would be #copy and #loadNBTData. Be sure to also include the current side (e.g. "Is client? " + player.worldObj.isRemote) so you know which side it's on - only time it will be client is when you receive the sync packet.
Btw, you likely have a bug in your spendPlayerPoints method, as it only spends the points if there are enough, but doesn't return 'true' or 'false' to notify whatever code called it of its success or failure. I'm not really sure what the point of the method as written should be.
I've had no luck in trying to track the issue down. Thanks for your help though.
Rollback Post to RevisionRollBack
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
The Meaning of Life, the Universe, and Everything.
Join Date:
9/30/2011
Posts:
43
Minecraft:
statphantom
Member Details
Hello, been reading through your guides and they are amazing and very helpful! however I have hit a snag, I am trying to do something simple which is to not allow wood to be broken by hand using a PlayerInteractEvent.event. however I can not find a up-to-date tutorial on how to get the block that the player clicked on. even my IDE (eclipse) is showing there is no method that returns the block. can you help me with this or point me in the right direction?
very simply have this at the moment
@SubscribeEvent
public void onPlayerClickEvent(PlayerInteractEvent event) {
if (event.action == Action.LEFT_CLICK_BLOCK) {
}
}
Hello, been reading through your guides and they are amazing and very helpful! however I have hit a snag, I am trying to do something simple which is to not allow wood to be broken by hand using a PlayerInteractEvent.event. however I can not find a up-to-date tutorial on how to get the block that the player clicked on. even my IDE (eclipse) is showing there is no method that returns the block. can you help me with this or point me in the right direction?
very simply have this at the moment
@SubscribeEvent
public void onPlayerClickEvent(PlayerInteractEvent event) {
if (event.action == Action.LEFT_CLICK_BLOCK) {
}
}
Any help Is greatly appreciated, thanks.
I know this isn't my thread but while there isn't a reference to the block there is a world and coords. So something like this should work:
if (event.world.getBlock(event.x, event.y, event.z) instanceof BlockWood)
{
//Your result here.
}
Rollback Post to RevisionRollBack
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
The Meaning of Life, the Universe, and Everything.
Join Date:
9/30/2011
Posts:
43
Minecraft:
statphantom
Member Details
Thanks a lot! I thought there was due to there used to be in the old API according to some tutorials I found, one question, is using this to search for block via coords every event seems inefficient. is there a better way to do what I am after? (clear blockdamagedata based on what's in your hand?
Thanks a lot! I thought there was due to there used to be in the old API according to some tutorials I found, one question, is using this to search for block via coords every event seems inefficient. is there a better way to do what I am after? (clear blockdamagedata based on what's in your hand?
Any other alternatives I can think of would all require the use of an event anyway so I don't think it should be a problem. I personally use a whole bunch of events. Maybe if there were 500 people all trying to break wood with their bare hands at the same time you'd notice some issues starting to pop up but I think the game would crumble under the pressure of that many players on at once anyway so you should be fine
Rollback Post to RevisionRollBack
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
The Meaning of Life, the Universe, and Everything.
Join Date:
9/30/2011
Posts:
43
Minecraft:
statphantom
Member Details
This doesnt seem to work it says that 'x' is not a field in event. there is getPos. but getBlock(BlockPos) is not valid either anything else you can suggest?
@SubscribeEvent
public void onPlayerClickEvent(PlayerEvent.BreakSpeed event) {
if (event.state.getBlock() != Blocks.log) {
event.newSpeed = -1;
}
}
Maybe PlayerInteractEvent has been depreciated? Unsure
Oh, are you in 1.8? I've done very little with that. I opened my mod in it and had 12,000 errors and after about 3 hours I still had about 7,000 errors so I decided since 1.9 seems relatively close and it looks like they actually finished the features that are only half way finished in 1.8 I'd wait. I'm sure PlayerInteractEvent still works but the event you're using should work fine. However, what you have there looks like it will make every block except for logs impossible to break. Also, that code will make it so the block won't be able to be broken ever. Even with a tool.
Rollback Post to RevisionRollBack
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
Oh, are you in 1.8? I've done very little with that. I opened my mod in it and had 12,000 errors and after about 3 hours I still had about 7,000 errors so I decided since 1.9 seems relatively close and it looks like they actually finished the features that are only half way finished in 1.8 I'd wait. I'm sure PlayerInteractEvent still works but the event you're using should work fine. However, what you have there looks like it will make every block except for logs impossible to break. Also, that code will make it so the block won't be able to be broken ever. Even with a tool.
correct, I am just experimenting seeing how things act / react, this isn't something for people to play this is for my own knowledge
yea 1.8 I am using, I want to mod for the latest version so I will move on to 1.9 when it is out but learning in 1.8 will still give me good insight into mod development
correct, I am just experimenting seeing how things act / react, this isn't something for people to play this is for my own knowledge
yea 1.8 I am using, I want to mod for the latest version so I will move on to 1.9 when it is out but learning in 1.8 will still give me good insight into mod development
I understand that. If you're starting a new mod then it's perfectly fine but if you have a huge mod already it really is a pain, especially when it's not your primary job to make a mod. It's hard to justify all that time when you know you're just going to have to do it all again in two months.
Rollback Post to RevisionRollBack
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
I understand that. If you're starting a new mod then it's perfectly fine but if you have a huge mod already it really is a pain, especially when it's not your primary job to make a mod. It's hard to justify all that time when you know you're just going to have to do it all again in two months.
No doubt at all, maybe oneday when I get better I could even help out I am really passionate about coding and gaming so this is a perfect middle ground for me to learn, but like you, job and university does take precedence.
The Meaning of Life, the Universe, and Everything.
Join Date:
9/30/2011
Posts:
43
Minecraft:
statphantom
Member Details
so my previous example works for 'mining' but not for one click events. for that I still need to use a PlayerInteractEvent, so if I want to do something like "right clicking on a grass block turns it to dirt" I still need a way to get the block that I right click on, so still need help lol
so my previous example works for 'mining' but not for one click events. for that I still need to use a PlayerInteractEvent, so if I want to do something like "right clicking on a grass block turns it to dirt" I still need a way to get the block that I right click on, so still need help lol
Here are some references for break speed / preventing mining by hand, which it sounds like you already figured out: One, another, and another.
PlayerInteractEvent works perfectly fine. The event gives you a BlockPos, World, EnumFacing, type of click, and the Player entity - enough to do pretty much anything.
Right-clicking on grass to turn it to dirt, for example, can easily be done:
@SubscribeEvent
public void onInteract(PlayerInteractEvent event) {
switch(event.action) {
case RIGHT_CLICK_BLOCK:
Block block = event.world.getBlockState(event.pos).getBlock();
if (block instanceof BlockGrass && !event.world.isRemote) {
event.world.setBlockState(event.pos, Blocks.dirt.getDefaultState());
}
break;
}
}
Something like that ought to work.You can do a lot with enough knowledge of the various Minecraft and Forge classes, and that comes by scrupulously searching through both code sources whenever you run into a problem. If you want to get better, you need to spend lots of time reading and experimenting, with experimenting being the more important of the two.
When you experiment, use LOTS of println statements to see what is going on in your code, rather than typing some code and thinking 'oh, that didn't work' - why didn't it work? What, exactly, was it doing? Debugging should be your best friend.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumComing back from the End is like dying - have you followed the section on persisting your data through death, i.e. using the Clone event? That should solve your problem.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumDying (by environment, mobs, players, void, and /kill), going to the Nether, leaving the Nether, and going to the End all work perfectly fine. It's only when I leave the End that things don't work. Custom inventory stuff stay like it should but integers are reset to their defaults.
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
I made a thing:
Forum Thread: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2091787-1-7-2-tynkyn-v1-3-out-now-elementurtles


Website: https://sites.google.com/site/tynkynwiki/
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumShow your code, then, as it sounds like you are either not copying the data correctly to the new player instance, or you are not sending all of your data to the client so it 'looks' like your data is reset when it actually is not (which would explain why logging out and back in fixes it, as you probably send all your IEEP data to the client at that time).
I'm trying to make an extended player but I've been doing packets differently what's in your tutorial.
For the packet on syncing the player, would this basically be the same thing?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYes, but you have to write and read the NBT tag to the byte buffer or no data is actually sent in the packet.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumFinally got around to getting this. Hope you can help. Thanks again
From Event Handler:
@SubscribeEvent public void onEntityConstructing(EntityConstructing event) { if (event.entity instanceof EntityPlayer) { if (ExtendedPlayer.get((EntityPlayer) event.entity) == null) { ExtendedPlayer.register((EntityPlayer) event.entity); } } } @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote) { HeroSuitsPacketHandler.INSTANCE.sendTo(new SyncExtendedPlayer((EntityPlayer)event.entity), (EntityPlayerMP)event.entity); } } @SubscribeEvent public void onClonePlayer(PlayerEvent.Clone event) { ExtendedPlayer.get(event.entityPlayer).copy(ExtendedPlayer.get(event.original)); }Extended Player:
[/p] [p]package jx.herosuits.player;[/p] [p]import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties;[/p] [p]public class ExtendedPlayer implements IExtendedEntityProperties { public final static String EXT_PLAYER = "ExtendedPlayer"; private final EntityPlayer player; private int maxEnergy; public final InventoryPlayerAccessories inventory = new InventoryPlayerAccessories(); public static final int ENERGY_WATCHER = 20; public static final int POINT_WATCHER = 21; public ExtendedPlayer(EntityPlayer player) { this.player = player; this.maxEnergy = 1000; this.player.getDataWatcher().addObject(ENERGY_WATCHER, this.maxEnergy); this.player.getDataWatcher().addObject(POINT_WATCHER, 0); } public static final void register(EntityPlayer player) { player.registerExtendedProperties(ExtendedPlayer.EXT_PLAYER, new ExtendedPlayer(player)); } public static final ExtendedPlayer get(EntityPlayer player) { return (ExtendedPlayer) player.getExtendedProperties(EXT_PLAYER); } public void copy(ExtendedPlayer props) { inventory.copy(props.inventory); player.getDataWatcher().updateObject(ENERGY_WATCHER, props.getCurrentEnergy()); maxEnergy = props.maxEnergy; player.getDataWatcher().updateObject(POINT_WATCHER, props.getPlayerPoints()); } @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); inventory.writeToNBT(properties); properties.setInteger("CurrentEnergy", player.getDataWatcher().getWatchableObjectInt(ENERGY_WATCHER)); properties.setInteger("MaxEnergy", maxEnergy); properties.setInteger("CurrentPoints", player.getDataWatcher().getWatchableObjectInt(POINT_WATCHER)); compound.setTag(EXT_PLAYER, properties); }[/p] [p]@Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PLAYER); inventory.readFromNBT(properties); player.getDataWatcher().updateObject(ENERGY_WATCHER, properties.getInteger("CurrentEnergy")); maxEnergy = properties.getInteger("MaxEnergy"); player.getDataWatcher().updateObject(POINT_WATCHER, properties.getInteger("CurrentPoints")); }[/p] [p]@Override public void init(Entity entity, World world) {} public void onUpdate() { if (!player.worldObj.isRemote) { if (getCurrentEnergy() < getMaxEnergy()) { replenishEnergy(2); } } } public final void replenishEnergy(int amount) { setCurrentEnergy(getCurrentEnergy() + amount); } public final boolean useEnergy(int amount) { boolean hasEnough = amount <= getCurrentEnergy(); setCurrentEnergy(getCurrentEnergy() - amount); return hasEnough; } public final void setEnergyToMax() { this.player.getDataWatcher().updateObject(ENERGY_WATCHER, this.maxEnergy); } public final int getCurrentEnergy() { return player.getDataWatcher().getWatchableObjectInt(ENERGY_WATCHER); } public final void setCurrentEnergy(int amount) { player.getDataWatcher().updateObject(ENERGY_WATCHER, amount > 0 ? (amount < maxEnergy ? amount : maxEnergy) : 0); } public final int getMaxEnergy() { return maxEnergy; } public int getPlayerPoints() { return player.getDataWatcher().getWatchableObjectInt(POINT_WATCHER); }[/p] [p]public void setPlayerPoints(int amount) { player.getDataWatcher().updateObject(POINT_WATCHER, amount); }[/p] [p]public void addPlayerPoints(int amount) { int added = getPlayerPoints() + amount; player.getDataWatcher().updateObject(POINT_WATCHER, added); }[/p] [p]public void spendPlayerPoints(int amount) { int points = player.getDataWatcher().getWatchableObjectInt(POINT_WATCHER);[/p] [p]boolean hasEnough = amount <= points; int spent = getPlayerPoints() - amount; if (hasEnough) { player.getDataWatcher().updateObject(POINT_WATCHER, spent); } } }[/p] [p]Sync Packet:
package jx.herosuits.network; import java.io.IOException; import jx.herosuits.network.AbstractPacket.AbstractClientMessage; import jx.herosuits.player.ExtendedPlayer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; import cpw.mods.fml.relauncher.Side; public class SyncExtendedPlayer extends AbstractClientMessage<SyncExtendedPlayer> { private NBTTagCompound data; public SyncExtendedPlayer() {} public SyncExtendedPlayer(EntityPlayer player) { this.data = new NBTTagCompound(); ExtendedPlayer.get(player).saveNBTData(data); } @Override protected void read(PacketBuffer buffer) throws IOException { data = buffer.readNBTTagCompoundFromBuffer(); } @Override protected void write(PacketBuffer buffer) throws IOException { buffer.writeNBTTagCompoundToBuffer(data); } @Override public void process(EntityPlayer player, Side side) { System.out.println("Did it!"); ExtendedPlayer.get(player).loadNBTData(data); } }Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
I made a thing:
Forum Thread: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2091787-1-7-2-tynkyn-v1-3-out-now-elementurtles


Website: https://sites.google.com/site/tynkynwiki/
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThat's interesting... hm. It looks like your code is all set up correctly, and the only thing different is that your 'int' fields are stored in DataWatcher rather than as class fields.
What I do in situations like this is start printing out values like it's going out of style, with information about where that value was printed from, and then run my code and see what I get. More often than not, this pinpoints the location where my expectations and reality diverge.
Initial points of interest would be #copy and #loadNBTData. Be sure to also include the current side (e.g. "Is client? " + player.worldObj.isRemote) so you know which side it's on - only time it will be client is when you receive the sync packet.
Btw, you likely have a bug in your spendPlayerPoints method, as it only spends the points if there are enough, but doesn't return 'true' or 'false' to notify whatever code called it of its success or failure. I'm not really sure what the point of the method as written should be.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI've had no luck in trying to track the issue down. Thanks for your help though.
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
I made a thing:
Forum Thread: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2091787-1-7-2-tynkyn-v1-3-out-now-elementurtles


Website: https://sites.google.com/site/tynkynwiki/
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHello, been reading through your guides and they are amazing and very helpful! however I have hit a snag, I am trying to do something simple which is to not allow wood to be broken by hand using a PlayerInteractEvent.event. however I can not find a up-to-date tutorial on how to get the block that the player clicked on. even my IDE (eclipse) is showing there is no method that returns the block. can you help me with this or point me in the right direction?
very simply have this at the moment
@SubscribeEvent public void onPlayerClickEvent(PlayerInteractEvent event) { if (event.action == Action.LEFT_CLICK_BLOCK) { } }Any help Is greatly appreciated, thanks.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI know this isn't my thread but while there isn't a reference to the block there is a world and coords. So something like this should work:
if (event.world.getBlock(event.x, event.y, event.z) instanceof BlockWood) { //Your result here. }Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
I made a thing:
Forum Thread: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2091787-1-7-2-tynkyn-v1-3-out-now-elementurtles


Website: https://sites.google.com/site/tynkynwiki/
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThanks a lot! I thought there was due to there used to be in the old API according to some tutorials I found, one question, is using this to search for block via coords every event seems inefficient. is there a better way to do what I am after? (clear blockdamagedata based on what's in your hand?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumAny other alternatives I can think of would all require the use of an event anyway so I don't think it should be a problem. I personally use a whole bunch of events. Maybe if there were 500 people all trying to break wood with their bare hands at the same time you'd notice some issues starting to pop up but I think the game would crumble under the pressure of that many players on at once anyway so you should be fine
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
I made a thing:
Forum Thread: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2091787-1-7-2-tynkyn-v1-3-out-now-elementurtles


Website: https://sites.google.com/site/tynkynwiki/
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThis doesnt seem to work
it says that 'x' is not a field in event. there is getPos. but getBlock(BlockPos) is not valid either
anything else you can suggest?
-
View User Profile
-
View Posts
-
Send Message
Curse Premiumthis worked!
@SubscribeEvent public void onPlayerClickEvent(PlayerEvent.BreakSpeed event) { if (event.state.getBlock() != Blocks.log) { event.newSpeed = -1; } }Maybe PlayerInteractEvent has been depreciated? Unsure
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumOh, are you in 1.8? I've done very little with that. I opened my mod in it and had 12,000 errors and after about 3 hours I still had about 7,000 errors so I decided since 1.9 seems relatively close and it looks like they actually finished the features that are only half way finished in 1.8 I'd wait. I'm sure PlayerInteractEvent still works but the event you're using should work fine. However, what you have there looks like it will make every block except for logs impossible to break. Also, that code will make it so the block won't be able to be broken ever. Even with a tool.
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
I made a thing:
Forum Thread: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2091787-1-7-2-tynkyn-v1-3-out-now-elementurtles


Website: https://sites.google.com/site/tynkynwiki/
-
View User Profile
-
View Posts
-
Send Message
Curse Premiumcorrect, I am just experimenting seeing how things act / react, this isn't something for people to play this is for my own knowledge
yea 1.8 I am using, I want to mod for the latest version so I will move on to 1.9 when it is out but learning in 1.8 will still give me good insight into mod development
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI understand that. If you're starting a new mod then it's perfectly fine but if you have a huge mod already it really is a pain, especially when it's not your primary job to make a mod. It's hard to justify all that time when you know you're just going to have to do it all again in two months.
Matthew 11:28-30 Come to me, all you who are weary and burdened, and I will give you rest. Take my yoke upon you, and learn from me; for I am gentle and humble in heart: and you will find rest for your souls. For my yoke is light, and my burden is easy.
I made a thing:
Forum Thread: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2091787-1-7-2-tynkyn-v1-3-out-now-elementurtles


Website: https://sites.google.com/site/tynkynwiki/
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumNo doubt at all, maybe oneday when I get better I could even help out
I am really passionate about coding and gaming so this is a perfect middle ground for me to learn, but like you, job and university does take precedence.
-
View User Profile
-
View Posts
-
Send Message
Curse Premiumso my previous example works for 'mining' but not for one click events. for that I still need to use a PlayerInteractEvent, so if I want to do something like "right clicking on a grass block turns it to dirt" I still need a way to get the block that I right click on, so still need help
lol
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHere are some references for break speed / preventing mining by hand, which it sounds like you already figured out:
One, another, and another.
PlayerInteractEvent works perfectly fine. The event gives you a BlockPos, World, EnumFacing, type of click, and the Player entity - enough to do pretty much anything.
Right-clicking on grass to turn it to dirt, for example, can easily be done:
Something like that ought to work.You can do a lot with enough knowledge of the various Minecraft and Forge classes, and that comes by scrupulously searching through both code sources whenever you run into a problem. If you want to get better, you need to spend lots of time reading and experimenting, with experimenting being the more important of the two.
When you experiment, use LOTS of println statements to see what is going on in your code, rather than typing some code and thinking 'oh, that didn't work' - why didn't it work? What, exactly, was it doing? Debugging should be your best friend.