本文介紹了我的世界鍛造如何阻止暴徒在命中后變得無懈可擊(Java)1.10.2的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我做了一個定制的弓,可以非常快地開火,我了解到所有的怪物在被擊中后的短時間內都是無敵的。這使得我的弓幾乎毫無用處。我想知道有沒有什么方法可以改變怪物無敵的持續時間,或者干脆把它去掉。
射弓方式代碼:
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) {
// int charge = 1;
// charge = ForgeEventFactory.onArrowLoose(stack, worldIn, playerIn, charge, true);
player123 = playerIn;
if (!worldIn.isRemote) {
final ItemArrow itemArrow = (ItemArrow) (Items.ARROW instanceof ItemArrow ? Items.ARROW : Items.ARROW);
final ItemStack ammo = new ItemStack(Items.ARROW, 1);
final float arrowVelocity = 1;
final EntityArrow entityArrow = itemArrow.createArrow(worldIn, ammo, playerIn);
entityArrow.setAim(playerIn, playerIn.rotationPitch, playerIn.rotationYawHead, 0.0F, arrowVelocity * 3.5F, 0F);
entityArrow.setDamage(2);
entityArrow.pickupStatus = EntityArrow.PickupStatus.DISALLOWED;
// entityArrow.setVelocity(0.2F, 0.1F, 0.2F);
final ItemStack magicarrow = new ItemStack(TheGalaxyMod.magicarrow, 1);
EntityLivingBase living = (playerIn);
if (FastMode.fastmode == 1){
int index = GetItemSlot(playerIn, magicarrow);
if (playerIn.inventory.hasItemStack(new ItemStack(TheGalaxyMod.creativequiver)))
{
entityArrow.setDamage(5000);
worldIn.spawnEntityInWorld(entityArrow);
}
else if (playerIn.inventory.hasItemStack(new ItemStack(TheGalaxyMod.magicquiver)))
{
worldIn.spawnEntityInWorld(entityArrow);
}
else if (!(playerIn.inventory.getStackInSlot(index).getItem() == null) && playerIn.inventory.getStackInSlot(index).getItem() == TheGalaxyMod.magicarrow)
{
damageItem(playerIn, magicarrow, 1);
worldIn.spawnEntityInWorld(entityArrow);
ItemStack stack2 = playerIn.inventory.getStackInSlot(index);
if(stack2.getItemDamage() > 500)
{
playerIn.inventory.setInventorySlotContents(index, null);
}
}
else if(playerIn.inventory.hasItemStack(ammo) ){
worldIn.spawnEntityInWorld(entityArrow);
removeItem(playerIn, ammo);
}
}
else if
(FastMode.fastmode == 2)
{
final ItemArrow itemArrow2 = (ItemArrow) (Items.ARROW instanceof ItemArrow ? Items.ARROW : Items.ARROW);
final ItemStack ammo2 = new ItemStack(Items.ARROW);
final float arrowVelocity2 = 1;
final EntityArrow entityArrow2 = itemArrow2.createArrow(worldIn, ammo2, playerIn);
entityArrow2.setAim(playerIn, playerIn.rotationPitch, playerIn.rotationYawHead, 0.0F, arrowVelocity2 * 3.5F, 0F);
entityArrow2.setDamage(2);
entityArrow2.pickupStatus = EntityArrow.PickupStatus.DISALLOWED;
int index = GetItemSlot(playerIn, magicarrow);
if (playerIn.inventory.hasItemStack(new ItemStack(TheGalaxyMod.creativequiver)))
{
entityArrow.setDamage(5000);
worldIn.spawnEntityInWorld(entityArrow);
entityArrow2.setDamage(5000);
worldIn.spawnEntityInWorld(entityArrow2);
}
else if (playerIn.inventory.hasItemStack(new ItemStack(TheGalaxyMod.magicquiver)))
{
worldIn.spawnEntityInWorld(entityArrow);
worldIn.spawnEntityInWorld(entityArrow2);
}
else if (!(playerIn.inventory.getStackInSlot(index).getItem() == null) && playerIn.inventory.getStackInSlot(index).getItem() == TheGalaxyMod.magicarrow)
{
damageItem(playerIn, magicarrow, 2);
worldIn.spawnEntityInWorld(entityArrow);
worldIn.spawnEntityInWorld(entityArrow2);
ItemStack stack2 = playerIn.inventory.getStackInSlot(index);
if(stack2.getItemDamage() > 500)
{
playerIn.inventory.setInventorySlotContents(index, null);
}
}
else if(playerIn.inventory.hasItemStack(ammo) ){
worldIn.spawnEntityInWorld(entityArrow);
worldIn.spawnEntityInWorld(entityArrow2);
removeItem(playerIn, ammo);
}
}
else if
(FastMode.fastmode == 3)
{
entityArrow.setFire(50);
int index = GetItemSlot(playerIn, magicarrow);
if (playerIn.inventory.hasItemStack(new ItemStack(TheGalaxyMod.creativequiver)))
{
entityArrow.setDamage(5000);
worldIn.spawnEntityInWorld(entityArrow);
}
else if (playerIn.inventory.hasItemStack(new ItemStack(TheGalaxyMod.magicquiver)))
{
worldIn.spawnEntityInWorld(entityArrow);
}
else if (!(playerIn.inventory.getStackInSlot(index).getItem() == null) && playerIn.inventory.getStackInSlot(index).getItem() == TheGalaxyMod.magicarrow)
{
damageItem(playerIn, magicarrow, 2);
worldIn.spawnEntityInWorld(entityArrow);
ItemStack stack2 = playerIn.inventory.getStackInSlot(index);
if(stack2.getItemDamage() > 500)
{
playerIn.inventory.setInventorySlotContents(index, null);
}
}
else if(playerIn.inventory.hasItemStack(ammo) ){
worldIn.spawnEntityInWorld(entityArrow);
removeItem(playerIn, ammo);
}
}
}
return super.onItemRightClick(stack, worldIn, playerIn, hand);
}
編輯:
找到解決方案:
多虧了@Draco18,我找到了解決方案。
我所要做的就是添加行
entityArrow.hurtResistantTime = 0
推薦答案
您需要這個:
entityHit.hurtResistantTime = 0;
注意:確切的字段名稱可能會因”我的世界”版本和Forge的內部版本號而異。
在你傷害實體之前(繞過所有其他傷害來源施加的傷害抗性計時器)或之后(如果有計時器,你的傷害被忽略,但如果它造成傷害,下一個來源不會因為計時器而被忽略)。此行需要位于箭頭類中。如果您沒有自定義Arrow類,現在是創建一個類的好時機。
不幸的是,沒有(好的)方法根據先前的傷害類型有條件地將計時器設置為0。如果您使用的是1.10或更高版本,則可以使用功能,盡管可能比較笨拙。
這篇關于我的世界鍛造如何阻止暴徒在命中后變得無懈可擊(Java)1.10.2的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,