sk9zist :l
Исправился
- 981
- 18
- 157
Задумка такая: стрела останавливаеться (медленно, 3-5 секунд до полной остановки, но этого хватает чтобы она не успела задеть тебя) при подлёте к игроку, если у него в инвентаре есть мой предмет в состоянии active. В тестовом клиенте (запуск из eclipse) - всё работает. А вот если поставить мод на сервер - там уже это не будет работать. Ниже приложен код всего, что связано с этим (предмет, хук):
Hooks.java:
public class Hooks
{
@Hook(injectOnExit = true, returnCondition = ReturnCondition.ALWAYS)
public static void onUpdate(EntityArrow fb)
{
if(variables.s == true)
{
double r = 4.5;
EntityPlayer targetEntity = (EntityPlayer) fb.world.findNearestEntityWithinAABB(EntityPlayer.class, fb.getEntityBoundingBox().grow(r), fb);
if(targetEntity != null)
{
fb.motionX *= (double)14.0F / (1 * 20);
fb.motionY = 0;
fb.motionZ *= (double)14.0F / (1 * 20);
}
}
}
}
TestItem.java:
public class TestItem extends Item{
public TestItem(String name, int maxStackSize){
setUnlocalizedName(name);
setRegistryName(name);
setMaxStackSize(maxStackSize);
}
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
//if(playerIn.getHeldItem(handIn).hasTagCompound() == false)
//{
// NBTTagCompound nbt = new NBTTagCompound();
// nbt.setBoolean("s", true);
// playerIn.getHeldItem(handIn).setTagCompound(nbt);
//} else {
// if(playerIn.getHeldItem(handIn).getTagCompound().getBoolean("s") == true)
// {
// playerIn.getHeldItem(handIn).getTagCompound().setBoolean("s", false);
// }
// if(playerIn.getHeldItem(handIn).getTagCompound().getBoolean("s") == false)
// {
// playerIn.getHeldItem(handIn).getTagCompound().setBoolean("s", true);
// }
//}
if(!worldIn.isRemote)
{
if(variables.s == true)
{
variables.s = false;
} else {
variables.s = true;
}
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
}
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack par1ItemStack)
{
if(variables.s == true)
{
return true;
} else {
return false;
}
}
}