Skip to content

Commit 7cd3dac

Browse files
authored
Merge pull request #243 from RedstoneTools/dev
Update to 1.2.0
2 parents 5412b25 + f0c6f42 commit 7cd3dac

File tree

17 files changed

+151
-115
lines changed

17 files changed

+151
-115
lines changed

.github/workflows/gradle.yml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,54 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
1+
# Build Workflow
72

8-
name: Java CI with Gradle
3+
name: Build & test
94

105
on:
116
pull_request:
12-
branches: ['main']
7+
8+
concurrency:
9+
group: ${{ github.head_ref || format('{0}-{1}', github.ref, github.run_number) }}
10+
cancel-in-progress: true
1311

1412
permissions:
1513
contents: read
1614

1715
jobs:
1816
build:
17+
name: Build
18+
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 10
26+
2327
- name: Set up JDK 17
2428
uses: actions/setup-java@v3
2529
with:
26-
java-version: '17'
27-
distribution: 'adopt'
28-
- name: Build with Gradle and run tests
29-
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
30+
java-version: 17
31+
distribution: temurin
32+
33+
- uses: actions/cache@v3
34+
with:
35+
path: |
36+
~/.gradle/caches
37+
~/.gradle/wrapper
38+
**/loom-cache
39+
**/prebundled-jars
40+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
41+
restore-keys: |
42+
${{ runner.os }}-gradle-
43+
44+
- name: Chmod Gradle
45+
run: chmod +x ./gradlew
46+
47+
- name: Build
48+
run: ./gradlew build --no-daemon
49+
50+
- name: Upload Build Artifacts
51+
uses: actions/upload-artifact@v3
3052
with:
31-
arguments: test
53+
name: dev-artifacts
54+
path: build/libs/

build.gradle

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//file:noinspection GroovyAssignabilityCheck
2+
13
plugins {
24
id 'fabric-loom' version '1.2-SNAPSHOT'
35
id 'maven-publish'
@@ -21,15 +23,19 @@ repositories {
2123
name = "WorldEdit Maven"
2224
url = "https://maven.enginehub.org/repo/"
2325
}
26+
maven {
27+
name = "JitPack"
28+
url = "https://jitpack.io"
29+
}
2430
}
2531

