mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-10-26 14:23:57 +00:00
Use extended interface (#125)
This commit is contained in:
1 parent
a217884480
commit
4b364a93db
3 files changed
+25
-14
No files matched your search
@@ -25,19 +25,6 @@ public interface IArmorApiarist {
|
||||
*/
|
||||
boolean protectEntity(EntityLivingBase entity, ItemStack armor, String cause, boolean doProtect);
|
||||
|
||||
/**
|
||||
* Called to determine how many pieces an armor "counts for". For instance, if this returns 4, the single piece will
|
||||
* act as full protection.
|
||||
*
|
||||
* @param entity Entity being attacked
|
||||
* @param armor Armor item
|
||||
* @param cause Optional cause of attack, such as a bee effect identifier
|
||||
* @return Amount of effective protected slots
|
||||
*/
|
||||
default int getProtectionCount(EntityLivingBase entity, ItemStack armor, String cause) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the apiarist's armor acts as protection against an attack.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IArmorApiaristMulti extends IArmorApiarist {
|
||||
|
||||
/**
|
||||
* Called to determine how many pieces an armor "counts for". For instance, if this returns 4, the single piece will
|
||||
* act as full protection.
|
||||
*
|
||||
* @param entity Entity being attacked
|
||||
* @param armor Armor item
|
||||
* @param cause Optional cause of attack, such as a bee effect identifier
|
||||
* @return Amount of effective protected slots
|
||||
*/
|
||||
default int getProtectionCount(EntityLivingBase entity, ItemStack armor, String cause) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,12 @@ package forestry.apiculture;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.IArmorApiarist;
|
||||
import forestry.api.apiculture.IArmorApiaristHelper;
|
||||
import forestry.api.apiculture.IArmorApiaristMulti;
|
||||
|
||||
public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
|
||||
@@ -40,7 +42,9 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
ItemStack armorItem = entity.getEquipmentInSlot(i);
|
||||
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
|
||||
count += ((IArmorApiarist) armorItem.getItem()).getProtectionCount(entity, armorItem, cause);
|
||||
Item item = armorItem.getItem();
|
||||
if (item instanceof IArmorApiaristMulti am) count += am.getProtectionCount(entity, armorItem, cause);
|
||||
else count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user