Framework for ARC

Initial framework for the ARC block, including GUI, Container, Tile Entity, and Block.
This commit is contained in:
WayofTime 2020-10-26 15:53:09 -04:00
parent 2a8143844a
commit ec1b0644cb
32 changed files with 847 additions and 70 deletions

View file

@ -0,0 +1,162 @@
package wayoftime.bloodmagic.common.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.LivingEntity;
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.ItemStack;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.AbstractFurnaceTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
public class BlockAlchemicalReactionChamber extends Block
{
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
public static final BooleanProperty LIT = BlockStateProperties.LIT;
public BlockAlchemicalReactionChamber()
{
super(Properties.create(Material.ROCK).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.STONE));
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH).with(LIT, Boolean.valueOf(false)));
}
@Override
public boolean hasTileEntity(BlockState state)
{
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TileAlchemicalReactionChamber();
}
@Override
public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
{
TileAlchemicalReactionChamber arc = (TileAlchemicalReactionChamber) world.getTileEntity(blockPos);
if (arc != null)
arc.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 TileAlchemicalReactionChamber)
{
((TileAlchemicalReactionChamber) tileentity).dropItems();
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}
@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 TileAlchemicalReactionChamber))
return ActionResultType.FAIL;
NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tile, pos);
// player.openGui(BloodMagic.instance, Constants.Gui.SOUL_FORGE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
return ActionResultType.SUCCESS;
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context)
{
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place
* logic
*/
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack)
{
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof AbstractFurnaceTileEntity)
{
((AbstractFurnaceTileEntity) tileentity).setCustomName(stack.getDisplayName());
}
}
}
/**
* Returns the blockstate with the given rotation from the passed blockstate. If
* inapplicable, returns the passed blockstate.
*
* @deprecated call via {@link IBlockState#withRotation(Rotation)} whenever
* possible. Implementing/overriding is fine.
*/
@Override
public BlockState rotate(BlockState state, Rotation rot)
{
return state.with(FACING, rot.rotate(state.get(FACING)));
}
/**
* Returns the blockstate with the given mirror of the passed blockstate. If
* inapplicable, returns the passed blockstate.
*
* @deprecated call via {@link IBlockState#withMirror(Mirror)} whenever
* possible. Implementing/overriding is fine.
*/
@Override
public BlockState mirror(BlockState state, Mirror mirrorIn)
{
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
{
builder.add(FACING, LIT);
}
public boolean eventReceived(BlockState state, World worldIn, BlockPos pos, int id, int param)
{
super.eventReceived(state, worldIn, pos, id, param);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity == null ? false : tileentity.receiveClientEvent(id, param);
}
}

View file

@ -15,6 +15,7 @@ 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.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
@ -27,13 +28,6 @@ public class BlockSoulForge extends Block// implements IBMBlock
public BlockSoulForge()
{
super(Properties.create(Material.IRON).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(1));
// setTranslationKey(BloodMagic.MODID + ".soulForge");
// setHardness(2.0F);
// setResistance(5.0F);
// setSoundType(SoundType.METAL);
// setHarvestLevel("pickaxe", 1);
// setCreativeTab(BloodMagic.TAB_BM);
}
@Override
@ -76,20 +70,29 @@ public class BlockSoulForge extends Block// implements IBMBlock
return ActionResultType.SUCCESS;
}
// @Override
// public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
// {
// TileSoulForge tileSoulForge = (TileSoulForge) world.getTileEntity(blockPos);
// if (tileSoulForge != null)
// tileSoulForge.dropItems();
//
// super.breakBlock(world, blockPos, blockState);
// }
@Override
public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
{
TileSoulForge forge = (TileSoulForge) world.getTileEntity(blockPos);
if (forge != null)
forge.dropItems();
//
// @Override
// public BlockItem getItem()
// {
// return new BlockItem(this);
// }
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 TileSoulForge)
{
((TileSoulForge) tileentity).dropItems();
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}
}

View file

@ -19,6 +19,7 @@ import wayoftime.bloodmagic.BloodMagic;
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.ContainerSoulForge;
public class BloodMagicBlocks
@ -59,6 +60,8 @@ 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());
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);
@ -71,6 +74,7 @@ public class BloodMagicBlocks
public static RegistryObject<Item> LIFE_ESSENCE_BUCKET = ITEMS.register("life_essence_bucket", () -> new BucketItem(LIFE_ESSENCE_FLUID, new Item.Properties().containerItem(Items.BUCKET).maxStackSize(1).group(BloodMagic.TAB)));
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<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

