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

okay I have a OnRightclick method that spawns 5 entitys into the world, the problem is, is that the item spawns 5 ghost entitys as well, here's my code.

package com.OlympiansMod.Item;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

import com.OlympiansMod.entity.EntitySGolem;
import com.OlympiansMod.entity.EntityUndead;

public class UndeadRomanSpawn extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(!player.capabilities.isCreativeMode){
		--itemstack.stackSize;


	}

	EntityUndead undead = new EntityUndead(world);
	undead.setPosition(player.posX, player.posY, player.posZ);
	world.spawnEntityInWorld(undead);




	return itemstack;


}
}

 

 

Im serious don't look at it!!

Entities should be spawned server-side.

Wrap your spawning with if (!world.isRemote).

 

(I am not sure of stuff below, I am only pointing out what you might run into)

Also: After direct manipulation of ItemStack: "--itemstack.stackSize;" you might have to do player.inventory.detectAndSendChanges() (not sure about method name). You will most certainly NOT have to do this if you would run "--itemstack.stackSize;" on both sides, and spawning entity on server only.

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

  • Author

ok I changed it but it still is not working

 

package com.OlympiansMod.Item;

import com.OlympiansMod.entity.EntityUndead;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class DioceltiansSepter extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(player.capabilities.isCreativeMode){

	}	
	if(!world.isRemote);

	for (int i = 0 ; i < 5 ; i++){
	EntityUndead undead = new EntityUndead(world);
	undead.setPosition(player.posX, player.posY, player.posZ);
	world.spawnEntityInWorld(undead);



}
	return itemstack;


}
}


Im serious don't look at it!!

Isnt there a method that takes x, y, and z parameters? I think its world.spawnEntityInWorld(entity, x, y, z, motionX, motionY, motionZ);

 

I think your problem is that your entity hasn't been spawned before you set its coordinates.

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.