Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

拉取上游更新 #80

Merged
merged 6 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 55 additions & 30 deletions src/main/java/org/polaris2023/wild_wind/common/init/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.mojang.datafixers.types.Type;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.HangingSignItem;
import net.minecraft.world.item.SignItem;
import net.minecraft.world.level.block.*;
Expand All @@ -22,12 +20,11 @@

import org.polaris2023.annotation.modelgen.item.BasicBlockItem;
import org.polaris2023.annotation.modelgen.item.BasicItem;
import org.polaris2023.wild_wind.common.block.*;
import org.polaris2023.wild_wind.common.block.BrittleIceBlock;

import org.polaris2023.wild_wind.common.block.CookingPotBlock;
import org.polaris2023.wild_wind.common.block.GlowMucusBlock;
import org.polaris2023.wild_wind.common.block.entity.CookingPotBlockEntity;
import org.polaris2023.wild_wind.common.block.entity.DuckweedBlockEntity;
import org.polaris2023.wild_wind.common.block.entity.WoolBlockEntity;
import org.polaris2023.wild_wind.common.block.item.WoolBlockItem;

import java.util.Arrays;

Expand Down Expand Up @@ -94,42 +91,22 @@ public class ModBlocks {
public static final DeferredItem<BlockItem> COOKING_POT_ITEM =
register("cooking_pot", COOKING_POT);

@I18n(en_us = "Duckweed", zh_cn = "浮萍", zh_tw = "浮萍")
public static final DeferredBlock<DuckweedBlock> DUCKWEED =
register("duckweed", DuckweedBlock::new, BlockBehaviour.Properties.of());
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<DuckweedBlockEntity>> DUCKWEED_TILE =
entity("duckweed", DSL.remainderType(), DuckweedBlockEntity::new, DUCKWEED);
public static final DeferredItem<BlockItem> DUCKWEED_ITEM =
register("duckweed", DUCKWEED);

@I18n(en_us = "Sculk Jaw", zh_cn = "幽匿厄口", zh_tw = "幽匿厄口")
public static final DeferredBlock<SculkJawBlock> SCULK_JAW =
register("sculk_jaw", SculkJawBlock::new, BlockBehaviour.Properties.of());
public static final DeferredItem<BlockItem> SCULK_JAW_ITEM =
register("sculk_jaw", SCULK_JAW);


@I18n(en_us = "Brittle Ice", zh_cn = "脆冰", zh_tw = "脆冰")
public static final DeferredBlock<BrittleIceBlock> BRITTLE_ICE =
register("brittle_ice", BrittleIceBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.ICE)
.strength(0.1F).isValidSpawn(Blocks::never).pushReaction(PushReaction.DESTROY));
@BasicBlockItem
public static final DeferredItem<BlockItem> BRITTLE_ICE_ITEM =
register("brittle_ice", BRITTLE_ICE);

