Readded the Alchemy Table
Finished adding the Alchemy Table with JEI compatability. Also added recipes for the ARC block and the Alchemy Table.
This commit is contained in:
parent
37c5e807b0
commit
bf6250272c
41 changed files with 1915 additions and 29 deletions
|
@ -9,6 +9,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.arc.ItemARCToolBase;
|
||||
import wayoftime.bloodmagic.common.item.block.ItemBlockAlchemyTable;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilAir;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilBloodLight;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilDivination;
|
||||
|
@ -71,6 +72,7 @@ public class BloodMagicItems
|
|||
public static final RegistryObject<Item> MASTER_RITUAL_STONE_ITEM = ITEMS.register("masterritualstone", () -> new BlockItem(BloodMagicBlocks.MASTER_RITUAL_STONE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
|
||||
public static final RegistryObject<Item> BLOOD_ALTAR_ITEM = ITEMS.register("altar", () -> new BlockItem(BloodMagicBlocks.BLOOD_ALTAR.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> ALCHEMY_TABLE_ITEM = ITEMS.register("alchemytable", () -> new ItemBlockAlchemyTable(BloodMagicBlocks.ALCHEMY_TABLE.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.
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package wayoftime.bloodmagic.common.item.block;
|
||||
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.common.block.BlockAlchemyTable;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyTable;
|
||||
|
||||
public class ItemBlockAlchemyTable extends BlockItem
|
||||
{
|
||||
public ItemBlockAlchemyTable(Block block, Properties properties)
|
||||
{
|
||||
super(block, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType tryPlace(BlockItemUseContext context)
|
||||
{
|
||||
// PlayerEntity player = context.getPlayer()
|
||||
// float yaw = player.rotationYaw;
|
||||
Direction direction = context.getPlacementHorizontalFacing();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
|
||||
if (direction.getYOffset() != 0)
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
|
||||
if (!world.isAirBlock(pos.offset(direction)))
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
BlockState thisState = this.getBlock().getDefaultState().with(BlockAlchemyTable.DIRECTION, direction).with(BlockAlchemyTable.INVISIBLE, false);
|
||||
BlockState newState = this.getBlock().getDefaultState().with(BlockAlchemyTable.DIRECTION, direction).with(BlockAlchemyTable.INVISIBLE, true);
|
||||
|
||||
if (!this.canPlace(context, thisState) || !world.setBlockState(pos.offset(direction), newState, 3))
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if (!world.setBlockState(pos, thisState, 3))
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == this.getBlock())
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileAlchemyTable)
|
||||
{
|
||||
((TileAlchemyTable) tile).setInitialTableParameters(direction, false, pos.offset(direction));
|
||||
}
|
||||
|
||||
TileEntity slaveTile = world.getTileEntity(pos.offset(direction));
|
||||
if (slaveTile instanceof TileAlchemyTable)
|
||||
{
|
||||
((TileAlchemyTable) slaveTile).setInitialTableParameters(direction, true, pos);
|
||||
}
|
||||
|
||||
setTileEntityNBT(world, context.getPlayer(), pos, context.getItem());
|
||||
this.getBlock().onBlockPlacedBy(world, pos, state, context.getPlayer(), context.getItem());
|
||||
if (player instanceof ServerPlayerEntity)
|
||||
{
|
||||
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) player, pos, context.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
SoundType soundtype = state.getSoundType(world, pos, context.getPlayer());
|
||||
world.playSound(player, pos, this.getPlaceSound(state, world, pos, context.getPlayer()), SoundCategory.BLOCKS, (soundtype.getVolume()
|
||||
+ 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
if (player == null || !player.abilities.isCreativeMode)
|
||||
{
|
||||
context.getItem().shrink(1);
|
||||
}
|
||||
|
||||
return ActionResultType.func_233537_a_(world.isRemote);
|
||||
|
||||
// return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue