Kloonder Posted September 1, 2015 Posted September 1, 2015 So I don't know if I should register my entity at all, but if, I don't know how to do this correctly this??? EntityRegistry.registerGlobalEntityID(EntityBlock.class, MODID + "Block Entity", 24324983); or that?? EntityRegistry.registerModEntity(EntityBlock.class, "MODID + "Block Entity", 0, this, 80, 3, true); cuz if I do it that way, it doesn't seem to update at all Quote Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
delpi Posted September 1, 2015 Posted September 1, 2015 Look up a tutorial and follow it. Here is one that will fix your lack of understanding. http://jabelarminecraft.blogspot.com/p/creating-custom-entities.html Quote Long time Bukkit & Forge Programmer Happy to try and help
Kloonder Posted September 1, 2015 Author Posted September 1, 2015 Hm, I show you: public Entity entity; @Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { System.out.println(world.getBlockState(pos).getBlock()); Block block = world.getBlockState(pos).getBlock(); world.setBlockToAir(pos); IBlockState state = world.getBlockState(pos); EntityBlock entityfallingblock = new EntityBlock(world, (double)player.posX + 0.5D, (double)player.posY, (double)player.posZ + 0.5D, BlockSand.getStateById(2)); entity = entityfallingblock; world.spawnEntityInWorld(entityfallingblock); return true; } @Override public void onUpdate(ItemStack stack, World worldIn, Entity player, int itemSlot, boolean isSelected) { if(!stack.hasTagCompound()){ stack.setTagCompound(new NBTTagCompound()); } if(player instanceof EntityPlayer){ if(entity != null){ if(player.rayTrace(5, 1) != null){ if(player.rayTrace(5, 1).hitVec != null){ entity.setPositionAndUpdate(player.rayTrace(5, 1).hitVec.xCoord, player.rayTrace(5, 1).hitVec.yCoord, player.rayTrace(5, 1).hitVec.zCoord); } } } } } The Entity need more than 1 sec to teleport to the crosshair position, so its really bad, even the block falls, although: public class EntityBlock extends EntityFallingBlock{ public EntityBlock(World world){ super(world); } public EntityBlock(World worldIn, double x, double y, double z, IBlockState fallingBlockState) { super(worldIn, x, y, z, fallingBlockState); } @Override public void onUpdate() { System.out.println(posX + "\t" + posY + "\t" + posZ); } } It can't fall cuz theres no method for calling a fall Quote Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
delpi Posted September 1, 2015 Posted September 1, 2015 So, you really are asking a different question than your original post. First off, I'm assuming your first set of code is a custom item. Delete 'public Entity entity;', its useless in an item. You can store the value in the itemstacks NBT. With your code for onUpdate 'entity will always be null' Also, write proper English. Quote Long time Bukkit & Forge Programmer Happy to try and help
Kloonder Posted September 1, 2015 Author Posted September 1, 2015 No I don't think its useless, 'because' I need the Entity to synchro the coords, and then I don't have to call it, anyway, I don't need to save it, 'because' after the player takes the item out of hand or disconnects, the block should fall to the ground and crate a new block, anyway, its the same question, I want to know if there is a way to faster synchro the entity so it does not take 1 sec to synchro. Do you have any idea how to synchro it faster, that it does not take 1 sek? Quote Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
delpi Posted September 2, 2015 Posted September 2, 2015 If you don't think it is useless then you don't understand what an Item is in minecraft. Delete it and use the other method I told you. Quote Long time Bukkit & Forge Programmer Happy to try and help
Ernio Posted September 2, 2015 Posted September 2, 2015 Damn 1. Use !world.isRemote to run code on server logical side - that is regarding to operation on world (chaning blocks) aswell as spawning entities. 2. What was said - you cannot hold ANY fields that are not shared between all Items in YourItem.class. There is ever only one instance of Item, what player is holding (or world, or whatever) is an ItemStack and only it holds stack-specific data. Globall Entity field will cause issues when used with more than one item (multiplayer). That said - you need to save everything you need to ItemStack used by player - if you need it CAN BE a reference to block spawned in world (entityId) - note that it does not presist through sessions so it is useless after unload. 3. You problem lies in bad minecraft code understanding, not "how to make it synchro faster" - fix issues mentioned above. Quote 1.7.10 is no longer supported by forge, you are on your own.
thebest108 Posted September 2, 2015 Posted September 2, 2015 I would recommend expanding the falling block into a new entity and then you could just change its render method to render Exactly where the player is looking at for a nice effect. Edit: If you want it to spawn instantly you could technically allow the entity to only exist on client and instruct that one client to ignore the entity the server has (or just not render it). That way its really smooth and other people see it too Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.