Framework for ARC
Initial framework for the ARC block, including GUI, Container, Tile Entity, and Block.
This commit is contained in:
parent
2a8143844a
commit
ec1b0644cb
32 changed files with 847 additions and 70 deletions
|
@ -16,6 +16,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
|||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.client.render.block.RenderAlchemyArray;
|
||||
import wayoftime.bloodmagic.client.render.block.RenderAltar;
|
||||
import wayoftime.bloodmagic.client.screens.ScreenAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.client.screens.ScreenSoulForge;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
|
@ -39,6 +40,7 @@ public class ClientEvents
|
|||
public static void registerContainerScreens()
|
||||
{
|
||||
ScreenManager.registerFactory(BloodMagicBlocks.SOUL_FORGE_CONTAINER.get(), ScreenSoulForge::new);
|
||||
ScreenManager.registerFactory(BloodMagicBlocks.ARC_CONTAINER.get(), ScreenAlchemicalReactionChamber::new);
|
||||
}
|
||||
|
||||
public static void registerItemModelProperties(FMLClientSetupEvent event)
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package wayoftime.bloodmagic.client.screens;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
||||
|
||||
public class ScreenAlchemicalReactionChamber extends ScreenBase<ContainerAlchemicalReactionChamber>
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation(BloodMagic.MODID, "textures/gui/arc_gui.png");
|
||||
public TileAlchemicalReactionChamber tileARC;
|
||||
|
||||
public ScreenAlchemicalReactionChamber(ContainerAlchemicalReactionChamber container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
tileARC = container.tileARC;
|
||||
this.xSize = 176;
|
||||
this.ySize = 205;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
// public
|
||||
|
||||
// public ScreenSoulForge(InventoryPlayer playerInventory, IInventory tileSoulForge)
|
||||
// {
|
||||
// super(new ContainerSoulForge(playerInventory, tileSoulForge));
|
||||
// this.tileSoulForge = tileSoulForge;
|
||||
// this.xSize = 176;
|
||||
// this.ySize = 205;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
// {
|
||||
// this.drawDefaultBackground();
|
||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
// this.renderHoveredToolTip(mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int mouseX, int mouseY)
|
||||
{
|
||||
this.font.func_243248_b(stack, new TranslationTextComponent("tile.bloodmagic.arc.name"), 8, 5, 4210752);
|
||||
this.font.func_243248_b(stack, new TranslationTextComponent("container.inventory"), 8, 111, 4210752);
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
getMinecraft().getTextureManager().bindTexture(background);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.blit(stack, i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
// int l = this.getCookProgressScaled(90);
|
||||
// this.blit(stack, i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l);
|
||||
}
|
||||
|
||||
////
|
||||
// public int getCookProgressScaled(int scale)
|
||||
// {
|
||||
// double progress = ((TileSoulForge) tileSoulForge).getProgressForGui();
|
||||
//// if (tileSoulForge != null)
|
||||
//// {
|
||||
//// System.out.println("Tile is NOT null");
|
||||
//// }
|
||||
//// double progress = ((float) this.container.data.get(0)) / ((float) this.container.data.get(1));
|
||||
//// System.out.println(this.container.data.get(0));
|
||||
// return (int) (progress * scale);
|
||||
// }
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
|
@ -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).
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)));
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
public interface IARCTool
|
||||
{
|
||||
|
||||
}
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
package wayoftime.bloodmagic.tile;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
public class TileAlchemicalReactionChamber extends TileInventory implements ITickableTileEntity, INamedContainerProvider
|
||||
{
|
||||
@ObjectHolder("bloodmagic:alchemicalreactionchamber")
|
||||
public static TileEntityType<TileAlchemicalReactionChamber> TYPE;
|
||||
|
||||
public static final int ARC_TOOL_SLOT = 0;
|
||||
public static final int OUTPUT_SLOT = 1;
|
||||
public static final int NUM_OUTPUTS = 5;
|
||||
public static final int INPUT_SLOT = 6;
|
||||
public static final int INPUT_BUCKET_SLOT = 7;
|
||||
public static final int OUTPUT_BUCKET_SLOT = 8;
|
||||
|
||||
public FluidTank inputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 2);
|
||||
public FluidTank outputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 2);
|
||||
|
||||
// Input slots are from 0 to 3.
|
||||
|
||||
public int burnTime = 0;
|
||||
|
||||
public TileAlchemicalReactionChamber(TileEntityType<?> type)
|
||||
{
|
||||
super(type, 9, "alchemicalreactionchamber");
|
||||
}
|
||||
|
||||
public TileAlchemicalReactionChamber()
|
||||
{
|
||||
this(TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(CompoundNBT tag)
|
||||
{
|
||||
super.deserialize(tag);
|
||||
|
||||
burnTime = tag.getInt(Constants.NBT.SOUL_FORGE_BURN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serialize(CompoundNBT tag)
|
||||
{
|
||||
super.serialize(tag);
|
||||
|
||||
tag.putInt(Constants.NBT.SOUL_FORGE_BURN, burnTime);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// private boolean canCraft(RecipeTartaricForge recipe)
|
||||
// {
|
||||
// if (recipe == null)
|
||||
// return false;
|
||||
//
|
||||
// ItemStack currentOutputStack = getStackInSlot(outputSlot);
|
||||
// if (recipe.getOutput().isEmpty())
|
||||
// return false;
|
||||
// if (currentOutputStack.isEmpty())
|
||||
// return true;
|
||||
// if (!currentOutputStack.isItemEqual(recipe.getOutput()))
|
||||
// return false;
|
||||
// int result = currentOutputStack.getCount() + recipe.getOutput().getCount();
|
||||
// return result <= getInventoryStackLimit() && result <= currentOutputStack.getMaxStackSize();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void craftItem(RecipeTartaricForge recipe)
|
||||
// {
|
||||
// if (this.canCraft(recipe))
|
||||
// {
|
||||
// ItemStack currentOutputStack = getStackInSlot(outputSlot);
|
||||
//
|
||||
// List<ItemStack> inputList = new ArrayList<>();
|
||||
// for (int i = 0; i < 4; i++) if (!getStackInSlot(i).isEmpty())
|
||||
// inputList.add(getStackInSlot(i).copy());
|
||||
//
|
||||
// BloodMagicCraftedEvent.SoulForge event = new BloodMagicCraftedEvent.SoulForge(recipe.getOutput().copy(), inputList.toArray(new ItemStack[0]));
|
||||
// MinecraftForge.EVENT_BUS.post(event);
|
||||
//
|
||||
// if (currentOutputStack.isEmpty())
|
||||
// {
|
||||
// setInventorySlotContents(outputSlot, event.getOutput());
|
||||
// } else if (ItemHandlerHelper.canItemStacksStack(currentOutputStack, event.getOutput()))
|
||||
// {
|
||||
// currentOutputStack.grow(event.getOutput().getCount());
|
||||
// }
|
||||
//
|
||||
// consumeInventory();
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_)
|
||||
{
|
||||
assert world != null;
|
||||
return new ContainerAlchemicalReactionChamber(this, p_createMenu_1_, p_createMenu_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return new StringTextComponent("Alchemical Reaction Chamber");
|
||||
}
|
||||
|
||||
public double getProgressForGui()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,198 @@
|
|||
package wayoftime.bloodmagic.tile.contailer;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.IARCTool;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
||||
|
||||
public class ContainerAlchemicalReactionChamber extends Container
|
||||
{
|
||||
public final TileAlchemicalReactionChamber tileARC;
|
||||
|
||||
// public ContainerSoulForge(InventoryPlayer inventoryPlayer, IInventory tileARC)
|
||||
// {
|
||||
// this.tileARC = tileARC;
|
||||
//
|
||||
// }
|
||||
|
||||
public ContainerAlchemicalReactionChamber(int windowId, PlayerInventory playerInventory, PacketBuffer extraData)
|
||||
{
|
||||
this((TileAlchemicalReactionChamber) playerInventory.player.world.getTileEntity(extraData.readBlockPos()), windowId, playerInventory);
|
||||
}
|
||||
|
||||
public ContainerAlchemicalReactionChamber(@Nullable TileAlchemicalReactionChamber tile, int windowId, PlayerInventory playerInventory)
|
||||
{
|
||||
super(BloodMagicBlocks.ARC_CONTAINER.get(), windowId);
|
||||
this.tileARC = tile;
|
||||
this.setup(playerInventory, tile);
|
||||
}
|
||||
|
||||
public void setup(PlayerInventory inventory, IInventory tileARC)
|
||||
{
|
||||
this.addSlot(new SlotARCTool(tileARC, TileAlchemicalReactionChamber.ARC_TOOL_SLOT, 35, 51));
|
||||
for (int i = 0; i < TileAlchemicalReactionChamber.NUM_OUTPUTS; i++)
|
||||
{
|
||||
this.addSlot(new SlotOutput(tileARC, TileAlchemicalReactionChamber.OUTPUT_SLOT + i, 116, 15 + i * 18));
|
||||
}
|
||||
this.addSlot(new Slot(tileARC, TileAlchemicalReactionChamber.INPUT_SLOT, 71, 15));
|
||||
this.addSlot(new SlotBucket(tileARC, TileAlchemicalReactionChamber.INPUT_BUCKET_SLOT, 8, 15, true));
|
||||
this.addSlot(new SlotBucket(tileARC, TileAlchemicalReactionChamber.OUTPUT_BUCKET_SLOT, 152, 87, false));
|
||||
|
||||
// this.addSlot(new SlotSoul(tileARC, TileSoulForge.soulSlot, 152, 51));
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 123 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
addSlot(new Slot(inventory, i, 8 + i * 18, 181));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if ((index >= 1 && index < 1 + 5) || (index == 7 || index == 8))// Attempting to transfer from output slots
|
||||
// or bucket slots
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 9, 9 + 36, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
} else if (index > 9) // Attempting to transfer from main inventory
|
||||
{
|
||||
if (itemstack1.getItem() instanceof IARCTool) // Try the tool slot first
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (isBucket(itemstack1, true)) // If it's a full bucket, transfer to tank filler slot.
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 7, 8, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (isBucket(itemstack1, false)) // If it's an empty bucket, transfer to tank emptier slot.
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 8, 9, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemstack1, 6, 7, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemstack1, 9, 45, false)) // Attempting to transfer from input slots
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == 0)
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity playerIn)
|
||||
{
|
||||
return this.tileARC.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
private class SlotARCTool extends Slot
|
||||
{
|
||||
public SlotARCTool(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItem() instanceof IARCTool;
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotBucket extends Slot
|
||||
{
|
||||
private final boolean needsFullBucket;
|
||||
|
||||
public SlotBucket(IInventory inventory, int slotIndex, int x, int y, boolean needsFullBucket)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
this.needsFullBucket = needsFullBucket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
Optional<FluidStack> fluidStackOptional = FluidUtil.getFluidContained(itemStack);
|
||||
|
||||
return fluidStackOptional.isPresent() && ((needsFullBucket && !fluidStackOptional.get().isEmpty())
|
||||
|| (!needsFullBucket && fluidStackOptional.get().isEmpty()));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isBucket(ItemStack stack, boolean requiredFull)
|
||||
{
|
||||
Optional<FluidStack> fluidStackOptional = FluidUtil.getFluidContained(stack);
|
||||
|
||||
return fluidStackOptional.isPresent() && ((requiredFull && !fluidStackOptional.get().isEmpty())
|
||||
|| (!requiredFull && fluidStackOptional.get().isEmpty()));
|
||||
}
|
||||
|
||||
private class SlotOutput extends Slot
|
||||
{
|
||||
public SlotOutput(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue