我目前正在开发一个沙盒java游戏我的世界中的mod我做了一个项目,在右键点击推动播放器到空中。不幸的是,这不起作用,当我尝试激活游戏中的能力时,没有任何反应。该计划的代码如下:
package net.minecraft.src;
public class PhageWings extends Item{
public PhageWings(int par1){
super(par1);
this.maxStackSize = 1;
this.setCreativeTab(CreativeTabs.tabTransport);
}
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer){
entityplayer.motionY += 1; //fling player up in the air
return itemstack;
}
}
我正在开发一个类似的项目,它给我相同的结果,代码如下: 包net.minecraft.src;
public class PhageWand extends Item {
public PhageWand(int par1) {
super(par1);
this.maxStackSize = 1;
this.setCreativeTab(CreativeTabs.tabTransport);
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par3EntityPlayer.capabilities.isCreativeMode)
{
return par1ItemStack;
}
else if (par3EntityPlayer.ridingEntity != null)
{
return par1ItemStack;
}
else
{
--par1ItemStack.stackSize;
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!par2World.isRemote)
{
par2World.spawnEntityInWorld(new EntityEnderPearl(par2World, par3EntityPlayer));
}
return par1ItemStack;
}
}
}