我目前正在沙盒 java 游戏 minecraft 中开发一个 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;
}
}
我正在研究一个类似的项目,它给了我相同的结果,代码也如下:package 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;
}
}
}