Add metadata support to block/item list config options, fixes #353
This commit is contained in:
@@ -21,6 +21,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
@@ -65,11 +66,14 @@ public class Divination extends Spell {
|
||||
|
||||
List<BlockPos> sphere = WizardryUtilities.getBlockSphere(caster.getPosition(), range);
|
||||
|
||||
sphere.removeIf(b -> !(world.getBlockState(b).getBlock() instanceof BlockOre
|
||||
|| world.getBlockState(b).getBlock() instanceof BlockRedstoneOre
|
||||
|| world.getBlockState(b).getBlock() instanceof BlockCrystalOre
|
||||
|| Arrays.asList(Wizardry.settings.divinationOreWhitelist)
|
||||
.contains(world.getBlockState(b).getBlock().getRegistryName())));
|
||||
sphere.removeIf(b -> {
|
||||
Block block = world.getBlockState(b).getBlock();
|
||||
return !(block instanceof BlockOre
|
||||
|| block instanceof BlockRedstoneOre
|
||||
|| block instanceof BlockCrystalOre
|
||||
|| Arrays.asList(Wizardry.settings.divinationOreWhitelist)
|
||||
.contains(Pair.of(block.getRegistryName(), block.getMetaFromState(world.getBlockState(b)))));
|
||||
});
|
||||
|
||||
Strength strength = Strength.NOTHING;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class FlamingWeapon extends Spell {
|
||||
|
||||
for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){
|
||||
|
||||
if((ImbueWeapon.isSword(stack.getItem()) || ImbueWeapon.isBow(stack.getItem()))
|
||||
if((ImbueWeapon.isSword(stack) || ImbueWeapon.isBow(stack))
|
||||
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.flaming_weapon)){
|
||||
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
|
||||
// weird float processing doesn't incorrectly round it down.
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FreezingWeapon extends Spell {
|
||||
|
||||
for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){
|
||||
|
||||
if((ImbueWeapon.isSword(stack.getItem()) || ImbueWeapon.isBow(stack.getItem()))
|
||||
if((ImbueWeapon.isSword(stack) || ImbueWeapon.isBow(stack))
|
||||
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.freezing_weapon)){
|
||||
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
|
||||
// weird float processing doesn't incorrectly round it down.
|
||||
|
||||
@@ -11,9 +11,13 @@ import electroblob.wizardry.util.SpellModifiers;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -32,7 +36,7 @@ public class ImbueWeapon extends Spell {
|
||||
|
||||
for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){
|
||||
|
||||
if(isSword(stack.getItem())
|
||||
if(isSword(stack)
|
||||
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_sword)
|
||||
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_sword) <= 0){
|
||||
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
|
||||
@@ -44,7 +48,7 @@ public class ImbueWeapon extends Spell {
|
||||
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_sword,
|
||||
(int)(getProperty(EFFECT_DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)));
|
||||
|
||||
}else if(isBow(stack.getItem())
|
||||
}else if(isBow(stack)
|
||||
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_bow)
|
||||
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_bow) <= 0){
|
||||
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
|
||||
@@ -77,13 +81,13 @@ public class ImbueWeapon extends Spell {
|
||||
}
|
||||
|
||||
/** Returns true if the given item counts as a sword, i.e. it extends {@link ItemSword} or is in the whitelist. */
|
||||
public static boolean isSword(Item item){
|
||||
return item instanceof ItemSword || Arrays.asList(Wizardry.settings.swordItemWhitelist).contains(item.getRegistryName());
|
||||
public static boolean isSword(ItemStack stack){
|
||||
return stack.getItem() instanceof ItemSword || Arrays.asList(Wizardry.settings.swordItemWhitelist).contains(Pair.of(stack.getItem().getRegistryName(), stack.getMetadata()));
|
||||
}
|
||||
|
||||
/** Returns true if the given item counts as a bow, i.e. it extends {@link ItemBow} or is in the whitelist. */
|
||||
public static boolean isBow(Item item){
|
||||
return item instanceof ItemBow || Arrays.asList(Wizardry.settings.bowItemWhitelist).contains(item.getRegistryName());
|
||||
public static boolean isBow(ItemStack stack){
|
||||
return stack.getItem() instanceof ItemBow || Arrays.asList(Wizardry.settings.bowItemWhitelist).contains(Pair.of(stack.getItem().getRegistryName(), stack.getMetadata()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -37,9 +38,9 @@ public class PocketFurnace extends Spell {
|
||||
|
||||
result = FurnaceRecipes.instance().getSmeltingResult(stack);
|
||||
|
||||
if(!result.isEmpty() && !(result.getItem() instanceof ItemTool) && !(result.getItem() instanceof ItemSword)
|
||||
&& !(result.getItem() instanceof ItemArmor)
|
||||
&& !Arrays.asList(Wizardry.settings.pocketFurnaceItemBlacklist).contains(result.getItem().getRegistryName())){
|
||||
if(!result.isEmpty() && !(stack.getItem() instanceof ItemTool) && !(stack.getItem() instanceof ItemSword)
|
||||
&& !(stack.getItem() instanceof ItemArmor)
|
||||
&& !Arrays.asList(Wizardry.settings.pocketFurnaceItemBlacklist).contains(Pair.of(stack.getItem().getRegistryName(), stack.getMetadata()))){
|
||||
|
||||
if(stack.getCount() <= usesLeft){
|
||||
ItemStack stack2 = new ItemStack(result.getItem(), stack.getCount(), result.getItemDamage());
|
||||
|
||||
Reference in New Issue
Block a user