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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.Getter;
import lombok.Setter;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand All @@ -21,7 +22,9 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.energy.EnergyStorage;
import net.neoforged.neoforge.energy.IEnergyStorage;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;
Expand Down Expand Up @@ -112,12 +115,33 @@ public void tick() {
fe2kw();
} else {
kw2fe();
fe_output();
}
if (prevPower != power) {
grid.markChanged();
}
}

private void fe_output() {
if (level == null) return;
// 向每个方向输出能量
for (Direction direction : Direction.values()) {
BlockPos adjacentPos = getBlockPos().relative(direction);
BlockEntity adjacentBlockEntity = level.getBlockEntity(adjacentPos);
if (adjacentBlockEntity == null) continue;

IEnergyStorage energyStorage = level.getCapability(Capabilities.EnergyStorage.BLOCK, adjacentPos, direction.getOpposite());
if (energyStorage == null) continue;
if (!energyStorage.canReceive()) continue;

int receiveEnergy = energyStorage.receiveEnergy(feEnergy.getEnergyStored(), false);
feEnergy.extractEnergy(receiveEnergy, false);

if (feEnergy.getEnergyStored() <= 0) break;
}

}

private void fe2kw() {
power = 0;
int feConverted = powerTarget * AnvilCraft.CONFIG.powerConverter.powerConverterEfficiency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.client.event.ModelEvent;

@EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD, modid = AnvilCraftPigsPlus.MOD_ID)
@EventBusSubscriber(value = Dist.CLIENT, modid = AnvilCraftPigsPlus.MOD_ID)
public class RegisterAdditionalEventListener {
/**
* 注册模型
Expand All @@ -16,5 +16,6 @@ public class RegisterAdditionalEventListener {
public static void registerModels(ModelEvent.RegisterAdditional event) {
event.register(ModelResourceLocation.standalone(AnvilCraftPigsPlus.of("block/enchanted_generator_head")));
event.register(ModelResourceLocation.standalone(AnvilCraftPigsPlus.of("block/adjustable_power_converter_core")));
event.register(ModelResourceLocation.standalone(AnvilCraftPigsPlus.of("block/adjustable_power_converter_core_out")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class AdjustablePowerConverterRenderer extends PowerProducerRenderer<Adju
public static final ModelResourceLocation MODEL = ModelResourceLocation.standalone(
AnvilCraftPigsPlus.of("block/adjustable_power_converter_core")
);
public static final ModelResourceLocation MODEL_OUT = ModelResourceLocation.standalone(
AnvilCraftPigsPlus.of("block/adjustable_power_converter_core_out")
);

public AdjustablePowerConverterRenderer(BlockEntityRendererProvider.Context context) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/anvilcraft/pigsplus/data/ModDatagen.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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

@EventBusSubscriber(modid = AnvilCraftPigsPlus.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
@EventBusSubscriber(modid = AnvilCraftPigsPlus.MOD_ID)
public class ModDatagen {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import java.util.List;

@EventBusSubscriber(modid = AnvilCraftPigsPlus.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
@EventBusSubscriber(modid = AnvilCraftPigsPlus.MOD_ID)
public class CapabilitiesEventListener {
@SubscribeEvent
public static void registerCapabilities(final RegisterCapabilitiesEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public class AddonBlocks {
.block("adjustable_power_converter", AdjustablePowerConverterBlock::new)
.lang("Adjustable Power Converter")
.initialProperties(() -> Blocks.IRON_BLOCK)
.properties(p -> p.noOcclusion().isValidSpawn(Blocks::never))
.properties(p -> p.lightLevel(state -> 9).noOcclusion().isValidSpawn(Blocks::never).emissiveRendering(ModBlocks::always))
.blockstate(DataGenUtil::noExtraModelOrState)
.simpleItem()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "可调式能量转换器"
title: "§a可调式能量转换器"
icon: "anvilcraft_pigsplus:adjustable_power_converter"
position: 105
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "自动加工机"
title: "§a自动加工机"
icon: "anvilcraft_pigsplus:auto_royal_smithing_table"
position: 102
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "方块破坏器"
title: "§a方块破坏器"
icon: "anvilcraft_pigsplus:block_breaker"
position: 101
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "回响母岩"
title: "§a回响母岩"
icon: "anvilcraft_pigsplus:budding_echo_shard"
position: 110
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "炼药锅输出槽"
title: "§a炼药锅输出槽"
icon: "anvilcraft_pigsplus:cauldron_output"
position: 101
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "连锁锻造台"
title: "§a连锁锻造台"
icon: "anvilcraft_pigsplus:chain_smithing_table"
position: 101
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "混沌粗矿"
title: "§6混沌粗矿"
icon: "anvilcraft_pigsplus:chaotic_raw_ore"
position: 215
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "电力附魔台"
title: "§d电力附魔台"
icon: "anvilcraft_pigsplus:electric_enchanting_table"
position: 311
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "附魔发电机"
title: "§6附魔发电机"
icon: "anvilcraft_pigsplus:enchanted_generator"
position: 205
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "末影部件"
title: "§6末影部件"
icon: "anvilcraft_pigsplus:ender_component"
position: 210
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "机巧部件"
title: "§a机巧部件"
icon: "anvilcraft_pigsplus:karakuri_component"
position: 100
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "便携无限充电器"
title: "§a便携无限充电器"
icon: "anvilcraft_pigsplus:portable_wireless_charger"
position: 105
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "红石传导块"
title: "§a红石传导块"
icon: "anvilcraft_pigsplus:redstone_conduit_block"
position: 101
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "幽匿萃取体"
title: "§6幽匿萃取体"
icon: "anvilcraft_pigsplus:sculk_extractor"
position: 201
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
navigation:
title: "灵媒部件"
title: "§6灵媒部件"
icon: "anvilcraft_pigsplus:spiritual_component"
position: 200
parent: anvilcraft_guideme:pigsplus.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"format_version": "1.9.0",
"credit": "Made with Blockbench",
"parent": "minecraft:block/cube",
"ambientocclusion": false,
"render_type": "minecraft:cutout",
"textures": {
"0": "anvilcraft_pigsplus:block/adjustable_power_converter_frame_side",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"format_version": "1.9.0",
"credit": "Made with Blockbench",
"parent": "minecraft:block/cube",
"textures": {
"1": "anvilcraft_pigsplus:block/adjustable_power_converter_core_out",
"particle": "anvilcraft_pigsplus:block/adjustable_power_converter_core_out"
},
"elements": [
{
"from": [-4, -4, -4],
"to": [4, 4, 4],
"faces": {
"north": {"uv": [0, 0, 8, 8], "texture": "#1"},
"east": {"uv": [0, 0, 8, 8], "texture": "#1"},
"south": {"uv": [0, 0, 8, 8], "texture": "#1"},
"west": {"uv": [0, 0, 8, 8], "texture": "#1"},
"up": {"uv": [0, 0, 8, 8], "texture": "#1"},
"down": {"uv": [0, 0, 8, 8], "texture": "#1"}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"format_version": "1.9.0",
"credit": "Made with Blockbench",
"parent": "minecraft:block/cube",
"ambientocclusion": false,
"render_type": "minecraft:cutout",
"textures": {
"0": "anvilcraft_pigsplus:block/adjustable_power_converter_frame_side",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"neoforge:conditions": [
{
"type": "neoforge:mod_loaded",
"modid": "anvilcraft_alloyextension"
}
],
"type": "anvilcraft:time_warp",
"ingredients": [
{
"count": 6,
"items": "anvilcraft_alloyextension:ender_dust"
},
{
"count": 18,
"items": "minecraft:end_stone"
}
],
"results": [
{
"id": "anvilcraft_pigsplus:ender_component"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"neoforge:conditions": [
{
"type": "neoforge:mod_loaded",
"modid": "anvilcraft_alloyextension"
}
],
"type": "minecraft:crafting_shaped",
"category": "building",
"key": {
"I": {
"item": "minecraft:iron_ingot"
},
"E": {
"item": "anvilcraft_pigsplus:ender_component"
},
"S": {
"item": "anvilcraft:magnetic_chute"
}
},
"pattern": [
" ",
" E ",
"ISI"
],
"result": {
"count": 8,
"id": "anvilcraft_alloyextension:item_transporter"
}
}