Add realtime counter that uses MC world game-time ticks.

This commit is contained in:
Florian Nücke
2020-12-11 05:50:58 +01:00
parent d15a09c3cd
commit 896130189f
14 changed files with 9713 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
c4123949a3263af465a2e2c59089c2b5e60bffac assets/oc2/blockstates/bus_cable.json
16959897ee915fd4dffcc2c0f71f9456257bf734 assets/oc2/blockstates/computer.json
2b0784120d27ff9c1d43dc11435ca1d1372f4187 assets/oc2/blockstates/redstone_interface.json
b46109b5f2f88f81e12822d7b36ad358eb0b612d assets/oc2/blockstates/screen.json
9ed931619e39f59a8520c1e3b03fea2e9a56fb60 assets/oc2/models/block/computer.json
9ed931619e39f59a8520c1e3b03fea2e9a56fb60 assets/oc2/models/block/redstone_interface.json
9ed931619e39f59a8520c1e3b03fea2e9a56fb60 assets/oc2/models/block/screen.json
53935dcfeefb89e634fdd58aebcfd827ddc21136 assets/oc2/models/item/bus_cable.json
2c39515bad0488e8c058ed9cdcfca514a6d1add9 assets/oc2/models/item/computer.json
08c2c6c0eac587d5a5d202d4b315d573d63a75ff assets/oc2/models/item/redstone_interface.json
2b7f354376808f7d1c0e89d509ad1ddb7c5822ee assets/oc2/models/item/screen.json

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
{
"variants": {
"facing=north": {
"model": "oc2:block/computer"
},
"facing=south": {
"model": "oc2:block/computer",
"y": 180
},
"facing=west": {
"model": "oc2:block/computer",
"y": 270
},
"facing=east": {
"model": "oc2:block/computer",
"y": 90
}
}
}

View File

@@ -0,0 +1,19 @@
{
"variants": {
"facing=north": {
"model": "oc2:block/redstone_interface"
},
"facing=south": {
"model": "oc2:block/redstone_interface",
"y": 180
},
"facing=west": {
"model": "oc2:block/redstone_interface",
"y": 270
},
"facing=east": {
"model": "oc2:block/redstone_interface",
"y": 90
}
}
}

View File

@@ -0,0 +1,19 @@
{
"variants": {
"facing=north": {
"model": "oc2:block/screen"
},
"facing=south": {
"model": "oc2:block/screen",
"y": 180
},
"facing=west": {
"model": "oc2:block/screen",
"y": 270
},
"facing=east": {
"model": "oc2:block/screen",
"y": 90
}
}
}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,3 @@
{
"parent": "oc2:block/cable_base"
}

View File

@@ -0,0 +1,3 @@
{
"parent": "oc2:block/computer"
}

View File

@@ -0,0 +1,3 @@
{
"parent": "oc2:block/redstone_interface"
}

View File

@@ -0,0 +1,3 @@
{
"parent": "oc2:block/screen"
}

View File

@@ -0,0 +1,30 @@
package li.cil.oc2.common.vm.device;
import li.cil.sedna.api.device.rtc.RealTimeCounter;
import net.minecraft.world.World;
public final class MinecraftRealTimeCounter implements RealTimeCounter {
private static final int TICKS_PER_DAY = 24000;
private static final int FREQUENCY = TICKS_PER_DAY;
private World world;
public void setWorld(final World world) {
this.world = world;
}
@Override
public long getTime() {
final long ticks = world != null ? world.getGameTime() : 0;
final long days = ticks; // / TICKS_PER_DAY
final long hours = days * 24;
final long minutes = hours * 60;
final long seconds = minutes * 60;
return seconds; // * FREQUENCY
}
@Override
public int getFrequency() {
return FREQUENCY;
}
}

View File

@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.common.vm.device;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;