Skip to content

Commit

Permalink
添加:稻米
Browse files Browse the repository at this point in the history
  • Loading branch information
MCZME committed Aug 1, 2024
1 parent 083b765 commit 3e87ecf
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 199 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.21 2024-08-01T22:24:42.609971 Loot Tables
b82daccc5f953aaa0327a61f85766c8394427685 data/lingshi/loot_table/blocks/rice.json
21 changes: 21 additions & 0 deletions src/generated/resources/data/lingshi/loot_table/blocks/rice.json
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:rice"
}
],
"rolls": 1.0
}
],
"random_sequence": "lingshi:blocks/rice"
}
63 changes: 0 additions & 63 deletions src/main/java/mczme/lingshi/Config.java

This file was deleted.

136 changes: 0 additions & 136 deletions src/main/java/mczme/lingshi/ExampleMod.java

This file was deleted.

56 changes: 56 additions & 0 deletions src/main/java/mczme/lingshi/common/block/RiceSeedling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package mczme.lingshi.common.block;

import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
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.LiquidBlockContainer;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import org.jetbrains.annotations.Nullable;

public class RiceSeedling extends BushBlock implements BonemealableBlock, LiquidBlockContainer {

public RiceSeedling(Properties properties) {
super(properties);
}

@Override
protected MapCodec<? extends BushBlock> codec() {
return null;
}

@Override
public boolean isValidBonemealTarget(LevelReader pLevel, BlockPos pPos, BlockState pState) {
return false;
}

@Override
public boolean isBonemealSuccess(Level pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) {
return false;
}

@Override
public void performBonemeal(ServerLevel pLevel, RandomSource pRandom, BlockPos pPos, BlockState pState) {

}

@Override
public boolean canPlaceLiquid(@Nullable Player pPlayer, BlockGetter pLevel, BlockPos pPos, BlockState pState, Fluid pFluid) {
return false;
}

@Override
public boolean placeLiquid(LevelAccessor pLevel, BlockPos pPos, BlockState pState, FluidState pFluidState) {
return false;
}
}
28 changes: 28 additions & 0 deletions src/main/java/mczme/lingshi/common/createtab/CreateTabs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mczme.lingshi.common.createtab;

import mczme.lingshi.common.registry.ModItems;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

import static mczme.lingshi.lingshi.MODID;

public class CreateTabs {
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> LINGSHI_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
.title(Component.translatable("lingshi.lingshi_tab")) //The language key for the title of your CreativeModeTab
.withTabsBefore(CreativeModeTabs.COMBAT)
.icon(() -> ModItems.RICE.get().getDefaultInstance())
.displayItems((parameters, output) -> {
output.accept(ModItems.RICE.get());
output.accept(ModItems.RICE_SEEDING.get());
}).build());

public static void register(IEventBus modEventBus) {
CREATIVE_MODE_TABS.register(modEventBus);
}
}
36 changes: 36 additions & 0 deletions src/main/java/mczme/lingshi/common/data/DataGenerators.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package mczme.lingshi.common.data;

import mczme.lingshi.common.data.loot.BlockLoot;
import mczme.lingshi.lingshi;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.data.event.GatherDataEvent;

import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD, modid = lingshi.MODID)
public class DataGenerators {

@SubscribeEvent
public static void onGatherData(GatherDataEvent event) {

DataGenerator generator = event.getGenerator();
PackOutput output = generator.getPackOutput();
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();

// block loot
event.getGenerator().addProvider(
event.includeServer(),
new LootTableProvider(output, Set.of(), List.of(new LootTableProvider.SubProviderEntry(BlockLoot::new, LootContextParamSets.BLOCK)),lookupProvider)
);
}
}
31 changes: 31 additions & 0 deletions src/main/java/mczme/lingshi/common/data/loot/BlockLoot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package mczme.lingshi.common.data.loot;

import mczme.lingshi.common.registry.ModBlocks;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.level.block.Block;

import java.util.Set;

public class BlockLoot extends BlockLootSubProvider {

public static final Set<Block> BLOCK = Set.of(
ModBlocks.RICE.get()
);

public BlockLoot(HolderLookup.Provider lookupProvider) {
super(Set.of(), FeatureFlags.DEFAULT_FLAGS,lookupProvider);
}


@Override
protected void generate() {
this.dropSelf(ModBlocks.RICE.get());
}

@Override
protected Iterable<Block> getKnownBlocks() {
return BLOCK;
}
}
Loading

0 comments on commit 3e87ecf

Please sign in to comment.