forked from Anvil-Dev/AnvilCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Anvil-Dev#270 from Gu-ZT/Power
尝试设计电网系统
- Loading branch information
Showing
146 changed files
with
3,157 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# User-specific stuff | ||
.idea/ | ||
!.idea/icon.svg | ||
|
||
*.iml | ||
*.ipr | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package dev.dubhe.anvilcraft.api.power; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* 电力元件 | ||
*/ | ||
@SuppressWarnings("unused") | ||
public interface IPowerComponent { | ||
/** | ||
* @return 元件位置 | ||
*/ | ||
@NotNull | ||
BlockPos getPos(); | ||
|
||
default VoxelShape getRange() { | ||
return Shapes.block(); | ||
} | ||
|
||
/** | ||
* 设置电网 | ||
* | ||
* @param grid 电网 | ||
*/ | ||
void setGrid(@Nullable PowerGrid grid); | ||
|
||
/** | ||
* 获取电网 | ||
* | ||
* @return 电网 | ||
*/ | ||
@Nullable | ||
PowerGrid getGrid(); | ||
|
||
/** | ||
* @return 元件类型 | ||
*/ | ||
@NotNull | ||
PowerComponentType getComponentType(); | ||
} |
20 changes: 20 additions & 0 deletions
20
common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package dev.dubhe.anvilcraft.api.power; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* 用电 | ||
*/ | ||
public interface IPowerConsumer extends IPowerComponent { | ||
/** | ||
* @return 输入功率 | ||
*/ | ||
default int getInputPower() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
default @NotNull PowerComponentType getComponentType() { | ||
return PowerComponentType.CONSUMER; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package dev.dubhe.anvilcraft.api.power; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* 发电 | ||
*/ | ||
public interface IPowerProducer extends IPowerComponent { | ||
/** | ||
* @return 输出功率 | ||
*/ | ||
default int getOutputPower() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
default @NotNull PowerComponentType getComponentType() { | ||
return PowerComponentType.PRODUCER; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dev.dubhe.anvilcraft.api.power; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* 储电 | ||
*/ | ||
public interface IPowerStorage extends IPowerProducer, IPowerConsumer { | ||
/** | ||
* 输入电量 | ||
* | ||
* @param power 输入值 | ||
* @return 无法输入的值 | ||
*/ | ||
int insert(int power); | ||
|
||
/** | ||
* 获取电量 | ||
* | ||
* @param power 想要获取的值 | ||
* @return 实际获取的值 | ||
*/ | ||
int extract(int power); | ||
|
||
@Override | ||
default @NotNull PowerComponentType getComponentType() { | ||
return PowerComponentType.STORAGE; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerTransmitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package dev.dubhe.anvilcraft.api.power; | ||
|
||
import dev.dubhe.anvilcraft.AnvilCraft; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* 电力中继器 | ||
*/ | ||
public interface IPowerTransmitter extends IPowerComponent { | ||
@Override | ||
default VoxelShape getRange() { | ||
int range = AnvilCraft.config.powerTransmitterRange; | ||
return Shapes.box(-range, -range, -range, range + 1, range + 1, range + 1); | ||
} | ||
|
||
@Override | ||
default @NotNull PowerComponentType getComponentType() { | ||
return PowerComponentType.TRANSMITTER; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerComponentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dev.dubhe.anvilcraft.api.power; | ||
|
||
/** | ||
* 电力元件类型 | ||
*/ | ||
public enum PowerComponentType { | ||
INVALID, | ||
PRODUCER, | ||
CONSUMER, | ||
STORAGE, | ||
TRANSMITTER | ||
} |
Oops, something went wrong.