Fixed the Blood Altar not inputting Fluids properly.

Also added the Vein Mining charge.
This commit is contained in:
WayofTime 2021-01-23 17:54:32 -05:00
parent 4749eecccf
commit 2c3af715d7
23 changed files with 346 additions and 9 deletions

View file

@ -78,6 +78,7 @@ import wayoftime.bloodmagic.tile.TileMasterRitualStone;
import wayoftime.bloodmagic.tile.TileMimic;
import wayoftime.bloodmagic.tile.TileShapedExplosive;
import wayoftime.bloodmagic.tile.TileSoulForge;
import wayoftime.bloodmagic.tile.TileVeinMineCharge;
import wayoftime.bloodmagic.util.handler.event.GenericHandler;
import wayoftime.bloodmagic.util.handler.event.WillHandler;
@ -201,6 +202,8 @@ public class BloodMagic
event.getRegistry().register(TileEntityType.Builder.create(TileMimic::new, BloodMagicBlocks.MIMIC.get(), BloodMagicBlocks.ETHEREAL_MIMIC.get()).build(null).setRegistryName("mimic"));
event.getRegistry().register(TileEntityType.Builder.create(TileShapedExplosive::new, BloodMagicBlocks.SHAPED_CHARGE.get()).build(null).setRegistryName("shaped_explosive"));
event.getRegistry().register(TileEntityType.Builder.create(TileDeforesterCharge::new, BloodMagicBlocks.DEFORESTER_CHARGE.get()).build(null).setRegistryName("deforester_charge"));
event.getRegistry().register(TileEntityType.Builder.create(TileVeinMineCharge::new, BloodMagicBlocks.VEINMINE_CHARGE.get()).build(null).setRegistryName("veinmine_charge"));
}
@SubscribeEvent

View file

@ -237,6 +237,10 @@ public class BloodAltar// implements IFluidHandler
//
// System.out.println("There are currently " + altarRecipes.size() + " Altar Recipes loaded.");
//
// this.fluidInput = new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), 1000);
// System.out.println(this.fluidOutput.getAmount());
World world = tileAltar.getWorld();
BlockPos pos = tileAltar.getPos();
@ -671,7 +675,7 @@ public class BloodAltar// implements IFluidHandler
if (!doFill)
{
if (fluidInput == null)
if (fluidInput == null || fluidInput.isEmpty())
{
return Math.min(bufferCapacity, resource.getAmount());
}

View file

@ -0,0 +1,20 @@
package wayoftime.bloodmagic.common.block;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
import wayoftime.bloodmagic.tile.TileVeinMineCharge;
public class BlockVeinMineCharge extends BlockShapedExplosive
{
public BlockVeinMineCharge(int explosionSize, Properties properties)
{
super(explosionSize, properties);
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileVeinMineCharge();
}
}

View file

@ -176,6 +176,7 @@ public class BloodMagicBlocks
public static final RegistryObject<Block> SHAPED_CHARGE = BLOCKS.register("shaped_charge", () -> new BlockShapedExplosive(3, Properties.create(Material.IRON).hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestTool(ToolType.PICKAXE).harvestLevel(1).setRequiresTool()));
public static final RegistryObject<Block> DEFORESTER_CHARGE = BLOCKS.register("deforester_charge", () -> new BlockDeforesterCharge(3, Properties.create(Material.IRON).hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestTool(ToolType.PICKAXE).harvestLevel(1).setRequiresTool()));
public static final RegistryObject<Block> VEINMINE_CHARGE = BLOCKS.register("veinmine_charge", () -> new BlockVeinMineCharge(3, Properties.create(Material.IRON).hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestTool(ToolType.PICKAXE).harvestLevel(1).setRequiresTool()));
//
//// private static <T extends Block> RegistryObject<T> register(String name, Supplier<? extends T> sup, Function<RegistryObject<T>, Supplier<? extends Item>> itemCreator)

View file

@ -94,6 +94,7 @@ public class GeneratorBlockStates extends BlockStateProvider
buildOrientable(BloodMagicBlocks.SHAPED_CHARGE.get(), "shaped_charge", modLoc("block/sub/shaped_charge"), modLoc("block/dungeon/dungeon_stone"), modLoc("block/dungeon/dungeon_tile"), modLoc("block/blankrune"), modLoc("block/largebloodstonebrick"), modLoc("models/defaultcrystal"));
buildOrientable(BloodMagicBlocks.DEFORESTER_CHARGE.get(), "deforester_charge", modLoc("block/sub/shaped_charge"), new ResourceLocation("block/oak_log_top"), new ResourceLocation("block/oak_log_top"), modLoc("block/blankrune"), new ResourceLocation("block/oak_planks"), modLoc("models/defaultcrystal"));
buildOrientable(BloodMagicBlocks.VEINMINE_CHARGE.get(), "veinmine_charge", modLoc("block/sub/shaped_charge"), new ResourceLocation("block/sandstone_bottom"), new ResourceLocation("block/sandstone_bottom"), modLoc("block/blankrune"), new ResourceLocation("block/sand"), modLoc("models/defaultcrystal"));
}
private void buildOrientable(Block block, String name, ResourceLocation modelPath, ResourceLocation base, ResourceLocation edges, ResourceLocation centerCap, ResourceLocation binding, ResourceLocation core)

