Skip to content
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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ minecraft = "1.21.1"
neoForge = "21.1.152"
registrate = "MC1.21-1.3.0+62"
anvillib = "1.4.0+build.172"
anvilcraft = "1.5.0"
anvilcraft = "1.5.0+hotfix.1570"
anvilcraft_patchouli = "1.0.0+build.6"
curios = "9.0.15+1.21.1"
jei = "19.21.0.247"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"anvilcraft_pigsplus.configuration.enchanted_generator.power_per_level": "ןǝʌǝꞀ ɹǝԀ ɹǝʍoԀ",
"anvilcraft_pigsplus.configuration.enchanted_generator.power_per_level.tooltip": "ןǝʌǝן s,ʇuǝɯʇuɐɥɔuǝ ɹǝd ɹǝʍoԀ",
"anvilcraft_pigsplus.configuration.enchanted_generator.tooltip": "ɹoʇɐɹǝuǝ⅁ pǝʇuɐɥɔuƎ",
"anvilcraft_pigsplus.configuration.portable_wireless_charger_energy_conversion": "uoısɹǝʌuoƆ ʎbɹǝuƎ ɹǝbɹɐɥƆ ssǝןǝɹıM ǝןqɐʇɹoԀ",
"anvilcraft_pigsplus.configuration.portable_wireless_charger_energy_conversion.tooltip": ")Mʞ( ɹǝbɹɐɥɔ ssǝןǝɹıʍ ǝןqɐʇɹod ɟo ʎʇıʇuɐnb uoısɹǝʌuoɔ ʎbɹǝuƎ",
"anvilcraft_pigsplus.configuration.section.anvilcraft_pigsplus.server.toml": "uoıʇɐɹnbıɟuoƆ ɹǝʌɹǝS snןdsbıԀ ʇɟɐɹɔןıʌuⱯ",
"anvilcraft_pigsplus.configuration.section.anvilcraft_pigsplus.server.toml.title": "uoıʇɐɹnbıɟuoƆ ɹǝʌɹǝS snןdsbıԀ ʇɟɐɹɔןıʌuⱯ",
"anvilcraft_pigsplus.configuration.title": "uoıʇɐɹnbıɟuoƆ snןdsbıԀ ʇɟɐɹɔןıʌuⱯ",
Expand Down Expand Up @@ -57,8 +59,9 @@
"itemGroup.anvilcraft_pigsplus.addon_items": "snןԀ sbıԀ :ʇɟɐɹƆןıʌuⱯ",
"jei.anvilcraft.pigsplus.info.ender_component": "˙ʇuǝuodɯoƆ ɹǝpuƎ ɐ uıɐʇqo oʇ ǝɔuɐɥɔ %%ɟ0˙% ɐ sı ǝɹǝɥʇ 'ןɐʇɹod puƎ ǝɥʇ oʇuı ʇuǝuodɯoƆ ıɹnʞɐɹɐʞ ɐ ʍoɹɥ⟘",
"jei.anvilcraft.pigsplus.info.spiritual_component": "˙ʇuǝuodɯoƆ ɯnıpǝW ǝuo ʇsoɯ ʇɐ ǝʇɐɹǝuǝb oʇ ǝɔuɐɥɔ %%ɟ0˙% ɐ sǝpıʌoɹd ʇuǝɯʇuɐɥɔuǝ ɥɔɐǝ 'pǝʎoɹʇsǝp sı ʇuǝuodɯoƆ ıɹnʞɐɹɐʞ ɐ uǝɥM",
"tooltip.anvilcraft.pigsplus.enchanted_generator.max_power_value": "Mʞ %d :uoıʇdɯnsuoɔ ɹǝʍod xɐW",
"tooltip.anvilcraft.pigsplus.enchanted_generator.power_rate": "%s :ǝʇɐɹ uoıʇdɯnsuoɔ ɹǝʍoԀ",
"tooltip.anvilcraft.pigsplus.enchanted_generator.previous_energy_consumption": "%d :uoıʇdɯnsuoɔ ʎbɹǝuǝ ɯǝʇı snoıʌǝɹԀ",
"tooltip.anvilcraft.pigsplus.enchanted_generator.time": "%s :ǝɯıʇ buıuıɐɯǝᴚ"
"tooltip.anvilcraft_pigsplus.enchanted_generator.max_power_value": "Mʞ %d :uoıʇdɯnsuoɔ ɹǝʍod xɐW",
"tooltip.anvilcraft_pigsplus.enchanted_generator.power_rate": "%s :ǝʇɐɹ uoıʇdɯnsuoɔ ɹǝʍoԀ",
"tooltip.anvilcraft_pigsplus.enchanted_generator.previous_energy_consumption": "%d :uoıʇdɯnsuoɔ ʎbɹǝuǝ ɯǝʇı snoıʌǝɹԀ",
"tooltip.anvilcraft_pigsplus.enchanted_generator.time": "%s :ǝɯıʇ buıuıɐɯǝᴚ",
"tooltip.anvilcraft_pigsplus.portable_wireless_charger": "ʇ/ƎℲ %d sǝʇɐɹǝuǝb puɐ Mʞ %d sǝɯnsuoɔ ʇı 'ʞɔɐdʞɔɐq uǝɥM"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"anvilcraft_pigsplus.configuration.enchanted_generator.power_per_level": "Power Per Level",
"anvilcraft_pigsplus.configuration.enchanted_generator.power_per_level.tooltip": "Power per enchantment's level",
"anvilcraft_pigsplus.configuration.enchanted_generator.tooltip": "Enchanted Generator",
"anvilcraft_pigsplus.configuration.portable_wireless_charger_energy_conversion": "Portable Wireless Charger Energy Conversion",
"anvilcraft_pigsplus.configuration.portable_wireless_charger_energy_conversion.tooltip": "Energy conversion quantity of portable wireless charger (kW)",
"anvilcraft_pigsplus.configuration.section.anvilcraft_pigsplus.server.toml": "Anvilcraft Pigsplus Server Configuration",
"anvilcraft_pigsplus.configuration.section.anvilcraft_pigsplus.server.toml.title": "Anvilcraft Pigsplus Server Configuration",
"anvilcraft_pigsplus.configuration.title": "Anvilcraft Pigsplus Configuration",
Expand Down Expand Up @@ -57,8 +59,9 @@
"itemGroup.anvilcraft_pigsplus.addon_items": "AnvilCraft: Pigs Plus",
"jei.anvilcraft.pigsplus.info.ender_component": "Throw a Karakuri Component into the End portal, there is a %.0f%% chance to obtain a Ender Component.",
"jei.anvilcraft.pigsplus.info.spiritual_component": "When a Karakuri Component is destroyed, each enchantment provides a %.0f%% chance to generate at most one Medium Component.",
"tooltip.anvilcraft.pigsplus.enchanted_generator.max_power_value": "Max power consumption: %d kW",
"tooltip.anvilcraft.pigsplus.enchanted_generator.power_rate": "Power consumption rate: %s",
"tooltip.anvilcraft.pigsplus.enchanted_generator.previous_energy_consumption": "Previous item energy consumption: %d",
"tooltip.anvilcraft.pigsplus.enchanted_generator.time": "Remaining time: %s"
"tooltip.anvilcraft_pigsplus.enchanted_generator.max_power_value": "Max power consumption: %d kW",
"tooltip.anvilcraft_pigsplus.enchanted_generator.power_rate": "Power consumption rate: %s",
"tooltip.anvilcraft_pigsplus.enchanted_generator.previous_energy_consumption": "Previous item energy consumption: %d",
"tooltip.anvilcraft_pigsplus.enchanted_generator.time": "Remaining time: %s",
"tooltip.anvilcraft_pigsplus.portable_wireless_charger": "When backpack, it consumes %d kW and generates %d FE/t"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.Optional;

