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

@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.network.IPacket;
import net.minecraft.tags.BlockTags;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
@ -19,14 +20,17 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.network.NetworkHooks;
import wayoftime.bloodmagic.anointment.AnointmentHolder;
import wayoftime.bloodmagic.common.block.BlockShapedExplosive;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes;
import wayoftime.bloodmagic.tile.TileShapedExplosive;
public class EntityShapedCharge extends ThrowableEntity
{
// private static final DataParameter<Optional<BlockState>> ITEMSTACK_DATA = EntityDataManager.createKey(ProjectileItemEntity.class, DataSerializers.OPTIONAL_BLOCK_STATE);
private BlockState fallTile = BloodMagicBlocks.SHAPED_CHARGE.get().getDefaultState();
private AnointmentHolder holder;
public EntityShapedCharge(EntityType<EntityShapedCharge> p_i50159_1_, World p_i50159_2_)
{
@ -45,6 +49,11 @@ public class EntityShapedCharge extends ThrowableEntity
this.fallTile = block.getDefaultState();
}
public void setAnointmentHolder(AnointmentHolder holder)
{
this.holder = holder;
}
@Override
public void tick()
{
@ -65,6 +74,11 @@ public class EntityShapedCharge extends ThrowableEntity
if (blockstate.isAir() || blockstate.isIn(BlockTags.FIRE) || material.isLiquid() || material.isReplaceable())
{
this.getEntityWorld().setBlockState(blockpos, fallTile.with(BlockShapedExplosive.ATTACHED, faceHit));
TileEntity tile = this.getEntityWorld().getTileEntity(blockpos);
if (tile instanceof TileShapedExplosive)
{
((TileShapedExplosive) tile).setAnointmentHolder(holder);
}
this.setDead();
} else
{
@ -80,6 +94,8 @@ public class EntityShapedCharge extends ThrowableEntity
protected void writeAdditional(CompoundNBT compound)
{
compound.put("BlockState", NBTUtil.writeBlockState(this.fallTile));
if (holder != null)
compound.put("holder", holder.serialize());
// compound.putInt("Time", this.fallTime);
// compound.putBoolean("DropItem", this.shouldDropItem);
// compound.putBoolean("HurtEntities", this.hurtEntities);
@ -98,6 +114,8 @@ public class EntityShapedCharge extends ThrowableEntity
protected void readAdditional(CompoundNBT compound)
{
this.fallTile = NBTUtil.readBlockState(compound.getCompound("BlockState"));
if (compound.contains("holder"))
this.holder = AnointmentHolder.fromNBT(compound.getCompound("holder"));
// this.fallTime = compound.getInt("Time");
// if (compound.contains("HurtEntities", 99)) {
// this.hurtEntities = compound.getBoolean("HurtEntities");
@ -115,8 +133,6 @@ public class EntityShapedCharge extends ThrowableEntity
// this.tileEntityData = compound.getCompound("TileEntityData");
// }
System.out.println("Reading additional data");
if (this.fallTile.isAir())
{
this.fallTile = BloodMagicBlocks.SHAPED_CHARGE.get().getDefaultState();