由于tfcambiental篝火可以取暖,篝火上放了锅和烤架却无法取暖,便产生自己写mod补充的想法
现在情况是可以正常安装没有任何报错,但就是没效果。一共也就3个文件,真不知道哪里出问题(感觉应该是注册的问题,但也不知道怎么改……)故求助广大网友
文件:/tfc_pot_is_hot/TFCPotIsHot.java
- package com.mauritiuschief.tfc_pot_is_hot;
- import com.mojang.logging.LogUtils;
- import net.minecraftforge.fml.common.Mod;
- import org.slf4j.Logger;
- // The value here should match an entry in the META-INF/mods.toml file
- @Mod(TFCPotIsHot.MODID)
- public class TFCPotIsHot {
- // Define mod id in a common place for everything to reference
- public static final String MODID = "tfc_pot_is_hot";
- // Directly reference a slf4j logger
- private static final Logger LOGGER = LogUtils.getLogger();
- }
复制代码
文件:/tfc_pot_is_hot/api/AmbientalFixRegistry.java
- package com.mauritiuschief.tfc_pot_is_hot.api;
- import com.lumintorious.tfcambiental.api.AmbientalRegistry;
- // import com.lumintorious.tfcambiental.api.BlockEntityTemperatureProvider;
- public class AmbientalFixRegistry {
- static {
- // Register your methods with the existing registry
- AmbientalRegistry.BLOCK_ENTITIES.register(EnhancedBlockEntityTemperatureProvider::handlePot);
- AmbientalRegistry.BLOCK_ENTITIES.register(EnhancedBlockEntityTemperatureProvider::handleGrill);
- }
- }
复制代码
文件:/tfc_pot_is_hot/api/EnhancedBlockEntityTemperatureProvider.java- package com.mauritiuschief.tfc_pot_is_hot.api;
- import com.lumintorious.tfcambiental.TFCAmbientalConfig;
- import com.lumintorious.tfcambiental.item.TFCAmbientalItems;
- import com.lumintorious.tfcambiental.api.BlockEntityTemperatureProvider;
- import com.lumintorious.tfcambiental.api.EnvironmentalTemperatureProvider;
- import com.lumintorious.tfcambiental.modifier.TempModifier;
- // import net.dries007.tfc.common.blockentities.FirepitBlockEntity;
- import net.dries007.tfc.common.blockentities.PotBlockEntity;
- import net.dries007.tfc.common.blockentities.GrillBlockEntity;
- import top.theillusivec4.curios.api.CuriosApi;
- import net.minecraft.world.level.block.entity.BlockEntity;
- import net.minecraft.world.entity.player.Player;
- import java.util.Optional;
- public interface EnhancedBlockEntityTemperatureProvider extends BlockEntityTemperatureProvider {
- // New methods here
- private static boolean hasProtectionAlt(Player player) { // 由于原作者的hasProtection是private,只能出此下策
- var item = CuriosApi.getCuriosHelper().findCurios(player, TFCAmbientalItems.LEATHER_APRON.get());
- if (item.isEmpty()) {
- return false;
- }
- float environmentTemperature = EnvironmentalTemperatureProvider.getEnvironmentTemperatureWithTimeOfDay(player);
- float AVERAGE = TFCAmbientalConfig.COMMON.averageTemperature.get().floatValue();
- return environmentTemperature > AVERAGE;
- }
-
- static Optional<TempModifier> handlePot(Player player, BlockEntity entity) { // 照抄的原作者handleFirePit
- if (entity instanceof PotBlockEntity pot) {
- float temp = pot.getTemperature();
- float change = temp / 100f;
- if (hasProtectionAlt(player)) {
- change = change * 0.3f;
- }
- return TempModifier.defined("pot", Math.min(6f, change), 0);
- }
- return TempModifier.none();
- }
- static Optional<TempModifier> handleGrill(Player player, BlockEntity entity) { // 照抄的原作者handleFirePit
- if (entity instanceof GrillBlockEntity grill) {
- float temp = grill.getTemperature();
- float change = temp / 100f;
- if (hasProtectionAlt(player)) {
- change = change * 0.3f;
- }
- return TempModifier.defined("grill", Math.min(6f, change), 0);
- }
- return TempModifier.none();
- }
- }
复制代码
|
|