diff --git a/src/main/java/com/ncpbails/culturaldelights/CulturalDelights.java b/src/main/java/com/ncpbails/culturaldelights/CulturalDelights.java index 78ea1f8..e526ae7 100644 --- a/src/main/java/com/ncpbails/culturaldelights/CulturalDelights.java +++ b/src/main/java/com/ncpbails/culturaldelights/CulturalDelights.java @@ -2,11 +2,18 @@ import com.mojang.logging.LogUtils; import com.ncpbails.culturaldelights.block.ModBlocks; +import com.ncpbails.culturaldelights.block.entity.ModBlockEntities; import com.ncpbails.culturaldelights.item.ModItems; +import com.ncpbails.culturaldelights.screen.BambooMatScreen; +import com.ncpbails.culturaldelights.screen.ModMenuTypes; +import net.minecraft.client.gui.screens.MenuScreens; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; @@ -30,17 +37,40 @@ public CulturalDelights() ModItems.register(eventBus); ModBlocks.register(eventBus); + ModBlockEntities.register(eventBus); + ModMenuTypes.register(eventBus); eventBus.addListener(this::setup); - + eventBus.addListener(this::clientSetup); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } + private void clientSetup(final FMLClientSetupEvent event) { + ItemBlockRenderTypes.setRenderLayer(ModBlocks.BAMBOO_MAT.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.WILD_CUCUMBERS.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.WILD_CORN.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.WILD_EGGPLANTS.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.AVOCADO_LEAVES.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.AVOCADO_SAPLING.get(), RenderType.cutoutMipped()); + //ItemBlockRenderTypes.setRenderLayer(ModBlocks.AVOCADO_PIT.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.CUCUMBERS.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.EGGPLANTS.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.WHITE_EGGPLANTS.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.CORN.get(), RenderType.cutoutMipped()); + ItemBlockRenderTypes.setRenderLayer(ModBlocks.CORN_UPPER.get(), RenderType.cutoutMipped()); + + + MenuScreens.register(ModMenuTypes.BAMBOO_MAT_MENU.get(), BambooMatScreen::new); + + //ModItemProperties.addCustomItemProperties(); + } + private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); + } } diff --git a/src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java b/src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java index d574310..8106d3f 100644 --- a/src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java +++ b/src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java @@ -3,6 +3,7 @@ import com.ncpbails.culturaldelights.CulturalDelights; import com.ncpbails.culturaldelights.block.custom.*; import com.ncpbails.culturaldelights.item.ModItems; +import com.ncpbails.culturaldelights.world.feature.tree.AvocadoPitGrower; import com.ncpbails.culturaldelights.world.feature.tree.AvocadoTreeGrower; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -34,20 +35,20 @@ public class ModBlocks { .strength(0, 1f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject BAMBOO_MAT = registerBlock("bamboo_mat", - () -> new Block(BlockBehaviour.Properties.of(Material.BAMBOO, MaterialColor.COLOR_GREEN) + () -> new BambooMatBlock(BlockBehaviour.Properties.of(Material.BAMBOO, MaterialColor.COLOR_GREEN) .strength(0, 1f).noOcclusion()), FarmersDelight.CREATIVE_TAB, true, 0); public static final RegistryObject WILD_CUCUMBERS = registerBlock("wild_cucumbers", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(0, 0f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.WILD_BEETROOTS.get()) + .noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject WILD_CORN = registerBlock("wild_corn", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(0, 0f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.WILD_BEETROOTS.get()) + .noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject WILD_EGGPLANTS = registerBlock("wild_eggplants", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(0, 0f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.WILD_BEETROOTS.get()) + .noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject AVOCADO_LOG = registerBlock("avocado_log", () -> new RotatedPillarBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_LOG)) { @@ -70,15 +71,14 @@ public class ModBlocks { }, FarmersDelight.CREATIVE_TAB, true, 0); public static final RegistryObject AVOCADO_LEAVES = registerBlock("avocado_leaves", - () -> new LeavesBlock(BlockBehaviour.Properties.of(Material.LEAVES, MaterialColor.COLOR_GREEN) - .strength(0, 0.2f).noOcclusion()) { + () -> new LeavesBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_LEAVES)) { @Override public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return true; } @Override public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 60; } @Override public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 30; } }, FarmersDelight.CREATIVE_TAB, true, 0); public static final RegistryObject AVOCADO_SAPLING = registerBlock("avocado_sapling", - () -> new SaplingBlock(new AvocadoTreeGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING)), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new SaplingBlock(new AvocadoTreeGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING)), FarmersDelight.CREATIVE_TAB, true, 0); public static final RegistryObject CUCUMBERS = registerBlockWithoutBlockItem("cucumbers", () -> new CucumbersBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion())); @@ -89,38 +89,38 @@ public class ModBlocks { public static final RegistryObject EGGPLANTS = registerBlockWithoutBlockItem("eggplants", () -> new EggplantsBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion())); - public static final RegistryObject CORN = registerBlock("corn", - () -> new CornBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + public static final RegistryObject CORN = registerBlockWithoutBlockItem("corn", + () -> new CornBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion())); - public static final RegistryObject CORN_UPPER = registerBlock("corn_upper", - () -> new CornUpperBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + public static final RegistryObject CORN_UPPER = registerBlockWithoutBlockItem("corn_upper", + () -> new CornUpperBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion())); - //public static final RegistryObject AVOCADO_PIT = registerBlock("avocado_pit", - // () -> new AvocadoPitBlock(new AvocadoPit(), (BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + public static final RegistryObject AVOCADO_PIT = registerBlock("avocado_pit", + () -> new AvocadoPitBlock(new AvocadoPitGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING)), FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject AVOCADO_CRATE = registerBlock("avocado_crate", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.CARROT_CRATE.get())) + , FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject CUCUMBER_CRATE = registerBlock("cucumber_crate", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.CARROT_CRATE.get())) + , FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject PICKLE_CRATE = registerBlock("pickle_crate", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.CARROT_CRATE.get())) + , FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject CORN_COB_CRATE = registerBlock("corn_cob_crate", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.CARROT_CRATE.get())) + , FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject EGGPLANT_CRATE = registerBlock("eggplant_crate", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.CARROT_CRATE.get())) + , FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject WHITE_EGGPLANT_CRATE = registerBlock("white_eggplant_crate", - () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) - .strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.CARROT_CRATE.get())) + , FarmersDelight.CREATIVE_TAB, false, 0); diff --git a/src/main/java/com/ncpbails/culturaldelights/block/custom/AvocadoPitBlock.java b/src/main/java/com/ncpbails/culturaldelights/block/custom/AvocadoPitBlock.java index 57a8c2e..43fc818 100644 --- a/src/main/java/com/ncpbails/culturaldelights/block/custom/AvocadoPitBlock.java +++ b/src/main/java/com/ncpbails/culturaldelights/block/custom/AvocadoPitBlock.java @@ -15,9 +15,7 @@ public class AvocadoPitBlock extends SaplingBlock { - private static final VoxelShape SHAPE_PIT = (VoxelShape) Stream.of( - Block.box(6, 0, 6, 10, 3, 10) - ); + private static final VoxelShape SHAPE_PIT = Block.box(6, 0, 6, 10, 3, 10); public AvocadoPitBlock(AbstractTreeGrower treeIn, Properties properties) { super(treeIn, properties); diff --git a/src/main/java/com/ncpbails/culturaldelights/block/custom/BambooMatBlock.java b/src/main/java/com/ncpbails/culturaldelights/block/custom/BambooMatBlock.java index 854281c..ad452d3 100644 --- a/src/main/java/com/ncpbails/culturaldelights/block/custom/BambooMatBlock.java +++ b/src/main/java/com/ncpbails/culturaldelights/block/custom/BambooMatBlock.java @@ -1,25 +1,35 @@ package com.ncpbails.culturaldelights.block.custom; +import com.ncpbails.culturaldelights.block.entity.ModBlockEntities; +import com.ncpbails.culturaldelights.block.entity.custom.BambooMatBlockEntity; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Mirror; -import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.network.NetworkHooks; +import org.jetbrains.annotations.Nullable; -import javax.annotation.Nullable; import java.util.Optional; import java.util.stream.Stream; -public class BambooMatBlock extends Block { +public class BambooMatBlock extends BaseEntityBlock { public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public BambooMatBlock(Properties properties) { @@ -55,4 +65,50 @@ public BlockState mirror(BlockState pState, Mirror pMirror) { protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { pBuilder.add(FACING); } -} + + /* BLOCK ENTITY */ + + @Override + public RenderShape getRenderShape(BlockState pState) { + return RenderShape.MODEL; + } + + @Override + public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) { + if (pState.getBlock() != pNewState.getBlock()) { + BlockEntity blockEntity = pLevel.getBlockEntity(pPos); + if (blockEntity instanceof BambooMatBlockEntity) { + ((BambooMatBlockEntity) blockEntity).drops(); + } + } + super.onRemove(pState, pLevel, pPos, pNewState, pIsMoving); + } + + @Override + public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, + Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { + if (!pLevel.isClientSide()) { + BlockEntity entity = pLevel.getBlockEntity(pPos); + if(entity instanceof BambooMatBlockEntity) { + NetworkHooks.openGui(((ServerPlayer)pPlayer), (BambooMatBlockEntity)entity, pPos); + } else { + throw new IllegalStateException("Our Container provider is missing!"); + } + } + + return InteractionResult.sidedSuccess(pLevel.isClientSide()); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { + return new BambooMatBlockEntity(pPos, pState); + } + + @Nullable + @Override + public BlockEntityTicker getTicker(Level pLevel, BlockState pState, BlockEntityType pBlockEntityType) { + return createTickerHelper(pBlockEntityType, ModBlockEntities.BAMBOO_MAT_BLOCK_ENTITY.get(), + BambooMatBlockEntity::tick); + } +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/block/entity/ModBlockEntities.java b/src/main/java/com/ncpbails/culturaldelights/block/entity/ModBlockEntities.java new file mode 100644 index 0000000..f1f6dfa --- /dev/null +++ b/src/main/java/com/ncpbails/culturaldelights/block/entity/ModBlockEntities.java @@ -0,0 +1,26 @@ +package com.ncpbails.culturaldelights.block.entity; + +import com.ncpbails.culturaldelights.CulturalDelights; +import com.ncpbails.culturaldelights.block.ModBlocks; +import com.ncpbails.culturaldelights.block.entity.custom.BambooMatBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +public class ModBlockEntities { + + public static final DeferredRegister> BLOCK_ENTITIES = + DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, CulturalDelights.MOD_ID); + + public static final RegistryObject> BAMBOO_MAT_BLOCK_ENTITY = + BLOCK_ENTITIES.register("bamboo_mat_block_entity", () -> + BlockEntityType.Builder.of(BambooMatBlockEntity::new, + ModBlocks.BAMBOO_MAT.get()).build(null)); + + + public static void register(IEventBus eventBus) { + BLOCK_ENTITIES.register(eventBus); + } +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/block/entity/custom/BambooMatBlockEntity.java b/src/main/java/com/ncpbails/culturaldelights/block/entity/custom/BambooMatBlockEntity.java new file mode 100644 index 0000000..cdd9436 --- /dev/null +++ b/src/main/java/com/ncpbails/culturaldelights/block/entity/custom/BambooMatBlockEntity.java @@ -0,0 +1,141 @@ +package com.ncpbails.culturaldelights.block.entity.custom; + +import com.ncpbails.culturaldelights.block.entity.ModBlockEntities; +import com.ncpbails.culturaldelights.item.ModItems; +import com.ncpbails.culturaldelights.screen.BambooMatMenu; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.Containers; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemStackHandler; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.Nonnull; +import java.util.Random; + +public class BambooMatBlockEntity extends BlockEntity implements MenuProvider { + + private final ItemStackHandler itemHandler = new ItemStackHandler(6) { + @Override + protected void onContentsChanged(int slot) { + setChanged(); + } + }; + + private LazyOptional lazyItemHandler = LazyOptional.empty(); + + public BambooMatBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { + super(ModBlockEntities.BAMBOO_MAT_BLOCK_ENTITY.get(), pWorldPosition, pBlockState); + } + + @Override + public Component getDisplayName() { + return new TextComponent("Gem Cutting Station"); + } + + @Nullable + @Override + public AbstractContainerMenu createMenu(int pContainerId, Inventory pInventory, Player pPlayer) { + return new BambooMatMenu(pContainerId, pInventory, this); + } + + @Nonnull + @Override + public LazyOptional getCapability(@Nonnull Capability cap, @javax.annotation.Nullable Direction side) { + if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return lazyItemHandler.cast(); + } + + return super.getCapability(cap, side); + } + + @Override + public void onLoad() { + super.onLoad(); + lazyItemHandler = LazyOptional.of(() -> itemHandler); + } + + @Override + public void invalidateCaps() { + super.invalidateCaps(); + lazyItemHandler.invalidate(); + } + + @Override + protected void saveAdditional(@NotNull CompoundTag tag) { + tag.put("inventory", itemHandler.serializeNBT()); + super.saveAdditional(tag); + } + + @Override + public void load(CompoundTag nbt) { + super.load(nbt); + itemHandler.deserializeNBT(nbt.getCompound("inventory")); + } + + public void drops() { + SimpleContainer inventory = new SimpleContainer(itemHandler.getSlots()); + for (int i = 0; i < itemHandler.getSlots(); i++) { + inventory.setItem(i, itemHandler.getStackInSlot(i)); + } + + Containers.dropContents(this.level, this.worldPosition, inventory); + } + + + public static void tick(Level pLevel, BlockPos pPos, BlockState pState, BambooMatBlockEntity pBlockEntity) { + if(hasRecipe(pBlockEntity) && hasNotReachedStackLimit(pBlockEntity)) { + craftItem(pBlockEntity); + } + } + + private static void craftItem(BambooMatBlockEntity entity) { + entity.itemHandler.extractItem(0, 1, false); + entity.itemHandler.extractItem(1, 1, false); + entity.itemHandler.getStackInSlot(2).hurt(1, new Random(), null); + + entity.itemHandler.setStackInSlot(3, new ItemStack(ModItems.AVOCADO_TOAST.get(), + entity.itemHandler.getStackInSlot(3).getCount() + 1)); + } + + private static boolean hasRecipe(BambooMatBlockEntity entity) { + boolean hasItemInWaterSlot = PotionUtils.getPotion(entity.itemHandler.getStackInSlot(0)) == Potions.WATER; + boolean hasItemInFirstSlot = entity.itemHandler.getStackInSlot(1).getItem() == ModItems.AVOCADO.get(); + boolean hasItemInSecondSlot = entity.itemHandler.getStackInSlot(2).getItem() == Items.IRON_AXE; + + return hasItemInWaterSlot && hasItemInFirstSlot && hasItemInSecondSlot; + } + + private static boolean hasNotReachedStackLimit(BambooMatBlockEntity entity) { + return entity.itemHandler.getStackInSlot(3).getCount() < entity.itemHandler.getStackInSlot(3).getMaxStackSize(); + } +} + + +//entity.itemHandler.extractItem(0, 1, false); +// entity.itemHandler.extractItem(1, 1, false); +// entity.itemHandler.extractItem(2, 1, false); +// entity.itemHandler.extractItem(3, 1, false); +// entity.itemHandler.extractItem(4, 1, false); +// entity.itemHandler.setStackInSlot(3, new ItemStack(ModItems.AVOCADO_TOAST.get(), +// entity.itemHandler.getStackInSlot(5).getCount() + 1)); \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/item/ModFoods.java b/src/main/java/com/ncpbails/culturaldelights/item/ModFoods.java index c9a1064..b04e048 100644 --- a/src/main/java/com/ncpbails/culturaldelights/item/ModFoods.java +++ b/src/main/java/com/ncpbails/culturaldelights/item/ModFoods.java @@ -7,50 +7,59 @@ import vectorwing.farmersdelight.common.registry.ModEffects; public class ModFoods { - public static final FoodProperties AVOCADO = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.6F).build(); - public static final FoodProperties CUT_AVOCADO = (new FoodProperties.Builder()).fast().nutrition(2).saturationMod(0.3F).fast().build(); - public static final FoodProperties CUCUMBER = (new FoodProperties.Builder()).fast().nutrition(2).saturationMod(0.5F).build(); - public static final FoodProperties CUT_CUCUMBER = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.9F).fast().build(); - public static final FoodProperties PICKLE = (new FoodProperties.Builder()).fast().nutrition(1).saturationMod(0.2F).build(); - public static final FoodProperties CUT_PICKLE = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.5F).fast().build(); - public static final FoodProperties EGGPLANT = (new FoodProperties.Builder()).fast().nutrition(2).saturationMod(0.4F).build(); - public static final FoodProperties CUT_EGGPLANT = (new FoodProperties.Builder()).fast().nutrition(8).saturationMod(0.4F).fast().build(); - public static final FoodProperties SMOKED_EGGPLANT = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.8F).build(); - public static final FoodProperties SMOKED_TOMATO = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.6F).build(); - public static final FoodProperties SMOKED_CORN = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.6F).build(); - public static final FoodProperties SMOKED_CUT_EGGPLANT = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.8F).fast().build(); - public static final FoodProperties SMOKED_WHITE_EGGPLANT = (new FoodProperties.Builder()).fast().nutrition(2).saturationMod(0.8F).build(); - public static final FoodProperties WHITE_EGGPLANT = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.3F).build(); - public static final FoodProperties CORN_COB = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.6F).build(); - public static final FoodProperties POPCORN = (new FoodProperties.Builder()).fast().nutrition(1).saturationMod(0.2F).fast().build(); - public static final FoodProperties CORN_DOUGH = (new FoodProperties.Builder()).fast().nutrition(1).saturationMod(0.1F).build(); - public static final FoodProperties TORTILLA = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.6F).build(); - public static final FoodProperties TORTILLA_CHIPS = (new FoodProperties.Builder()).fast().nutrition(2).saturationMod(0.3F).fast().build(); + + //FOODS + public static final FoodProperties AVOCADO = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + public static final FoodProperties CUCUMBER = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.5F).build(); + public static final FoodProperties PICKLE = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.9F).build(); + public static final FoodProperties EGGPLANT = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.2F).build(); + public static final FoodProperties SMOKED_EGGPLANT = (new FoodProperties.Builder()).nutrition(8).saturationMod(1.4F).build(); + public static final FoodProperties SMOKED_TOMATO = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + public static final FoodProperties SMOKED_CORN = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.7F).build(); + public static final FoodProperties SMOKED_WHITE_EGGPLANT = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).build(); + public static final FoodProperties WHITE_EGGPLANT = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).build(); + public static final FoodProperties CORN_COB = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.4F).build(); + public static final FoodProperties CORN_DOUGH = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).build(); + public static final FoodProperties TORTILLA = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + + public static final FoodProperties ELOTE = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.8F).build(); + public static final FoodProperties BEEF_BURRITO = (new FoodProperties.Builder()).nutrition(14).saturationMod(0.7F).build(); + public static final FoodProperties MUTTON_SANDWICH = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties AVOCADO_TOAST = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.5F).build(); - public static final FoodProperties ELOTE = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.8F).build(); - public static final FoodProperties HEARTY_SALAD = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(1.1F) + //FAST TO EAT + public static final FoodProperties CUT_AVOCADO = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).fast().build(); + public static final FoodProperties CUT_CUCUMBER = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.3F).fast().build(); + public static final FoodProperties CUT_PICKLE = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.4F).fast().build(); + public static final FoodProperties CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).fast().build(); + public static final FoodProperties SMOKED_CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.7F).fast().build(); + public static final FoodProperties POPCORN = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.2F).fast().build(); + public static final FoodProperties TORTILLA_CHIPS = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).fast().build(); + + public static final FoodProperties VEGETABLE_MAKI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.4F).fast().build(); + public static final FoodProperties TAMAGO = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).fast().build(); + public static final FoodProperties CHICKEN_MAKI = (new FoodProperties.Builder()).nutrition(10).saturationMod(1F).fast().build(); + public static final FoodProperties COD_MAKI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).fast().build(); + public static final FoodProperties KOI_NIGIRI = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.5F).fast().build(); + public static final FoodProperties LIONFISH_MAKI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F) + .effect(() -> new MobEffectInstance(ModEffects.NOURISHMENT.get(), FoodValues.LONG_DURATION, 0), 1.0F).fast().build(); + public static final FoodProperties PERCH_NIGIRI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.25F).fast().build(); + public static final FoodProperties PIKE_MAKI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).fast().build(); + public static final FoodProperties PUFFERFISH_NIGIRI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F) + .effect(() -> new MobEffectInstance(MobEffects.CONFUSION, 200, 0), 1.0F) + .effect(() -> new MobEffectInstance(MobEffects.HUNGER, 200, 1), 1.0F).fast().build(); + public static final FoodProperties SALMON_NIGIRI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.6F).fast().build(); + public static final FoodProperties TROPICAL_NIGIRI = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.15F).fast().build(); + public static final FoodProperties ONIGIRI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).fast().build(); + + //MEALS + public static final FoodProperties HEARTY_SALAD = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.7F) .effect(() -> new MobEffectInstance(ModEffects.NOURISHMENT.get(), FoodValues.LONG_DURATION, 0), 1.0F).build(); - public static final FoodProperties BEEF_BURRITO = (new FoodProperties.Builder()).fast().nutrition(14).saturationMod(0.7F).build(); - public static final FoodProperties MUTTON_SANDWICH = (new FoodProperties.Builder()).fast().nutrition(10).saturationMod(0.8F).build(); - public static final FoodProperties FRIED_EGGPLANT_PASTA = (new FoodProperties.Builder()).fast().nutrition(12).saturationMod(0.9F) + public static final FoodProperties FRIED_EGGPLANT_PASTA = (new FoodProperties.Builder()).nutrition(12).saturationMod(0.9F) .effect(() -> new MobEffectInstance(ModEffects.NOURISHMENT.get(), FoodValues.LONG_DURATION, 0), 1.0F).build(); - public static final FoodProperties EGGPLANT_BURGER = (new FoodProperties.Builder()).fast().nutrition(12).saturationMod(0.7F).build(); - public static final FoodProperties AVOCADO_TOAST = (new FoodProperties.Builder()).fast().nutrition(4).saturationMod(0.5F).build(); + public static final FoodProperties EGGPLANT_BURGER = (new FoodProperties.Builder()).nutrition(12).saturationMod(0.7F).build(); + - public static final FoodProperties VEGETABLE_MAKI = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.4F).build(); - public static final FoodProperties TAMAGO = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.5F).build(); - public static final FoodProperties CHICKEN_MAKI = (new FoodProperties.Builder()).fast().nutrition(10).saturationMod(1F).build(); - public static final FoodProperties COD_MAKI = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.5F).build(); - public static final FoodProperties KOI_NIGIRI = (new FoodProperties.Builder()).fast().nutrition(1).saturationMod(0.5F).build(); - public static final FoodProperties LIONFISH_MAKI = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.5F) - .effect(() -> new MobEffectInstance(ModEffects.NOURISHMENT.get(), FoodValues.LONG_DURATION, 0), 1.0F).build(); - public static final FoodProperties PERCH_NIGIRI = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.25F).build(); - public static final FoodProperties PIKE_MAKI = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.5F).build(); - public static final FoodProperties PUFFERFISH_NIGIRI = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.5F) - .effect(() -> new MobEffectInstance(MobEffects.CONFUSION, 200, 0), 1.0F) - .effect(() -> new MobEffectInstance(MobEffects.HUNGER, 200, 1), 1.0F).build(); - public static final FoodProperties SALMON_NIGIRI = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.6F).build(); - public static final FoodProperties TROPICAL_NIGIRI = (new FoodProperties.Builder()).fast().nutrition(1).saturationMod(0.15F).build(); - public static final FoodProperties ONIGIRI = (new FoodProperties.Builder()).fast().nutrition(3).saturationMod(0.5F).build(); + } \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/item/ModItems.java b/src/main/java/com/ncpbails/culturaldelights/item/ModItems.java index 15c043e..536d7ac 100644 --- a/src/main/java/com/ncpbails/culturaldelights/item/ModItems.java +++ b/src/main/java/com/ncpbails/culturaldelights/item/ModItems.java @@ -103,7 +103,7 @@ public class ModItems { () -> new Item(new Item.Properties().tab(FarmersDelight.CREATIVE_TAB).food(ModFoods.MUTTON_SANDWICH))); public static final RegistryObject FRIED_EGGPLANT_PASTA = ITEMS.register("fried_eggplant_pasta", - () -> new Item(new Item.Properties().tab(FarmersDelight.CREATIVE_TAB).food(ModFoods.FRIED_EGGPLANT_PASTA))); + () -> new BowlFoodItem(new Item.Properties().tab(FarmersDelight.CREATIVE_TAB).food(ModFoods.FRIED_EGGPLANT_PASTA))); public static final RegistryObject EGGPLANT_BURGER = ITEMS.register("eggplant_burger", () -> new Item(new Item.Properties().tab(FarmersDelight.CREATIVE_TAB).food(ModFoods.EGGPLANT_BURGER))); diff --git a/src/main/java/com/ncpbails/culturaldelights/screen/BambooMatMenu.java b/src/main/java/com/ncpbails/culturaldelights/screen/BambooMatMenu.java new file mode 100644 index 0000000..04eaff6 --- /dev/null +++ b/src/main/java/com/ncpbails/culturaldelights/screen/BambooMatMenu.java @@ -0,0 +1,117 @@ +package com.ncpbails.culturaldelights.screen; + +import com.ncpbails.culturaldelights.block.ModBlocks; +import com.ncpbails.culturaldelights.block.entity.custom.BambooMatBlockEntity; +import com.ncpbails.culturaldelights.screen.slot.ModResultSlot; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.SlotItemHandler; + +public class BambooMatMenu extends AbstractContainerMenu { + + private final BambooMatBlockEntity blockEntity; + private final Level level; + + public BambooMatMenu(int pContainerId, Inventory inv, FriendlyByteBuf extraData) { + this(pContainerId, inv, inv.player.level.getBlockEntity(extraData.readBlockPos())); + } + + public BambooMatMenu(int pContainerId, Inventory inv, BlockEntity entity) { + super(ModMenuTypes.BAMBOO_MAT_MENU.get(), pContainerId); + checkContainerSize(inv, 6); + blockEntity = ((BambooMatBlockEntity) entity); + this.level = inv.player.level; + + addPlayerInventory(inv); + addPlayerHotbar(inv); + + this.blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(handler -> { + this.addSlot(new SlotItemHandler(handler, 0, 34, 40)); + this.addSlot(new SlotItemHandler(handler, 1, 57, 18)); + this.addSlot(new SlotItemHandler(handler, 2, 103, 18)); + this.addSlot(new SlotItemHandler(handler, 3, 103, 18)); + this.addSlot(new SlotItemHandler(handler, 4, 103, 18)); + this.addSlot(new ModResultSlot(handler, 5, 80, 60)); + }); + } + + + // CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons + // must assign a slot number to each of the slots used by the GUI. + // For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar. + // Each time we add a Slot to the container, it automatically increases the slotIndex, which means + // 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8) + // 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35) + // 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8) + private static final int HOTBAR_SLOT_COUNT = 9; + private static final int PLAYER_INVENTORY_ROW_COUNT = 3; + private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9; + private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT; + private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT; + private static final int VANILLA_FIRST_SLOT_INDEX = 0; + private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT; + + // THIS YOU HAVE TO DEFINE! + private static final int TE_INVENTORY_SLOT_COUNT = 6; // must be the number of slots you have! + + @Override + public ItemStack quickMoveStack(Player playerIn, int index) { + Slot sourceSlot = slots.get(index); + if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM + ItemStack sourceStack = sourceSlot.getItem(); + ItemStack copyOfSourceStack = sourceStack.copy(); + + // Check if the slot clicked is one of the vanilla container slots + if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) { + // This is a vanilla container slot so merge the stack into the tile inventory + if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + + TE_INVENTORY_SLOT_COUNT, false)) { + return ItemStack.EMPTY; // EMPTY_ITEM + } + } else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) { + // This is a TE slot so merge the stack into the players inventory + if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) { + return ItemStack.EMPTY; + } + } else { + System.out.println("Invalid slotIndex:" + index); + return ItemStack.EMPTY; + } + // If stack size == 0 (the entire stack was moved) set slot contents to null + if (sourceStack.getCount() == 0) { + sourceSlot.set(ItemStack.EMPTY); + } else { + sourceSlot.setChanged(); + } + sourceSlot.onTake(playerIn, sourceStack); + return copyOfSourceStack; + } + + @Override + public boolean stillValid(Player pPlayer) { + return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), + pPlayer, ModBlocks.BAMBOO_MAT.get()); + } + + private void addPlayerInventory(Inventory playerInventory) { + for (int i = 0; i < 3; ++i) { + for (int l = 0; l < 9; ++l) { + this.addSlot(new Slot(playerInventory, l + i * 9 + 9, 8 + l * 18, 86 + i * 18)); + } + } + } + + private void addPlayerHotbar(Inventory playerInventory) { + for (int i = 0; i < 9; ++i) { + this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 144)); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/screen/BambooMatScreen.java b/src/main/java/com/ncpbails/culturaldelights/screen/BambooMatScreen.java new file mode 100644 index 0000000..ea2d380 --- /dev/null +++ b/src/main/java/com/ncpbails/culturaldelights/screen/BambooMatScreen.java @@ -0,0 +1,38 @@ +package com.ncpbails.culturaldelights.screen; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.ncpbails.culturaldelights.CulturalDelights; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; + +public class BambooMatScreen extends AbstractContainerScreen { + private static final ResourceLocation TEXTURE = + new ResourceLocation(CulturalDelights.MOD_ID, "textures/gui/bamboo_mat_gui.png"); + + public BambooMatScreen(BambooMatMenu pMenu, Inventory pPlayerInventory, Component pTitle) { + super(pMenu, pPlayerInventory, pTitle); + } + + @Override + protected void renderBg(PoseStack pPoseStack, float pPartialTick, int pMouseX, int pMouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, TEXTURE); + int x = (width - imageWidth) / 2; + int y = (height - imageHeight) / 2; + + this.blit(pPoseStack, x, y, 0, 0, imageWidth, imageHeight); + } + + @Override + public void render(PoseStack pPoseStack, int mouseX, int mouseY, float delta) { + renderBackground(pPoseStack); + super.render(pPoseStack, mouseX, mouseY, delta); + renderTooltip(pPoseStack, mouseX, mouseY); + } +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/screen/ModMenuTypes.java b/src/main/java/com/ncpbails/culturaldelights/screen/ModMenuTypes.java new file mode 100644 index 0000000..4c284d5 --- /dev/null +++ b/src/main/java/com/ncpbails/culturaldelights/screen/ModMenuTypes.java @@ -0,0 +1,28 @@ +package com.ncpbails.culturaldelights.screen; + +import com.ncpbails.culturaldelights.CulturalDelights; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraftforge.common.extensions.IForgeMenuType; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.network.IContainerFactory; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +public class ModMenuTypes { + public static final DeferredRegister> MENUS = + DeferredRegister.create(ForgeRegistries.CONTAINERS, CulturalDelights.MOD_ID); + + public static final RegistryObject> BAMBOO_MAT_MENU = + registerMenuType(BambooMatMenu::new, "bamboo_mat_menu"); + + + private static RegistryObject> registerMenuType(IContainerFactory factory, String name) { + return MENUS.register(name, () -> IForgeMenuType.create(factory)); + } + + public static void register(IEventBus eventBus) { + MENUS.register(eventBus); + } +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/screen/slot/ModResultSlot.java b/src/main/java/com/ncpbails/culturaldelights/screen/slot/ModResultSlot.java new file mode 100644 index 0000000..b828e42 --- /dev/null +++ b/src/main/java/com/ncpbails/culturaldelights/screen/slot/ModResultSlot.java @@ -0,0 +1,16 @@ +package com.ncpbails.culturaldelights.screen.slot; + +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.SlotItemHandler; + +public class ModResultSlot extends SlotItemHandler { + public ModResultSlot(IItemHandler itemHandler, int index, int x, int y) { + super(itemHandler, index, x, y); + } + + @Override + public boolean mayPlace(ItemStack stack) { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/world/feature/ModConfiguredFeatures.java b/src/main/java/com/ncpbails/culturaldelights/world/feature/ModConfiguredFeatures.java index ecd3bff..2ec380d 100644 --- a/src/main/java/com/ncpbails/culturaldelights/world/feature/ModConfiguredFeatures.java +++ b/src/main/java/com/ncpbails/culturaldelights/world/feature/ModConfiguredFeatures.java @@ -41,4 +41,13 @@ public class ModConfiguredFeatures { FeatureUtils.register("avocado_spawn", Feature.RANDOM_SELECTOR, new RandomFeatureConfiguration(List.of(new WeightedPlacedFeature(AVOCADO_CHECKED, 0.5F)), AVOCADO_CHECKED)); + + + public static final Holder> AVOCADO_PIT = + FeatureUtils.register("avocado_pit", Feature.TREE, new TreeConfiguration.TreeConfigurationBuilder( + BlockStateProvider.simple(ModBlocks.AVOCADO_SAPLING.get()), + new StraightTrunkPlacer(3, 2, 0), + BlockStateProvider.simple(ModBlocks.AVOCADO_SAPLING.get()), + new AcaciaFoliagePlacer(ConstantInt.of(0), ConstantInt.of(0)), + new TwoLayersFeatureSize(1, 0, 1)).build()); } diff --git a/src/main/java/com/ncpbails/culturaldelights/world/feature/ModPlacedFeatures.java b/src/main/java/com/ncpbails/culturaldelights/world/feature/ModPlacedFeatures.java index 8652e50..313b507 100644 --- a/src/main/java/com/ncpbails/culturaldelights/world/feature/ModPlacedFeatures.java +++ b/src/main/java/com/ncpbails/culturaldelights/world/feature/ModPlacedFeatures.java @@ -7,5 +7,5 @@ public class ModPlacedFeatures { public static final Holder AVOCADO_PLACED = PlacementUtils.register("avocado_placed", - ModConfiguredFeatures.AVOCADO_SPAWN, VegetationPlacements.treePlacement(PlacementUtils.countExtra(3, 0.1f, 2))); + ModConfiguredFeatures.AVOCADO_SPAWN, VegetationPlacements.treePlacement(PlacementUtils.countExtra(1, 0.1f, 1))); } diff --git a/src/main/java/com/ncpbails/culturaldelights/world/feature/tree/AvocadoPitGrower.java b/src/main/java/com/ncpbails/culturaldelights/world/feature/tree/AvocadoPitGrower.java new file mode 100644 index 0000000..b1148ed --- /dev/null +++ b/src/main/java/com/ncpbails/culturaldelights/world/feature/tree/AvocadoPitGrower.java @@ -0,0 +1,17 @@ +package com.ncpbails.culturaldelights.world.feature.tree; + +import com.ncpbails.culturaldelights.world.feature.ModConfiguredFeatures; +import net.minecraft.core.Holder; +import net.minecraft.world.level.block.grower.AbstractTreeGrower; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; + +import javax.annotation.Nullable; +import java.util.Random; + +public class AvocadoPitGrower extends AbstractTreeGrower { + @Nullable + @Override + protected Holder> getConfiguredFeature(Random pRandom, boolean pLargeHive) { + return ModConfiguredFeatures.AVOCADO_PIT; + } +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/world/feature/tree/AvocadoTreeGrower.java b/src/main/java/com/ncpbails/culturaldelights/world/feature/tree/AvocadoTreeGrower.java index 3f0465b..a36f22a 100644 --- a/src/main/java/com/ncpbails/culturaldelights/world/feature/tree/AvocadoTreeGrower.java +++ b/src/main/java/com/ncpbails/culturaldelights/world/feature/tree/AvocadoTreeGrower.java @@ -1,5 +1,6 @@ package com.ncpbails.culturaldelights.world.feature.tree; +import com.ncpbails.culturaldelights.world.feature.ModConfiguredFeatures; import net.minecraft.core.Holder; import net.minecraft.world.level.block.grower.AbstractTreeGrower; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; @@ -11,6 +12,6 @@ public class AvocadoTreeGrower extends AbstractTreeGrower { @Nullable @Override protected Holder> getConfiguredFeature(Random pRandom, boolean pLargeHive) { - return null; + return ModConfiguredFeatures.AVOCADO_TREE; } } \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index b030d0f..4b55cba 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -54,3 +54,9 @@ description="A Farmer's Delight addon that adds food systems from around the wor versionRange="[1.18.2,1.19)" ordering="NONE" side="BOTH" +[[dependencies.culturaldelights]] + modId = "farmersdelight" + mandatory = true + versionRange = "[0.6.0,)" + ordering = "AFTER" + side = "BOTH" \ No newline at end of file diff --git a/src/main/resources/assets/culturaldelights/lang/en_us.json b/src/main/resources/assets/culturaldelights/lang/en_us.json index 811f7cd..b6393de 100644 --- a/src/main/resources/assets/culturaldelights/lang/en_us.json +++ b/src/main/resources/assets/culturaldelights/lang/en_us.json @@ -1,6 +1,11 @@ { "itemGroup.culturalTab": "Cultural Delights", + "item.culturaldelights.cucumber_seeds": "Cucumber Seeds", + "item.culturaldelights.eggplant_seeds": "Eggplant Seeds", + "item.culturaldelights.white_eggplant_seeds": "White Eggplant Seeds", + "item.culturaldelights.corn_kernels": "Corn Kernels", + "item.culturaldelights.avocado": "Avocado", "item.culturaldelights.cut_avocado": "Cut Avocado", "item.culturaldelights.cucumber": "Cucumber", @@ -47,11 +52,6 @@ "block.culturaldelights.wild_cucumbers": "Wild Cucumbers", "block.culturaldelights.wild_corn": "Wild Corn", "block.culturaldelights.wild_eggplants": "Wild Eggplants", - "block.culturaldelights.cucumbers": "Cucumber Seeds", - "block.culturaldelights.eggplants": "Eggplant Seeds", - "block.culturaldelights.white_eggplants": "White Eggplant Seeds", - "block.culturaldelights.corn": "Corn Kernels", - "block.culturaldelights.corn_upper": "Corn Kernels", "block.culturaldelights.avocado_log": "Avocado Log", "block.culturaldelights.avocado_wood": "Avocado Wood", "block.culturaldelights.avocado_leaves": "Avocado Leaves", diff --git a/src/main/resources/data/culturaldelights/recipes/avocado_toast.json b/src/main/resources/data/culturaldelights/recipes/avocado_toast.json index c30921a..1696434 100644 --- a/src/main/resources/data/culturaldelights/recipes/avocado_toast.json +++ b/src/main/resources/data/culturaldelights/recipes/avocado_toast.json @@ -13,6 +13,6 @@ ], "result": { "item": "culturaldelights:avocado_toast", - "count": 2 + "count": 4 } } \ No newline at end of file diff --git a/src/main/resources/data/culturaldelights/recipes/mat_rolling/avocado_toast.json b/src/main/resources/data/culturaldelights/recipes/mat_rolling/avocado_toast.json index b7bc46d..09deeb5 100644 --- a/src/main/resources/data/culturaldelights/recipes/mat_rolling/avocado_toast.json +++ b/src/main/resources/data/culturaldelights/recipes/mat_rolling/avocado_toast.json @@ -19,6 +19,6 @@ ], "output": { "item": "culturaldelights:avocado_toast", - "count": 4 + "count": 8 } } diff --git a/src/main/resources/data/culturaldelights/recipes/mutton_sandwich.json b/src/main/resources/data/culturaldelights/recipes/mutton_sandwich.json index 6d13576..3e694bd 100644 --- a/src/main/resources/data/culturaldelights/recipes/mutton_sandwich.json +++ b/src/main/resources/data/culturaldelights/recipes/mutton_sandwich.json @@ -2,7 +2,7 @@ "type": "minecraft:crafting_shapeless", "ingredients": [ { - "item": "minecraft:bread" + "tag": "forge:bread" }, { "tag": "forge:cooked_mutton"