im trying to create a mod which extends the reach of the Player...
i can raytrace the block the player is looking on but if i call
minecraft.theWorld.destroyBlock(new BlockPos(x, y, z), true);
the block breaks, but im still colliding with it but i cant hit it anymore after restarting the world the block is back.
i think i'm missing some update function anywhere
it tested:
minecraft.theWorld.markBlockForUpdate(new BlockPos(x, y, z));
minecraft.theWorld.notifyBlockOfStateChange(new BlockPos(x, y, z), minecraft.theWorld.getBlockState(new BlockPos(x, y, z)).getBlock());
minecraft.theWorld.notifyNeighborsOfStateChange(new BlockPos(x, y, z), minecraft.theWorld.getBlockState(new BlockPos(x, y, z)).getBlock());
minecraft.theWorld.tick();
minecraft.theWorld.getWorldChunkManager().cleanupCache();
Don't use raytrace if you want to do something serverside. The way I made a thingy that detects the entity you're looking at server-side is I made a custom vector class and did some mathses.
Even in single player, there is the server and the client halves of the game.
The server side keeps track of mobs and blocks and all of that stuff, and gives sends it to the client part of single player for the rendering.
The client part renders everything and does other things like drawing GUIs (the server still knows if you have a GUI open).
Even if you are in single player, you still need to make sure that you're changing things on the server.
Your code uses the client side world, and the server-side part does not know that the block should be broken. You need to use a server world in order to prevent ghost blocks.
Ok guys i found a solution which works atm only for singleplayer but i will look forward for Mp stuff
minecraft.getIntegratedServer().getEntityWorld().destroyBlock(new BlockPos(x, y, z), true);
that is the solution
edit:
minecraft.theWorld.destroyBlock(new BlockPos(x, y, z), true);
this works for mp if not blocked by a plugin
edit2: Ups testing helps still a Ghost Block for mp^.^
Ok guys i found a solution which works atm only for singleplayer but i will look forward for Mp stuff
minecraft.getIntegratedServer().getEntityWorld().destroyBlock(new BlockPos(x, y, z), true);
that is the solution
edit:
minecraft.theWorld.destroyBlock(new BlockPos(x, y, z), true);
this works for mp if not blocked by a plugin
edit2: Ups testing helps still a Ghost Block for mp^.^
Minecraft.getMinecraft().theWorld is the CLIENT world - making ANY changes there will affect only the one client, and results in a ghost block because the server still says there is a block there, but the client cannot see it because they were told it was destroyed (though they cannot walk through it due to it still existing).
The solution is to use rayTrace code that works on the server (i.e. without using Minecraft.getMinecraft for anything at all) and let your entire logic run on the server - clients are all updated automatically.
If, for whatever reason, you absolutely must run your code on the client side, then you HAVE to send a packet to the server telling it which block to destroy. Do not use getIntegratedServer or any of that, just send a packet to the server (whichever one is running) and use the message context to get a world object reference - this will work in both single and multi-player.
im trying to create a mod which extends the reach of the Player...
i can raytrace the block the player is looking on but if i call
minecraft.theWorld.destroyBlock(new BlockPos(x, y, z), true);
the block breaks, but im still colliding with it but i cant hit it anymore after restarting the world the block is back.
i think i'm missing some update function anywhere
it tested:
minecraft.theWorld.markBlockForUpdate(new BlockPos(x, y, z));
minecraft.theWorld.notifyBlockOfStateChange(new BlockPos(x, y, z), minecraft.theWorld.getBlockState(new BlockPos(x, y, z)).getBlock());
minecraft.theWorld.notifyNeighborsOfStateChange(new BlockPos(x, y, z), minecraft.theWorld.getBlockState(new BlockPos(x, y, z)).getBlock());
minecraft.theWorld.tick();
minecraft.theWorld.getWorldChunkManager().cleanupCache();
but that does not help
anyone who know a solution for my problem?
ClothingCraft - Highly customizable and realistic clothing! No more silly leather armor!
The main problem is still that the broken block is saved somewhere and not deleted
btw. i tested this in Eclipse so it should be the integrated Server not any standalone version
http://pastebin.com/BpPdRtCc
the rest of the code is here
https://github.com/1337Zero/Zombe
Liteloader... is a simple loader without much functions you have to use minecraft defaults... but i think there is a relationship to forge but idk.
the Buildscript ist on Github in the ant folder
all in all its like you make an standalone mod without changing the original code
but that is still not the problem
The server side keeps track of mobs and blocks and all of that stuff, and gives sends it to the client part of single player for the rendering.
The client part renders everything and does other things like drawing GUIs (the server still knows if you have a GUI open).
Even if you are in single player, you still need to make sure that you're changing things on the server.
Your code uses the client side world, and the server-side part does not know that the block should be broken. You need to use a server world in order to prevent ghost blocks.
ClothingCraft - Highly customizable and realistic clothing! No more silly leather armor!
minecraft.getIntegratedServer().getEntityWorld().destroyBlock(new BlockPos(x, y, z), true);
that is the solution
edit:
minecraft.theWorld.destroyBlock(new BlockPos(x, y, z), true);
this works for mp if not blocked by a plugin
edit2: Ups testing helps still a Ghost Block for mp^.^
ClothingCraft - Highly customizable and realistic clothing! No more silly leather armor!
Placing Blocks and destroying Blocks in Sp works, i have to find a way to let it happen in MP
Hey there. I'm having similar problems and was wondering if you have figured it out. I'm looking everywhere for a solution
I complicate easy problems, come begging for help, and leave with a simple solution.
Sorry, I'm a little bit of a noob with server packets, but would I post that code in my item methods?
here is my current code
//when left clicked
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player)
{
firstPos = pos;
return true;
}
}
Would I post the code in there?
That code is in my Item class, so it is called when I start to destroy a block.
Thanks for the fast reply
I complicate easy problems, come begging for help, and leave with a simple solution.
Minecraft.getMinecraft().theWorld is the CLIENT world - making ANY changes there will affect only the one client, and results in a ghost block because the server still says there is a block there, but the client cannot see it because they were told it was destroyed (though they cannot walk through it due to it still existing).
The solution is to use rayTrace code that works on the server (i.e. without using Minecraft.getMinecraft for anything at all) and let your entire logic run on the server - clients are all updated automatically.
If, for whatever reason, you absolutely must run your code on the client side, then you HAVE to send a packet to the server telling it which block to destroy. Do not use getIntegratedServer or any of that, just send a packet to the server (whichever one is running) and use the message context to get a world object reference - this will work in both single and multi-player.
How would one create a packet?
I complicate easy problems, come begging for help, and leave with a simple solution.
If you don't already know how, then you should search for a tutorial. I have one linked in my profile if you can't find one via Google.