Fixed NPE in Blood Altar and added some WIP blocks

Also included is a fix for the Blood Altar not receiving piped in fluids, as well as standardizing the Blood Altar's capabilities.
This commit is contained in:
WayofTime 2021-01-02 12:13:51 -05:00
parent e36f8f4e24
commit d719b85958
23 changed files with 883 additions and 6 deletions

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.TileDeforesterCharge;
public class BlockDeforesterCharge extends BlockShapedExplosive
{
public BlockDeforesterCharge(int explosionSize, Properties properties)
{
super(explosionSize, properties);
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileDeforesterCharge();
}
}

View file

@ -0,0 +1,107 @@
package wayoftime.bloodmagic.common.block;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import wayoftime.bloodmagic.tile.TileShapedExplosive;
public class BlockShapedExplosive extends Block
{
private static final VoxelShape UP = Block.makeCuboidShape(2, 0, 2, 14, 7, 14);
private static final VoxelShape DOWN = Block.makeCuboidShape(2, 9, 2, 14, 16, 14);
private static final VoxelShape NORTH = Block.makeCuboidShape(2, 2, 7, 14, 14, 16);
private static final VoxelShape SOUTH = Block.makeCuboidShape(2, 2, 0, 14, 14, 7);
private static final VoxelShape EAST = Block.makeCuboidShape(0, 2, 2, 7, 14, 14);
private static final VoxelShape WEST = Block.makeCuboidShape(16, 2, 2, 9, 14, 14);
public static final EnumProperty<Direction> ATTACHED = EnumProperty.create("attached", Direction.class);
protected final int explosionSize;
public BlockShapedExplosive(int explosionSize, Properties properties)
{
super(properties);
this.explosionSize = explosionSize;
this.setDefaultState(this.stateContainer.getBaseState().with(ATTACHED, Direction.UP));
}
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos)
{
return facing.getOpposite() == stateIn.get(ATTACHED) && !stateIn.isValidPosition(worldIn, currentPos)
? Blocks.AIR.getDefaultState()
: stateIn;
}
@Nullable
public BlockState getStateForPlacement(BlockItemUseContext context)
{
BlockState blockstate = this.getDefaultState();
IWorldReader iworldreader = context.getWorld();
BlockPos blockpos = context.getPos();
Direction[] adirection = context.getNearestLookingDirections();
for (Direction direction : adirection)
{
Direction direction1 = direction.getOpposite();
blockstate = blockstate.with(ATTACHED, direction1);
if (blockstate.isValidPosition(iworldreader, blockpos))
{
return blockstate;
}
}
return null;
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
{
builder.add(ATTACHED);
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
{
switch (state.get(ATTACHED))
{
case DOWN:
return DOWN;
case NORTH:
return NORTH;
case SOUTH:
return SOUTH;
case EAST:
return EAST;
case WEST:
return WEST;
case UP:
default:
return UP;
}
}
@Override
public boolean hasTileEntity(BlockState state)
{
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileShapedExplosive();
}
}

View file

@ -29,6 +29,7 @@ import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
import wayoftime.bloodmagic.block.enums.BloodRuneType;
import wayoftime.bloodmagic.common.block.base.BlockPillarCap;
import wayoftime.bloodmagic.common.item.BloodMagicItems;
@ -36,7 +37,6 @@ import wayoftime.bloodmagic.ritual.EnumRuneType;
import wayoftime.bloodmagic.tile.container.ContainerAlchemicalReactionChamber;
import wayoftime.bloodmagic.tile.container.ContainerAlchemyTable;
import wayoftime.bloodmagic.tile.container.ContainerSoulForge;
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
public class BloodMagicBlocks
{
@ -171,6 +171,10 @@ public class BloodMagicBlocks
{
return false;
}
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()));
//
//// private static <T extends Block> RegistryObject<T> register(String name, Supplier<? extends T> sup, Function<RegistryObject<T>, Supplier<? extends Item>> itemCreator)
//// {

View file

@ -25,6 +25,7 @@ import net.minecraftforge.fml.RegistryObject;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.block.BlockAlchemicalReactionChamber;
import wayoftime.bloodmagic.common.block.BlockDemonCrystal;
import wayoftime.bloodmagic.common.block.BlockShapedExplosive;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.common.block.base.BlockPillarCap;
@ -90,6 +91,25 @@ public class GeneratorBlockStates extends BlockStateProvider
buildCubeAllWithTextureName("solidopaquemimic");
buildCrop(BloodMagicBlocks.GROWING_DOUBT.get(), CropsBlock.AGE, 7, BloodMagic.rl("block/creeping_doubt_1"), BloodMagic.rl("block/creeping_doubt_2"), BloodMagic.rl("block/creeping_doubt_3"), BloodMagic.rl("block/creeping_doubt_4"), BloodMagic.rl("block/creeping_doubt_5"), BloodMagic.rl("block/creeping_doubt_6"), BloodMagic.rl("block/creeping_doubt_7"), BloodMagic.rl("block/creeping_doubt_8"));
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"));
}
private void buildOrientable(Block block, String name, ResourceLocation modelPath, ResourceLocation base, ResourceLocation edges, ResourceLocation centerCap, ResourceLocation binding, ResourceLocation core)
{
// ModelFile furnace_off = models().orientableWithBottom("alchemicalreactionchamber", BloodMagic.rl("block/arc_side"), BloodMagic.rl("block/arc_front"), BloodMagic.rl("block/arc_bottom"), BloodMagic.rl("block/arc_top"));
// getVariantBuilder(block).addModels(block.getDefaultState().with(BlockAlchemicalReactionChamber.FACING, Direction.NORTH).with(BlockAlchemicalReactionChamber.LIT, false), furnaceModel);
ModelFile model = models().withExistingParent(name, modelPath).texture("1", edges).texture("3", base).texture("4", centerCap).texture("5", binding).texture("6", core).texture("particle", core);
VariantBlockStateBuilder builder = getVariantBuilder(block);
builder.partialState().with(BlockShapedExplosive.ATTACHED, Direction.UP).modelForState().modelFile(model).addModel();
builder.partialState().with(BlockShapedExplosive.ATTACHED, Direction.DOWN).modelForState().modelFile(model).rotationX(180).addModel();
builder.partialState().with(BlockShapedExplosive.ATTACHED, Direction.EAST).modelForState().modelFile(model).rotationX(90).rotationY(90).addModel();
builder.partialState().with(BlockShapedExplosive.ATTACHED, Direction.WEST).modelForState().modelFile(model).rotationX(90).rotationY(270).addModel();
builder.partialState().with(BlockShapedExplosive.ATTACHED, Direction.NORTH).modelForState().modelFile(model).rotationX(90).addModel();
builder.partialState().with(BlockShapedExplosive.ATTACHED, Direction.SOUTH).modelForState().modelFile(model).rotationX(270).addModel();
}
private void buildCrop(Block block, IntegerProperty prop, int maxAge, ResourceLocation... textures)

View file

@ -9,9 +9,9 @@ import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.fml.RegistryObject;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.common.item.BloodMagicItems;
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
public class GeneratorItemModels extends ItemModelProvider
{
@ -87,6 +87,9 @@ public class GeneratorItemModels extends ItemModelProvider
registerCustomFullTexture(BloodMagicBlocks.MIMIC.get(), "solidopaquemimic");
registerCustomFullTexture(BloodMagicBlocks.ETHEREAL_MIMIC.get(), "etherealopaquemimic");
this.crop(BloodMagicBlocks.GROWING_DOUBT.get().getRegistryName().getPath(), modLoc("block/creeping_doubt_8"));
registerBlockModel(BloodMagicBlocks.SHAPED_CHARGE.get());
registerBlockModel(BloodMagicBlocks.DEFORESTER_CHARGE.get());
}
private void registerCustomFullTexture(Block block, String texturePath)

View file

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

View file

@ -96,6 +96,9 @@ public class BloodMagicItems
public static final RegistryObject<Item> NETHE_SOIL_ITEM = ITEMS.register("nether_soil", () -> new BlockItem(BloodMagicBlocks.NETHER_SOIL.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> GROWING_DOUBT_ITEM = ITEMS.register("growing_doubt", () -> new BlockItem(BloodMagicBlocks.GROWING_DOUBT.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> SHAPED_CHARGE_ITEM = ITEMS.register("shaped_charge", () -> new BlockItem(BloodMagicBlocks.SHAPED_CHARGE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> DEFORESTER_CHARGE_ITEM = ITEMS.register("deforester_charge", () -> new BlockItem(BloodMagicBlocks.DEFORESTER_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.