Skip to content

Commit 208d5ab

Browse files
committed
Add Output Hatch
1 parent 46bcaa5 commit 208d5ab

24 files changed

Lines changed: 546 additions & 75 deletions

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ This mod can be used to add kinetic power on the Modular Machinery Reborn custom
88

99
```
1010
ServerEvents.recipes(event => {
11-
event.recipes.modular_machinery_reborn.machine_recipe("mmr:testing", 150)
11+
event.recipes.modular_machinery_reborn.machine_recipe("mmr:testing_input", 150)
1212
.requireItem("1x minecraft:oak_log", 16, 16)
1313
.produceItem('1x minecraft:oak_planks', 16+ 22, 16 )
14-
.requireKinetic(1024, 16, 42)
14+
.requireKinetic(1024, 16, 42) //requireKinetic(stressUnits, x, y)
15+
16+
event.recipes.modular_machinery_reborn.machine_recipe("mmr:testing_output", 150)
17+
.requireItem("1x minecraft:oak_log", 16, 16)
18+
.produceKinetic(256, 32000, 16, 42) //produceKinetic(rpm, stressCapacity, x, y) // each hatch in the structure would produce the same amount of energy.
1519
})
1620
1721
1822
MMREvents.machines(event => {
19-
event.create("mmr:testing")
20-
.name('Testing Kinetic machineJS')
23+
event.create("mmr:testing_input")
24+
.name('Testing Kinetic Input machineJS')
2125
.structure(
2226
MMRStructureBuilder.create()
2327
.pattern(
@@ -35,14 +39,35 @@ MMREvents.machines(event => {
3539
)
3640
)
3741
.controllerModel(ControllerModel.of("minecraft:furnace"))
42+
43+
event.create("mmr:testing_output")
44+
.name('Testing Kinetic Output machineJS')
45+
.structure(
46+
MMRStructureBuilder.create()
47+
.pattern(
48+
[
49+
["mklik"],
50+
]
51+
)
52+
.keys(
53+
{
54+
"k": "mmrcreate:kinetic_output_hatch",
55+
"l": "minecraft:iron_block",
56+
"i": "#modular_machinery_reborn:inputbus"
57+
}
58+
)
59+
)
60+
.controllerModel(ControllerModel.of("minecraft:furnace"))
3861
})
62+
3963
```
4064

4165
## Available Tags
4266

