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:
WayofTime 2020-10-31 13:42:28 -04:00
parent 37c5e807b0
commit bf6250272c
41 changed files with 1915 additions and 29 deletions

View file

@ -0,0 +1,183 @@
package wayoftime.bloodmagic.common.block;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
import wayoftime.bloodmagic.common.item.BloodMagicItems;
import wayoftime.bloodmagic.tile.TileAlchemyTable;
public class BlockAlchemyTable extends Block// implements IBMBlock
{
public static final DirectionProperty DIRECTION = DirectionProperty.create("direction", Direction.Plane.HORIZONTAL);
public static final BooleanProperty INVISIBLE = BooleanProperty.create("invisible");
protected static final VoxelShape BODY = Block.makeCuboidShape(1, 0, 1, 15, 15, 15);
public BlockAlchemyTable()
{
super(AbstractBlock.Properties.create(Material.IRON).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(1).notSolid().setOpaque(BlockAlchemyTable::isntSolid).setBlocksVision(BlockAlchemyTable::isntSolid));
}
private static boolean isntSolid(BlockState state, IBlockReader reader, BlockPos pos)
{
return false;
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
{
return BODY;
}
public VoxelShape getRayTraceShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context)
{
return VoxelShapes.empty();
}
@Override
public boolean hasTileEntity(BlockState state)
{
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileAlchemyTable();
}
@Override
public BlockRenderType getRenderType(BlockState state)
{
return BlockRenderType.MODEL;
}
@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult)
{
if (world.isRemote)
return ActionResultType.SUCCESS;
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileAlchemyTable)
{
if (((TileAlchemyTable) tile).isSlave())
{
NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) world.getTileEntity(((TileAlchemyTable) tile).getConnectedPos()), ((TileAlchemyTable) tile).getConnectedPos());
} else
{
NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tile, pos);
}
return ActionResultType.SUCCESS;
}
// player.openGui(BloodMagic.instance, Constants.Gui.SOUL_FORGE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
return ActionResultType.FAIL;
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context)
{
return this.getDefaultState().with(DIRECTION, context.getPlacementHorizontalFacing());
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
{
builder.add(DIRECTION, INVISIBLE);
}
@Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor)
{
TileAlchemyTable tile = (TileAlchemyTable) world.getTileEntity(pos);
if (tile != null)
{
BlockPos connectedPos = tile.getConnectedPos();
TileEntity connectedTile = world.getTileEntity(connectedPos);
if (!(connectedTile instanceof TileAlchemyTable
&& ((TileAlchemyTable) connectedTile).getConnectedPos().equals(pos)))
{
this.onPlayerDestroy(tile.getWorld(), pos, state);
this.removedByPlayer(state, tile.getWorld(), pos, null, true, this.getFluidState(state));
}
}
}
@Override
public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
{
TileAlchemyTable forge = (TileAlchemyTable) world.getTileEntity(blockPos);
if (forge != null && !forge.isSlave())
{
forge.dropItems();
}
super.onPlayerDestroy(world, blockPos, blockState);
}
@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 TileAlchemyTable && !((TileAlchemyTable) tileentity).isSlave())
{
((TileAlchemyTable) tileentity).dropItems();
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}
// @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 TileSoulForge)
// {
// ((TileSoulForge) tileentity).dropItems();
// worldIn.updateComparatorOutputLevel(pos, this);
// }
//
// super.onReplaced(state, worldIn, pos, newState, isMoving);
// }
// }
@Override
public Item asItem()
{
return BloodMagicItems.ALCHEMY_TABLE_ITEM.get();
}
}

View file