public class EnchantedGeneratorBlock extends BetterBaseEntityBlock implements IHammerRemovable {
public static VoxelShape SHAPE = Block.box(0, 0, 0, 16, 4, 16);
public static VoxelShape SHAPE = Block.box(0, 0, 0, 16, 4.8, 16);
public static BooleanProperty POWERED = BlockStateProperties.POWERED;

public EnchantedGeneratorBlock(Properties pProperties) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.anvilcraft.pigsplus.block.entity;

import dev.anvilcraft.pigsplus.AnvilCraftPigsPlus;
import dev.anvilcraft.pigsplus.block.AutoRoyalGrindstoneBlock;
import dev.anvilcraft.pigsplus.init.AddonBlocks;
import dev.anvilcraft.pigsplus.init.AddonMenuTypes;
Expand Down Expand Up @@ -50,7 +51,6 @@
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

import static dev.anvilcraft.pigsplus.AnvilCraftPigsPlus.CONFIG;
import static dev.dubhe.anvilcraft.inventory.RoyalGrindstoneMenu.DEFAULT_REPAIR_MATERIAL;
import static dev.dubhe.anvilcraft.inventory.RoyalGrindstoneMenu.GOLD_PER_CURSE;
import static dev.dubhe.anvilcraft.inventory.RoyalGrindstoneMenu.REPAIR_COST_RECIPES;
Expand Down Expand Up @@ -156,7 +156,7 @@ public void tick(Level level, BlockPos pos) {
// 红石信号上升沿且冷却完毕,尝试进行自动研磨
cooldown = Math.max(0, cooldown - 1);
if (powered && !poweredBefore && !level.isClientSide && this.cooldown == 0) {
if (work(level)) cooldown = CONFIG.autoRoyalSmithingTableCooldown;
if (work(level)) cooldown = AnvilCraftPigsPlus.CONFIG.autoRoyalSmithingTableCooldown;
}
poweredBefore = powered;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public class AddonServerConfig {
@BoundedDiscrete(min = 1, max = 80)
public int autoRoyalSmithingTableCooldown = 4;

// 便携无线充电器
@Comment("Energy conversion quantity of portable wireless charger (kW)")
@BoundedDiscrete(min = 1, max = 1024000)
public int portableWirelessChargerEnergyConversion = 512;

// 电力附魔台
@CollapsibleObject
public ElectricEnchantingTable electricEnchantingTable = new ElectricEnchantingTable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public static void init(RegistrateLangProvider provider) {
"Too close to another enchanted generator"
);

provider.add("tooltip.anvilcraft.pigsplus.enchanted_generator.time", "Remaining time: %s");
provider.add("tooltip.anvilcraft.pigsplus.enchanted_generator.max_power_value", "Max power consumption: %d kW");
provider.add("tooltip.anvilcraft.pigsplus.enchanted_generator.power_rate", "Power consumption rate: %s");
provider.add("tooltip.anvilcraft.pigsplus.enchanted_generator.previous_energy_consumption", "Previous item energy consumption: %d");
provider.add("tooltip.anvilcraft_pigsplus.enchanted_generator.time", "Remaining time: %s");
provider.add("tooltip.anvilcraft_pigsplus.enchanted_generator.max_power_value", "Max power consumption: %d kW");
provider.add("tooltip.anvilcraft_pigsplus.enchanted_generator.power_rate", "Power consumption rate: %s");
provider.add("tooltip.anvilcraft_pigsplus.enchanted_generator.previous_energy_consumption", "Previous item energy consumption: %d");
provider.add("tooltip.anvilcraft_pigsplus.portable_wireless_charger", "When backpack, it consumes %d kW and generates %d FE/t");

provider.add("config.jade.plugin_anvilcraft_pigsplus.electric_enchanting_table", "Electric Enchanting Table");
provider.add("config.jade.plugin_anvilcraft_pigsplus.enchanted_generator", "Enchanted Generator");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/anvilcraft/pigsplus/init/AddonBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import static dev.anvilcraft.pigsplus.AnvilCraftPigsPlus.REGISTRATE;

public class AddonBlocks {
public class AddonBlocks {
static {
REGISTRATE.defaultCreativeTab(AddonItemGroups.ADDON_ITEMS.getKey());
}
Expand Down Expand Up @@ -264,7 +264,7 @@ public class AddonBlocks {
.block("enchanted_generator", EnchantedGeneratorBlock::new)
.lang("Enchanted Generator")
.initialProperties(() -> Blocks.IRON_BLOCK)
.properties(p -> p.strength(5.0f, 1200f))
.properties(p -> p.lightLevel(state -> 9).strength(5.0f, 1200f).noOcclusion().emissiveRendering(ModBlocks::always))
.blockstate(DataGenUtil::noExtraModelOrState)
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.simpleItem()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfi
CompoundTag serverData = accessor.getServerData();
if (serverData.contains("time")) {
tooltip.add(Component.translatable(
"tooltip.anvilcraft.pigsplus.enchanted_generator.time",
"tooltip.anvilcraft_pigsplus.enchanted_generator.time",
FormattingUtil.toFormattedTime(serverData.getInt("time"), 5)));
}
if (serverData.contains("maxPowerValue")) {
tooltip.add(Component.translatable(
"tooltip.anvilcraft.pigsplus.enchanted_generator.max_power_value",
"tooltip.anvilcraft_pigsplus.enchanted_generator.max_power_value",
serverData.getInt("maxPowerValue")));
}
if (serverData.contains("powerRate")) {
tooltip.add(Component.translatable(
"tooltip.anvilcraft.pigsplus.enchanted_generator.power_rate",
"tooltip.anvilcraft_pigsplus.enchanted_generator.power_rate",
String.format("%.3f", serverData.getDouble("powerRate"))));
}
if (serverData.contains("prevPowerValue")) {
tooltip.add(Component.translatable(
"tooltip.anvilcraft.pigsplus.enchanted_generator.previous_energy_consumption",
"tooltip.anvilcraft_pigsplus.enchanted_generator.previous_energy_consumption",
serverData.getInt("prevPowerValue")));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package dev.anvilcraft.pigsplus.item;

import dev.anvilcraft.pigsplus.AnvilCraftPigsPlus;
import dev.anvilcraft.pigsplus.init.AddonItems;
import dev.dubhe.anvilcraft.AnvilCraft;
import dev.dubhe.anvilcraft.api.power.DynamicPowerComponent;
import dev.dubhe.anvilcraft.api.power.IDynamicPowerComponentHolder;
import dev.dubhe.anvilcraft.api.power.PowerGrid;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.energy.IEnergyStorage;

import java.util.List;

public class PortableWirelessChargerItem extends Item {
public static final DynamicPowerComponent.PowerConsumption CONSUMPTION = new DynamicPowerComponent.PowerConsumption(512);
public static final DynamicPowerComponent.PowerConsumption CONSUMPTION =
new DynamicPowerComponent.PowerConsumption(AnvilCraftPigsPlus.CONFIG.portableWirelessChargerEnergyConversion);


public PortableWirelessChargerItem(Properties properties) {
Expand All @@ -35,9 +43,16 @@ public static void refreshPower(ServerPlayer player) {
}

public static void chargePlayerItems(ServerPlayer player) {
IDynamicPowerComponentHolder holder = IDynamicPowerComponentHolder.of(player);
DynamicPowerComponent powerComponent = holder.anvilcraft$getPowerComponent();
PowerGrid powerGrid = powerComponent.getPowerGrid();
if (powerGrid == null) return;
if (!powerGrid.isWorking()) return;

boolean isInInventory = player.getInventory().contains(AddonItems.PORTABLE_WIRELESS_CHARGER.asStack());
int feEnergy = CONSUMPTION.amount() * AnvilCraft.CONFIG.powerConverter.powerConverterEfficiency;
if (!isInInventory) return;

int feEnergy = AnvilCraftPigsPlus.CONFIG.portableWirelessChargerEnergyConversion * AnvilCraft.CONFIG.powerConverter.powerConverterEfficiency;
// 遍历玩家物品栏,尝试为有能量槽的物品充电
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
ItemStack itemStack = player.getInventory().getItem(i);
Expand All @@ -53,5 +68,13 @@ public static void chargePlayerItems(ServerPlayer player) {
}
}


@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
tooltipComponents.add(Component.translatable(
"tooltip.anvilcraft_pigsplus.portable_wireless_charger",
AnvilCraftPigsPlus.CONFIG.portableWirelessChargerEnergyConversion,
AnvilCraftPigsPlus.CONFIG.portableWirelessChargerEnergyConversion * AnvilCraft.CONFIG.powerConverter.powerConverterEfficiency
).withStyle(ChatFormatting.GRAY));
}
}
15 changes: 9 additions & 6 deletions src/main/resources/assets/anvilcraft_pigsplus/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"anvilcraft_pigsplus.configuration.auto_royal_smithing_table_cooldown": "Auto Royal Smithing Table Cooldown",
"anvilcraft_pigsplus.configuration.auto_royal_smithing_table_cooldown.tooltip": "自动皇家锻造台的冷却时长 (in ticks)",
"anvilcraft_pigsplus.configuration.auto_royal_smithing_table_cooldown.tooltip": "自动皇家锻造台的冷却时长(tick)",
"anvilcraft_pigsplus.configuration.electric_enchanting_table": "电力附魔台",
"anvilcraft_pigsplus.configuration.electric_enchanting_table.base_power_consumption_limit": "Base Power Consumption Limit",
"anvilcraft_pigsplus.configuration.electric_enchanting_table.base_power_consumption_limit.tooltip": "电力附魔台的基础能耗上限",
Expand All @@ -27,6 +27,8 @@
"anvilcraft_pigsplus.configuration.enchanted_generator.power_per_level": "Power Per Level",
"anvilcraft_pigsplus.configuration.enchanted_generator.power_per_level.tooltip": "每个附魔等级提供的能量",
"anvilcraft_pigsplus.configuration.enchanted_generator.tooltip": "附魔发电机",
"anvilcraft_pigsplus.configuration.portable_wireless_charger_energy_conversion": "Portable Wireless Charger Energy Conversion (kW)",
"anvilcraft_pigsplus.configuration.portable_wireless_charger_energy_conversion.tooltip": "便携无线充电器的能量转换量",
"anvilcraft_pigsplus.configuration.section.anvilcraft_pigsplus.server.toml": "铁砧工艺:猪+ 服务端配置",
"anvilcraft_pigsplus.configuration.section.anvilcraft_pigsplus.server.toml.title": "铁砧工艺:猪+ 服务端配置",
"anvilcraft_pigsplus.configuration.title": "铁砧工艺:猪+ 配置",
Expand All @@ -52,13 +54,14 @@
"item.anvilcraft_pigsplus.chaotic_raw_ore": "混沌粗矿",
"item.anvilcraft_pigsplus.ender_component": "末影部件",
"item.anvilcraft_pigsplus.karakuri_component": "机巧部件",
"item.anvilcraft_pigsplus.portable_wireless_charger": "便携无限充电器",
"item.anvilcraft_pigsplus.portable_wireless_charger": "便携无线充电器",
"item.anvilcraft_pigsplus.spiritual_component": "灵媒部件",
"itemGroup.anvilcraft_pigsplus.addon_items": "铁砧工艺:猪+",
"jei.anvilcraft.pigsplus.info.ender_component": "将机巧部件丢入末地传送门,有%.0f%%概率获得",
"jei.anvilcraft.pigsplus.info.spiritual_component": "携带附魔的机巧部件被摧毁时,每条附魔提供%.0f%%的概率,生成最多一个灵媒部件",
"tooltip.anvilcraft.pigsplus.enchanted_generator.max_power_value": "耗电上限: %d kW",
"tooltip.anvilcraft.pigsplus.enchanted_generator.power_rate": "耗能率: %s",
"tooltip.anvilcraft.pigsplus.enchanted_generator.previous_energy_consumption": "上一次附魔的能量消耗: %d",
"tooltip.anvilcraft.pigsplus.enchanted_generator.time": "剩余时间: %s"
"tooltip.anvilcraft_pigsplus.enchanted_generator.max_power_value": "耗电上限: %d kW",
"tooltip.anvilcraft_pigsplus.enchanted_generator.power_rate": "耗能率: %s",
"tooltip.anvilcraft_pigsplus.enchanted_generator.previous_energy_consumption": "上一次附魔的能量消耗: %d",
"tooltip.anvilcraft_pigsplus.enchanted_generator.time": "剩余时间: %s",
"tooltip.anvilcraft_pigsplus.portable_wireless_charger": "放在背包里,消耗 %d kW 以生产 %d FE/t"
}
Loading