Skip to content
Closed
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions src/hfas/java/org/polaris2023/wildwind/hfas/HFASMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public HFASMod(IEventBus bus, ModContainer container) {
// 注册属性
ModAttributes.register(bus);

// 注册状态效果、药水
ModMobEffects.register(bus);
ModPotions.register(bus);

// 注册食人鱼音效
ModSoundEvents.register(bus);

// 注册配置文件
container.registerConfig(net.neoforged.fml.config.ModConfig.Type.COMMON, ModCommonConfig.SPEC);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.polaris2023.wildwind.hfas.client.entity.model;

import com.geckolib.model.DefaultedEntityGeoModel;
import com.geckolib.renderer.base.GeoRenderState;
import net.minecraft.resources.Identifier;
import org.polaris2023.wildwind.hfas.HFASMod;
import org.polaris2023.wildwind.hfas.entity.animal.Piranha;

/**
* 食人鱼实体的几何模型定义喵~
*/
public class PiranhaModel extends DefaultedEntityGeoModel<Piranha> {

/**
* 创建食人鱼模型实例喵~
*/
public PiranhaModel() {
super(HFASMod.id("piranha"));
}

/**
* 获取当前食人鱼对应的材质资源喵~
*/
@Override
public Identifier getTextureResource(GeoRenderState state) {
return HFASMod.id("textures/entity/piranha.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.polaris2023.wildwind.hfas.client.entity.renderer;

import com.geckolib.renderer.GeoEntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import org.polaris2023.wildwind.hfas.client.entity.model.PiranhaModel;
import org.polaris2023.wildwind.hfas.client.entity.renderstate.PiranhaRenderState;
import org.polaris2023.wildwind.hfas.entity.animal.Piranha;

import javax.annotation.Nullable;

/**
* 食人鱼渲染器
* @author huimanman
*/
public class PiranhaRenderer extends GeoEntityRenderer<Piranha, PiranhaRenderState> {
public PiranhaRenderer(EntityRendererProvider.Context renderManager) {
super(renderManager, new PiranhaModel());
}

@Override
public PiranhaRenderState createRenderState(Piranha animatable, @Nullable Void relatedObject) {
return new PiranhaRenderState();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.polaris2023.wildwind.hfas.client.entity.renderstate;

import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;

/**
* 食人鱼渲染状态喵~
*/
public class PiranhaRenderState extends LivingEntityRenderState {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
import org.polaris2023.wildwind.hfas.client.entity.renderer.MudcrabRenderer;
import org.polaris2023.wildwind.hfas.client.entity.renderer.PiranhaRenderer;
import org.polaris2023.wildwind.hfas.registry.ModEntities;

@EventBusSubscriber(value = Dist.CLIENT)
public class EntitiesClientHandler {
@SubscribeEvent
static void registerRenderers(EntityRenderersEvent.RegisterRenderers event) {
event.registerEntityRenderer(ModEntities.PIRANHA.get(), PiranhaRenderer::new);
event.registerEntityRenderer(ModEntities.MUDCRAB.get(), MudcrabRenderer::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.neoforged.neoforge.registries.DeferredHolder;
import org.polaris2023.wildwind.hfas.datagen.provider.loot.BlockLoot;
import org.polaris2023.wildwind.hfas.registry.ModEntities;
import org.polaris2023.wildwind.hfas.registry.ModItems;

import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -52,6 +53,28 @@ protected Stream<EntityType<?>> getKnownEntityTypes() {
@Override
public void generate() {
this.emptyLoot(ModEntities.MUDCRAB);
this.add(
ModEntities.PIRANHA.get(),
LootTable.lootTable()
.withPool(
LootPool.lootPool()
.setRolls(ConstantValue.exactly(1.0F))
.add(LootItem.lootTableItem(ModItems.PIRANHA.get())
.apply(SmeltItemFunction.smelted().when(this.shouldSmeltLoot())))
)
.withPool(
LootPool.lootPool()
.setRolls(ConstantValue.exactly(1.0F))
.add(LootItem.lootTableItem(Items.BONE_MEAL))
.when(LootItemRandomChanceCondition.randomChance(0.05F))
)
.withPool(
LootPool.lootPool()
.setRolls(ConstantValue.exactly(1.0F))
.add(LootItem.lootTableItem(ModItems.FANG.get()))
.when(LootItemRandomChanceCondition.randomChance(0.05F))
)
);
}

private <T extends Entity> void emptyLoot(DeferredHolder<EntityType<?>, EntityType<T>> entityType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ protected void registerModels(BlockModelGenerators blockModels, ItemModelGenerat
);
simpleItem(itemModels, ModItems.MUDCRAB_BUCKET);
simpleItem(itemModels, ModItems.MUDCRAB_SPAWN_EGG);

// ==================== 食人鱼 ====================
registerPiranhaModels(itemModels);
}

/**
Expand Down Expand Up @@ -171,4 +174,12 @@ private void createCrossBlock(BlockModelGenerators blockModels, Block block) {
private void simpleItem(ItemModelGenerators itemModels, Supplier<? extends Item> item){
itemModels.generateFlatItem(item.get(), ModelTemplates.FLAT_ITEM);
}

private void registerPiranhaModels(ItemModelGenerators itemModels) {
simpleItem(itemModels, ModItems.PIRANHA);
simpleItem(itemModels, ModItems.COOKED_PIRANHA);
simpleItem(itemModels, ModItems.PIRANHA_BUCKET);
simpleItem(itemModels, ModItems.PIRANHA_SPAWN_EGG);
simpleItem(itemModels, ModItems.FANG);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.CookingBookCategory;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
Expand Down Expand Up @@ -37,6 +39,10 @@ protected ModRecipeProvider(HolderLookup.Provider registries, RecipeOutput outpu
protected void buildRecipes() {
// 生成所有箭矢组合配方
generateArrowRecipes();
// 生食人鱼 -> 熟食人鱼(熔炉)
SimpleCookingRecipeBuilder.smelting(Ingredient.of(ModItems.PIRANHA.get()), RecipeCategory.FOOD, CookingBookCategory.FOOD, ModItems.COOKED_PIRANHA.get(), 0.35F, 200)
.unlockedBy("has_" + ModItems.PIRANHA.getId().getPath(), this.has(ModItems.PIRANHA.get()))
.save(this.output);
// 万用蟹钳:铜锭x6 + 蟹钳x3
ShapedRecipeBuilder.shaped(this.items, RecipeCategory.TOOLS, ModItems.OMNI_CLAW.get())
.define('I', Items.COPPER_INGOT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ protected void addTranslations() {
// 属性
add("attributes.ww_hfas.extra_item_pickup_range", "Extra Item Pickup Range");

// Reach effect & potions
add("effect.ww_hfas.reach", "Reach");
add("item.minecraft.potion.effect.reach", "Potion of Reach");
add("item.minecraft.splash_potion.effect.reach", "Splash Potion of Reach");
add("item.minecraft.lingering_potion.effect.reach", "Lingering Potion of Reach");
add("item.minecraft.tipped_arrow.effect.reach", "Arrow of Reach");
add("item.minecraft.potion.effect.long_reach", "Potion of Reach");
add("item.minecraft.splash_potion.effect.long_reach", "Splash Potion of Reach");
add("item.minecraft.lingering_potion.effect.long_reach", "Lingering Potion of Reach");
add("item.minecraft.tipped_arrow.effect.long_reach", "Arrow of Reach");

// Piranha sound subtitles
add("subtitles.entity.piranha.attack", "Piranha attacks");
add("subtitles.entity.piranha.death", "Piranha dies");

//创造模式物品栏
add("mod.wild_wind.name", "Wild Wind");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ protected void addTranslations() {
// 属性
add("attributes.ww_hfas.extra_item_pickup_range", "额外物品拾取距离");

// 延展(reach)效果与药水
add("effect.ww_hfas.reach", "延展");
add("item.minecraft.potion.effect.reach", "延展药水");
add("item.minecraft.splash_potion.effect.reach", "喷溅型延展药水");
add("item.minecraft.lingering_potion.effect.reach", "滞留型延展药水");
add("item.minecraft.tipped_arrow.effect.reach", "延展之箭");
add("item.minecraft.potion.effect.long_reach", "延展药水");
add("item.minecraft.splash_potion.effect.long_reach", "喷溅型延展药水");
add("item.minecraft.lingering_potion.effect.long_reach", "滞留型延展药水");
add("item.minecraft.tipped_arrow.effect.long_reach", "延展之箭");

// 食人鱼音效字幕
add("subtitles.entity.piranha.attack", "食人鱼袭击");
add("subtitles.entity.piranha.death", "食人鱼死亡");

//创造模式物品栏
add("mod.wild_wind.name", "原野之风");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ private static void addItems() {
addItem(ModItems.MUDCRAB_BUCKET, "Bucket of Mudcrab", "泥沼蟹桶");
addItem(ModItems.CRAB_CLAW, "Crab Claw", "蟹钳");
addItem(ModItems.OMNI_CLAW, "Omni Craw", "万用蟹钳");
addItem(ModItems.PIRANHA_SPAWN_EGG, "Piranha Spawn Egg", "食人鱼刷怪蛋");
addItem(ModItems.PIRANHA, "Raw Piranha", "生食人鱼");
addItem(ModItems.COOKED_PIRANHA, "Cooked Piranha", "熟食人鱼");
addItem(ModItems.FANG, "Fang", "尖牙");
addItem(ModItems.PIRANHA_BUCKET, "Bucket of Piranha", "食人鱼桶");
}

private static void addBlocks() {
}

private static void addEntities() {
addEntity(ModEntities.MUDCRAB, "Mudcrab", "泥沼蟹");
addEntity(ModEntities.PIRANHA, "Piranha", "食人鱼");
}

private static void addItem(Supplier<? extends Item> s, String en, String zh){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ protected void addTags(HolderLookup.Provider provider) {
.add(Biomes.SNOWY_TAIGA)
.add(Biomes.SNOWY_BEACH)
.addTag(BiomeTags.IS_END);
tag(ModBiomeTags.EntityGen.PIRANHA_SPAWNS)
.add(Biomes.JUNGLE)
.addTag(Tags.Biomes.IS_SWAMP);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ public ModEntityTypeTagsProvider(PackOutput output, CompletableFuture<HolderLook
@Override
protected void addTags(HolderLookup.Provider provider) {
tag(EntityTypeTags.AQUATIC)
.add(ModEntities.MUDCRAB.getKey());
.add(ModEntities.MUDCRAB.getKey())
.add(ModEntities.PIRANHA.getKey());
tag(EntityTypeTags.CAN_BREATHE_UNDER_WATER)
.add(ModEntities.MUDCRAB.getKey());
.add(ModEntities.MUDCRAB.getKey())
.add(ModEntities.PIRANHA.getKey());
tag(EntityTypeTags.NOT_SCARY_FOR_PUFFERFISH)
.add(ModEntities.MUDCRAB.getKey());
.add(ModEntities.MUDCRAB.getKey())
.add(ModEntities.PIRANHA.getKey());
tag(EntityTypeTags.AXOLOTL_HUNT_TARGETS)
.add(ModEntities.PIRANHA.getKey());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.Identifier;
import net.minecraft.data.tags.TagAppender;
import net.minecraft.data.tags.TagsProvider;
import net.minecraft.tags.BlockItemTagId;
Expand All @@ -16,6 +17,7 @@
import net.neoforged.neoforge.common.Tags;
import org.polaris2023.wildwind.hfas.HFASMod;
import org.polaris2023.wildwind.hfas.block.ModBlocks;
import org.polaris2023.wildwind.hfas.registry.ModItems;
import org.polaris2023.wildwind.hfas.tag.ModItemTags;

import java.util.Arrays;
Expand All @@ -42,6 +44,16 @@ public ModItemTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Pro

@Override
protected void addTags(HolderLookup.Provider provider) {
registerWoodLogItemTag("blaze",
ModBlocks.BLAZE_LOG.get(), ModBlocks.BLAZE_WOOD.get(),
ModBlocks.STRIPPED_BLAZE_LOG.get(), ModBlocks.STRIPPED_BLAZE_WOOD.get());
registerWoodLogItemTag("soul",
ModBlocks.SOUL_LOG.get(), ModBlocks.SOUL_WOOD.get(),
ModBlocks.STRIPPED_SOUL_LOG.get(), ModBlocks.STRIPPED_SOUL_WOOD.get());
registerWoodLogItemTag("azalea",
ModBlocks.AZALEA_LOG.get(), ModBlocks.AZALEA_WOOD.get(),
ModBlocks.STRIPPED_AZALEA_LOG.get(), ModBlocks.STRIPPED_AZALEA_WOOD.get());

// ==================== 焚烬木物品标签 ====================
registerWoodItemTags(
ModBlocks.BLAZE_LOG.get(),
Expand Down Expand Up @@ -102,6 +114,17 @@ protected void addTags(HolderLookup.Provider provider) {
tag(Tags.Items.ANIMAL_FOODS)
.addTag(ModItemTags.MUDCRAB_FOOD);
addToTag(ModItemTags.MUDCRAB_FOOD, Items.SPIDER_EYE);

// ==================== 食人鱼相关物品标签 ====================
// 猫、豹猫以生食人鱼为食
addToTag(ItemTags.CAT_FOOD, ModItems.PIRANHA.get());
addToTag(ItemTags.OCELOT_FOOD, ModItems.PIRANHA.get());
// 狼以生/熟食人鱼为食
addToTag(ItemTags.WOLF_FOOD, ModItems.PIRANHA.get(), ModItems.COOKED_PIRANHA.get());
// 原版鱼类标签
addToTag(ItemTags.FISHES, ModItems.PIRANHA.get(), ModItems.COOKED_PIRANHA.get());
// 熟鱼食物标签
addToTag(Tags.Items.FOODS_COOKED_FISH, ModItems.COOKED_PIRANHA.get());
}

/**
Expand All @@ -118,6 +141,9 @@ private void registerWoodItemTags(

// 原木物品标签
addToTag(ItemTags.LOGS, log, wood, strippedLog, strippedWood);
addToTag(ItemTags.LOGS_THAT_BURN, log, wood, strippedLog, strippedWood);
addToTag(Tags.Items.STRIPPED_LOGS, strippedLog);
addToTag(Tags.Items.STRIPPED_WOODS, strippedWood);
// tag(ItemTags.LOGS)
// .add(log.asItem())
// .add(wood.asItem())
Expand All @@ -134,6 +160,7 @@ private void registerWoodItemTags(
addToTag(ItemTags.WOODEN_SLABS, slab);

// 木质栅栏物品标签
addToTag(ItemTags.WOODEN_FENCES, fence);
addToTag(Tags.Items.FENCES_WOODEN, fence);

// 栅栏物品标签
Expand Down Expand Up @@ -185,6 +212,14 @@ private void registerWoodItemTags(
}
}

private void registerWoodLogItemTag(String name, Block log, Block wood, Block strippedLog, Block strippedWood) {
TagKey<Item> logsTag = TagKey.create(
Registries.ITEM,
Identifier.fromNamespaceAndPath(HFASMod.MOD_ID, name + "_logs")
);
addToTag(logsTag, log, wood, strippedLog, strippedWood);
}

@SuppressWarnings("all")
public void addToTag(TagKey<Item> tag, Block... items){
if(items.length == 0) return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.polaris2023.wildwind.hfas.effect;

import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;

/**
* 用于拓宽 {@link MobEffect} 构造方法的访问权限
*/
public class WildWindMobEffect extends MobEffect {
/**
* 创建一个基础生物效果喵~
*
* @param category 效果分类喵~
* @param color 效果颜色喵~
*/
public WildWindMobEffect(MobEffectCategory category, int color) {
super(category, color);
}

/**
* 创建一个带粒子效果的生物效果喵~
*
* @param category 效果分类喵~
* @param color 效果颜色喵~
* @param particle 粒子效果喵~
*/
public WildWindMobEffect(MobEffectCategory category, int color, ParticleOptions particle) {
super(category, color, particle);
}
}
Loading
Loading