@I18n(en_us = "wool", zh_cn = "羊毛", zh_tw = "羊毛")
public static final DeferredBlock<WoolBlock> WOOL = register("wool", WoolBlock::new, BlockBehaviour.Properties.of()

public static final DeferredBlock<Block> WOOL = register("wool", BlockBehaviour.Properties.of()
.instrument(NoteBlockInstrument.GUITAR)
.strength(0.8F)
.sound(SoundType.WOOL)
.ignitedByLava());
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<WoolBlockEntity>> WOOL_TILE =
entity("wool", DSL.remainderType(), WoolBlockEntity::new, WOOL);
@BasicBlockItem
public static final DeferredItem<BlockItem> WOOL_ITEM =
register("wool", p -> new WoolBlockItem(WOOL.get(), p));
// register("wood", WOOL);
public static final DeferredItem<BlockItem> WOOL_ITEM = register("wool", WOOL);

@I18n(en_us = "carpet", zh_cn = "地毯", zh_tw = "地毯")
public static final DeferredBlock<CarpetBlock> CARPET =
Expand Down Expand Up @@ -180,7 +157,7 @@ public class ModBlocks {

@BasicBlockItem
public static final DeferredItem<BlockItem> DEEPSLATE_SALT_ORE_ITEM =
register("deepslate_salt_ore", DEEPSLATE_SALT_ORE);
register("deepslate_salt_ore", SALT_ORE);

@I18n(en_us = "Azalea Log", zh_cn = "杜鹃木原木", zh_tw = "杜鵑木原木")
public static final DeferredBlock<RotatedPillarBlock> AZALEA_LOG =
Expand All @@ -198,6 +175,30 @@ public class ModBlocks {
@I18n(en_us = "Azalea Planks", zh_cn = "杜鹃木木板", zh_tw = "杜鵑木材")
public static final DeferredBlock<Block> AZALEA_PLANKS =
register("azalea_planks", Block::new, BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_PLANKS));
@I18n(en_us = "Azalea Button", zh_cn = "杜鹃木按钮", zh_tw = "杜鵑木按鈕")
public static final DeferredBlock<ButtonBlock> AZALEA_BUTTON =
register("azalea_button", props -> new ButtonBlock(ModBlockSetTypes.AZALEA, 30, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_BUTTON));
@I18n(en_us = "Azalea Fence", zh_cn = "杜鹃木栅栏", zh_tw = "杜鵑木柵欄")
public static final DeferredBlock<FenceBlock> AZALEA_FENCE =
register("azalea_fence", FenceBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_FENCE));
@I18n(en_us = "Azalea Fence Gate", zh_cn = "杜鹃木栅栏门", zh_tw = "杜鵑木柵欄門")
public static final DeferredBlock<FenceGateBlock> AZALEA_FENCE_GATE =
register("azalea_fence_gate", props -> new FenceGateBlock(ModWoodTypes.AZALEA, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_FENCE_GATE));
@I18n(en_us = "Azalea Pressure Plate", zh_cn = "杜鹃木压力板", zh_tw = "杜鵑木压力板")
public static final DeferredBlock<PressurePlateBlock> AZALEA_PRESSURE_PLATE =
register("azalea_pressure_plate", props -> new PressurePlateBlock(ModBlockSetTypes.AZALEA, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_PRESSURE_PLATE));
@I18n(en_us = "Azalea Slab", zh_cn = "杜鹃木台阶", zh_tw = "杜鵑木半磚")
public static final DeferredBlock<SlabBlock> AZALEA_SLAB =
register("azalea_slab", SlabBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_SLAB));
@I18n(en_us = "Azalea Stairs", zh_cn = "杜鹃木楼梯", zh_tw = "杜鵑木樓梯")
public static final DeferredBlock<StairBlock> AZALEA_STAIRS =
register("azalea_stairs", props -> new StairBlock(AZALEA_PLANKS.get().defaultBlockState(), props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_STAIRS));
@I18n(en_us = "Azalea Door", zh_cn = "杜鹃木门", zh_tw = "杜鵑木門")
public static final DeferredBlock<DoorBlock> AZALEA_DOOR =
register("azalea_door", props -> new DoorBlock(ModBlockSetTypes.AZALEA, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_DOOR));
@I18n(en_us = "Azalea Door", zh_cn = "杜鹃木活板门", zh_tw = "杜鵑木地板門")
public static final DeferredBlock<TrapDoorBlock> AZALEA_TRAPDOOR =
register("azalea_trapdoor", props -> new TrapDoorBlock(ModBlockSetTypes.AZALEA, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_TRAPDOOR));
@I18n(en_us = "Azalea Sign", zh_cn = "杜鹃木告示牌", zh_tw = "杜鵑木告示牌")
public static final DeferredBlock<StandingSignBlock> AZALEA_SIGN =
register("azalea_sign", props -> new StandingSignBlock(ModWoodTypes.AZALEA, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_SIGN));
Expand Down Expand Up @@ -227,6 +228,30 @@ public class ModBlocks {
public static final DeferredItem<BlockItem> AZALEA_PLANKS_ITEM =
register("azalea_planks", AZALEA_PLANKS);
@BasicBlockItem
public static final DeferredItem<BlockItem> AZALEA_BUTTON_ITEM =
register("azalea_button", AZALEA_BUTTON);
@BasicBlockItem
public static final DeferredItem<BlockItem> AZALEA_FENCE_ITEM =
register("azalea_fence", AZALEA_FENCE);
@BasicBlockItem
public static final DeferredItem<BlockItem> AZALEA_FENCE_GATE_ITEM =
register("azalea_fence_gate", AZALEA_FENCE_GATE);
@BasicBlockItem
public static final DeferredItem<BlockItem> AZALEA_PRESSURE_PLATE_ITEM =
register("azalea_pressure_plate", AZALEA_PRESSURE_PLATE);
@BasicBlockItem
public static final DeferredItem<BlockItem> AZALEA_SLAB_ITEM =
register("azalea_slab", AZALEA_SLAB);
@BasicBlockItem
public static final DeferredItem<BlockItem> AZALEA_STAIRS_ITEM =
register("azalea_stairs", AZALEA_STAIRS);
@BasicBlockItem
public static final DeferredItem<BlockItem> AZALEA_DOOR_ITEM =
register("azalea_door", AZALEA_DOOR);
@BasicBlockItem
public static final DeferredItem<BlockItem> AZALEA_TRAPDOOR_ITEM =
register("azalea_trapdoor", AZALEA_TRAPDOOR);
@BasicBlockItem
public static final DeferredItem<SignItem> AZALEA_SIGN_ITEM =
registerSign("azalea_sign", AZALEA_SIGN, AZALEA_WALL_SIGN);
@BasicBlockItem
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.polaris2023.wild_wind.datagen;

import net.minecraft.world.level.block.*;
import org.polaris2023.wild_wind.common.init.ModBlocks;

public class ModBlockFamilies {
public static final ModBlockFamily AZALEA_PLANKS = family(
ModBlocks.AZALEA_PLANKS.get(), ModBlocks.AZALEA_BUTTON.get(), ModBlocks.AZALEA_FENCE.get(), ModBlocks.AZALEA_FENCE_GATE.get(), ModBlocks.AZALEA_PRESSURE_PLATE.get(),
ModBlocks.AZALEA_SIGN.get(), ModBlocks.AZALEA_WALL_SIGN.get(), ModBlocks.AZALEA_HANGING_SIGN.get(), ModBlocks.AZALEA_WALL_HANGING_SIGN.get(),
ModBlocks.AZALEA_SLAB.get(), ModBlocks.AZALEA_STAIRS.get(), ModBlocks.AZALEA_DOOR.get(), ModBlocks.AZALEA_TRAPDOOR.get(), "wooden","has_planks");

public static ModBlockFamily family(Block baseBlock, ButtonBlock button, FenceBlock fence, FenceGateBlock fenceGate, PressurePlateBlock pressurePlate,
StandingSignBlock standingSign, WallSignBlock wallSign, CeilingHangingSignBlock ceilingHangingSign, WallHangingSignBlock wallHangingSign,
SlabBlock slab, StairBlock stair, DoorBlock door, TrapDoorBlock trapdoor, String recipeGroupPrefix, String recipeUnlockedBy) {
return new ModBlockFamily(baseBlock, button, fence, fenceGate, pressurePlate, standingSign, wallSign, ceilingHangingSign, wallHangingSign, slab, stair, door, trapdoor, recipeGroupPrefix, recipeUnlockedBy);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.polaris2023.wild_wind.datagen;

import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.*;
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
import org.polaris2023.wild_wind.util.Helpers;

import java.util.function.Consumer;
import java.util.function.Function;

public record ModBlockFamily(Block baseBlock, ButtonBlock button, FenceBlock fence, FenceGateBlock fenceGate,
PressurePlateBlock pressurePlate, StandingSignBlock standingSign, WallSignBlock wallSign,
CeilingHangingSignBlock ceilingHangingSign, WallHangingSignBlock wallHangingSign,
SlabBlock slab, StairBlock stair, DoorBlock door, TrapDoorBlock trapdoor,
String recipeGroupPrefix, String recipeUnlockedBy) {
public void registerStatesAndModels(BlockStateProvider provider, String name) {
ResourceLocation planks = Helpers.location("block/" + name + "_planks");
ResourceLocation log = Helpers.location("block/" + name + "_log");
provider.buttonBlock(this.button, planks);
provider.fenceBlock(this.fence, planks);
provider.fenceGateBlock(this.fenceGate, planks);
provider.pressurePlateBlock(this.pressurePlate, planks);
provider.signBlock(this.standingSign, this.wallSign, planks);
provider.hangingSignBlock(this.ceilingHangingSign, this.wallHangingSign, log);
provider.slabBlock(this.slab, planks, planks);
provider.stairsBlock(this.stair, planks);
provider.doorBlock(this.door, Helpers.location("block/" + name + "_door_bottom"), Helpers.location("block/" + name + "_door_top"));
provider.trapdoorBlock(this.trapdoor, Helpers.location("block/" + name + "_trapdoor"), true);
}

public void generateBlockLoot(Consumer<Block> dropSelf) {
dropSelf.accept(this.button);
dropSelf.accept(this.fence);
dropSelf.accept(this.fenceGate);
dropSelf.accept(this.pressurePlate);
dropSelf.accept(this.standingSign);
dropSelf.accept(this.wallSign);
dropSelf.accept(this.ceilingHangingSign);
dropSelf.accept(this.wallHangingSign);
dropSelf.accept(this.slab);
dropSelf.accept(this.stair);
dropSelf.accept(this.door);
dropSelf.accept(this.trapdoor);
}

public void generateBlockTags(Function<TagKey<Block>, IntrinsicHolderTagsProvider.IntrinsicTagAppender<Block>> tag) {
tag.apply(BlockTags.WOODEN_BUTTONS).add(this.button);
tag.apply(BlockTags.WOODEN_FENCES).add(this.fence);
tag.apply(BlockTags.FENCE_GATES).add(this.fenceGate);
tag.apply(BlockTags.WOODEN_PRESSURE_PLATES).add(this.pressurePlate);
tag.apply(BlockTags.STANDING_SIGNS).add(this.standingSign);
tag.apply(BlockTags.WALL_SIGNS).add(this.wallSign);
tag.apply(BlockTags.CEILING_HANGING_SIGNS).add(this.ceilingHangingSign);
tag.apply(BlockTags.WALL_HANGING_SIGNS).add(this.wallHangingSign);
tag.apply(BlockTags.WOODEN_SLABS).add(this.slab);
tag.apply(BlockTags.WOODEN_STAIRS).add(this.stair);
tag.apply(BlockTags.WOODEN_DOORS).add(this.door);
tag.apply(BlockTags.WOODEN_TRAPDOORS).add(this.trapdoor);
}
public void generateItemTags(Function<TagKey<Item>, IntrinsicHolderTagsProvider.IntrinsicTagAppender<Item>> tag) {
tag.apply(ItemTags.WOODEN_BUTTONS).add(this.button.asItem());
tag.apply(ItemTags.WOODEN_FENCES).add(this.fence.asItem());
tag.apply(ItemTags.FENCE_GATES).add(this.fenceGate.asItem());
tag.apply(ItemTags.WOODEN_PRESSURE_PLATES).add(this.pressurePlate.asItem());
tag.apply(ItemTags.SIGNS).add(this.standingSign.asItem(), this.wallSign.asItem());
tag.apply(ItemTags.HANGING_SIGNS).add(this.ceilingHangingSign.asItem(), this.wallHangingSign.asItem());
tag.apply(ItemTags.WOODEN_SLABS).add(this.slab.asItem());
tag.apply(ItemTags.WOODEN_STAIRS).add(this.stair.asItem());
tag.apply(ItemTags.WOODEN_DOORS).add(this.door.asItem());
tag.apply(ItemTags.WOODEN_TRAPDOORS).add(this.trapdoor.asItem());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.core.Direction;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.neoforged.neoforge.client.model.generators.*;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.polaris2023.wild_wind.WildWindMod;
Expand Down Expand Up @@ -32,15 +33,6 @@ public ModBlockStateProvider(PackOutput output, ExistingFileHelper exFileHelper)
Helpers.location("block/brittle_ice_2"),
Helpers.location("block/brittle_ice_3")
};
public static final ResourceLocation[] WOOL = new ResourceLocation[] {
Helpers.location("block/wool")
};
public static final ResourceLocation[] CONCRETE = new ResourceLocation[] {
Helpers.location("block/concrete")
};
public static final ResourceLocation[] GLAZED_TERRACOTTA = new ResourceLocation[] {
Helpers.location("block/glazed_terracotta")
};

@Override
protected void registerStatesAndModels() {
Expand Down Expand Up @@ -79,32 +71,34 @@ protected void registerStatesAndModels() {
}
}

// Wood
BlockModelBuilder woodModel = models().cubeAll("wool", WOOL[0]);
simpleBlock(ModBlocks.WOOL.get(), woodModel);

//Carpet
BlockModelBuilder carpetModel = models().carpet("carpet", WOOL[0]);
simpleBlock(ModBlocks.CARPET.get(), carpetModel);
// Logs
logModel(getVariantBuilder(ModBlocks.AZALEA_LOG.get()), "azalea");
logModel(getVariantBuilder(ModBlocks.STRIPPED_AZALEA_LOG.get()), "stripped_azalea");
woodModel(getVariantBuilder(ModBlocks.AZALEA_WOOD.get()), "azalea");
woodModel(getVariantBuilder(ModBlocks.STRIPPED_AZALEA_WOOD.get()), "stripped_azalea");
simpleBlock(ModBlocks.AZALEA_PLANKS.get(), models().cubeAll("azalea_planks", Helpers.location("block/azalea_planks")));
ModBlockFamilies.AZALEA_PLANKS.registerStatesAndModels(this, "azalea");

//Concrete
BlockModelBuilder concreteModel = models().cubeAll("concrete", CONCRETE[0]);
simpleBlock(ModBlocks.CONCRETE.get(), concreteModel);
// Wool
simpleBlock(ModBlocks.WOOL.get(), models().cubeAll("wool", Helpers.location("block/wool")));

// Carpet
simpleBlock(ModBlocks.CARPET.get(), models().carpet("carpet", Helpers.location("block/wool")));

// Concrete
simpleBlock(ModBlocks.CONCRETE.get(), models().cubeAll("concrete", Helpers.location("block/concrete")));

// Glazed Terracotta
VariantBlockStateBuilder glazedTerracottaStates = getVariantBuilder(ModBlocks.GLAZED_TERRACOTTA.get());
for (Direction facing : Direction.Plane.HORIZONTAL) {
int yRotation = switch (facing) {
case EAST -> 270;
case NORTH -> 180;
case SOUTH -> 0;
case WEST -> 90;
case WEST -> 90;
default -> 0;
};
glazedTerracottaStates.partialState().with(net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING, facing)
.addModels(new ConfiguredModel(models().cubeAll("glazed_terracotta", GLAZED_TERRACOTTA[0]), 0, yRotation, false));
glazedTerracottaStates.partialState().with(BlockStateProperties.HORIZONTAL_FACING, facing)
.addModels(new ConfiguredModel(models().cubeAll("glazed_terracotta", Helpers.location("block/glazed_terracotta")), 0, yRotation, false));
}
}

Expand All @@ -124,4 +118,39 @@ private void brittleIceModel(VariantBlockStateBuilder brittleIceStates, int age,
new ConfiguredModel(models().getExistingFile(BRITTLE_ICES[age]))
);
}

private void logModel(VariantBlockStateBuilder woodStates, String name) {
ResourceLocation side = Helpers.location("block/" + name + "_log");
ResourceLocation top = Helpers.location("block/" + name + "_log_top");
woodStates.addModels(
woodStates.partialState().with(BlockStateProperties.AXIS, Direction.Axis.Y),
new ConfiguredModel(models().cubeColumn(name + "_log", side, top))
);
BlockModelBuilder azaleaLogHorizontal = models().cubeColumnHorizontal(name + "_log_horizontal", side, top);
woodStates.addModels(
woodStates.partialState().with(BlockStateProperties.AXIS, Direction.Axis.X),
new ConfiguredModel(azaleaLogHorizontal, 90, 90, false)
);
woodStates.addModels(
woodStates.partialState().with(BlockStateProperties.AXIS, Direction.Axis.Z),
new ConfiguredModel(azaleaLogHorizontal, 90, 0, false)
);
}

private void woodModel(VariantBlockStateBuilder woodStates, String name) {
ResourceLocation side = Helpers.location("block/" + name + "_log");
woodStates.addModels(
woodStates.partialState().with(BlockStateProperties.AXIS, Direction.Axis.Y),
new ConfiguredModel(models().cubeColumn(name + "_wood", side, side))
);
BlockModelBuilder azaleaLogHorizontal = models().cubeColumnHorizontal(name + "_wood_horizontal", side, side);
woodStates.addModels(
woodStates.partialState().with(BlockStateProperties.AXIS, Direction.Axis.X),
new ConfiguredModel(azaleaLogHorizontal, 90, 90, false)
);
woodStates.addModels(
woodStates.partialState().with(BlockStateProperties.AXIS, Direction.Axis.Z),
new ConfiguredModel(azaleaLogHorizontal, 90, 0, false)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected void addShapedRecipe() {
.pattern("SS ")
.pattern("SS ")
.pattern(" ")
.group("wood")
.group("wool")
.define('S', Items.STRING);
}));
add(shaped(RecipeCategory.MISC, ModBlocks.CARPET.get(), 1,
Expand Down
Loading
Loading