Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 1.19.2-1.0.3 #2

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .architectury-transformer/debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Architectury Transformer DEBUG] Closed File Systems for D:\projects\java\Mine Ways\common\build\libs\mineways-common-1.0.3+1.19.2.jar
[Architectury Transformer DEBUG] Closed File Systems for D:\projects\java\Mine Ways\fabric-like\build\libs\mineways-fabric-like-1.0.3+1.19.2.jar
14 changes: 7 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
env:
MINECRAFT_VERSION: 1.19.2
JAVA_VERSION: 17
VERSION: 1.0.2+1.19.2
RELEASE_NAME: Mine Ways 1.0.2 for Minecraft 1.19.2
VERSION: 1.0.3+1.19.2
RELEASE_NAME: 1.0.3+1.19.2
RELEASE_TYPE: alpha
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.UPLOAD_GITHUB_TOKEN }}
Expand Down Expand Up @@ -60,12 +60,12 @@ jobs:
name: "${{env.RELEASE_NAME}}"
version: "${{env.VERSION}}"
version-type: "${{env.RELEASE_TYPE}}"
changelog-file: CHANGELOG.md
changelog-file: "changelogs/${{env.VERSION}}-CHANGELOG.md"

loaders: |
fabric
forge
quilt
loaders:
- fabric
- forge
- quilt

game-versions: "${{env.MINECRAFT_VERSION}}"
java: "${{env.JAVA_VERSION}}"
647 changes: 647 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
# Mine Ways

"Minecraft Mine Ways" is a mod that adds a variety of transportation options to the game,
including roads, vehicles, and more. The mod is designed to make it easier for
players to navigate their way around the game world and to connect different locations
together. With Mine Ways, players can create a network of roads and paths, allowing them
to quickly and easily travel between different areas of the game. Whether you're looking to
explore new areas, transport goods and resources, or simply move around more efficiently,
Mine Ways has something to offer.
Experience the ultimate airport management adventure with "Mine Ways," the groundbreaking Minecraft mod.
Step into the shoes of an airport manager and take control of every aspect of your virtual airport.
This feature-packed mod introduces an array of game-changing elements, including cutting-edge RADAR systems,
robust security protocols, immersive passport control, and much more.
Immerse yourself in the intricate world of airport operations, optimize efficiency,
and create an engaging and realistic airport environment.
With "Mine Ways," the sky's the limit as you embark on an unforgettable journey of airport management mastery.

Curse Forge: https://www.curseforge.com/minecraft/mc-mods/mineways
## Downloads

Wiki: https://github.com/ajh123/MineWays/wiki
* Curse Forge: https://www.curseforge.com/minecraft/mc-mods/mineways
* GitHub Releases: https://github.com/ajh123/MineWays/tags

## Links

* GitHub: https://github.com/ajh123/MineWays
* Wiki: https://minersonline.tk/docs/en/mineways

## Important Notes


This mod is currently in very early development, so expect bugs!

## Contributing

We would be very happy if you want to contribute to our project. Just make sure you use the latest "non-master" branch, then [publish your PR](https://github.com/ajh123/MineWays/pulls). You may create the PR as a "draft" so we can see your progress before it gets merged.
24 changes: 17 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
id "architectury-plugin" version "3.4.145"
id "dev.architectury.loom" version "1.1.329" apply false
}

architectury {
Expand All @@ -11,16 +11,22 @@ subprojects {
archives_base_name = "mineways-$project.name"
apply plugin: "dev.architectury.loom"

loom {
silentMojangMappingsLicense()
}
loom {
silentMojangMappingsLicense()
}

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings loom.officialMojangMappings()
// mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.19.2+build.3:v2"
mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2"

// This doesn't seem to work ...
// mappings loom.layered { // We want to use both mappings, but the use the Mojang ones as a fallback.
// // officialMojangMappings() // Layered mappings don't seem to work yet.
// mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2")
//}
}
}

Expand All @@ -39,6 +45,10 @@ allprojects {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
url 'https://cursemaven.com'
content { includeGroup "curse.maven" }
}
}

