From 39cdc0c42ff4cf77446277cbf18bc7dee0d14fc7 Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 5 Sep 2019 04:02:39 +0200 Subject: [PATCH] Lava Crystals can now set things on fire! (#1652) * Lava Crystals can now set things on fire! * Remove unecessary else --- .../bloodmagic/item/ItemLavaCrystal.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java index f99408df..f4144990 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java @@ -7,13 +7,23 @@ import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; import net.minecraft.init.MobEffects; +import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTUtil; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -73,6 +83,26 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide return new Binding(NBTUtil.getUUIDFromTag(nbt.getCompoundTag("id")), nbt.getString("name")); } + @Override + public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + pos = pos.offset(facing); + ItemStack itemstack = player.getHeldItem(hand); + + if (!player.canPlayerEdit(pos, facing, itemstack)) + return EnumActionResult.FAIL; + + if (worldIn.isAirBlock(pos) && NetworkHelper.getSoulNetwork(getBinding(player.getHeldItem(hand))).syphonAndDamage(player, SoulTicket.item(player.getHeldItem(hand), 100)).isSuccess()) { + worldIn.playSound(player, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState(), 11); + } else + return EnumActionResult.FAIL; + + if (player instanceof EntityPlayerMP) + CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP) player, pos, itemstack); + + return EnumActionResult.SUCCESS; + } + @Override public void gatherVariants(@Nonnull Int2ObjectMap variants) { variants.put(0, "type=normal");