Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

  • Author

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 :/

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

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.

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

  • Author

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?

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

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.

Long time Bukkit & Forge Programmer

Happy to try and help

Damn :D

 

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.

1.7.10 is no longer supported by forge, you are on your own.

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

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.