Skip to content

Commit 946b217

Browse files
committed
- Extract static method form IMachineController to MachineController.
1 parent d5fbf9f commit 946b217

2 files changed

Lines changed: 55 additions & 42 deletions

File tree

src/main/java/github/kasuminova/mmce/common/helper/IMachineController.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import crafttweaker.annotations.ZenRegister;
44
import crafttweaker.api.block.IBlockState;
55
import crafttweaker.api.data.IData;
6-
import crafttweaker.api.minecraft.CraftTweakerMC;
76
import crafttweaker.api.world.IBlockPos;
87
import crafttweaker.api.world.IFacing;
98
import crafttweaker.api.world.IWorld;
@@ -13,9 +12,6 @@
1312
import hellfirepvp.modularmachinery.common.modifier.RecipeModifier;
1413
import hellfirepvp.modularmachinery.common.tiles.base.TileMultiblockMachineController;
1514
import hellfirepvp.modularmachinery.common.util.SmartInterfaceData;
16-
import net.minecraft.tileentity.TileEntity;
17-
import net.minecraft.util.math.BlockPos;
18-
import net.minecraft.world.World;
1915
import stanhebben.zenscript.annotations.ZenClass;
2016
import stanhebben.zenscript.annotations.ZenGetter;
2117
import stanhebben.zenscript.annotations.ZenMethod;
@@ -27,44 +23,6 @@
2723
@ZenClass("mods.modularmachinery.IMachineController")
2824
public interface IMachineController {
2925

30-
/**
31-
* 获取对应 IWorld 中的某个坐标的控制器。
32-
*
33-
* @param worldCT IWorld
34-
* @param posCT IBlockPos
35-
* @return 如果无控制器则返回 null,否则返回 IMachineController 实例。
36-
*/
37-
@ZenMethod
38-
static IMachineController getControllerAt(IWorld worldCT, IBlockPos posCT) {
39-
World world = CraftTweakerMC.getWorld(worldCT);
40-
BlockPos pos = CraftTweakerMC.getBlockPos(posCT);
41-
if (world == null || pos == null || !world.isBlockLoaded(pos)) {
42-
return null;
43-
}
44-
45-
TileEntity te = world.getTileEntity(pos);
46-
return te instanceof IMachineController ? (IMachineController) te : null;
47-
}
48-
49-
/**
50-
* 获取对应 IWorld 中的某个坐标的控制器。
51-
*
52-
* @param worldCT IWorld
53-
* @return 如果无控制器则返回 null,否则返回 IMachineController 实例。
54-
*/
55-
@ZenMethod
56-
static IMachineController getControllerAt(IWorld worldCT, int x, int y, int z) {
57-
World world = CraftTweakerMC.getWorld(worldCT);
58-
BlockPos pos = new BlockPos(x, y, z);
59-
60-
if (world == null || !world.isBlockLoaded(pos)) {
61-
return null;
62-
}
63-
64-
TileEntity te = world.getTileEntity(pos);
65-
return te instanceof IMachineController ? (IMachineController) te : null;
66-
}
67-
6826
/**
6927
* 获取控制器所在的世界。
7028
*
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package github.kasuminova.mmce.common.helper;
2+
3+
import crafttweaker.annotations.ZenRegister;
4+
import crafttweaker.api.minecraft.CraftTweakerMC;
5+
import crafttweaker.api.world.IBlockPos;
6+
import crafttweaker.api.world.IWorld;
7+
import net.minecraft.tileentity.TileEntity;
8+
import net.minecraft.util.math.BlockPos;
9+
import net.minecraft.world.World;
10+
import stanhebben.zenscript.annotations.ZenClass;
11+
import stanhebben.zenscript.annotations.ZenMethod;
12+
13+
@ZenRegister
14+
@ZenClass("mods.modularmachinery.MachineController")
15+
public class MachineController {
16+
17+
/**
18+
* 获取对应 IWorld 中的某个坐标的控制器。
19+
*
20+
* @param worldCT IWorld
21+
* @param posCT IBlockPos
22+
* @return 如果无控制器则返回 null,否则返回 IMachineController 实例。
23+
*/
24+
@ZenMethod
25+
static IMachineController getControllerAt(IWorld worldCT, IBlockPos posCT) {
26+
World world = CraftTweakerMC.getWorld(worldCT);
27+
BlockPos pos = CraftTweakerMC.getBlockPos(posCT);
28+
if (world == null || pos == null || !world.isBlockLoaded(pos)) {
29+
return null;
30+
}
31+
32+
TileEntity te = world.getTileEntity(pos);
33+
return te instanceof IMachineController ? (IMachineController) te : null;
34+
}
35+
36+
/**
37+
* 获取对应 IWorld 中的某个坐标的控制器。
38+
*
39+
* @param worldCT IWorld
40+
* @return 如果无控制器则返回 null,否则返回 IMachineController 实例。
41+
*/
42+
@ZenMethod
43+
static IMachineController getControllerAt(IWorld worldCT, int x, int y, int z) {
44+
World world = CraftTweakerMC.getWorld(worldCT);
45+
BlockPos pos = new BlockPos(x, y, z);
46+
47+
if (world == null || !world.isBlockLoaded(pos)) {
48+
return null;
49+
}
50+
51+
TileEntity te = world.getTileEntity(pos);
52+
return te instanceof IMachineController ? (IMachineController) te : null;
53+
}
54+
55+
}

0 commit comments

Comments
 (0)