tasks.withType(JavaCompile) {
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions changelogs/1.0.3+1.19.2-CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Mine Ways 1.0.3 for Minecraft 1.19.2

Changes:
* Added important details to mod config files.
* Added the "GNU General Public License Version 3" to the sources.
* Added the Road Builder item. It allows you to build a road / path with the item in your other hand.
* Updated to the Yarn mappings
* Actually implement the Road Builder, and made the Road Builder more survival friendly.
* Added dummy texture for the Road Builder.
* Added the Traffic Light.
* Added the Traffic Light Controller, which is used to sequence Traffic Lights.
* Added a new network system to allow devices to bv connected to each other.
30 changes: 10 additions & 20 deletions common/src/main/java/tk/minersonline/mineways/MineWaysMod.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
package tk.minersonline.mineways;

import com.google.common.base.Suppliers;
import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.Registries;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

import java.util.function.Supplier;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import tk.minersonline.mineways.setup.ModItems;
import tk.minersonline.mineways.setup.Registration;

public class MineWaysMod {
public static final String MOD_ID = "mineways";
// We can use this if we don't want to use DeferredRegister
public static final Supplier<Registries> REGISTRIES = Suppliers.memoize(() -> Registries.get(MOD_ID));
//public static final Supplier<Registries> REGISTRIES = Suppliers.memoize(() -> Registries.get(MOD_ID));
// Registering a new creative tab
public static final CreativeModeTab EXAMPLE_TAB = CreativeTabRegistry.create(new ResourceLocation(MOD_ID, "mineays_main"), () ->
new ItemStack(MineWaysMod.EXAMPLE_ITEM.get()));

public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(MOD_ID, Registry.ITEM_REGISTRY);
public static final RegistrySupplier<Item> EXAMPLE_ITEM = ITEMS.register("example_item", () ->
new Item(new Item.Properties().tab(MineWaysMod.EXAMPLE_TAB)));

public static final ItemGroup MAIN_TAB = CreativeTabRegistry.create(new Identifier(MOD_ID, "mineays_main"), () ->
new ItemStack(ModItems.ROAD_BUILDER.get()));

public static void init() {
ITEMS.register();

Registration.init();
System.out.println(MineWaysExpectPlatform.getConfigDirectory().toAbsolutePath().normalize().toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package tk.minersonline.mineways.api.event;

public interface EventHandler {
boolean handleEvent(Events.Event<?> event);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package tk.minersonline.mineways.api.event;

import net.minecraft.block.BlockState;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class Events {
public static abstract class EventData {

}

public static class Event<T extends EventData> {
private final EventData data;

public Event(EventData data) {
this.data = data;
}

public EventData getData() {
return data;
}
}

public static class BlockBreakEvent extends EventData {
private final World world;
private final BlockPos pos;
private final BlockState state;
private final ServerPlayerEntity player;

public BlockBreakEvent(World world, BlockPos pos, BlockState state, ServerPlayerEntity player) {
this.world = world;
this.pos = pos;
this.state = state;
this.player = player;
}

public World getWorld() {
return world;
}

public BlockPos getPos() {
return pos;
}

public BlockState getState() {
return state;
}

public ServerPlayerEntity getPlayer() {
return player;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package tk.minersonline.mineways.api.network;

import net.minecraft.nbt.NbtCompound;

import java.util.ArrayList;
import java.util.UUID;

public class AbstractDevice {
private final UUID id;
private final ArrayList<Packet> buffer;
private final DeviceProvider provider;

private AbstractDevice(DeviceProvider provider, UUID id) {
this.id = id;
this.provider = provider;
buffer = new ArrayList<>();
}

public static AbstractDevice create(DeviceProvider provider) {
AbstractDevice device = new AbstractDevice(provider, UUID.randomUUID());
NetworkManager.getInstance().registerDevice(device);
return device;
}

public static AbstractDevice fromNbt(DeviceProvider provider, NbtCompound nbt) {
AbstractDevice device = new AbstractDevice(provider, nbt.getUuid("id"));
NetworkManager.getInstance().registerDevice(device);
return device;
}

public NbtCompound writeNbt() {
NbtCompound compound = new NbtCompound();
compound.putUuid("id", this.id);
return compound;
}

protected void receivePacket(Packet packet) {
buffer.add(packet);
}

public void processPackets() {
for (Packet packet : buffer) {
this.provider.processPacket(packet);
}
buffer.clear();
}

public UUID getId() {
return id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package tk.minersonline.mineways.api.network;

import tk.minersonline.mineways.api.network.AbstractDevice;
import tk.minersonline.mineways.api.network.Packet;

public interface DeviceProvider {
void processPacket(Packet packet);
AbstractDevice getDevice();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package tk.minersonline.mineways.api.network;

import java.util.*;

public class NetworkManager {
private static NetworkManager instance;
private final Map<UUID, AbstractDevice> devices;
private final List<Connection> connections;

private NetworkManager() {
devices = new HashMap<>();
connections = new ArrayList<>();
}

public static synchronized NetworkManager getInstance() {
if (instance == null) {
instance = new NetworkManager();
}
return instance;
}

public void registerDevice(AbstractDevice device) {
if (!devices.containsKey(device.getId())) {
devices.put(device.getId(), device);
}
}

public void removeDevice(AbstractDevice device) {
devices.remove(device.getId());
connections.removeIf(connection -> connection.contains(device));
}

public void connectDevices(AbstractDevice device1, AbstractDevice device2) {
connections.add(new Connection(device1, device2));
}

public void disconnectDevices(AbstractDevice device1, AbstractDevice device2) {
connections.removeIf(connection -> connection.contains(device1) && connection.contains(device2));
}

public boolean devicesLinked(AbstractDevice device1, AbstractDevice device2) {
for (Connection connection : connections) {
if (connection.contains(device1, device2)) {
return true;
}
}
return false;
}

public Collection<AbstractDevice> getNeighbours(AbstractDevice device) {
List<AbstractDevice> neighbours = new ArrayList<>();
for (Connection connection : connections) {
if (connection.contains(device)) {
neighbours.add(connection.getOther(device));
}
}
return Collections.unmodifiableList(neighbours);
}

public void forwardPacket(Packet packet, AbstractDevice sender, AbstractDevice recipient) {
if (devices.containsValue(sender) && devices.containsValue(recipient)) {
for (Connection connection : connections) {
if (connection.contains(sender) && connection.contains(recipient)) {
recipient.receivePacket(packet);
break;
}
}
}
}

private static class Connection {
private final AbstractDevice device1;
private final AbstractDevice device2;

public Connection(AbstractDevice device1, AbstractDevice device2) {
this.device1 = device1;
this.device2 = device2;
}

public boolean contains(AbstractDevice device) {
return device == device1 || device == device2;
}

public boolean contains(AbstractDevice device1, AbstractDevice device2) {
return contains(device1) && contains(device2);
}

public AbstractDevice getOther(AbstractDevice device) {
if (device == device1) {
return device2;
} else if (device == device2) {
return device1;
} else {
return null;
}
}
}
}
Loading