forked from Nyancatpig/Cultural-Delights-1.18.2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
382 changed files
with
4,732 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package com.ncpbails.culturaldelights.block; | ||
|
||
import com.ncpbails.culturaldelights.CulturalDelights; | ||
import com.ncpbails.culturaldelights.block.custom.*; | ||
import com.ncpbails.culturaldelights.item.ModItems; | ||
import com.ncpbails.culturaldelights.world.feature.tree.AvocadoTreeGrower; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.*; | ||
import net.minecraft.world.item.crafting.RecipeType; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.*; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.material.Material; | ||
import net.minecraft.world.level.material.MaterialColor; | ||
import net.minecraftforge.common.ToolAction; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.registries.DeferredRegister; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import net.minecraftforge.registries.RegistryObject; | ||
import org.jetbrains.annotations.Nullable; | ||
import vectorwing.farmersdelight.FarmersDelight; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class ModBlocks { | ||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, CulturalDelights.MOD_ID); | ||
|
||
public static final RegistryObject<Block> AVOCADO_BUNDLE = registerBlock("avocado_bundle", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) | ||
.strength(0, 1f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> BAMBOO_MAT = registerBlock("bamboo_mat", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.BAMBOO, MaterialColor.COLOR_GREEN) | ||
.strength(0, 1f).noOcclusion()), FarmersDelight.CREATIVE_TAB, true, 0); | ||
|
||
public static final RegistryObject<Block> WILD_CUCUMBERS = registerBlock("wild_cucumbers", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) | ||
.strength(0, 0f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> WILD_CORN = registerBlock("wild_corn", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) | ||
.strength(0, 0f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> WILD_EGGPLANTS = registerBlock("wild_eggplants", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) | ||
.strength(0, 0f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> AVOCADO_LOG = registerBlock("avocado_log", | ||
() -> new RotatedPillarBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_LOG)) { | ||
@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; } | ||
@Nullable @Override public BlockState getToolModifiedState(BlockState state, Level world, BlockPos pos, Player player, ItemStack stack, ToolAction toolAction){ | ||
if(stack.getItem() instanceof AxeItem) { return Blocks.JUNGLE_LOG.defaultBlockState().setValue(AXIS, state.getValue(AXIS)); } | ||
return super.getToolModifiedState(state, world, pos, player, stack, toolAction); } | ||
}, FarmersDelight.CREATIVE_TAB, true, 0); | ||
|
||
public static final RegistryObject<Block> AVOCADO_WOOD = registerBlock("avocado_wood", | ||
() -> new RotatedPillarBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_WOOD)) { | ||
@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; } | ||
@Nullable @Override public BlockState getToolModifiedState(BlockState state, Level world, BlockPos pos, Player player, ItemStack stack, ToolAction toolAction){ | ||
if(stack.getItem() instanceof AxeItem) { return Blocks.JUNGLE_WOOD.defaultBlockState().setValue(AXIS, state.getValue(AXIS)); } | ||
return super.getToolModifiedState(state, world, pos, player, stack, toolAction); } | ||
}, FarmersDelight.CREATIVE_TAB, true, 0); | ||
|
||
public static final RegistryObject<Block> AVOCADO_LEAVES = registerBlock("avocado_leaves", | ||
() -> new LeavesBlock(BlockBehaviour.Properties.of(Material.LEAVES, MaterialColor.COLOR_GREEN) | ||
.strength(0, 0.2f).noOcclusion()) { | ||
@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<Block> AVOCADO_SAPLING = registerBlock("avocado_sapling", | ||
() -> new SaplingBlock(new AvocadoTreeGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING)), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> CUCUMBERS = registerBlockWithoutBlockItem("cucumbers", | ||
() -> new CucumbersBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion())); | ||
|
||
public static final RegistryObject<Block> WHITE_EGGPLANTS = registerBlockWithoutBlockItem("white_eggplants", | ||
() -> new WhiteEggplantsBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion())); | ||
|
||
public static final RegistryObject<Block> EGGPLANTS = registerBlockWithoutBlockItem("eggplants", | ||
() -> new EggplantsBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion())); | ||
|
||
public static final RegistryObject<Block> CORN = registerBlock("corn", | ||
() -> new CornBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> CORN_UPPER = registerBlock("corn_upper", | ||
() -> new CornUpperBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
//public static final RegistryObject<Block> 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<Block> AVOCADO_CRATE = registerBlock("avocado_crate", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) | ||
.strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> CUCUMBER_CRATE = registerBlock("cucumber_crate", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) | ||
.strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> PICKLE_CRATE = registerBlock("pickle_crate", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) | ||
.strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> 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); | ||
|
||
public static final RegistryObject<Block> EGGPLANT_CRATE = registerBlock("eggplant_crate", | ||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN) | ||
.strength(2, 3f)), FarmersDelight.CREATIVE_TAB, false, 0); | ||
|
||
public static final RegistryObject<Block> 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); | ||
|
||
|
||
|
||
|
||
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block, CreativeModeTab tab, Boolean isFuel, Integer fuelAmount) { | ||
RegistryObject<T> toReturn = BLOCKS.register(name, block); | ||
registerBlockItem(name, toReturn, tab, isFuel, fuelAmount); | ||
return toReturn; | ||
} | ||
|
||
private static <T extends Block> RegistryObject<T> registerBlockWithoutBlockItem(String name, Supplier<T> block) { | ||
return BLOCKS.register(name, block); | ||
} | ||
|
||
private static <T extends Block> RegistryObject<Item> registerBlockItem(String name, RegistryObject<T> block, CreativeModeTab tab, Boolean isFuel, Integer fuelAmount) { | ||
if(isFuel == false) { | ||
return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), | ||
new Item.Properties().tab(tab))); | ||
} else { | ||
return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), | ||
new Item.Properties().tab(tab)){ | ||
@Override public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType) {return fuelAmount;}}); | ||
} | ||
} | ||
|
||
public static void register(IEventBus eventBus) { | ||
BLOCKS.register(eventBus); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/ncpbails/culturaldelights/block/custom/AvocadoPitBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.ncpbails.culturaldelights.block.custom; | ||
|
||
|
||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.SaplingBlock; | ||
import net.minecraft.world.level.block.grower.AbstractTreeGrower; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class AvocadoPitBlock extends SaplingBlock { | ||
|
||
private static final VoxelShape SHAPE_PIT = (VoxelShape) Stream.of( | ||
Block.box(6, 0, 6, 10, 3, 10) | ||
); | ||
|
||
public AvocadoPitBlock(AbstractTreeGrower treeIn, Properties properties) { | ||
super(treeIn, properties); | ||
} | ||
|
||
@Override | ||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { | ||
return SHAPE_PIT; | ||
|
||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/ncpbails/culturaldelights/block/custom/BambooMatBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.ncpbails.culturaldelights.block.custom; | ||
|
||
|
||
import net.minecraft.core.BlockPos; | ||
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.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.shapes.CollisionContext; | ||
import net.minecraftforge.items.CapabilityItemHandler; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.Optional; | ||
import java.util.stream.Stream; | ||
|
||
public class BambooMatBlock extends Block { | ||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; | ||
|
||
public BambooMatBlock(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
//start of block model | ||
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 1, 15); | ||
|
||
@Override | ||
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { | ||
return SHAPE; | ||
} | ||
|
||
/* FACING */ | ||
|
||
@Override | ||
public BlockState getStateForPlacement(BlockPlaceContext pContext) { | ||
return this.defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite()); | ||
} | ||
|
||
@Override | ||
public BlockState rotate(BlockState pState, Rotation pRotation) { | ||
return pState.setValue(FACING, pRotation.rotate(pState.getValue(FACING))); | ||
} | ||
|
||
@Override | ||
public BlockState mirror(BlockState pState, Mirror pMirror) { | ||
return pState.rotate(pMirror.getRotation(pState.getValue(FACING))); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { | ||
pBuilder.add(FACING); | ||
} | ||
} |
Oops, something went wrong.