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)
//// {