@ -34,7 +34,7 @@ public class GeneratorBaseRecipes extends BaseRecipeProvider
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.BLOOD_ALTAR.get()).key('a', Tags.Items.STONE).key('b', Items.FURNACE).key('c', Tags.Items.INGOTS_GOLD).key('d', BloodMagicItems.MONSTER_SOUL_RAW.get()).patternLine("a a").patternLine("aba").patternLine("cdc").addCriterion("has_will", hasItem(BloodMagicItems.MONSTER_SOUL_RAW.get())).build(consumer, BloodMagic.rl("blood_altar"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SOUL_FORGE.get()).key('s', Tags.Items.STONE).key('g', Tags.Items.INGOTS_GOLD).key('i', Tags.Items.INGOTS_IRON).key('o', Tags.Items.STORAGE_BLOCKS_IRON).patternLine("i i").patternLine("sgs").patternLine("sos").addCriterion("has_gold", hasItem(Items.GOLD_INGOT)).build(consumer, BloodMagic.rl("soul_forge"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.SOUL_SNARE.get(), 4).key('r', Tags.Items.DUSTS_REDSTONE).key('s', Tags.Items.STRING).key('i', Tags.Items.INGOTS_IRON).patternLine("sis").patternLine("iri").patternLine("sis").addCriterion("has_redstone", hasItem(Items.REDSTONE)).build(consumer, BloodMagic.rl("soul_snare"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.BASE_RITUAL_DIVINER.get()).key('a', BloodMagicItems.AIR_INSCRIPTION_TOOL.get()).key('s', Tags.Items.RODS_WOODEN).key('d', Tags.Items.GEMS_DIAMOND).key('e', BloodMagicItems.EARTH_INSCRIPTION_TOOL.get()).key('f', BloodMagicItems.FIRE_INSCRIPTION_TOOL.get()).key('w', BloodMagicItems.WATER_INSCRIPTION_TOOL.get()).addCriterion("has_scribe", hasItem(BloodMagicItems.AIR_INSCRIPTION_TOOL.get())).build(consumer, BloodMagic.rl("ritual_diviner_0"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.BASE_RITUAL_DIVINER.get()).key('a', BloodMagicItems.AIR_INSCRIPTION_TOOL.get()).key('s', Tags.Items.RODS_WOODEN).key('d', Tags.Items.GEMS_DIAMOND).key('e', BloodMagicItems.EARTH_INSCRIPTION_TOOL.get()).key('f', BloodMagicItems.FIRE_INSCRIPTION_TOOL.get()).key('w', BloodMagicItems.WATER_INSCRIPTION_TOOL.get()).patternLine("dfd").patternLine("ase").patternLine("dwd").addCriterion("has_scribe", hasItem(BloodMagicItems.AIR_INSCRIPTION_TOOL.get())).build(consumer, BloodMagic.rl("ritual_diviner_0"));
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.DUSK_RITUAL_DIVINER.get()).key('S', BloodMagicItems.DEMONIC_SLATE.get()).key('t', BloodMagicItems.DUSK_INSCRIPTION_TOOL.get()).key('d', BloodMagicItems.BASE_RITUAL_DIVINER.get()).patternLine(" S ").patternLine("tdt").patternLine(" S ").addCriterion("has_demon_slate", hasItem(BloodMagicItems.DEMONIC_SLATE.get())).build(consumer, BloodMagic.rl("ritual_diviner_1"));
}

View file

@ -2,11 +2,15 @@ package wayoftime.bloodmagic.common.data;
import net.minecraft.block.Block;
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.ModelFile;
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.BloodMagicBlocks;
public class GeneratorBlockStates extends BlockStateProvider
@ -35,6 +39,8 @@ public class GeneratorBlockStates extends BlockStateProvider
buildCubeAll(BloodMagicBlocks.EARTH_RITUAL_STONE.get());
buildCubeAll(BloodMagicBlocks.DUSK_RITUAL_STONE.get());
buildCubeAll(BloodMagicBlocks.DAWN_RITUAL_STONE.get());
buildFurnace(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get());
}
private void buildCubeAll(Block block)
@ -42,4 +48,23 @@ public class GeneratorBlockStates extends BlockStateProvider
getVariantBuilder(block).forAllStates(state -> ConfiguredModel.builder().modelFile(cubeAll(block)).build());
}
private void buildFurnace(Block block)
{
// ConfiguredModel[] furnaceModel = ConfiguredModel.builder().modelFile().build();
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);
VariantBlockStateBuilder builder = getVariantBuilder(block);
builder.partialState().with(BlockAlchemicalReactionChamber.FACING, Direction.NORTH).with(BlockAlchemicalReactionChamber.LIT, false).modelForState().modelFile(furnace_off).addModel();
builder.partialState().with(BlockAlchemicalReactionChamber.FACING, Direction.EAST).with(BlockAlchemicalReactionChamber.LIT, false).modelForState().modelFile(furnace_off).rotationY(90).addModel();
builder.partialState().with(BlockAlchemicalReactionChamber.FACING, Direction.SOUTH).with(BlockAlchemicalReactionChamber.LIT, false).modelForState().modelFile(furnace_off).rotationY(180).addModel();
builder.partialState().with(BlockAlchemicalReactionChamber.FACING, Direction.WEST).with(BlockAlchemicalReactionChamber.LIT, false).modelForState().modelFile(furnace_off).rotationY(270).addModel();
builder.partialState().with(BlockAlchemicalReactionChamber.FACING, Direction.NORTH).with(BlockAlchemicalReactionChamber.LIT, true).modelForState().modelFile(furnace_off).addModel();
builder.partialState().with(BlockAlchemicalReactionChamber.FACING, Direction.EAST).with(BlockAlchemicalReactionChamber.LIT, true).modelForState().modelFile(furnace_off).rotationY(90).addModel();
builder.partialState().with(BlockAlchemicalReactionChamber.FACING, Direction.SOUTH).with(BlockAlchemicalReactionChamber.LIT, true).modelForState().modelFile(furnace_off).rotationY(180).addModel();
builder.partialState().with(BlockAlchemicalReactionChamber.FACING, Direction.WEST).with(BlockAlchemicalReactionChamber.LIT, true).modelForState().modelFile(furnace_off).rotationY(270).addModel();
// getVariantBuilder(block).
}
}

