Allowed Shaped Charges to have Anointments applied to them

Reformatted the checks, and also readded the Arcane Ash recipe
This commit is contained in:
WayofTime 2021-01-23 06:51:03 -05:00
parent e0b0f13792
commit 5fda25052d
25 changed files with 193 additions and 255 deletions

View file

@ -3,14 +3,18 @@ package wayoftime.bloodmagic.common.item.block;
import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;
import wayoftime.bloodmagic.anointment.AnointmentHolder;
import wayoftime.bloodmagic.entity.projectile.EntityShapedCharge;
import wayoftime.bloodmagic.tile.TileShapedExplosive;
public class ItemBlockShapedCharge extends BlockItem
{
@ -32,10 +36,10 @@ public class ItemBlockShapedCharge extends BlockItem
if (!worldIn.isRemote)
{
System.out.println("Attempting to spawn");
// EntitySoulSnare snare = new EntitySoulSnare(worldIn, playerIn);
EntityShapedCharge charge = new EntityShapedCharge(worldIn, this.getBlock(), playerIn);
charge.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
charge.setAnointmentHolder(AnointmentHolder.fromItemStack(stack));
worldIn.addEntity(charge);
//
// SnowballEntity snowballentity = new SnowballEntity(worldIn, playerIn);
@ -46,4 +50,22 @@ public class ItemBlockShapedCharge extends BlockItem
return new ActionResult<>(ActionResultType.SUCCESS, stack);
}
@Override
public ActionResultType tryPlace(BlockItemUseContext context)
{
ActionResultType result = super.tryPlace(context);
AnointmentHolder holder = AnointmentHolder.fromItemStack(context.getItem());
if (holder != null)
{
TileEntity tile = context.getWorld().getTileEntity(context.getPos());
if (tile instanceof TileShapedExplosive)
{
((TileShapedExplosive) tile).setAnointmentHolder(holder);
}
}
return result;
}
}