generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
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.
- Loading branch information
MCZME
committed
Aug 6, 2024
1 parent
6b82ce1
commit f5d08e8
Showing
24 changed files
with
542 additions
and
28 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
// 1.21 2024-08-02T19:21:51.9075616 Loot Tables | ||
// 1.21 2024-08-06T21:56:13.9856387 Loot Tables | ||
c843630bb0739aad37078f0119c9cc31f5316c3a data/lingshi/loot_table/blocks/tea_leaf.json | ||
3cd0ced47f090fec162cddcb8b2f75284fa134cb data/lingshi/loot_table/blocks/tea_tree.json |
2 changes: 2 additions & 0 deletions
2
src/generated/resources/.cache/85f12f813aff948f91f5cd129c0ffa86bcb17361
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,2 @@ | ||
// 1.21 2024-08-06T21:56:13.987637 Languages: zh_cn for mod: lingshi | ||
e555acbe8820b73ef1de654d149cfca34bba5963 assets/lingshi/lang/zh_cn.json |
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,8 @@ | ||
{ | ||
"block.lingshi.rice": "稻米", | ||
"block.lingshi.tea_tree": "茶树", | ||
"item.lingshi.rice_of_ear": "稻穗", | ||
"item.lingshi.rice_seedling": "稻苗", | ||
"item.lingshi.tea_leaf": "茶叶", | ||
"lingshi.lingshi_tab": "灵食" | ||
} |
21 changes: 21 additions & 0 deletions
21
src/generated/resources/data/lingshi/loot_table/blocks/tea_leaf.json
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,21 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "lingshi:tea_leaf" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
], | ||
"random_sequence": "lingshi:blocks/tea_leaf" | ||
} |
21 changes: 21 additions & 0 deletions
21
src/generated/resources/data/lingshi/loot_table/blocks/tea_tree.json
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,21 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "lingshi:tea_tree" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
], | ||
"random_sequence": "lingshi:blocks/tea_tree" | ||
} |
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
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
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,73 @@ | ||
package mczme.lingshi.common.block; | ||
|
||
import mczme.lingshi.common.registry.ModBlocks; | ||
import mczme.lingshi.common.registry.ModItems; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.ItemLike; | ||
import net.minecraft.world.level.LevelReader; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.CropBlock; | ||
import net.minecraft.world.level.block.SoundType; | ||
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.IntegerProperty; | ||
import net.minecraft.world.level.material.PushReaction; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
public class TeaBlock extends CropBlock { | ||
public static final IntegerProperty AGE = BlockStateProperties.AGE_3; | ||
private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{ | ||
Block.box(0, 0.0, 0, 16.0, 2.0, 16.0), | ||
Block.box(0, 0.0, 0, 16.0, 4.0, 16.0), | ||
Block.box(0, 0.0, 0, 16.0, 6.0, 16.0), | ||
Block.box(0, 0.0, 0, 16.0, 8.0, 16.0) | ||
}; | ||
|
||
public TeaBlock(Properties properties) { | ||
super(properties.randomTicks().noCollission().instabreak().sound(SoundType.CROP).pushReaction(PushReaction.DESTROY)); | ||
} | ||
|
||
@Override | ||
public IntegerProperty getAgeProperty() { | ||
return AGE; | ||
} | ||
|
||
@Override | ||
public int getAge(BlockState state) { | ||
return state.getValue(this.getAgeProperty()); | ||
} | ||
|
||
@Override | ||
public int getMaxAge() { | ||
return 3; | ||
} | ||
|
||
@Override | ||
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { | ||
return SHAPE_BY_AGE[this.getAge(state)]; | ||
} | ||
|
||
@Override | ||
public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { | ||
return (level.getRawBrightness(pos, 0) >= 8 || level.canSeeSky(pos)) && this.mayPlaceOn(level.getBlockState(pos.below()), level, pos); | ||
} | ||
|
||
@Override | ||
protected ItemLike getBaseSeedId() { | ||
return ModItems.TEA_LEAF.get(); | ||
} | ||
|
||
@Override | ||
protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) { | ||
return state.is(ModBlocks.TEA_TREE.get()); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { | ||
pBuilder.add(AGE); | ||
} | ||
|
||
} |
143 changes: 143 additions & 0 deletions
143
src/main/java/mczme/lingshi/common/block/TeaTreeBlock.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,143 @@ | ||
package mczme.lingshi.common.block; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import mczme.lingshi.common.registry.ModBlocks; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.LevelReader; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.BonemealableBlock; | ||
import net.minecraft.world.level.block.BushBlock; | ||
import net.minecraft.world.level.block.SoundType; | ||
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.IntegerProperty; | ||
import net.minecraft.world.level.material.PushReaction; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
public class TeaTreeBlock extends BushBlock implements BonemealableBlock { | ||
|
||
public static final IntegerProperty AGE = BlockStateProperties.AGE_3; | ||
public static final VoxelShape[] SHAPE = new VoxelShape[]{Block.box(7.0, 0, 7.0, 10, 10, 10), | ||
Shapes.or(Block.box(7.0, 0, 7.0, 10, 8, 10),Block.box(3.5,8,3.5,12.5,14,12.5)), | ||
Shapes.or(Block.box(7.0, 0, 7.0, 10, 6, 10),Block.box(2.0,6,2,14,14,14)), | ||
Shapes.or(Block.box(7.0, 0, 7.0, 10, 5, 10),Block.box(0,5,0,16,16,16))}; | ||
|
||
public TeaTreeBlock(Properties properties) { | ||
super(properties.randomTicks().noCollission().instabreak().sound(SoundType.CROP).pushReaction(PushReaction.DESTROY)); | ||
this.registerDefaultState(this.defaultBlockState().setValue(AGE, 0)); | ||
} | ||
|
||
@Override | ||
protected MapCodec<? extends BushBlock> codec() { | ||
return null; | ||
} | ||
|
||
public IntegerProperty getAgeProperty() { | ||
return AGE; | ||
} | ||
|
||
protected int getAge(BlockState state) { | ||
return state.getValue(this.getAgeProperty()); | ||
} | ||
|
||
public int getMaxAge() { | ||
return 3; | ||
} | ||
|
||
public BlockState getStateForAge(int pAge) { | ||
return this.defaultBlockState().setValue(this.getAgeProperty(), pAge); | ||
} | ||
|
||
@Override | ||
public void randomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) { | ||
super.tick(pState, pLevel, pPos, pRandom); | ||
if (!pLevel.isAreaLoaded(pPos, 1)) return; | ||
if (pLevel.getRawBrightness(pPos.above(), 0) >= 6) { | ||
int age = getAge(pState); | ||
if (age <= getMaxAge()) { | ||
float f = 12.0F; | ||
if (net.neoforged.neoforge.common.CommonHooks.canCropGrow(pLevel, pPos, pState, pRandom.nextInt((int) (25.0F / f) + 1) == 0)) { | ||
if (age != getMaxAge()) { | ||
pLevel.setBlock(pPos, this.getStateForAge(age + 1), 2); | ||
net.neoforged.neoforge.common.CommonHooks.fireCropGrowPost(pLevel, pPos, pState); | ||
} else { | ||
TeaBlock topBlock = ModBlocks.TEA_LEAF.get(); | ||
if (topBlock.defaultBlockState().canSurvive(pLevel, pPos.above()) && pLevel.isEmptyBlock(pPos.above())) { | ||
pLevel.setBlockAndUpdate(pPos.above(), topBlock.defaultBlockState()); | ||
net.neoforged.neoforge.common.CommonHooks.fireCropGrowPost(pLevel, pPos, pState); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isValidBonemealTarget(LevelReader pLevel, BlockPos pPos, BlockState pState) { | ||
BlockState upperState = pLevel.getBlockState(pPos.above()); | ||
if (upperState.getBlock() instanceof TeaBlock) { | ||
return !((TeaBlock) upperState.getBlock()).isMaxAge(upperState); | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isBonemealSuccess(Level pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) { | ||
return true; | ||
} | ||
|
||
protected int getBonemealAgeIncrease(Level level) { | ||
return Mth.nextInt(level.random, 1, 2); | ||
} | ||
|
||
@Override | ||
public void performBonemeal(ServerLevel pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) { | ||
int ageGrowth = Math.min(this.getAge(pState) + this.getBonemealAgeIncrease(pLevel), 5); | ||
if (ageGrowth <= this.getMaxAge()) { | ||
pLevel.setBlockAndUpdate(pPos, pState.setValue(AGE, ageGrowth)); | ||
} else { | ||
BlockState top = pLevel.getBlockState(pPos.above()); | ||
if (top.getBlock() == ModBlocks.TEA_LEAF.get()) { | ||
BonemealableBlock growable = (BonemealableBlock) pLevel.getBlockState(pPos.above()).getBlock(); | ||
if (growable.isValidBonemealTarget(pLevel, pPos.above(), top)) { | ||
growable.performBonemeal(pLevel, pLevel.random, pPos.above(), top); | ||
} | ||
} else { | ||
TeaBlock Upper = ModBlocks.TEA_LEAF.get(); | ||
int remainingGrowth = ageGrowth - this.getMaxAge() - 1; | ||
if (Upper.defaultBlockState().canSurvive(pLevel, pPos.above()) && pLevel.isEmptyBlock(pPos.above())) { | ||
pLevel.setBlockAndUpdate(pPos, pState.setValue(AGE, this.getMaxAge())); | ||
pLevel.setBlock(pPos.above(), Upper.defaultBlockState().setValue(TeaBlock.AGE, remainingGrowth), 2); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected void entityInside(BlockState pState, Level pLevel, BlockPos pPos, Entity pEntity) { | ||
if (pEntity instanceof LivingEntity) { | ||
pEntity.makeStuckInBlock(pState, new Vec3(0.8F, 0.75, 0.8F)); | ||
} | ||
} | ||
|
||
@Override | ||
protected VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { | ||
return SHAPE[getAge(pState)]; | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { | ||
pBuilder.add(AGE); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/mczme/lingshi/common/data/lang/ChineseLanguageProvider.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,25 @@ | ||
package mczme.lingshi.common.data.lang; | ||
|
||
import mczme.lingshi.common.registry.ModItems; | ||
import net.minecraft.data.PackOutput; | ||
import net.neoforged.neoforge.common.data.LanguageProvider; | ||
|
||
import static mczme.lingshi.lingshi.MODID; | ||
|
||
public class ChineseLanguageProvider extends LanguageProvider { | ||
public ChineseLanguageProvider(PackOutput output) { | ||
super(output, MODID, "zh_cn"); | ||
} | ||
|
||
@Override | ||
protected void addTranslations() { | ||
this.add("lingshi.lingshi_tab", "灵食"); | ||
|
||
this.add(ModItems.RICE.get(), "稻米"); | ||
this.add(ModItems.RICE_SEEDLING.get(), "稻苗"); | ||
this.add(ModItems.RICE_OF_EAR.get(),"稻穗"); | ||
|
||
this.add(ModItems.TEA_TREE.get(), "茶树"); | ||
this.add(ModItems.TEA_LEAF.get(), "茶叶"); | ||
} | ||
} |
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
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
Oops, something went wrong.