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

@ -37,6 +37,11 @@ public class AnointmentHolder
this(Maps.newHashMap());
}
public boolean isEmpty()
{
return anointments.isEmpty();
}
// Returns true if the anointment is applied successfully.
public boolean applyAnointment(ItemStack stack, Anointment anointment, AnointmentData data)
{

View file

@ -5,6 +5,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer;
@ -16,6 +17,7 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import wayoftime.bloodmagic.tile.TileShapedExplosive;
public class BlockShapedExplosive extends Block
@ -104,4 +106,29 @@ public class BlockShapedExplosive extends Block
{
return new TileShapedExplosive();
}
@Override
public void onBlockHarvested(World world, BlockPos blockPos, BlockState blockState, PlayerEntity player)
{
TileShapedExplosive tile = (TileShapedExplosive) world.getTileEntity(blockPos);
if (tile != null && !world.isRemote)
tile.dropSelf();
super.onBlockHarvested(world, blockPos, blockState, player);
}
// @Override
// public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
// {
// if (!state.isIn(newState.getBlock()))
// {
// TileEntity tileentity = worldIn.getTileEntity(pos);
// if (tileentity instanceof TileShapedExplosive)
// {
// ((TileShapedExplosive) tileentity).dropSelf();
// }
//
// super.onReplaced(state, worldIn, pos, newState, isMoving);
// }
// }
}

View file

@ -132,8 +132,8 @@ public class GeneratorLootTable extends LootTableProvider
registerCropDropLootTable(BloodMagicBlocks.GROWING_DOUBT.get(), BloodMagicItems.WEAK_BLOOD_SHARD.get());
registerDropSelfLootTable(BloodMagicBlocks.SHAPED_CHARGE.get());
registerDropSelfLootTable(BloodMagicBlocks.DEFORESTER_CHARGE.get());
registerNoDropLootTable(BloodMagicBlocks.SHAPED_CHARGE.get());
registerNoDropLootTable(BloodMagicBlocks.DEFORESTER_CHARGE.get());
}
private void registerNoDropLootTable(Block block)

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;
}
}

View file

@ -59,6 +59,7 @@ public class AlchemyTableRecipeProvider implements ISubRecipeProvider
}
{
AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.ARCANE_ASHES.get()), 500, 200, 1).addIngredient(Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE)).addIngredient(Ingredient.fromTag(Tags.Items.DYES_WHITE)).addIngredient(Ingredient.fromTag(Tags.Items.GUNPOWDER)).addIngredient(Ingredient.fromTag(ItemTags.COALS)).build(consumer, BloodMagic.rl(basePath + "arcane_ash"));
AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.REAGENT_AIR.get()), 2000, 200, 2).addIngredient(Ingredient.fromItems(Items.GHAST_TEAR)).addIngredient(Ingredient.fromTag(Tags.Items.FEATHERS)).addIngredient(Ingredient.fromTag(Tags.Items.FEATHERS)).build(consumer, BloodMagic.rl(basePath + "reagent_air"));
AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.REAGENT_WATER.get()), 300, 200, 1).addIngredient(Ingredient.fromItems(Items.SUGAR)).addIngredient(Ingredient.fromItems(Items.WATER_BUCKET)).addIngredient(Ingredient.fromItems(Items.WATER_BUCKET)).build(consumer, BloodMagic.rl(basePath + "reagent_water"));
AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(BloodMagicItems.REAGENT_LAVA.get()), 1000, 200, 1).addIngredient(Ingredient.fromItems(Items.LAVA_BUCKET)).addIngredient(Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE)).addIngredient(Ingredient.fromTag(Tags.Items.COBBLESTONE)).addIngredient(Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_COAL)).build(consumer, BloodMagic.rl(basePath + "reagent_lava"));

View file

@ -9,10 +9,13 @@ import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ItemTags;
import net.minecraftforge.common.Tags;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.anointment.AnointmentData;
import wayoftime.bloodmagic.anointment.AnointmentHolder;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.common.data.recipe.builder.TartaricForgeRecipeBuilder;
import wayoftime.bloodmagic.common.item.BloodMagicItems;
import wayoftime.bloodmagic.common.tags.BloodMagicTags;
import wayoftime.bloodmagic.core.AnointmentRegistrar;
public class TartaricForgeRecipeProvider implements ISubRecipeProvider
{
@ -47,19 +50,26 @@ public class TartaricForgeRecipeProvider implements ISubRecipeProvider
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicBlocks.SHAPED_CHARGE.get(), 8), 10, 0.5, Ingredient.fromTag(Tags.Items.COBBLESTONE), Ingredient.fromItems(Items.CHARCOAL), Ingredient.fromTag(Tags.Items.SAND), Ingredient.fromTag(Tags.Items.STONE)).build(consumer, BloodMagic.rl(basePath + "shaped_charge"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicBlocks.DEFORESTER_CHARGE.get(), 8), 10, 0.5, Ingredient.fromTag(Tags.Items.COBBLESTONE), Ingredient.fromItems(Items.CHARCOAL), Ingredient.fromTag(ItemTags.LOGS), Ingredient.fromTag(ItemTags.PLANKS)).build(consumer, BloodMagic.rl(basePath + "deforester_charge"));
ItemStack stack = new ItemStack(BloodMagicBlocks.DEFORESTER_CHARGE.get());
AnointmentHolder smeltingHolder = new AnointmentHolder();
smeltingHolder.applyAnointment(stack, AnointmentRegistrar.ANOINTMENT_SMELTING.get(), new AnointmentData(1, 1, 1));
smeltingHolder.toItemStack(stack);
TartaricForgeRecipeBuilder.tartaricForge(stack, 60, 1, Ingredient.fromItems(BloodMagicItems.DEFORESTER_CHARGE_ITEM.get())).build(consumer, BloodMagic.rl(basePath + "deforester_charge_smelting"));
// Changed Recipes
{
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.ARCANE_ASHES.get()), 0, 0, Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.DYES_WHITE), Ingredient.fromTag(Tags.Items.GUNPOWDER), Ingredient.fromTag(ItemTags.COALS)).build(consumer, BloodMagic.rl(basePath + "arcaneashes"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_AIR.get()), 128, 20, Ingredient.fromItems(Items.GHAST_TEAR), Ingredient.fromTag(Tags.Items.FEATHERS), Ingredient.fromTag(Tags.Items.FEATHERS)).build(consumer, BloodMagic.rl(basePath + "reagent_air"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_WATER.get()), 10, 3, Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.WATER_BUCKET), Ingredient.fromItems(Items.WATER_BUCKET)).build(consumer, BloodMagic.rl(basePath + "reagent_water"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_LAVA.get()), 32, 10, Ingredient.fromItems(Items.LAVA_BUCKET), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.COBBLESTONE), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_COAL)).build(consumer, BloodMagic.rl(basePath + "reagent_lava"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_VOID.get()), 64, 10, Ingredient.fromItems(Items.BUCKET), Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.GUNPOWDER)).build(consumer, BloodMagic.rl(basePath + "reagent_void"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_GROWTH.get()), 128, 20, Ingredient.fromTag(ItemTags.SAPLINGS), Ingredient.fromTag(ItemTags.SAPLINGS), Ingredient.fromItems(Items.SUGAR_CANE), Ingredient.fromItems(Items.SUGAR)).build(consumer, BloodMagic.rl(basePath + "reagent_growth"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_MAGNETISM.get()), 600, 10, Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_IRON)).build(consumer, BloodMagic.rl(basePath + "reagent_magnetism"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_FAST_MINER.get()), 128, 20, Ingredient.fromItems(Items.IRON_PICKAXE), Ingredient.fromItems(Items.IRON_AXE), Ingredient.fromItems(Items.IRON_SHOVEL), Ingredient.fromTag(Tags.Items.GUNPOWDER)).build(consumer, BloodMagic.rl(basePath + "reagent_fastminer"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_BLOOD_LIGHT.get()), 300, 10, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromItems(Items.TORCH), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE)).build(consumer, BloodMagic.rl(basePath + "reagent_blood_light"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_SIGHT.get()), 64, 0, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromTag(Tags.Items.GLASS), Ingredient.fromTag(Tags.Items.GLASS), Ingredient.fromItems(BloodMagicItems.DIVINATION_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "reagent_sight"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_BINDING.get()), 400, 10, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.GUNPOWDER), Ingredient.fromTag(Tags.Items.NUGGETS_GOLD)).build(consumer, BloodMagic.rl(basePath + "reagent_binding"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_AIR.get()), 128, 20, Ingredient.fromItems(Items.GHAST_TEAR), Ingredient.fromTag(Tags.Items.FEATHERS), Ingredient.fromTag(Tags.Items.FEATHERS)).build(consumer, BloodMagic.rl(basePath + "reagent_air"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_WATER.get()), 10, 3, Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.WATER_BUCKET), Ingredient.fromItems(Items.WATER_BUCKET)).build(consumer, BloodMagic.rl(basePath + "reagent_water"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_LAVA.get()), 32, 10, Ingredient.fromItems(Items.LAVA_BUCKET), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.COBBLESTONE), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_COAL)).build(consumer, BloodMagic.rl(basePath + "reagent_lava"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_VOID.get()), 64, 10, Ingredient.fromItems(Items.BUCKET), Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.GUNPOWDER)).build(consumer, BloodMagic.rl(basePath + "reagent_void"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_GROWTH.get()), 128, 20, Ingredient.fromTag(ItemTags.SAPLINGS), Ingredient.fromTag(ItemTags.SAPLINGS), Ingredient.fromItems(Items.SUGAR_CANE), Ingredient.fromItems(Items.SUGAR)).build(consumer, BloodMagic.rl(basePath + "reagent_growth"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_MAGNETISM.get()), 600, 10, Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_IRON)).build(consumer, BloodMagic.rl(basePath + "reagent_magnetism"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_FAST_MINER.get()), 128, 20, Ingredient.fromItems(Items.IRON_PICKAXE), Ingredient.fromItems(Items.IRON_AXE), Ingredient.fromItems(Items.IRON_SHOVEL), Ingredient.fromTag(Tags.Items.GUNPOWDER)).build(consumer, BloodMagic.rl(basePath + "reagent_fastminer"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_BLOOD_LIGHT.get()), 300, 10, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromItems(Items.TORCH), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE)).build(consumer, BloodMagic.rl(basePath + "reagent_blood_light"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_SIGHT.get()), 64, 0, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromTag(Tags.Items.GLASS), Ingredient.fromTag(Tags.Items.GLASS), Ingredient.fromItems(BloodMagicItems.DIVINATION_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "reagent_sight"));
// TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_BINDING.get()), 400, 10, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.GUNPOWDER), Ingredient.fromTag(Tags.Items.NUGGETS_GOLD)).build(consumer, BloodMagic.rl(basePath + "reagent_binding"));
}
{

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();

View file

@ -29,9 +29,8 @@ import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.registries.ObjectHolder;
import wayoftime.bloodmagic.common.block.BlockShapedExplosive;
import wayoftime.bloodmagic.tile.base.TileTicking;
public class TileDeforesterCharge extends TileTicking
public class TileDeforesterCharge extends TileShapedExplosive
{
@ObjectHolder("bloodmagic:deforester_charge")
public static TileEntityType<TileDeforesterCharge> TYPE;
@ -44,8 +43,8 @@ public class TileDeforesterCharge extends TileTicking
// private boolean cached = false;
public double internalCounter = 0;
public int explosionRadius;
public int explosionDepth;
// public int explosionRadius;
// public int explosionDepth;
public int currentLogs = 0;
@ -53,9 +52,9 @@ public class TileDeforesterCharge extends TileTicking
public TileDeforesterCharge(TileEntityType<?> type, int explosionRadius, int explosionDepth)
{
super(type);
this.explosionRadius = explosionRadius;
this.explosionDepth = explosionDepth;
super(type, explosionRadius, explosionDepth);
// this.explosionRadius = explosionRadius;
// this.explosionDepth = explosionDepth;
}
public TileDeforesterCharge()
@ -172,6 +171,7 @@ public class TileDeforesterCharge extends TileTicking
if (internalCounter == 100)
{
ItemStack toolStack = this.getHarvestingTool();
world.playSound((PlayerEntity) null, this.getPos().getX() + 0.5, this.getPos().getY() + 0.5, this.getPos().getZ() + 0.5, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
int numParticles = explosionDepth * (explosionRadius + 1);
@ -193,7 +193,7 @@ public class TileDeforesterCharge extends TileTicking
if (this.world instanceof ServerWorld)
{
TileEntity tileentity = blockstate.hasTileEntity() ? this.world.getTileEntity(blockPos) : null;
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(blockPos)).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity);
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(blockPos)).withParameter(LootParameters.TOOL, toolStack).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity);
// if (this.mode == Explosion.Mode.DESTROY) {
// lootcontext$builder.withParameter(LootParameters.EXPLOSION_RADIUS, this.size);
// }

View file

@ -8,7 +8,9 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.nbt.CompoundNBT;
@ -22,6 +24,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.registries.ObjectHolder;
import wayoftime.bloodmagic.anointment.AnointmentHolder;
import wayoftime.bloodmagic.common.block.BlockShapedExplosive;
import wayoftime.bloodmagic.tile.base.TileTicking;
@ -34,6 +37,8 @@ public class TileShapedExplosive extends TileTicking
public int explosionRadius;
public int explosionDepth;
public AnointmentHolder anointmentHolder = new AnointmentHolder();
public TileShapedExplosive(TileEntityType<?> type, int explosionRadius, int explosionDepth)
{
super(type);
@ -109,6 +114,8 @@ public class TileShapedExplosive extends TileTicking
break;
}
ItemStack toolStack = this.getHarvestingTool();
ObjectArrayList<Pair<ItemStack, BlockPos>> objectarraylist = new ObjectArrayList<>();
BlockPos initialPos = getPos();
@ -130,7 +137,7 @@ public class TileShapedExplosive extends TileTicking
{
TileEntity tileentity = blockstate.hasTileEntity() ? this.world.getTileEntity(blockpos)
: null;
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(blockpos)).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity);
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withRandom(this.world.rand).withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(blockpos)).withParameter(LootParameters.TOOL, toolStack).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity);
// if (this.mode == Explosion.Mode.DESTROY) {
// lootcontext$builder.withParameter(LootParameters.EXPLOSION_RADIUS, this.size);
// }
@ -180,16 +187,50 @@ public class TileShapedExplosive extends TileTicking
dropPositionArray.add(Pair.of(stack, pos));
}
public ItemStack getHarvestingTool()
{
ItemStack stack = new ItemStack(Items.DIAMOND_PICKAXE);
if (anointmentHolder != null)
anointmentHolder.toItemStack(stack);
return stack;
}
@Override
public void deserialize(CompoundNBT tag)
{
internalCounter = tag.getDouble("internalCounter");
if (tag.contains("holder"))
{
anointmentHolder = AnointmentHolder.fromNBT(tag.getCompound("holder"));
}
}
@Override
public CompoundNBT serialize(CompoundNBT tag)
{
tag.putDouble("internalCounter", internalCounter);
if (anointmentHolder != null)
{
tag.put("holder", anointmentHolder.serialize());
}
return tag;
}
public void setAnointmentHolder(AnointmentHolder holder)
{
this.anointmentHolder = holder;
}
public void dropSelf()
{
ItemStack stack = new ItemStack(getBlockState().getBlock());
if (anointmentHolder != null && !anointmentHolder.isEmpty())
{
anointmentHolder.toItemStack(stack);
}
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), stack);
}
}