First Checkup

This commit is contained in:
Corail31
2018-02-11 22:51:13 +01:00
parent 7f7605c089
commit d0fda72a59
86 changed files with 429 additions and 428 deletions
@@ -40,14 +40,14 @@ public interface Imbuement {
public static void onLivingDropsEvent(LivingDropsEvent event){
// Instantly disenchants an imbued weapon if it is dropped when the player dies.
for(EntityItem item : event.getDrops()){
removeImbuements(item.getEntityItem());
removeImbuements(item.getItem());
}
}
@SubscribeEvent
public static void onItemTossEvent(ItemTossEvent event){
// Instantly disenchants an imbued weapon if it is thrown on the ground.
removeImbuements(event.getEntityItem().getEntityItem());
removeImbuements(event.getEntityItem().getItem());
}
/** Removes all imbuements from the given itemstack. */
@@ -70,7 +70,7 @@ public interface Imbuement {
// Still not sure if it's better to set stacks in slots or modify the itemstack list directly, but I would
// imagine it's the former.
for(Slot slot : event.getContainer().inventorySlots){
if(slot.getStack() != null && slot.getStack().getItem() instanceof ItemEnchantedBook){
if(!slot.getStack().isEmpty() && slot.getStack().getItem() instanceof ItemEnchantedBook){
// We don't care about the level of the enchantments
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(slot.getStack());
// Removes all imbuements
@@ -104,9 +104,9 @@ public interface Imbuement {
ItemStack bow = archer.getHeldItemMainhand();
if(bow == null || !(bow.getItem() instanceof ItemBow)){
if(bow.isEmpty() || !(bow.getItem() instanceof ItemBow)){
bow = archer.getHeldItemOffhand();
if(bow == null || !(bow.getItem() instanceof ItemBow)) return;
if(bow.isEmpty() || !(bow.getItem() instanceof ItemBow)) return;
}
// Taken directly from ItemBow, so it works exactly the same as the power enchantment.