@ -24,6 +24,7 @@ import wayoftime.bloodmagic.block.enums.BloodRuneType;
import wayoftime.bloodmagic.common.item.BloodMagicItems;
import wayoftime.bloodmagic.ritual.EnumRuneType;
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemyTable;
import wayoftime.bloodmagic.tile.contailer.ContainerSoulForge;
public class BloodMagicBlocks
@ -68,6 +69,7 @@ public class BloodMagicBlocks
public static final RegistryObject<Block> MASTER_RITUAL_STONE = BASICBLOCKS.register("masterritualstone", () -> new BlockMasterRitualStone(false));
public static final RegistryObject<Block> ALCHEMICAL_REACTION_CHAMBER = BLOCKS.register("alchemicalreactionchamber", () -> new BlockAlchemicalReactionChamber());
public static final RegistryObject<Block> ALCHEMY_TABLE = BLOCKS.register("alchemytable", () -> new BlockAlchemyTable());
private static ForgeFlowingFluid.Properties makeProperties()
{
@ -82,6 +84,7 @@ public class BloodMagicBlocks
public static final RegistryObject<ContainerType<ContainerSoulForge>> SOUL_FORGE_CONTAINER = CONTAINERS.register("soul_forge_container", () -> IForgeContainerType.create(ContainerSoulForge::new));
public static final RegistryObject<ContainerType<ContainerAlchemicalReactionChamber>> ARC_CONTAINER = CONTAINERS.register("arc_container", () -> IForgeContainerType.create(ContainerAlchemicalReactionChamber::new));
public static final RegistryObject<ContainerType<ContainerAlchemyTable>> ALCHEMY_TABLE_CONTAINER = CONTAINERS.register("alchemy_table_container", () -> IForgeContainerType.create(ContainerAlchemyTable::new));
// public static final RegistryObject<BloodstoneBlock> BLOOD_STONE = registerNoItem("blood_stone", () -> new BloodstoneBlock());
//
//// private static <T extends Block> RegistryObject<T> register(String name, Supplier<? extends T> sup, Function<RegistryObject<T>, Supplier<? extends Item>> itemCreator)

View file

@ -2,12 +2,14 @@ package wayoftime.bloodmagic.common.data;
import java.util.function.Consumer;
import net.minecraft.block.Blocks;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.ShapedRecipeBuilder;
import net.minecraft.data.ShapelessRecipeBuilder;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ItemTags;
import net.minecraftforge.common.Tags;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
@ -53,6 +55,9 @@ public class GeneratorBaseRecipes extends BaseRecipeProvider
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.BLANK_RITUAL_STONE.get(), 4).key('a', Tags.Items.OBSIDIAN).key('b', BloodMagicItems.REINFORCED_SLATE.get()).key('c', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_APPRENTICE.get())).patternLine("aba").patternLine("bcb").patternLine("aba").addCriterion("has_apprentice_orb", hasItem(BloodMagicItems.APPRENTICE_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("ritual_stone_blank"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.MASTER_RITUAL_STONE.get()).key('a', Tags.Items.OBSIDIAN).key('b', BloodMagicBlocks.BLANK_RITUAL_STONE.get()).key('c', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MAGICIAN.get())).patternLine("aba").patternLine("bcb").patternLine("aba").addCriterion("has_magician_orb", hasItem(BloodMagicItems.MAGICIAN_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("ritual_stone_master"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.ALCHEMY_TABLE.get()).key('b', Tags.Items.RODS_BLAZE).key('s', Tags.Items.STONE).key('w', ItemTags.PLANKS).key('g', Tags.Items.INGOTS_GOLD).key('o', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).patternLine("sss").patternLine("wbw").patternLine("gog").addCriterion("has_weak_orb", hasItem(BloodMagicItems.WEAK_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("alchemy_table"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()).key('s', Tags.Items.STONE).key('f', Blocks.FURNACE).key('o', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MAGICIAN.get())).key('I', Tags.Items.STORAGE_BLOCKS_IRON).key('S', BloodMagicItems.IMBUED_SLATE.get()).patternLine("sss").patternLine("SoS").patternLine("IfI").addCriterion("has_magician_orb", hasItem(BloodMagicItems.MAGICIAN_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("arc"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.PRIMITIVE_FURNACE_CELL.get()).key('c', Tags.Items.COBBLESTONE).key('f', Tags.Items.STORAGE_BLOCKS_COAL).key('s', Ingredient.fromItems(BloodMagicItems.SLATE.get())).key('o', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MAGICIAN.get())).patternLine("csc").patternLine("cfc").patternLine("coc").addCriterion("has_magician_orb", hasItem(BloodMagicItems.MAGICIAN_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("primitive_furnace_cell"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.LAVA_CRYSTAL.get()).key('a', Tags.Items.GLASS).key('b', Items.LAVA_BUCKET).key('c', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).key('d', Tags.Items.OBSIDIAN).key('e', Tags.Items.GEMS_DIAMOND).patternLine("aba").patternLine("bcb").patternLine("ded").addCriterion("has_weak_orb", hasItem(BloodMagicItems.WEAK_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("lava_crystal"));
// ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SPEED_RUNE.get()).key('s', Items.GLASS).key('o', Ingredient.fromItems(Items.DIAMOND)).patternLine("sss").patternLine("sos").patternLine("sss").addCriterion("has_diamond", hasItem(Items.DIAMOND)).build(consumer, new ResourceLocation(BloodMagic.MODID, "speed_rune_from_standard"));

View file

@ -24,6 +24,7 @@ public class GeneratorLanguage extends LanguageProvider
// Tile Entitites
add("tile.bloodmagic.soulforge.name", "Hellfire Forge");
add("tile.bloodmagic.arc.name", "Alchemical Reaction Chamber");
add("tile.bloodmagic.alchemytable.name", "Alchemy Table");
// Blood Orb tooltips
add("tooltip.bloodmagic.extraInfo", "&9-Hold shift for more info-");
@ -162,6 +163,9 @@ public class GeneratorLanguage extends LanguageProvider
addBlock(BloodMagicBlocks.DAWN_RITUAL_STONE, "Dawn Ritual Stone");
addBlock(BloodMagicBlocks.MASTER_RITUAL_STONE, "Master Ritual Stone");
addBlock(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER, "Alchemical Reaction Chamber");
addBlock(BloodMagicBlocks.ALCHEMY_TABLE, "Alchemy Table");
addBlock(BloodMagicBlocks.BLOODSTONE, "Large Bloodstone Brick");
addBlock(BloodMagicBlocks.BLOODSTONE_BRICK, "Bloodstone Brick");
@ -243,6 +247,9 @@ public class GeneratorLanguage extends LanguageProvider
add("jei.bloodmagic.recipe.altar", "Blood Altar");
add("jei.bloodmagic.recipe.soulforge", "Hellfire Forge");
add("jei.bloodmagic.recipe.alchemyarraycrafting", "Alchemy Array");
add("jei.bloodmagic.recipe.arc", "ARC Recipe");
add("jei.bloodmagic.recipe.arcfurnace", "ARC Furnace Recipe");
add("jei.bloodmagic.recipe.alchemytable", "Alchemy Table");
// Chat
add("chat.bloodmagic.ritual.weak", "You feel a push, but are too weak to perform this ritual.");

View file

@ -60,6 +60,7 @@ public class GeneratorLootTable extends LootTableProvider
registerDropping(BloodMagicBlocks.EARTH_RITUAL_STONE.get(), BloodMagicBlocks.BLANK_RITUAL_STONE.get());
registerDropping(BloodMagicBlocks.DUSK_RITUAL_STONE.get(), BloodMagicBlocks.BLANK_RITUAL_STONE.get());
registerDropping(BloodMagicBlocks.DAWN_RITUAL_STONE.get(), BloodMagicBlocks.BLANK_RITUAL_STONE.get());
registerDropSelfLootTable(BloodMagicBlocks.ALCHEMY_TABLE.get());
registerDropSelfLootTable(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get());
}

View file

@ -7,6 +7,7 @@ import net.minecraft.data.DataGenerator;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.recipe.ARCRecipeProvider;
import wayoftime.bloodmagic.common.recipe.AlchemyArrayRecipeProvider;
import wayoftime.bloodmagic.common.recipe.AlchemyTableRecipeProvider;
import wayoftime.bloodmagic.common.recipe.BloodAltarRecipeProvider;
import wayoftime.bloodmagic.common.recipe.ISubRecipeProvider;
import wayoftime.bloodmagic.common.recipe.TartaricForgeRecipeProvider;
@ -21,6 +22,6 @@ public class BloodMagicRecipeProvider extends BaseRecipeProvider
@Override
protected List<ISubRecipeProvider> getSubRecipeProviders()
{
return Arrays.asList(new BloodAltarRecipeProvider(), new AlchemyArrayRecipeProvider(), new TartaricForgeRecipeProvider(), new ARCRecipeProvider());
return Arrays.asList(new BloodAltarRecipeProvider(), new AlchemyArrayRecipeProvider(), new TartaricForgeRecipeProvider(), new ARCRecipeProvider(), new AlchemyTableRecipeProvider());
}
}

View file

@ -0,0 +1,90 @@
package wayoftime.bloodmagic.common.data.recipe.builder;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import wayoftime.bloodmagic.api.SerializerHelper;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
import wayoftime.bloodmagic.common.data.recipe.BloodMagicRecipeBuilder;
import wayoftime.bloodmagic.util.Constants;
public class AlchemyTableRecipeBuilder extends BloodMagicRecipeBuilder<AlchemyTableRecipeBuilder>
{
private final List<Ingredient> input;
private final ItemStack output;
private final int syphon;
private final int ticks;
private final int minimumTier;
protected AlchemyTableRecipeBuilder(List<Ingredient> input, ItemStack output, int syphon, int ticks, int minimumTier)
{
super(bmSerializer("alchemytable"));
this.input = input;
this.output = output;
this.syphon = syphon;
this.ticks = ticks;
this.minimumTier = minimumTier;
}
public static AlchemyTableRecipeBuilder alchemyTable(ItemStack output, int syphon, int ticks, int minimumTier)
{
List<Ingredient> inputList = new ArrayList<Ingredient>();
return new AlchemyTableRecipeBuilder(inputList, output, syphon, ticks, minimumTier);
}
public AlchemyTableRecipeBuilder addIngredient(Ingredient ing)
{
if (input.size() < RecipeAlchemyTable.MAX_INPUTS)
{
input.add(ing);
}
return this;
}
@Override
protected AlchemyTableRecipeResult getResult(ResourceLocation id)
{
return new AlchemyTableRecipeResult(id);
}
public class AlchemyTableRecipeResult extends RecipeResult
{
protected AlchemyTableRecipeResult(ResourceLocation id)
{
super(id);
}
@Override
public void serialize(@Nonnull JsonObject json)
{
if (input.size() > 0)
{
JsonArray mainArray = new JsonArray();
for (Ingredient ing : input)
{
JsonElement jsonObj = ing.serialize();
mainArray.add(jsonObj);
}
json.add(Constants.JSON.INPUT, mainArray);
}
json.add(Constants.JSON.OUTPUT, SerializerHelper.serializeItemStack(output));
json.addProperty(Constants.JSON.SYPHON, syphon);
json.addProperty(Constants.JSON.TICKS, ticks);
json.addProperty(Constants.JSON.ALTAR_TIER, minimumTier);
}
}
}

View file

@ -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.

View file

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

View file

@ -0,0 +1,22 @@
package wayoftime.bloodmagic.common.recipe;
import java.util.function.Consumer;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tags.ItemTags;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.data.recipe.builder.AlchemyTableRecipeBuilder;
public class AlchemyTableRecipeProvider implements ISubRecipeProvider
{
@Override
public void addRecipes(Consumer<IFinishedRecipe> consumer)
{
String basePath = "alchemytable/";
AlchemyTableRecipeBuilder.alchemyTable(new ItemStack(Items.STRING, 4), 0, 100, 0).addIngredient(Ingredient.fromTag(ItemTags.WOOL)).addIngredient(Ingredient.fromItems(Items.FLINT)).build(consumer, BloodMagic.rl(basePath + "string"));
}
}

View file

@ -3,6 +3,7 @@ package wayoftime.bloodmagic.common.recipe;
import net.minecraft.item.crafting.IRecipeType;
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
@ -12,4 +13,5 @@ public class BloodMagicRecipeType
public static final IRecipeType<RecipeAlchemyArray> ARRAY = IRecipeType.register("array");
public static final IRecipeType<RecipeTartaricForge> TARTARICFORGE = IRecipeType.register("soulforge");
public static final IRecipeType<RecipeARC> ARC = IRecipeType.register("arc");
public static final IRecipeType<RecipeAlchemyTable> ALCHEMYTABLE = IRecipeType.register("alchemytable");
}

View file

@ -0,0 +1,122 @@
package wayoftime.bloodmagic.common.recipe.serializer;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistryEntry;
import wayoftime.bloodmagic.api.SerializerHelper;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
import wayoftime.bloodmagic.util.Constants;
public class AlchemyTableRecipeSerializer<RECIPE extends RecipeAlchemyTable>
extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<RECIPE>
{
private final IFactory<RECIPE> factory;
public AlchemyTableRecipeSerializer(IFactory<RECIPE> factory)
{
this.factory = factory;
}
@Nonnull
@Override
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json)
{
List<Ingredient> inputList = new ArrayList<Ingredient>();
if (json.has(Constants.JSON.INPUT) && JSONUtils.isJsonArray(json, Constants.JSON.INPUT))
{
JsonArray mainArray = JSONUtils.getJsonArray(json, Constants.JSON.INPUT);
arrayLoop: for (JsonElement element : mainArray)
{
if (inputList.size() >= RecipeAlchemyTable.MAX_INPUTS)
{
break arrayLoop;
}
if (element.isJsonArray())
{
element = element.getAsJsonArray();
} else
{
element.getAsJsonObject();
}
inputList.add(Ingredient.deserialize(element));
}
}
ItemStack output = SerializerHelper.getItemStack(json, Constants.JSON.OUTPUT);
int syphon = JSONUtils.getInt(json, Constants.JSON.SYPHON);
int ticks = JSONUtils.getInt(json, Constants.JSON.TICKS);
int minimumTier = JSONUtils.getInt(json, Constants.JSON.ALTAR_TIER);
return this.factory.create(recipeId, inputList, output, syphon, ticks, minimumTier);
}
@Override
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer)
{
try
{
int size = buffer.readInt();
List<Ingredient> input = new ArrayList<Ingredient>(size);
for (int i = 0; i < size; i++)
{
input.add(i, Ingredient.read(buffer));
}
buffer.writeInt(input.size());
for (int i = 0; i < input.size(); i++)
{
input.get(i).write(buffer);
}
ItemStack output = buffer.readItemStack();
int syphon = buffer.readInt();
int ticks = buffer.readInt();
int minimumTier = buffer.readInt();
return this.factory.create(recipeId, input, output, syphon, ticks, minimumTier);
} catch (Exception e)
{
//Mekanism.logger.error("Error reading electrolysis recipe from packet.", e);
throw e;
}
}
@Override
public void write(@Nonnull PacketBuffer buffer, @Nonnull RECIPE recipe)
{
try
{
recipe.write(buffer);
} catch (Exception e)
{
//Mekanism.logger.error("Error writing electrolysis recipe to packet.", e);
throw e;
}
}
@FunctionalInterface
public interface IFactory<RECIPE extends RecipeAlchemyTable>
{
RECIPE create(ResourceLocation id, List<Ingredient> input, ItemStack output, int syphon, int ticks, int minimumTier);
}
}

View file

@ -3,16 +3,19 @@ package wayoftime.bloodmagic.common.registries;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
import wayoftime.bloodmagic.common.recipe.serializer.ARCRecipeSerializer;
import wayoftime.bloodmagic.common.recipe.serializer.AlchemyArrayRecipeSerializer;
import wayoftime.bloodmagic.common.recipe.serializer.AlchemyTableRecipeSerializer;
import wayoftime.bloodmagic.common.recipe.serializer.BloodAltarRecipeSerializer;
import wayoftime.bloodmagic.common.recipe.serializer.TartaricForgeRecipeSerializer;
import wayoftime.bloodmagic.common.registration.impl.IRecipeSerializerDeferredRegister;
import wayoftime.bloodmagic.common.registration.impl.IRecipeSerializerRegistryObject;
import wayoftime.bloodmagic.recipe.IRecipeARC;
import wayoftime.bloodmagic.recipe.IRecipeAlchemyArray;
import wayoftime.bloodmagic.recipe.IRecipeAlchemyTable;
import wayoftime.bloodmagic.recipe.IRecipeBloodAltar;
import wayoftime.bloodmagic.recipe.IRecipeTartaricForge;
@ -29,6 +32,7 @@ public class BloodMagicRecipeSerializers
public static final IRecipeSerializerRegistryObject<RecipeAlchemyArray> ARRAY = RECIPE_SERIALIZERS.register("array", () -> new AlchemyArrayRecipeSerializer<>(IRecipeAlchemyArray::new));
public static final IRecipeSerializerRegistryObject<RecipeTartaricForge> TARTARIC = RECIPE_SERIALIZERS.register("soulforge", () -> new TartaricForgeRecipeSerializer<>(IRecipeTartaricForge::new));
public static final IRecipeSerializerRegistryObject<RecipeARC> ARC = RECIPE_SERIALIZERS.register("arc", () -> new ARCRecipeSerializer<>(IRecipeARC::new));
public static final IRecipeSerializerRegistryObject<RecipeAlchemyTable> ALCHEMYTABLE = RECIPE_SERIALIZERS.register("alchemytable", () -> new AlchemyTableRecipeSerializer<>(IRecipeAlchemyTable::new));
// public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, BloodMagic.MODID);