View file

@ -91,6 +91,7 @@ public class GeneratorItemModels extends ItemModelProvider
registerBlockModel(BloodMagicBlocks.SHAPED_CHARGE.get());
registerBlockModel(BloodMagicBlocks.DEFORESTER_CHARGE.get());
registerBlockModel(BloodMagicBlocks.VEINMINE_CHARGE.get());
registerMultiLayerItem(BloodMagicItems.SLATE_VIAL.get(), modLoc("item/alchemic_vial"), modLoc("item/alchemic_ribbon"));
registerMultiLayerItem(BloodMagicItems.MELEE_DAMAGE_ANOINTMENT.get(), modLoc("item/alchemic_vial"), modLoc("item/alchemic_liquid"), modLoc("item/alchemic_ribbon"));

View file

@ -171,7 +171,7 @@ public class GeneratorLanguage extends LanguageProvider
add("ritual.bloodmagic.crystalHarvestRitual", "Crack of the Fractured Crystal");
add("ritual.bloodmagic.forsakenSoulRitual", "Gathering of the Forsaken Souls");
add("ritual.bloodmagic.crystalSplitRitual", "Resonance of the Faceted Crystal");
add("ritual.bloodmagic.ellipsoidRitual", "Focus of the Ellipsoid");
add("ritual.bloodmagic.ellipseRitual", "Focus of the Ellipsoid");
add("ritual.bloodmagic.cobblestoneRitual", "Le Vulcanos Frigius");
add("ritual.bloodmagic.placerRitual", "The Filler");
@ -451,6 +451,7 @@ public class GeneratorLanguage extends LanguageProvider
addBlock(BloodMagicBlocks.SHAPED_CHARGE, "Shaped Charge");
addBlock(BloodMagicBlocks.DEFORESTER_CHARGE, "Deforester Charge");
addBlock(BloodMagicBlocks.VEINMINE_CHARGE, "Vein Charge");
// Item names
addItem(BloodMagicItems.WEAK_BLOOD_ORB, "Weak Blood Orb");

View file

@ -134,6 +134,7 @@ public class GeneratorLootTable extends LootTableProvider
registerNoDropLootTable(BloodMagicBlocks.SHAPED_CHARGE.get());
registerNoDropLootTable(BloodMagicBlocks.DEFORESTER_CHARGE.get());
registerNoDropLootTable(BloodMagicBlocks.VEINMINE_CHARGE.get());
}
private void registerNoDropLootTable(Block block)

View file

@ -101,6 +101,7 @@ public class BloodMagicItems
public static final RegistryObject<Item> SHAPED_CHARGE_ITEM = ITEMS.register("shaped_charge", () -> new ItemBlockShapedCharge(BloodMagicBlocks.SHAPED_CHARGE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> DEFORESTER_CHARGE_ITEM = ITEMS.register("deforester_charge", () -> new ItemBlockShapedCharge(BloodMagicBlocks.DEFORESTER_CHARGE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> VEINMINE_CHARGE_ITEM = ITEMS.register("veinmine_charge", () -> new ItemBlockShapedCharge(BloodMagicBlocks.VEINMINE_CHARGE.get(), new Item.Properties().group(BloodMagic.TAB)));
// TODO: Need to rework the above instantiations for the ItemBlocks so that it's
// done with the Blocks.

View file

@ -49,6 +49,7 @@ 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"));
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicBlocks.VEINMINE_CHARGE.get(), 8), 10, 0.5, Ingredient.fromTag(Tags.Items.COBBLESTONE), Ingredient.fromItems(Items.CHARCOAL), Ingredient.fromTag(Tags.Items.SANDSTONE), Ingredient.fromTag(Tags.Items.SAND)).build(consumer, BloodMagic.rl(basePath + "vein_charge"));
ItemStack stack = new ItemStack(BloodMagicBlocks.DEFORESTER_CHARGE.get());
AnointmentHolder smeltingHolder = new AnointmentHolder();

View file

@ -42,8 +42,6 @@ public class TileDeforesterCharge extends TileExplosiveCharge
// private boolean cached = false;
public double internalCounter = 0;
// public int explosionRadius;
// public int explosionDepth;
public int currentLogs = 0;

View file

@ -15,7 +15,6 @@ import wayoftime.bloodmagic.tile.base.TileTicking;
public class TileExplosiveCharge extends TileTicking
{
public AnointmentHolder anointmentHolder = new AnointmentHolder();
public TileExplosiveCharge(TileEntityType<?> type)

View file

@ -26,7 +26,7 @@ import wayoftime.bloodmagic.common.block.BlockShapedExplosive;
public class TileShapedExplosive extends TileExplosiveCharge
{
@ObjectHolder("bloodmagic:shaped_explosive")
public static TileEntityType<TileExplosiveCharge> TYPE;
public static TileEntityType<TileShapedExplosive> TYPE;
public double internalCounter = 0;
public int explosionRadius;

View file

@ -0,0 +1,225 @@
package wayoftime.bloodmagic.tile;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import com.mojang.datafixers.util.Pair;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
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.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
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.common.block.BlockShapedExplosive;
public class TileVeinMineCharge extends TileExplosiveCharge
{
@ObjectHolder("bloodmagic:veinmine_charge")
public static TileEntityType<TileVeinMineCharge> TYPE;
private Map<BlockPos, Boolean> veinPartsMap;
private List<BlockPos> veinPartsCache;
private boolean finishedAnalysis;
public double internalCounter = 0;
public int currentBlocks = 0;
public int maxBlocks = 128;
public TileVeinMineCharge(TileEntityType<?> type, int maxBlocks)
{
super(type);
this.maxBlocks = maxBlocks;
}
public TileVeinMineCharge()
{
this(TYPE, 64 * 3);
}
@Override
public void onUpdate()
{
if (world.isRemote)
{
return;
}
// System.out.println("Counter: " + internalCounter);
Direction explosiveDirection = this.getBlockState().get(BlockShapedExplosive.ATTACHED).getOpposite();
BlockState attachedState = world.getBlockState(pos.offset(explosiveDirection));
Block attachedBlock = attachedState.getBlock();
// if (!BlockTags.LOGS.contains(attachedState.getBlock()) && !BlockTags.LEAVES.contains(attachedState.getBlock()))
// {
// return;
// }
if (veinPartsMap == null)
{
veinPartsMap = new HashMap<BlockPos, Boolean>();
veinPartsMap.put(pos.offset(explosiveDirection), false);
veinPartsCache = new LinkedList<BlockPos>();
veinPartsCache.add(pos.offset(explosiveDirection));
internalCounter = 0;
// veinPartsMap.add(pos.offset(explosiveDirection));
}
boolean foundNew = false;
List<BlockPos> newPositions = new LinkedList<BlockPos>();
for (BlockPos currentPos : veinPartsCache)
{
if (!veinPartsMap.getOrDefault(currentPos, false)) // If the BlockPos wasn't checked yet
{
// BlockPos currentPos = entry.getKey();
for (Direction dir : Direction.values())
{
BlockPos checkPos = currentPos.offset(dir);
if (veinPartsMap.containsKey(checkPos))
{
continue;
}
BlockState checkState = world.getBlockState(checkPos);
boolean isTree = false;
if (currentBlocks >= maxBlocks)
{
continue;
}
if (attachedBlock.equals(checkState.getBlock()))
{
currentBlocks++;
isTree = true;
}
if (isTree)
{
veinPartsMap.put(checkPos, false);
newPositions.add(checkPos);
foundNew = true;
}
}
veinPartsMap.put(currentPos, true);
if (currentBlocks >= maxBlocks)
{
finishedAnalysis = true;
break;
}
}
}
veinPartsCache.addAll(newPositions);
// System.out.println("Found blocks: " + veinPartsMap.size());
if (foundNew)
{
return;
}
internalCounter++;
if (internalCounter == 20)
{
// worldIn.playSound((PlayerEntity)null, tntentity.getPosX(), tntentity.getPosY(), tntentity.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.playSound((PlayerEntity) null, this.getPos().getX() + 0.5, this.getPos().getY() + 0.5, this.getPos().getZ() + 0.5, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
((ServerWorld) this.world).spawnParticle(ParticleTypes.FLAME, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5, 0.02, 0.03, 0.02, 0);
}
if (internalCounter == 30)
{
world.playSound((PlayerEntity) null, this.getPos().getX() + 0.5, this.getPos().getY() + 0.5, this.getPos().getZ() + 0.5, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
if (internalCounter < 30)
{
return;
}
if (world.rand.nextDouble() < 0.3)
{
((ServerWorld) this.world).spawnParticle(ParticleTypes.SMOKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 1, 0.0D, 0.0D, 0.0D, 0);
}
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 = 10;
((ServerWorld) this.world).spawnParticle(ParticleTypes.EXPLOSION, pos.getX() + 0.5 + explosiveDirection.getXOffset(), pos.getY() + 0.5 + explosiveDirection.getYOffset(), pos.getZ() + 0.5 + explosiveDirection.getZOffset(), numParticles, 1.0D, 1.0D, 1.0D, 0);
ObjectArrayList<Pair<ItemStack, BlockPos>> objectarraylist = new ObjectArrayList<>();
for (BlockPos blockPos : veinPartsCache)
{
// BlockPos blockpos = initialPos.offset(explosiveDirection, i).offset(sweepDir1, j).offset(sweepDir2, k);
BlockState blockstate = this.world.getBlockState(blockPos);
Block block = blockstate.getBlock();
if (!blockstate.isAir(this.world, blockPos))
{
BlockPos blockpos1 = blockPos.toImmutable();
// this.world.getProfiler().startSection("explosion_blocks");
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, toolStack).withNullableParameter(LootParameters.BLOCK_ENTITY, tileentity);
// if (this.mode == Explosion.Mode.DESTROY) {
// lootcontext$builder.withParameter(LootParameters.EXPLOSION_RADIUS, this.size);
// }
blockstate.getDrops(lootcontext$builder).forEach((stack) -> {
handleExplosionDrops(objectarraylist, stack, blockpos1);
});
world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), 3);
// blockstate.onBlockExploded(this.world, blockpos, null);
// this.world.getProfiler().endSection();
}
}
}
for (Pair<ItemStack, BlockPos> pair : objectarraylist)
{
Block.spawnAsEntity(this.world, pair.getSecond(), pair.getFirst());
}
world.setBlockState(getPos(), Blocks.AIR.getDefaultState());
}
}
@Override
public void deserialize(CompoundNBT tag)
{
internalCounter = tag.getDouble("internalCounter");
}
@Override
public CompoundNBT serialize(CompoundNBT tag)
{
tag.putDouble("internalCounter", internalCounter);
return tag;
}
}

View file

@ -18,7 +18,7 @@
"north": {"uv": [0, 6, 10, 8], "texture": "#3"},
"east": {"uv": [0, 6, 10, 8], "texture": "#3"},
"south": {"uv": [0, 6, 10, 8], "texture": "#3"},
"west": {"uv": [8, 14, 18, 16], "texture": "#3"},
"west": {"uv": [6, 14, 16, 16], "texture": "#3"},
"up": {"uv": [10, 10, 0, 0], "texture": "#3"},
"down": {"uv": [10, 0, 0, 10], "texture": "#3"}
}