2632
dependencies {
27-
// Guice + dependencies
28-
include implementation("com.google.inject:guice:5.0.1")
29-
include "aopalliance:aopalliance:1.0"
30-
include "javax.inject:javax.inject:1"
31-
include "javax.json:javax.json-api:1.1.4"
32-
include "jakarta.inject:jakarta.inject-api:2.0.1"
33+
// Doctor (dependency-injection)
34+
include implementation("rip.hippo:Doctor:1.0.1")
35+
include implementation("javax.inject:javax.inject:1")
36+
37+
// Json
38+
include implementation("javax.json:javax.json-api:1.1.4")
3339
include "org.glassfish:javax.json:1.1.4"
3440

3541
// AutoService

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ org.gradle.parallel=true
99
loader_version=0.14.6
1010

1111
# Mod Properties
12-
mod_version = 1.18.2-1.1.4
12+
mod_version = 1.18.2-1.2.0
1313
maven_group = tools.redstone
1414
archives_base_name = redstonetools
1515

src/main/java/tools/redstone/redstonetools/RedstoneToolsClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package tools.redstone.redstonetools;
22

3-
import com.google.inject.Guice;
4-
import com.google.inject.Injector;
53
import net.fabricmc.api.ClientModInitializer;
64
import net.fabricmc.loader.api.FabricLoader;
75
import org.slf4j.Logger;
86
import org.slf4j.LoggerFactory;
7+
import rip.hippo.inject.Doctor;
8+
import rip.hippo.inject.Injector;
99
import tools.redstone.redstonetools.macros.WorldlessCommandHelper;
1010
import tools.redstone.redstonetools.utils.ReflectionUtils;
1111

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

1818
@Override
1919
public void onInitializeClient() {
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package tools.redstone.redstonetools.di;
22

33
import com.google.auto.service.AutoService;
4-
import com.google.inject.AbstractModule;
4+
import rip.hippo.inject.DoctorModule;
5+
import rip.hippo.inject.binding.Binder;
56
import tools.redstone.redstonetools.utils.ReflectionUtils;
67

7-
@AutoService(AbstractModule.class)
8-
public class FeatureModule extends AbstractModule {
8+
@AutoService(DoctorModule.class)
9+
public class FeatureModule implements DoctorModule {
910
@SuppressWarnings({"rawtypes", "unchecked"}) // this is probably the only way to make it work
1011
@Override
11-
protected void configure() {
12+
public void configure(Binder binder) {
1213
for (var feature : ReflectionUtils.getFeatures()) {
1314
Class clazz = feature.getClass();
14-
bind(clazz).toInstance(feature);
15+
binder.bind(clazz).toInstance(feature);
1516
}
1617
}
1718
}

src/main/java/tools/redstone/redstonetools/di/MacroModule.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/java/tools/redstone/redstonetools/di/TelemetryModule.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package tools.redstone.redstonetools.di;
22

33
import com.google.auto.service.AutoService;
4+
import rip.hippo.inject.DoctorModule;
5+
import rip.hippo.inject.binding.Binder;
46
import tools.redstone.redstonetools.features.feedback.AbstractFeedbackSender;
57
import tools.redstone.redstonetools.features.feedback.FeedbackSender;
6-
import com.google.inject.AbstractModule;
78

8-
@AutoService(AbstractModule.class)
9-
public class UtilityModule extends AbstractModule {
9+
@AutoService(DoctorModule.class)
10+
public class UtilityModule implements DoctorModule {
1011
@Override
11-
protected void configure() {
12-
bind(AbstractFeedbackSender.class).to(FeedbackSender.class).asEagerSingleton();
12+
public void configure(Binder binder) {
13+
binder.bind(AbstractFeedbackSender.class).to(FeedbackSender.class);
1314
}
1415
}

src/main/java/tools/redstone/redstonetools/features/commands/BinaryBlockReadFeature.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import net.minecraft.command.argument.BlockStateArgument;
1414
import net.minecraft.server.command.ServerCommandSource;
1515
import net.minecraft.util.math.BlockPos;
16+
17+
import java.util.Collections;
18+
1619
import static tools.redstone.redstonetools.features.arguments.serializers.BlockStateArgumentSerializer.blockState;
1720
import static tools.redstone.redstonetools.features.arguments.serializers.BoolSerializer.bool;
1821
import static tools.redstone.redstonetools.features.arguments.serializers.IntegerSerializer.integer;
@@ -22,7 +25,9 @@
2225
@Feature(name = "Binary Block Read", description = "Interprets your WorldEdit selection as a binary number.", command = "/read")
2326
public class BinaryBlockReadFeature extends CommandFeature {
2427
private static final BlockStateArgument LIT_LAMP_ARG = new BlockStateArgument(
25-
Blocks.REDSTONE_LAMP.getDefaultState().with(RedstoneLampBlock.LIT, true), null, null
28+
Blocks.REDSTONE_LAMP.getDefaultState().with(RedstoneLampBlock.LIT, true),
29+
Collections.singleton(RedstoneLampBlock.LIT),
30+
null
2631
);
2732

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

73-
var matches = true;
74-
for (var property : onBlock.getValue().getProperties()) {
75-
var propertyValue = onBlock.getValue().getBlockState().get(property);
78+
var matches = actualState.getBlock() == onBlock.getValue().getBlockState().getBlock();
79+
if (matches) {
80+
for (var property : onBlock.getValue().getProperties()) {
81+
var propertyValue = onBlock.getValue().getBlockState().get(property);
7682

77-
if (!actualState.get(property).equals(propertyValue)) {
78-
matches = false;
79-
break;
83+
if (!actualState.get(property).equals(propertyValue)) {
84+
matches = false;
85+
break;
86+
}
8087
}
8188
}
8289

src/main/java/tools/redstone/redstonetools/features/commands/CopyStateFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected Either<ItemStack, Feedback> getItemStack(ServerCommandSource source, B
2626
ItemStack itemStack = blockInfo.block.getPickStack(client.world, blockInfo.pos, blockInfo.state);
2727

2828
if (blockInfo.state.hasBlockEntity()) {
29-
((MinecraftClientAccessor) client).addBlockEntityNbt(itemStack, blockInfo.entity);
29+
((MinecraftClientAccessor) client).invokeAddBlockEntityNbt(itemStack, blockInfo.entity);
3030
}
3131

3232
int i = addBlockStateNbt(itemStack, blockInfo.state);

0 commit comments

Comments
 (0)