Skip to content

Commit

Permalink
Merge pull request #243 from RedstoneTools/dev
Browse files Browse the repository at this point in the history
Update to 1.2.0
  • Loading branch information
Matthias1590 authored Jun 5, 2023
2 parents 5412b25 + f0c6f42 commit 7cd3dac
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 115 deletions.
51 changes: 37 additions & 14 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,54 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
# Build Workflow

name: Java CI with Gradle
name: Build & test

on:
pull_request:
branches: ['main']

concurrency:
group: ${{ github.head_ref || format('{0}-{1}', github.ref, github.run_number) }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
name: Build

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 10

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Gradle and run tests
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
java-version: 17
distribution: temurin

- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
**/loom-cache
**/prebundled-jars
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Chmod Gradle
run: chmod +x ./gradlew

- name: Build
run: ./gradlew build --no-daemon

- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
arguments: test
name: dev-artifacts
path: build/libs/
18 changes: 12 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//file:noinspection GroovyAssignabilityCheck

plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
Expand All @@ -21,15 +23,19 @@ repositories {
name = "WorldEdit Maven"
url = "https://maven.enginehub.org/repo/"
}
maven {
name = "JitPack"
url = "https://jitpack.io"
}
}

dependencies {
// Guice + dependencies
include implementation("com.google.inject:guice:5.0.1")
include "aopalliance:aopalliance:1.0"
include "javax.inject:javax.inject:1"
include "javax.json:javax.json-api:1.1.4"
include "jakarta.inject:jakarta.inject-api:2.0.1"
// Doctor (dependency-injection)
include implementation("rip.hippo:Doctor:1.0.1")
include implementation("javax.inject:javax.inject:1")

// Json
include implementation("javax.json:javax.json-api:1.1.4")
include "org.glassfish:javax.json:1.1.4"

// AutoService
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ org.gradle.parallel=true
loader_version=0.14.6

# Mod Properties
mod_version = 1.18.2-1.1.4
mod_version = 1.18.2-1.2.0
maven_group = tools.redstone
archives_base_name = redstonetools

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package tools.redstone.redstonetools;

import com.google.inject.Guice;
import com.google.inject.Injector;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rip.hippo.inject.Doctor;
import rip.hippo.inject.Injector;
import tools.redstone.redstonetools.macros.WorldlessCommandHelper;
import tools.redstone.redstonetools.utils.ReflectionUtils;

public class RedstoneToolsClient implements ClientModInitializer {
public static final String MOD_ID = "redstonetools";
public static final String MOD_VERSION = "v" + FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow().getMetadata().getVersion().getFriendlyString();
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static final Injector INJECTOR = Guice.createInjector(ReflectionUtils.getModules());
public static final Injector INJECTOR = Doctor.createInjector(ReflectionUtils.getModules());

@Override
public void onInitializeClient() {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/tools/redstone/redstonetools/di/FeatureModule.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package tools.redstone.redstonetools.di;

import com.google.auto.service.AutoService;
import com.google.inject.AbstractModule;
import rip.hippo.inject.DoctorModule;
import rip.hippo.inject.binding.Binder;
import tools.redstone.redstonetools.utils.ReflectionUtils;

@AutoService(AbstractModule.class)
public class FeatureModule extends AbstractModule {
@AutoService(DoctorModule.class)
public class FeatureModule implements DoctorModule {
@SuppressWarnings({"rawtypes", "unchecked"}) // this is probably the only way to make it work
@Override
protected void configure() {
public void configure(Binder binder) {
for (var feature : ReflectionUtils.getFeatures()) {
Class clazz = feature.getClass();
bind(clazz).toInstance(feature);
binder.bind(clazz).toInstance(feature);
}
}
}
23 changes: 0 additions & 23 deletions src/main/java/tools/redstone/redstonetools/di/MacroModule.java

This file was deleted.

31 changes: 0 additions & 31 deletions src/main/java/tools/redstone/redstonetools/di/TelemetryModule.java

This file was deleted.

11 changes: 6 additions & 5 deletions src/main/java/tools/redstone/redstonetools/di/UtilityModule.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package tools.redstone.redstonetools.di;

import com.google.auto.service.AutoService;
import rip.hippo.inject.DoctorModule;
import rip.hippo.inject.binding.Binder;
import tools.redstone.redstonetools.features.feedback.AbstractFeedbackSender;
import tools.redstone.redstonetools.features.feedback.FeedbackSender;
import com.google.inject.AbstractModule;

@AutoService(AbstractModule.class)
public class UtilityModule extends AbstractModule {
@AutoService(DoctorModule.class)
public class UtilityModule implements DoctorModule {
@Override
protected void configure() {
bind(AbstractFeedbackSender.class).to(FeedbackSender.class).asEagerSingleton();
public void configure(Binder binder) {
binder.bind(AbstractFeedbackSender.class).to(FeedbackSender.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.math.BlockPos;

import java.util.Collections;

import static tools.redstone.redstonetools.features.arguments.serializers.BlockStateArgumentSerializer.blockState;
import static tools.redstone.redstonetools.features.arguments.serializers.BoolSerializer.bool;
import static tools.redstone.redstonetools.features.arguments.serializers.IntegerSerializer.integer;
Expand All @@ -22,7 +25,9 @@
@Feature(name = "Binary Block Read", description = "Interprets your WorldEdit selection as a binary number.", command = "/read")
public class BinaryBlockReadFeature extends CommandFeature {
private static final BlockStateArgument LIT_LAMP_ARG = new BlockStateArgument(
Blocks.REDSTONE_LAMP.getDefaultState().with(RedstoneLampBlock.LIT, true), null, null
Blocks.REDSTONE_LAMP.getDefaultState().with(RedstoneLampBlock.LIT, true),
Collections.singleton(RedstoneLampBlock.LIT),
null
);

public static final Argument<Integer> offset = Argument
Expand Down Expand Up @@ -70,13 +75,15 @@ protected Feedback execute(ServerCommandSource source) throws CommandSyntaxExcep
var pos = new BlockPos(point.getBlockX(), point.getBlockY(), point.getBlockZ());
var actualState = source.getWorld().getBlockState(pos);

var matches = true;
for (var property : onBlock.getValue().getProperties()) {
var propertyValue = onBlock.getValue().getBlockState().get(property);
var matches = actualState.getBlock() == onBlock.getValue().getBlockState().getBlock();
if (matches) {
for (var property : onBlock.getValue().getProperties()) {
var propertyValue = onBlock.getValue().getBlockState().get(property);

if (!actualState.get(property).equals(propertyValue)) {
matches = false;
break;
if (!actualState.get(property).equals(propertyValue)) {
matches = false;
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected Either<ItemStack, Feedback> getItemStack(ServerCommandSource source, B
ItemStack itemStack = blockInfo.block.getPickStack(client.world, blockInfo.pos, blockInfo.state);

if (blockInfo.state.hasBlockEntity()) {
((MinecraftClientAccessor) client).addBlockEntityNbt(itemStack, blockInfo.entity);
((MinecraftClientAccessor) client).invokeAddBlockEntityNbt(itemStack, blockInfo.entity);
}

int i = addBlockStateNbt(itemStack, blockInfo.state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;

import javax.inject.Singleton;

@Singleton
public class FeedbackSender extends AbstractFeedbackSender {
@Override
public void sendFeedback(ServerCommandSource source, Feedback feedback) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package tools.redstone.redstonetools.macros;

import tools.redstone.redstonetools.macros.actions.Action;
import tools.redstone.redstonetools.macros.actions.CommandAction;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.InputUtil;
import tools.redstone.redstonetools.macros.actions.Action;
import tools.redstone.redstonetools.macros.actions.CommandAction;

import javax.inject.Singleton;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
Expand All @@ -16,6 +17,7 @@
import java.util.ArrayList;
import java.util.List;

@Singleton
public class MacroManager {
private final Path macrosFilePath;
private final List<Macro> macros;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

@Mixin(MinecraftClient.class)
public interface MinecraftClientAccessor {
@Invoker("addBlockEntityNbt")
ItemStack addBlockEntityNbt(ItemStack stack, BlockEntity blockEntity);
@Invoker
ItemStack invokeAddBlockEntityNbt(ItemStack stack, BlockEntity blockEntity);
}
Loading

0 comments on commit 7cd3dac

Please sign in to comment.