Added more items
Added more items from previous versions, including the Demon Crystal Clusters.
This commit is contained in:
parent
4f46dc150d
commit
bacd3d27f2
101 changed files with 3992 additions and 21 deletions
|
@ -53,6 +53,7 @@ import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
|||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyTable;
|
||||
import wayoftime.bloodmagic.tile.TileAltar;
|
||||
import wayoftime.bloodmagic.tile.TileDemonCrystal;
|
||||
import wayoftime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import wayoftime.bloodmagic.tile.TileSoulForge;
|
||||
import wayoftime.bloodmagic.util.handler.event.GenericHandler;
|
||||
|
@ -154,6 +155,7 @@ public class BloodMagic
|
|||
event.getRegistry().register(TileEntityType.Builder.create(TileMasterRitualStone::new, BloodMagicBlocks.MASTER_RITUAL_STONE.get()).build(null).setRegistryName("masterritualstone"));
|
||||
event.getRegistry().register(TileEntityType.Builder.create(TileAlchemicalReactionChamber::new, BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()).build(null).setRegistryName("alchemicalreactionchamber"));
|
||||
event.getRegistry().register(TileEntityType.Builder.create(TileAlchemyTable::new, BloodMagicBlocks.ALCHEMY_TABLE.get()).build(null).setRegistryName("alchemytable"));
|
||||
event.getRegistry().register(TileEntityType.Builder.create(TileDemonCrystal::new, BloodMagicBlocks.RAW_CRYSTAL_BLOCK.get(), BloodMagicBlocks.CORROSIVE_CRYSTAL_BLOCK.get(), BloodMagicBlocks.DESTRUCTIVE_CRYSTAL_BLOCK.get(), BloodMagicBlocks.VENGEFUL_CRYSTAL_BLOCK.get(), BloodMagicBlocks.STEADFAST_CRYSTAL_BLOCK.get()).build(null).setRegistryName("demoncrystal"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -89,7 +89,6 @@ public class ScreenAlchemicalReactionChamber extends ScreenBase<ContainerAlchemi
|
|||
+ 15, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), null);
|
||||
|
||||
int w = this.getCookProgressScaled(38);
|
||||
System.out.println("Width: " + w);
|
||||
// FurnaceTileEntity d;
|
||||
this.blit(stack, i + 63, j + 44, 176, 90, w, 23);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,257 @@
|
|||
package wayoftime.bloodmagic.common.block;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.IntegerProperty;
|
||||
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.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import wayoftime.bloodmagic.common.item.ItemDemonCrystal;
|
||||
import wayoftime.bloodmagic.tile.TileDemonCrystal;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
|
||||
|
||||
public class BlockDemonCrystal extends Block
|
||||
{
|
||||
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 6);
|
||||
// public static final EnumProperty<EnumDemonWillType> TYPE = EnumProperty.create("type", EnumDemonWillType.class);
|
||||
public static final EnumProperty<Direction> ATTACHED = EnumProperty.create("attached", Direction.class);
|
||||
private static final EnumMap<Direction, VoxelShape> bounds = new EnumMap<>(Direction.class);
|
||||
|
||||
public final EnumDemonWillType type;
|
||||
|
||||
// Bounding / Collision boxes
|
||||
private static final VoxelShape[] UP =
|
||||
{ Block.makeCuboidShape(6, 0, 5, 10, 13, 9), Block.makeCuboidShape(7, 0, 0, 13, 6, 5),
|
||||
Block.makeCuboidShape(9, 0, 9, 13, 5, 14), Block.makeCuboidShape(2, 0, 1, 7, 6, 7),
|
||||
Block.makeCuboidShape(5, 0, 9, 9, 7, 15), Block.makeCuboidShape(0, 0, 7, 6, 6, 10),
|
||||
Block.makeCuboidShape(10, 0, 6, 15, 6, 9) };
|
||||
private static final VoxelShape[] DOWN =
|
||||
{ Block.makeCuboidShape(6, 3, 7, 10, 16, 11), Block.makeCuboidShape(7, 10, 11, 13, 16, 16),
|
||||
Block.makeCuboidShape(9, 11, 2, 13, 16, 7), Block.makeCuboidShape(2, 9, 11, 7, 16, 15),
|
||||
Block.makeCuboidShape(5, 9, 1, 9, 16, 7), Block.makeCuboidShape(0, 10, 6, 6, 16, 9),
|
||||
Block.makeCuboidShape(10, 11, 7, 15, 16, 10) };
|
||||
private static final VoxelShape[] NORTH =
|
||||
{ Block.makeCuboidShape(6, 5, 3, 10, 9, 16), Block.makeCuboidShape(9, 0, 6, 13, 5, 16),
|
||||
Block.makeCuboidShape(8, 9, 11, 13, 14, 16), Block.makeCuboidShape(2, 1, 9, 7, 7, 16),
|
||||
Block.makeCuboidShape(5, 9, 9, 9, 15, 16), Block.makeCuboidShape(0, 7, 10, 6, 10, 16),
|
||||
Block.makeCuboidShape(10, 7, 10, 15, 9, 15), };
|
||||
private static final VoxelShape[] SOUTH =
|
||||
{ Block.makeCuboidShape(6, 7, 0, 10, 11, 13), Block.makeCuboidShape(7, 11, 0, 13, 16, 6),
|
||||
Block.makeCuboidShape(8, 2, 9, 13, 7, 14), Block.makeCuboidShape(2, 9, 1, 7, 14, 7),
|
||||
Block.makeCuboidShape(5, 1, 9, 9, 7, 9), Block.makeCuboidShape(0, 6, 1, 6, 9, 7),
|
||||
Block.makeCuboidShape(10, 8, 1, 15, 10, 6) };
|
||||
private static final VoxelShape[] EAST =
|
||||
{ Block.makeCuboidShape(0, 6, 5, 13, 10, 9), Block.makeCuboidShape(0, 3, 0, 6, 9, 5),
|
||||
Block.makeCuboidShape(0, 3, 9, 5, 8, 14), Block.makeCuboidShape(1, 9, 1, 7, 13, 7),
|
||||
Block.makeCuboidShape(1, 0, 9, 7, 11, 15), Block.makeCuboidShape(0, 10, 7, 6, 16, 10),
|
||||
Block.makeCuboidShape(0, 1, 6, 5, 6, 9) };
|
||||
private static final VoxelShape[] WEST =
|
||||
{ Block.makeCuboidShape(3, 6, 5, 16, 10, 9), Block.makeCuboidShape(9, 7, 0, 16, 12, 5),
|
||||
Block.makeCuboidShape(11, 4, 9, 16, 13, 14), Block.makeCuboidShape(9, 3, 1, 16, 8, 7),
|
||||
Block.makeCuboidShape(9, 6, 9, 16, 8, 15), Block.makeCuboidShape(10, 1, 7, 16, 6, 10),
|
||||
Block.makeCuboidShape(10, 6, 6, 15, 15, 9) };
|
||||
|
||||
public BlockDemonCrystal(EnumDemonWillType type)
|
||||
{
|
||||
super(AbstractBlock.Properties.create(Material.IRON).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2));
|
||||
this.type = type;
|
||||
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(ATTACHED, Direction.UP).with(AGE, Integer.valueOf(0)));
|
||||
// this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumDemonWillType.DEFAULT).withProperty(ATTACHED, Direction.UP));
|
||||
|
||||
// setTranslationKey(BloodMagic.MODID + ".demonCrystal.");
|
||||
// setCreativeTab(BloodMagic.TAB_BM);
|
||||
// setHardness(2.0F);
|
||||
// setResistance(5.0F);
|
||||
// setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber)
|
||||
{
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
stack = EnumDemonWillType.CORROSIVE.getStack();
|
||||
break;
|
||||
case DEFAULT:
|
||||
stack = EnumDemonWillType.DEFAULT.getStack();
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
stack = EnumDemonWillType.DESTRUCTIVE.getStack();
|
||||
break;
|
||||
case STEADFAST:
|
||||
stack = EnumDemonWillType.STEADFAST.getStack();
|
||||
break;
|
||||
case VENGEFUL:
|
||||
stack = EnumDemonWillType.VENGEFUL.getStack();
|
||||
break;
|
||||
}
|
||||
|
||||
stack.setCount(crystalNumber);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
|
||||
{
|
||||
switch (state.get(ATTACHED))
|
||||
{
|
||||
case DOWN:
|
||||
return DOWN[0];
|
||||
case NORTH:
|
||||
return NORTH[0];
|
||||
case SOUTH:
|
||||
return SOUTH[0];
|
||||
case EAST:
|
||||
return EAST[0];
|
||||
case WEST:
|
||||
return WEST[0];
|
||||
case UP:
|
||||
default:
|
||||
return UP[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileDemonCrystal)
|
||||
{
|
||||
TileDemonCrystal crystal = (TileDemonCrystal) tile;
|
||||
boolean isCreative = player.isCreative();
|
||||
boolean holdsCrystal = player.getHeldItem(hand).getItem() instanceof ItemDemonCrystal;
|
||||
|
||||
if (PlayerDemonWillHandler.getTotalDemonWill(EnumDemonWillType.DEFAULT, player) > 1024
|
||||
&& !(holdsCrystal && isCreative))
|
||||
{
|
||||
crystal.dropSingleCrystal();
|
||||
|
||||
}
|
||||
if (!crystal.getWorld().isRemote && isCreative && holdsCrystal)
|
||||
{
|
||||
if (crystal.getCrystalCount() < 7)
|
||||
{
|
||||
crystal.internalCounter = 0;
|
||||
if (crystal.progressToNextCrystal > 0)
|
||||
crystal.progressToNextCrystal--;
|
||||
crystal.setCrystalCount(crystal.getCrystalCount() + 1);
|
||||
crystal.markDirty();
|
||||
crystal.notifyUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos)
|
||||
{
|
||||
Direction direction = state.get(ATTACHED);
|
||||
BlockPos blockpos = pos.offset(direction.getOpposite());
|
||||
BlockState blockstate = worldIn.getBlockState(blockpos);
|
||||
return blockstate.isSolidSide(worldIn, blockpos, direction);
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
// if (direction.getAxis().isHorizontal())
|
||||
{
|
||||
Direction direction1 = direction.getOpposite();
|
||||
blockstate = blockstate.with(ATTACHED, direction1);
|
||||
if (blockstate.isValidPosition(iworldreader, blockpos))
|
||||
{
|
||||
return blockstate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state)
|
||||
{
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
|
||||
{
|
||||
builder.add(ATTACHED, AGE);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
|
||||
// {
|
||||
//
|
||||
// super.onPlayerDestroy(world, blockPos, blockState);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
// {
|
||||
// TorchBlock d;
|
||||
// if (!state.isIn(newState.getBlock()))
|
||||
// {
|
||||
//
|
||||
// super.onReplaced(state, worldIn, pos, newState, isMoving);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world)
|
||||
{
|
||||
return new TileDemonCrystal(type);
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import wayoftime.bloodmagic.ritual.EnumRuneType;
|
|||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemyTable;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerSoulForge;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
|
||||
public class BloodMagicBlocks
|
||||
{
|
||||
|
@ -71,6 +72,12 @@ public class BloodMagicBlocks
|
|||
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());
|
||||
|
||||
public static final RegistryObject<Block> RAW_CRYSTAL_BLOCK = BLOCKS.register("rawdemoncrystal", () -> new BlockDemonCrystal(EnumDemonWillType.DEFAULT));
|
||||
public static final RegistryObject<Block> CORROSIVE_CRYSTAL_BLOCK = BLOCKS.register("corrosivedemoncrystal", () -> new BlockDemonCrystal(EnumDemonWillType.CORROSIVE));
|
||||
public static final RegistryObject<Block> DESTRUCTIVE_CRYSTAL_BLOCK = BLOCKS.register("destructivedemoncrystal", () -> new BlockDemonCrystal(EnumDemonWillType.DESTRUCTIVE));
|
||||
public static final RegistryObject<Block> VENGEFUL_CRYSTAL_BLOCK = BLOCKS.register("vengefuldemoncrystal", () -> new BlockDemonCrystal(EnumDemonWillType.VENGEFUL));
|
||||
public static final RegistryObject<Block> STEADFAST_CRYSTAL_BLOCK = BLOCKS.register("steadfastdemoncrystal", () -> new BlockDemonCrystal(EnumDemonWillType.STEADFAST));
|
||||
|
||||
private static ForgeFlowingFluid.Properties makeProperties()
|
||||
{
|
||||
return new ForgeFlowingFluid.Properties(LIFE_ESSENCE_FLUID, LIFE_ESSENCE_FLUID_FLOWING, FluidAttributes.builder(FLUID_STILL, FLUID_FLOWING)).bucket(LIFE_ESSENCE_BUCKET).block(LIFE_ESSENCE_BLOCK);
|
||||
|
|
|
@ -5,12 +5,16 @@ import net.minecraft.data.DataGenerator;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
||||
import net.minecraftforge.client.model.generators.ConfiguredModel.Builder;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder;
|
||||
import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder.PartBuilder;
|
||||
import net.minecraftforge.client.model.generators.VariantBlockStateBuilder;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
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.BloodMagicBlocks;
|
||||
|
||||
public class GeneratorBlockStates extends BlockStateProvider
|
||||
|
@ -41,6 +45,12 @@ public class GeneratorBlockStates extends BlockStateProvider
|
|||
buildCubeAll(BloodMagicBlocks.DAWN_RITUAL_STONE.get());
|
||||
|
||||
buildFurnace(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get());
|
||||
|
||||
buildCrystal(BloodMagicBlocks.RAW_CRYSTAL_BLOCK.get(), "defaultcrystal");
|
||||
buildCrystal(BloodMagicBlocks.CORROSIVE_CRYSTAL_BLOCK.get(), "corrosivecrystal");
|
||||
buildCrystal(BloodMagicBlocks.DESTRUCTIVE_CRYSTAL_BLOCK.get(), "destructivecrystal");
|
||||
buildCrystal(BloodMagicBlocks.VENGEFUL_CRYSTAL_BLOCK.get(), "vengefulcrystal");
|
||||
buildCrystal(BloodMagicBlocks.STEADFAST_CRYSTAL_BLOCK.get(), "steadfastcrystal");
|
||||
}
|
||||
|
||||
private void buildCubeAll(Block block)
|
||||
|
@ -48,6 +58,53 @@ public class GeneratorBlockStates extends BlockStateProvider
|
|||
getVariantBuilder(block).forAllStates(state -> ConfiguredModel.builder().modelFile(cubeAll(block)).build());
|
||||
}
|
||||
|
||||
private void buildCrystal(Block block, String name)
|
||||
{
|
||||
MultiPartBlockStateBuilder builder = getMultipartBuilder(block);
|
||||
|
||||
ModelFile[] crystalModels = new ModelFile[7];
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
crystalModels[i] = models().withExistingParent("block/crystal/" + name + (i + 1), modLoc("crystal" + (i + 1))).texture("crystal", modLoc("models/" + name));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
Integer[] intArray = new Integer[7 - i];
|
||||
for (int j = i; j < 7; j++)
|
||||
{
|
||||
intArray[j - i] = j;
|
||||
}
|
||||
|
||||
for (Direction direction : Direction.values())
|
||||
{
|
||||
Builder<PartBuilder> partBuilder = builder.part().modelFile(crystalModels[i]);
|
||||
switch (direction)
|
||||
{
|
||||
case UP:
|
||||
break;
|
||||
case DOWN:
|
||||
partBuilder = partBuilder.rotationX(180);
|
||||
break;
|
||||
case EAST:
|
||||
partBuilder = partBuilder.rotationX(90).rotationY(90);
|
||||
break;
|
||||
case WEST:
|
||||
partBuilder = partBuilder.rotationX(90).rotationY(270);
|
||||
break;
|
||||
case NORTH:
|
||||
partBuilder = partBuilder.rotationX(90);
|
||||
break;
|
||||
case SOUTH:
|
||||
partBuilder = partBuilder.rotationX(270);
|
||||
break;
|
||||
}
|
||||
|
||||
partBuilder.addModel().condition(BlockDemonCrystal.AGE, intArray).condition(BlockDemonCrystal.ATTACHED, direction).end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildFurnace(Block block)
|
||||
{
|
||||
// ConfiguredModel[] furnaceModel = ConfiguredModel.builder().modelFile().build();
|
||||
|
|
|
@ -45,6 +45,12 @@ public class GeneratorItemModels extends ItemModelProvider
|
|||
registerBlockModel(BloodMagicBlocks.DAWN_RITUAL_STONE.get());
|
||||
registerBlockModel(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get());
|
||||
|
||||
registerCustomBlockPath(BloodMagicBlocks.RAW_CRYSTAL_BLOCK.get(), "crystal/defaultcrystal1");
|
||||
registerCustomBlockPath(BloodMagicBlocks.CORROSIVE_CRYSTAL_BLOCK.get(), "crystal/corrosivecrystal1");
|
||||
registerCustomBlockPath(BloodMagicBlocks.DESTRUCTIVE_CRYSTAL_BLOCK.get(), "crystal/destructivecrystal1");
|
||||
registerCustomBlockPath(BloodMagicBlocks.VENGEFUL_CRYSTAL_BLOCK.get(), "crystal/vengefulcrystal1");
|
||||
registerCustomBlockPath(BloodMagicBlocks.STEADFAST_CRYSTAL_BLOCK.get(), "crystal/steadfastcrystal1");
|
||||
|
||||
registerToggleableItem(BloodMagicItems.GREEN_GROVE_SIGIL.get());
|
||||
registerToggleableItem(BloodMagicItems.FAST_MINER_SIGIL.get());
|
||||
registerToggleableItem(BloodMagicItems.MAGNETISM_SIGIL.get());
|
||||
|
@ -55,6 +61,12 @@ public class GeneratorItemModels extends ItemModelProvider
|
|||
registerDemonSword(BloodMagicItems.SENTIENT_SWORD.get());
|
||||
}
|
||||
|
||||
private void registerCustomBlockPath(Block block, String newPath)
|
||||
{
|
||||
String path = block.getRegistryName().getPath();
|
||||
getBuilder(path).parent(new ModelFile.UncheckedModelFile(modLoc("block/" + newPath)));
|
||||
}
|
||||
|
||||
private void registerBlockModel(Block block)
|
||||
{
|
||||
String path = block.getRegistryName().getPath();
|
||||
|
|
|
@ -10,21 +10,31 @@ import java.util.stream.Collectors;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.advancements.criterion.StatePropertiesPredicate;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.LootTableProvider;
|
||||
import net.minecraft.data.loot.BlockLootTables;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.loot.ConstantRange;
|
||||
import net.minecraft.loot.ItemLootEntry;
|
||||
import net.minecraft.loot.LootParameterSet;
|
||||
import net.minecraft.loot.LootParameterSets;
|
||||
import net.minecraft.loot.LootPool;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.loot.LootTableManager;
|
||||
import net.minecraft.loot.ValidationTracker;
|
||||
import net.minecraft.loot.conditions.BlockStateProperty;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
import net.minecraft.state.Property;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BlockDemonCrystal;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
|
||||
public class GeneratorLootTable extends LootTableProvider
|
||||
{
|
||||
|
@ -36,10 +46,10 @@ public class GeneratorLootTable extends LootTableProvider
|
|||
@Override
|
||||
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootParameterSet>> getTables()
|
||||
{
|
||||
return ImmutableList.of(Pair.of(Blocks::new, LootParameterSets.BLOCK));
|
||||
return ImmutableList.of(Pair.of(BMBlocks::new, LootParameterSets.BLOCK));
|
||||
}
|
||||
|
||||
private static class Blocks extends BlockLootTables
|
||||
private static class BMBlocks extends BlockLootTables
|
||||
{
|
||||
@Override
|
||||
protected void addTables()
|
||||
|
@ -62,6 +72,13 @@ public class GeneratorLootTable extends LootTableProvider
|
|||
registerDropping(BloodMagicBlocks.DAWN_RITUAL_STONE.get(), BloodMagicBlocks.BLANK_RITUAL_STONE.get());
|
||||
registerDropSelfLootTable(BloodMagicBlocks.ALCHEMY_TABLE.get());
|
||||
registerDropSelfLootTable(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get());
|
||||
// registerNoDropLootTable(BloodMagicBlocks.RAW_CRYSTAL_BLOCK.get());
|
||||
|
||||
registerDropCrystalsLootTable(BloodMagicBlocks.RAW_CRYSTAL_BLOCK.get(), BloodMagicItems.RAW_CRYSTAL.get());
|
||||
registerDropCrystalsLootTable(BloodMagicBlocks.CORROSIVE_CRYSTAL_BLOCK.get(), BloodMagicItems.CORROSIVE_CRYSTAL.get());
|
||||
registerDropCrystalsLootTable(BloodMagicBlocks.DESTRUCTIVE_CRYSTAL_BLOCK.get(), BloodMagicItems.DESTRUCTIVE_CRYSTAL.get());
|
||||
registerDropCrystalsLootTable(BloodMagicBlocks.VENGEFUL_CRYSTAL_BLOCK.get(), BloodMagicItems.VENGEFUL_CRYSTAL.get());
|
||||
registerDropCrystalsLootTable(BloodMagicBlocks.STEADFAST_CRYSTAL_BLOCK.get(), BloodMagicItems.STEADFAST_CRYSTAL.get());
|
||||
}
|
||||
|
||||
private void registerNoDropLootTable(Block block)
|
||||
|
@ -70,6 +87,24 @@ public class GeneratorLootTable extends LootTableProvider
|
|||
this.registerLootTable(block, LootTable.builder().addLootPool(builder));
|
||||
}
|
||||
|
||||
private void registerDropCrystalsLootTable(Block block, Item item)
|
||||
{
|
||||
LootTable.Builder builder = LootTable.builder();
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
ILootCondition.IBuilder harvestAge = BlockStateProperty.builder(block).fromProperties(StatePropertiesPredicate.Builder.newBuilder().withIntProp(BlockDemonCrystal.AGE, i));
|
||||
builder = builder.addLootPool(LootPool.builder().addEntry(ItemLootEntry.builder(item).quality(i + 1).acceptCondition(harvestAge)));
|
||||
}
|
||||
|
||||
this.registerLootTable(block, builder);
|
||||
}
|
||||
|
||||
protected static <T extends Comparable<T> & IStringSerializable> LootTable.Builder droppingWhen(Block block, Property<T> property, T value)
|
||||
{
|
||||
return LootTable.builder().addLootPool(withSurvivesExplosion(block, LootPool.builder().rolls(ConstantRange.of(1)).addEntry(ItemLootEntry.builder(block).acceptCondition(BlockStateProperty.builder(block).fromProperties(StatePropertiesPredicate.Builder.newBuilder().withProp(property, value))))));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Block> getKnownBlocks()
|
||||
{
|
||||
|
|
|
@ -144,6 +144,18 @@ public class BloodMagicItems
|
|||
public static final RegistryObject<Item> SOUL_SNARE = BASICITEMS.register("soulsnare", ItemSoulSnare::new);
|
||||
public static final RegistryObject<Item> SENTIENT_SWORD = ITEMS.register("soulsword", () -> new ItemSentientSword());
|
||||
|
||||
public static final RegistryObject<Item> RAW_CRYSTAL_BLOCK_ITEM = ITEMS.register("rawdemoncrystal", () -> new BlockItem(BloodMagicBlocks.RAW_CRYSTAL_BLOCK.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> CORROSIVE_CRYSTAL_BLOCK_ITEM = ITEMS.register("corrosivedemoncrystal", () -> new BlockItem(BloodMagicBlocks.CORROSIVE_CRYSTAL_BLOCK.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> DESTRUCTIVE_CRYSTAL_BLOCK_ITEM = ITEMS.register("destructivedemoncrystal", () -> new BlockItem(BloodMagicBlocks.DESTRUCTIVE_CRYSTAL_BLOCK.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> VENGEFUL_CRYSTAL_BLOCK_ITEM = ITEMS.register("vengefuldemoncrystal", () -> new BlockItem(BloodMagicBlocks.VENGEFUL_CRYSTAL_BLOCK.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> STEADFAST_CRYSTAL_BLOCK_ITEM = ITEMS.register("steadfastdemoncrystal", () -> new BlockItem(BloodMagicBlocks.STEADFAST_CRYSTAL_BLOCK.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
|
||||
public static final RegistryObject<Item> RAW_CRYSTAL = BASICITEMS.register("defaultcrystal", () -> new ItemDemonCrystal(EnumDemonWillType.DEFAULT));
|
||||
public static final RegistryObject<Item> CORROSIVE_CRYSTAL = BASICITEMS.register("corrosivecrystal", () -> new ItemDemonCrystal(EnumDemonWillType.CORROSIVE));
|
||||
public static final RegistryObject<Item> VENGEFUL_CRYSTAL = BASICITEMS.register("vengefulcrystal", () -> new ItemDemonCrystal(EnumDemonWillType.VENGEFUL));
|
||||
public static final RegistryObject<Item> DESTRUCTIVE_CRYSTAL = BASICITEMS.register("destructivecrystal", () -> new ItemDemonCrystal(EnumDemonWillType.DESTRUCTIVE));
|
||||
public static final RegistryObject<Item> STEADFAST_CRYSTAL = BASICITEMS.register("steadfastcrystal", () -> new ItemDemonCrystal(EnumDemonWillType.STEADFAST));
|
||||
|
||||
// ARC Tools
|
||||
public static final RegistryObject<Item> SANGUINE_REVERTER = BASICITEMS.register("sanguinereverter", () -> new ItemARCToolBase(32, 2));
|
||||
public static final RegistryObject<Item> PRIMITIVE_FURNACE_CELL = BASICITEMS.register("furnacecell_primitive", () -> new ItemARCToolBase(128, 1.25));
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.will.IDiscreteDemonWill;
|
||||
|
||||
public class ItemDemonCrystal extends Item implements IDiscreteDemonWill
|
||||
{
|
||||
private EnumDemonWillType type;
|
||||
|
||||
public ItemDemonCrystal(EnumDemonWillType type)
|
||||
{
|
||||
super(new Item.Properties().group(BloodMagic.TAB));
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWill(ItemStack willStack)
|
||||
{
|
||||
return getDiscretization(willStack) * willStack.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainWill(ItemStack willStack, double drainAmount)
|
||||
{
|
||||
double discretization = getDiscretization(willStack);
|
||||
int drainedNumber = (int) Math.floor(Math.min(willStack.getCount() * discretization, drainAmount)
|
||||
/ discretization);
|
||||
|
||||
if (drainedNumber > 0)
|
||||
{
|
||||
willStack.shrink(drainedNumber);
|
||||
return drainedNumber * discretization;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDiscretization(ItemStack willStack)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getType(ItemStack willStack)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
232
src/main/java/wayoftime/bloodmagic/tile/TileDemonCrystal.java
Normal file
232
src/main/java/wayoftime/bloodmagic/tile/TileDemonCrystal.java
Normal file
|
@ -0,0 +1,232 @@
|
|||
package wayoftime.bloodmagic.tile;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import wayoftime.bloodmagic.common.block.BlockDemonCrystal;
|
||||
import wayoftime.bloodmagic.demonaura.WorldDemonWillHandler;
|
||||
import wayoftime.bloodmagic.tile.base.TileTicking;
|
||||
import wayoftime.bloodmagic.will.DemonWillHolder;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
|
||||
public class TileDemonCrystal extends TileTicking
|
||||
{
|
||||
public static final double sameWillConversionRate = 50;
|
||||
public static final double defaultWillConversionRate = 100;
|
||||
public static final double timeDelayForWrongWill = 0.6;
|
||||
public final int maxWill = 100;
|
||||
public final double drainRate = 1;
|
||||
public DemonWillHolder holder = new DemonWillHolder();
|
||||
public double progressToNextCrystal = 0;
|
||||
public int internalCounter = 0;
|
||||
public Direction placement = Direction.UP; // Side that this crystal is placed on.
|
||||
|
||||
public EnumDemonWillType willType;
|
||||
|
||||
@ObjectHolder("bloodmagic:demoncrystal")
|
||||
public static TileEntityType<TileDemonCrystal> TYPE;
|
||||
|
||||
public TileDemonCrystal(TileEntityType<?> type, EnumDemonWillType willType)
|
||||
{
|
||||
super(type);
|
||||
this.willType = willType;
|
||||
}
|
||||
|
||||
public TileDemonCrystal(EnumDemonWillType willType)
|
||||
{
|
||||
this(TYPE, willType);
|
||||
}
|
||||
|
||||
public TileDemonCrystal()
|
||||
{
|
||||
this(TYPE, EnumDemonWillType.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if (getWorld().isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
internalCounter++;
|
||||
|
||||
if (internalCounter % 20 == 0)
|
||||
{
|
||||
int crystalCount = getCrystalCount();
|
||||
if (crystalCount < 7)
|
||||
{
|
||||
// this.setCrystalCount(crystalCount + 1);
|
||||
EnumDemonWillType type = getWillType();
|
||||
|
||||
double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
|
||||
if (type != EnumDemonWillType.DEFAULT)
|
||||
{
|
||||
if (value >= 0.5)
|
||||
{
|
||||
double nextProgress = getCrystalGrowthPerSecond(value);
|
||||
progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress
|
||||
* sameWillConversionRate, true) / sameWillConversionRate;
|
||||
} else
|
||||
{
|
||||
value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, EnumDemonWillType.DEFAULT);
|
||||
if (value > 0.5)
|
||||
{
|
||||
double nextProgress = getCrystalGrowthPerSecond(value) * timeDelayForWrongWill;
|
||||
progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), EnumDemonWillType.DEFAULT, nextProgress
|
||||
* defaultWillConversionRate, true) / defaultWillConversionRate;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (value > 0.5)
|
||||
{
|
||||
|
||||
double nextProgress = getCrystalGrowthPerSecond(value);
|
||||
progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress
|
||||
* sameWillConversionRate, true) / sameWillConversionRate;
|
||||
}
|
||||
}
|
||||
|
||||
checkAndGrowCrystal();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Encourages the crystal to grow by a large percentage by telling it to drain
|
||||
* will from the aura.
|
||||
*
|
||||
* @param willDrain The amount of drain that is needed for the crystal
|
||||
* to grow successfully for the desired amount. Can be
|
||||
* more than the base amount.
|
||||
* @param progressPercentage
|
||||
* @return percentage actually grown.
|
||||
*/
|
||||
public double growCrystalWithWillAmount(double willDrain, double progressPercentage)
|
||||
{
|
||||
int crystalCount = getCrystalCount();
|
||||
if (crystalCount >= 7)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
EnumDemonWillType type = this.getWillType();
|
||||
|
||||
double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
|
||||
double percentDrain = willDrain <= 0 ? 1 : Math.min(1, value / willDrain);
|
||||
if (percentDrain <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Verification that you can actually drain the will from this chunk, for future
|
||||
// proofing.
|
||||
WorldDemonWillHandler.drainWill(getWorld(), pos, type, percentDrain * willDrain, true);
|
||||
progressToNextCrystal += percentDrain * progressPercentage;
|
||||
|
||||
checkAndGrowCrystal();
|
||||
|
||||
return percentDrain * progressPercentage;
|
||||
}
|
||||
|
||||
public EnumDemonWillType getWillType()
|
||||
{
|
||||
return willType;
|
||||
}
|
||||
|
||||
public void checkAndGrowCrystal()
|
||||
{
|
||||
int crystalCount = getCrystalCount();
|
||||
if (progressToNextCrystal >= 1 && internalCounter % 100 == 0 && crystalCount < 7)
|
||||
{
|
||||
progressToNextCrystal--;
|
||||
this.setCrystalCount(crystalCount + 1);
|
||||
markDirty();
|
||||
notifyUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public double getMaxWillForCrystal()
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
public boolean dropSingleCrystal()
|
||||
{
|
||||
int crystalCount = getCrystalCount();
|
||||
if (!getWorld().isRemote && crystalCount > 1)
|
||||
{
|
||||
BlockState state = getWorld().getBlockState(pos);
|
||||
EnumDemonWillType type = getWillType();
|
||||
// EnumDemonWillType type = state.getValue(BlockDemonCrystal.TYPE);
|
||||
ItemStack stack = BlockDemonCrystal.getItemStackDropped(type, 1);
|
||||
if (!stack.isEmpty())
|
||||
{
|
||||
setCrystalCount(crystalCount - 1);
|
||||
InventoryHelper.spawnItemStack(getWorld(), pos.getX(), pos.getY(), pos.getZ(), stack);
|
||||
notifyUpdate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public double getCrystalGrowthPerSecond(double will)
|
||||
{
|
||||
return 1.0 / 200 * Math.sqrt(will / 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(CompoundNBT tag)
|
||||
{
|
||||
holder.readFromNBT(tag, "Will");
|
||||
placement = Direction.byIndex(tag.getInt("placement"));
|
||||
progressToNextCrystal = tag.getDouble("progress");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag)
|
||||
{
|
||||
holder.writeToNBT(tag, "Will");
|
||||
tag.putInt("placement", placement.getIndex());
|
||||
tag.putDouble("progress", progressToNextCrystal);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public int getCrystalCount()
|
||||
{
|
||||
BlockState state = world.getBlockState(getPos());
|
||||
return state.get(BlockDemonCrystal.AGE);
|
||||
}
|
||||
|
||||
public void setCrystalCount(int crystalCount)
|
||||
{
|
||||
BlockState state = world.getBlockState(getPos());
|
||||
world.setBlockState(getPos(), state.with(BlockDemonCrystal.AGE, crystalCount - 1));
|
||||
}
|
||||
|
||||
public Direction getPlacement()
|
||||
{
|
||||
return placement;
|
||||
}
|
||||
|
||||
public void setPlacement(Direction placement)
|
||||
{
|
||||
this.placement = placement;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected void onDataPacketClientReceived()
|
||||
// {
|
||||
// super.onDataPacketClientReceived();
|
||||
// notifyUpdate();
|
||||
// }
|
||||
}
|
|
@ -2,7 +2,9 @@ package wayoftime.bloodmagic.will;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
|
||||
public enum EnumDemonWillType implements IStringSerializable
|
||||
{
|
||||
|
@ -30,4 +32,23 @@ public enum EnumDemonWillType implements IStringSerializable
|
|||
{
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
public ItemStack getStack()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case CORROSIVE:
|
||||
return new ItemStack(BloodMagicItems.CORROSIVE_CRYSTAL.get());
|
||||
case DEFAULT:
|
||||
return new ItemStack(BloodMagicItems.RAW_CRYSTAL.get());
|
||||
case DESTRUCTIVE:
|
||||
return new ItemStack(BloodMagicItems.DESTRUCTIVE_CRYSTAL.get());
|
||||
case STEADFAST:
|
||||
return new ItemStack(BloodMagicItems.STEADFAST_CRYSTAL.get());
|
||||
case VENGEFUL:
|
||||
return new ItemStack(BloodMagicItems.VENGEFUL_CRYSTAL.get());
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue