Skip to content
Merged
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
7 changes: 2 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import org.gradle.internal.extensions.stdlib.toDefaultLowerCase
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.URI
import java.net.URL

plugins {
id("maven-publish")
id("fabric-loom") version "1.8.10"
id("babric-loom-extension") version "1.8.9"
id("fabric-loom") version "1.9.2"
id("babric-loom-extension") version "1.9.4"
}

//noinspection GroovyUnusedAssignment
Expand Down Expand Up @@ -74,7 +72,6 @@ dependencies {
modImplementation("net.modificationstation:StationAPI:${project.properties["stapi_version"]}")

modImplementation("net.glasslauncher.mods:ModMenu:${project.properties["modmenu_version"]}")
modImplementation("net.glasslauncher.mods:glass-networking:${project.properties["glassnetworking_version"]}")
modImplementation("net.glasslauncher.mods:GlassConfigAPI:${project.properties["gcapi_version"]}")
modImplementation("net.glasslauncher.mods:AlwaysMoreItems:${project.properties["alwaysmoreitems_version"]}")
}
Expand Down
9 changes: 4 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ maven_group=net.teamterminus
archives_base_name=machine_essentials

# Dependencies
stapi_version=2.0-alpha.2.4
stapi_version=2.0.0-alpha.4

# Extra Dependencies
gcapi_version=3.0.2
glassnetworking_version=1.0.3
alwaysmoreitems_version=1.2.0
modmenu_version=1.8.5-beta.9
gcapi_version=3.1.0
alwaysmoreitems_version=1.5.3
modmenu_version=1.8.5-beta.11
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,27 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.modificationstation.stationapi.api.event.mod.InitEvent;
import net.modificationstation.stationapi.api.mod.entrypoint.Entrypoint;
import net.modificationstation.stationapi.api.mod.entrypoint.EntrypointManager;
import net.modificationstation.stationapi.api.util.Namespace;
import net.modificationstation.stationapi.api.util.Null;
import net.modificationstation.stationapi.api.util.math.Direction;
import net.modificationstation.stationapi.api.world.StationFlatteningWorld;
import org.apache.logging.log4j.Logger;

import java.lang.invoke.MethodHandles;
import java.util.*;

public class MachineEssentials {
static {
EntrypointManager.registerLookup(MethodHandles.lookup());
}

@Entrypoint.Namespace
public static final Namespace NAMESPACE = Null.get();

@Entrypoint.Logger
public static final Logger LOGGER = Null.get();
@SuppressWarnings("UnstableApiUsage")
public static final Namespace NAMESPACE = Namespace.resolve();

@Entrypoint.Instance
public static final MachineEssentials INSTANCE = Null.get();
public static final Logger LOGGER = NAMESPACE.getLogger("MachineEssentials");

@EventListener
public static void init(InitEvent event) {
private static void init(InitEvent event) {
LOGGER.info("Machine Essentials initialized.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
import net.modificationstation.stationapi.api.template.block.TemplateBlockWithEntity;
import net.modificationstation.stationapi.api.util.Identifier;
import net.teamterminus.machineessentials.network.NetworkComponentBlock;
import net.teamterminus.machineessentials.util.BlockEntityInit;

public abstract class ElectricBlock extends TemplateBlockWithEntity implements NetworkComponentBlock {

public ElectricBlock(Identifier identifier, Material material) {
super(identifier, material);
}

@Override
public void onPlaced(World world, int x, int y, int z) {
super.onPlaced(world, x, y, z);
((BlockEntityInit) world.getBlockEntity(x, y, z)).init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
import net.teamterminus.machineessentials.energy.electric.api.Electric;
import net.teamterminus.machineessentials.energy.electric.api.HasVoltageTier;
import net.teamterminus.machineessentials.energy.electric.api.VoltageTier;
import net.teamterminus.machineessentials.network.NetworkComponent;
import net.teamterminus.machineessentials.network.Network;
import net.teamterminus.machineessentials.network.NetworkComponent;
import net.teamterminus.machineessentials.network.NetworkType;
import net.teamterminus.machineessentials.util.AveragingCounter;
import net.teamterminus.machineessentials.util.BlockEntityInit;

public abstract class ElectricBlockEntity extends BlockEntity implements BlockEntityInit, NetworkComponent, HasVoltageTier, Electric {
public abstract class ElectricBlockEntity extends BlockEntity implements NetworkComponent, HasVoltageTier, Electric {

/**
* Only use this directly if you know what you're doing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
import net.teamterminus.machineessentials.network.Network;
import net.teamterminus.machineessentials.network.NetworkType;
import net.teamterminus.machineessentials.util.AveragingCounter;
import net.teamterminus.machineessentials.util.BlockEntityInit;

public abstract class ElectricWireBlockEntity extends BlockEntity implements BlockEntityInit, ElectricWire {
public abstract class ElectricWireBlockEntity extends BlockEntity implements ElectricWire {

public Network energyNet;
@Getter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.teamterminus.machineessentials.network;

import com.google.common.collect.Maps;


import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.NbtCompound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
import net.modificationstation.stationapi.api.event.world.BlockSetEvent;
import net.modificationstation.stationapi.api.event.world.WorldEvent;
import net.modificationstation.stationapi.api.mod.entrypoint.Entrypoint;
import net.modificationstation.stationapi.api.mod.entrypoint.EntrypointManager;
import net.modificationstation.stationapi.api.mod.entrypoint.EventBusPolicy;
import net.modificationstation.stationapi.api.util.math.Vec3i;
import net.modificationstation.stationapi.api.world.StationFlatteningWorld;
import net.teamterminus.machineessentials.MachineEssentials;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.*;
import java.lang.invoke.MethodHandles;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

Expand All @@ -31,6 +29,9 @@
*/
@Entrypoint(eventBus = @EventBusPolicy(registerInstance = false))
public class NetworkManager {
static {
EntrypointManager.registerLookup(MethodHandles.lookup());
}

private static final Map<Integer, Set<Network>> NETS = new HashMap<>();
private static final AtomicInteger ID_PROVIDER = new AtomicInteger(0);
Expand All @@ -48,7 +49,7 @@ public static NetworkManager getInstance() {
}

@EventListener
public static void blockChanged(BlockSetEvent event) {
private void blockChanged(BlockSetEvent event) {
if (event.blockState == States.AIR.get()){
removeBlock(new BlockChangeInfo(event.world, new Vec3i(event.x, event.y, event.z), event.blockState, event.blockMeta));
} else {
Expand All @@ -58,34 +59,36 @@ public static void blockChanged(BlockSetEvent event) {

@EventListener
private static void initNetsEvent(WorldEvent.Init event) {
File file = event.world.dimensionData.getWorldPropertiesFile("networks_" + event.world.dimension.id);
if (!file.exists()) return;

try {
NbtCompound tag = NbtIo.readCompressed(new FileInputStream(file));
NetworkManager.netsFromTag(event.world, tag);
} catch (FileNotFoundException e) {
e.printStackTrace();
File file = event.world.dimensionData.getWorldPropertiesFile("networks");
if (file.exists()) {
try {
NbtCompound tag = NbtIo.readCompressed(new FileInputStream(file));
NetworkManager.netsFromTag(event.world, tag);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}

@EventListener
private static void saveNetsEvent(WorldEvent.Save event) {
File file = event.world.dimensionData.getWorldPropertiesFile("networks_" + event.world.dimension.id);
NbtCompound tag = new NbtCompound();

try {
tag = NbtIo.readCompressed(new FileInputStream(file));
} catch (FileNotFoundException ignored) {
MachineEssentials.LOGGER.info("Creating new networks file for dimension {}!", event.world.dimension.id);
}
NetworkManager.netsToTag(event.world, tag);
try {
File file = event.world.dimensionData.getWorldPropertiesFile("networks");
NbtCompound tag;
if (file.exists()) {
tag = NbtIo.readCompressed(new FileInputStream(file));
NetworkManager.netsToTag(event.world, tag);
}
else {
tag = new NbtCompound();
file.createNewFile();
}
NbtIo.writeCompressed(tag, new FileOutputStream(file));
} catch (FileNotFoundException e) {
}
catch (IOException e) {
e.printStackTrace();
}

}

public static void addBlock(BlockChangeInfo blockChanged) {
Expand Down Expand Up @@ -119,7 +122,7 @@ public static void addBlock(BlockChangeInfo blockChanged) {
int size = sideNets.size();
//no nets around, create one
if (size == 0) {
net = new Network(world, component.getType());
net = new Network(world,component.getType());
net.addBlock(x, y, z);
for (Vec3i offset: OFFSETS) {
int px = x + offset.getX();
Expand Down Expand Up @@ -163,7 +166,7 @@ else if (size == 1) {
}

if (net == null && getNet(world, x, y, z) == null) {
net = new Network(world, component.getType());
net = new Network(world,component.getType());
net.addBlock(x, y, z);
for (Vec3i offset: OFFSETS) {
int px = x + offset.getX();
Expand Down Expand Up @@ -279,7 +282,7 @@ public static void netsFromTag(World world, NbtCompound root) {
}

public static boolean canBeNet(StationFlatteningWorld world, int x, int y, int z) {
Block block = world.getBlockState(x, y, z).getBlock();
Block block = world.getBlockState(x,y,z).getBlock();
return canBeNet(block);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.teamterminus.machineessentials.network;

import net.modificationstation.stationapi.api.util.Identifier;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.modificationstation.stationapi.api.util.math.Vec3i;
import net.teamterminus.machineessentials.MachineEssentials;


import java.util.*;

/**
Expand Down Expand Up @@ -47,7 +46,7 @@ public NetworkWalker(World world, Vec3i source, int walkedBlocks, List<NetworkPa
}

public static <T extends NetworkComponent> List<NetworkPath> createNetworkPaths(World world, Vec3i source) {
if(world.getBlockEntity(source.getX(), source.getY(), source.getZ()) instanceof NetworkComponent) {
if (world.getBlockEntity(source.getX(), source.getY(), source.getZ()) instanceof NetworkComponent) {
NetworkWalker<T> walker = new NetworkWalker<>(world, source, 1, new ArrayList<>());
walker.traverse();
return walker.isFailed() ? null : walker.routes;
Expand All @@ -73,7 +72,7 @@ public void traverse() {
* @param max The maximum amount of blocks to traverse
*/
public void traverse(int max) {
if(used) {
if (used) {
throw new IllegalStateException("Walker already used!");
}
root = this;
Expand Down

This file was deleted.