View file

@ -43,6 +43,7 @@ public class GeneratorItemModels extends ItemModelProvider
registerBlockModel(BloodMagicBlocks.EARTH_RITUAL_STONE.get());
registerBlockModel(BloodMagicBlocks.DUSK_RITUAL_STONE.get());
registerBlockModel(BloodMagicBlocks.DAWN_RITUAL_STONE.get());
registerBlockModel(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get());
registerToggleableItem(BloodMagicItems.GREEN_GROVE_SIGIL.get());
registerToggleableItem(BloodMagicItems.FAST_MINER_SIGIL.get());

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.ALCHEMICAL_REACTION_CHAMBER.get());
}
private void registerNoDropLootTable(Block block)

View file

@ -62,6 +62,7 @@ public class BloodMagicItems
public static final RegistryObject<Item> EARTH_RITUAL_STONE_ITEM = ITEMS.register("earthritualstone", () -> new BlockItem(BloodMagicBlocks.EARTH_RITUAL_STONE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> DUSK_RITUAL_STONE_ITEM = ITEMS.register("duskritualstone", () -> new BlockItem(BloodMagicBlocks.DUSK_RITUAL_STONE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> DAWN_RITUAL_STONE_ITEM = ITEMS.register("lightritualstone", () -> new BlockItem(BloodMagicBlocks.DAWN_RITUAL_STONE.get(), new Item.Properties().group(BloodMagic.TAB)));
public static final RegistryObject<Item> ALCHEMICAL_REACTION_CHAMBER_ITEM = ITEMS.register("alchemicalreactionchamber", () -> new BlockItem(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get(), new Item.Properties().group(BloodMagic.TAB)));
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)));

View file

@ -0,0 +1,6 @@
package wayoftime.bloodmagic.common.item;
public interface IARCTool
{
}

View file

@ -5,7 +5,6 @@ import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BucketItem;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -54,10 +53,8 @@ public abstract class ItemSigilFluidBase extends ItemSigilBase
{
BlockState state = world.getBlockState(blockPos);
Block block = state.getBlock();
BucketItem b;
System.out.println(block);
IFluidHandler targetFluidHandler = FluidUtil.getFluidHandler(world, blockPos, side).orElse(null);
System.out.println(targetFluidHandler);
if (targetFluidHandler == null)