4367
```
4468
#mmrcreate:kinetic_hatch
4569
#mmrcreate:kinetic_input_hatch
70+
#mmrcreate:kinetic_output_hatch
4671
#mmrcreate:kinetic_input_hatch/slow
4772
#mmrcreate:kinetic_input_hatch/medium
4873
#mmrcreate:kinetic_input_hatch/fast
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"variants": {
3+
"facing=down": {
4+
"model": "mmrcreate:block/kinetic_output_hatch_tiny_none",
5+
"x": 180
6+
},
7+
"facing=east": {
8+
"model": "mmrcreate:block/kinetic_output_hatch_tiny_none",
9+
"x": 90,
10+
"y": 90
11+
},
12+
"facing=north": {
13+
"model": "mmrcreate:block/kinetic_output_hatch_tiny_none",
14+
"x": 90
15+
},
16+
"facing=south": {
17+
"model": "mmrcreate:block/kinetic_output_hatch_tiny_none",
18+
"x": 90,
19+
"y": 180
20+
},
21+
"facing=up": {
22+
"model": "mmrcreate:block/kinetic_output_hatch_tiny_none"
23+
},
24+
"facing=west": {
25+
"model": "mmrcreate:block/kinetic_output_hatch_tiny_none",
26+
"x": 90,
27+
"y": 270
28+
}
29+
}
30+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"parent": "mmrcreate:block/kinetic_hatch",
3+
"textures": {
4+
"back": "mmrcreate:block/hatch_output",
5+
"casing": "mmrcreate:block/casing_plain_none",
6+
"frame": "mmrcreate:block/andesite_hatch_frame_tiny"
7+
}
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"parent": "mmrcreate:block/kinetic_output_hatch_tiny_none"
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"mmrcreate:kinetic_output_hatch"
4+
]
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"mmrcreate:kinetic_output_hatch"
4+
]
5+
}

src/main/java/com/bymarcin/mmrcreate/MMRCreate.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ public static void registerBlockColors(final RegisterColorHandlersEvent.Block ev
148148
// VACUUM
149149
BlockRegistration.KINETIC_INPUT_HATCH_VACUUM_SLOW.get(),
150150
BlockRegistration.KINETIC_INPUT_HATCH_VACUUM_MEDIUM.get(),
151-
BlockRegistration.KINETIC_INPUT_HATCH_VACUUM_FAST.get()
151+
BlockRegistration.KINETIC_INPUT_HATCH_VACUUM_FAST.get(),
152+
153+
//OUTPUT
154+
BlockRegistration.KINETIC_OUTPUT_HATCH.get()
152155
);
153156
}
154157

@@ -193,7 +196,10 @@ public static void registerItemColors(final RegisterColorHandlersEvent.Item even
193196
// VACUUM
194197
BlockRegistration.KINETIC_INPUT_HATCH_VACUUM_SLOW.get().asItem(),
195198
BlockRegistration.KINETIC_INPUT_HATCH_VACUUM_MEDIUM.get().asItem(),
196-
BlockRegistration.KINETIC_INPUT_HATCH_VACUUM_FAST.get().asItem()
199+
BlockRegistration.KINETIC_INPUT_HATCH_VACUUM_FAST.get().asItem(),
200+
201+
//OUTPUT
202+
BlockRegistration.KINETIC_OUTPUT_HATCH.get().asItem()
197203
);
198204
}
199205
}

src/main/java/com/bymarcin/mmrcreate/MMRCreateTags.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public TagKey<T> get() {
3131
public static class Blocks extends Tag<Block> {
3232
public static final TagKey<Block> KINETIC = new Blocks(false, "kinetic_hatch").get();
3333
public static final TagKey<Block> KINETIC_INPUT = new Blocks(false, "kinetic_input_hatch").get();
34+
public static final TagKey<Block> KINETIC_OUTPUT = new Blocks(false, "kinetic_output_hatch").get();
3435
public static final TagKey<Block> KINETIC_INPUT_SLOW = new Blocks(false, "kinetic_input_hatch/slow").get();
3536
public static final TagKey<Block> KINETIC_INPUT_MEDIUM = new Blocks(false, "kinetic_input_hatch/medium").get();
3637
public static final TagKey<Block> KINETIC_INPUT_FAST = new Blocks(false, "kinetic_input_hatch/fast").get();
@@ -43,6 +44,7 @@ private Blocks(boolean isNeoForge, String name) {
4344
public static class Items extends Tag<Item> {
4445
public static final TagKey<Item> KINETIC = new Items(false, "kinetic_hatch").get();
4546
public static final TagKey<Item> KINETIC_INPUT = new Items(false, "kinetic_input_hatch").get();
47+
public static final TagKey<Item> KINETIC_OUTPUT = new Items(false, "kinetic_output_hatch").get();
4648
public static final TagKey<Item> KINETIC_INPUT_SLOW = new Items(false, "kinetic_input_hatch/slow").get();
4749
public static final TagKey<Item> KINETIC_INPUT_MEDIUM = new Items(false, "kinetic_input_hatch/medium").get();
4850
public static final TagKey<Item> KINETIC_INPUT_FAST = new Items(false, "kinetic_input_hatch/fast").get();
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.bymarcin.mmrcreate.block;
2+
3+
import com.bymarcin.mmrcreate.blockentity.KineticOutputHatchEntity;
4+
import com.simibubi.create.content.kinetics.base.DirectionalKineticBlock;
5+
import com.simibubi.create.foundation.block.IBE;
6+
import com.tterrag.registrate.util.entry.BlockEntityEntry;
7+
import es.degrassi.mmreborn.common.block.BlockDynamicColor;
8+
import net.minecraft.core.BlockPos;
9+
import net.minecraft.core.Direction;
10+
import net.minecraft.server.level.ServerLevel;
11+
import net.minecraft.util.RandomSource;
12+
import net.minecraft.world.level.Level;
13+
import net.minecraft.world.level.LevelReader;
14+
import net.minecraft.world.level.block.entity.BlockEntityType;
15+
import net.minecraft.world.level.block.state.BlockState;
16+
17+
public class BlockKineticOutputHatch<T extends KineticOutputHatchEntity> extends DirectionalKineticBlock implements IBE<T>, BlockDynamicColor {
18+
private final Class<T> tClass;
19+
private final BlockEntityEntry<? extends T> blockEntityType;
20+
21+
public BlockKineticOutputHatch(Properties properties, Class<T> tClass, BlockEntityEntry<? extends T> entityType) {
22+
super(properties);
23+
this.tClass = tClass;
24+
this.blockEntityType = entityType;
25+
}
26+
27+
@Override
28+
public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
29+
super.onPlace(state, worldIn, pos, oldState, isMoving);
30+
if (worldIn.isClientSide())
31+
return;
32+
if (!worldIn.getBlockTicks()
33+
.hasScheduledTick(pos, this))
34+
worldIn.scheduleTick(pos, this, 1);
35+
}
36+
37+
@Override
38+
protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
39+
withBlockEntityDo(level, pos, (e)->{
40+
e.updateGeneratedRotation();
41+
});
42+
}
43+
44+
@Override
45+
public Class<T> getBlockEntityClass() {
46+
return tClass;
47+
}
48+
49+
@Override
50+
public BlockEntityType<? extends T> getBlockEntityType() {
51+
return blockEntityType.get();
52+
}
53+
54+
@Override
55+
public Direction.Axis getRotationAxis(BlockState state) {
56+
return state.getValue(FACING).getAxis();
57+
}
58+
59+
@Override
60+
public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) {
61+
return face == state.getValue(FACING).getOpposite();
62+
}
63+
}

0 commit comments

Comments
 (0)