piotr_a3 Posted August 6, 2014 Posted August 6, 2014 Hi What's wrong with this piece of code? I just want to have a sword which behaves like a Bone, so you can tame a wolf with this sword using right click. package xeno.mci.swords2; import java.util.List; import java.util.Random; import scala.Int; import net.minecraft.client.Minecraft; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.passive.EntityWolf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.pathfinding.PathEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition.MovingObjectType; import net.minecraft.world.World; import xeno.mci.swords.mciSwords; public class sWilczyMiecz extends ItemSword { public sWilczyMiecz(ToolMaterial material) { super(material); //setMaxStackSize(1); this.setCreativeTab(mciSwords.ctab2); this.setUnlocalizedName("wilczymiecz"); this.setTextureName("mciswords:2wilczymiecz"); } public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { par3List.add("MCI #2 - Miecze"); par3List.add("Miejsce #3"); par3List.add("Autor: HeadPhoneKiller"); } @Override public boolean itemInteractionForEntity(ItemStack p1, EntityPlayer p2, EntityLivingBase p3) { return true; } public ItemStack onItemRightClick(ItemStack p1, World p2, EntityPlayer p3) { if(Minecraft.getMinecraft().objectMouseOver.entityHit != null){ if(Minecraft.getMinecraft().objectMouseOver.entityHit instanceof EntityLiving){ EntityLiving ent = (EntityLiving) Minecraft.getMinecraft().objectMouseOver.entityHit; //System.out.println("DEBUG1"); ItemStack bone = new ItemStack(Items.bone, 32); p3.setCurrentItemOrArmor(0, bone); p3.interactWith(ent); } } return p1; } } Quote
Jacky2611 Posted August 6, 2014 Posted August 6, 2014 Minecraft.getminecraft() is client only You have to get the Wolf entity at the server and then use something like this: if (!this.worldObj.isRemote) { wolf.setTamed(true); wolf.setPathToEntity((PathEntity)null); wolf.setAttackTarget((EntityLivingBase)null); wolf.aiSit.setSitting(true); wolf.setHealth(20.0F); wol.setOwner(par1EntityPlayer.getCommandSenderName()); wolf.playTameEffect(true); wolf.worldObj.setEntityState(this, (byte)7); } Quote Here could be your advertisement!
piotr_a3 Posted August 6, 2014 Author Posted August 6, 2014 How I can get the Wolf entity at the server? btw. wolf.setOwner do not exist aiSit is not visible playTameEffect is not visible too Quote
MultiMote Posted August 6, 2014 Posted August 6, 2014 setOwner is func_152115_b(player.getUniqueID().toString()); Quote
piotr_a3 Posted August 6, 2014 Author Posted August 6, 2014 But, Jacky said that Minecraft.getMinecraft() is clientside only. What should I do with this? Quote
nexusrightsi Posted August 6, 2014 Posted August 6, 2014 he also gave you the solution, its the if statement with the boolean that checks if the "game" is serversided "if (!this.worldObj.isRemote)" Quote
Jacky2611 Posted August 6, 2014 Posted August 6, 2014 nah, mineraft.getMinecraft() is client only. You will have to send that information to the server using a packet. Quote Here could be your advertisement!
piotr_a3 Posted August 7, 2014 Author Posted August 7, 2014 So, can you please tell me how I should do this? Quote
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.