Skip to content

Commit

Permalink
Merge pull request #211 from RedstoneTools/dev
Browse files Browse the repository at this point in the history
Update 1.1.4
  • Loading branch information
Matthias1590 authored Jun 3, 2023
2 parents 9e74d05 + ee7145b commit 707d387
Show file tree
Hide file tree
Showing 28 changed files with 164 additions and 88 deletions.
75 changes: 34 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'com.github.johnrengelman.shadow' version '8.+'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -23,39 +23,17 @@ repositories {
}
}


shadowJar {
archiveClassifier = "unmapped"

configurations = [project.configurations.shadow]

from("LICENSE")
}

remapJar {
inputFile = shadowJar.archiveFile
}

dependencies {
// jUnit 5
include implementation('org.junit.jupiter:junit-jupiter:5.8.1')

// Guice
include implementation('com.google.inject:guice:5.0.1')

// Reflections
include implementation('org.reflections:reflections:0.9.12')
// 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"
include "org.glassfish:javax.json:1.1.4"

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

// Gson
include implementation('com.google.code.gson:gson:2.8.9')

include 'org.javassist:javassist:3.26.0-GA'
include 'javax.inject:javax.inject:1'
include 'aopalliance:aopalliance:1.0'
// AutoService
annotationProcessor implementation("com.google.auto.service:auto-service:1.1.0")

// To change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.minecraft_version}")
Expand All @@ -69,7 +47,6 @@ dependencies {
modImplementation("com.sk89q.worldedit:worldedit-fabric-mc1.18.2:7.2.10")
}


processResources {
inputs.property "version", project.version

Expand All @@ -78,9 +55,30 @@ processResources {
}
}

java {
withSourcesJar()
withJavadocJar()

toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

shadowJar {
archiveClassifier.set("unmapped")

configurations = [project.configurations.shadow]

from("LICENSE")
}

remapJar {
inputFile = shadowJar.archiveFile
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release.set(17)
}

// configure the maven publication
Expand All @@ -98,9 +96,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

test {
useJUnit()
useJUnitPlatform()
}
}
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
yarn_mappings=1.18.2+build.4
loader_version=0.14.6

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

Expand Down
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-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ pluginManagement {
gradlePluginPortal()
}
}

rootProject.name = "redstonetools-mod"
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ public void onInitializeClient() {
RedstoneToolsGameRules.register();

// Register features
for (var featureClass : ReflectionUtils.getFeatureClasses()) {
var feature = INJECTOR.getInstance(featureClass);
ReflectionUtils.getFeatures().forEach(feature -> {
LOGGER.trace("Registering feature {}", feature);

feature.register();
}
});

WorldlessCommandHelper.dummyNetworkHandler.getCommandDispatcher();// should call the "static" method
// should call the "static" block
WorldlessCommandHelper.dummyNetworkHandler.getCommandDispatcher();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package tools.redstone.redstonetools.di;

import com.google.auto.service.AutoService;
import com.google.inject.AbstractModule;
import tools.redstone.redstonetools.utils.ReflectionUtils;

@AutoService(AbstractModule.class)
public class FeatureModule extends AbstractModule {
@SuppressWarnings({"rawtypes", "unchecked"}) // this is probably the only way to make it work
@Override
protected void configure() {
for (var featureClass : ReflectionUtils.getFeatureClasses()) {
bind(featureClass).asEagerSingleton();
for (var feature : ReflectionUtils.getFeatures()) {
Class clazz = feature.getClass();
bind(clazz).toInstance(feature);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package tools.redstone.redstonetools.di;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.macros.MacroManager;
import com.google.inject.AbstractModule;

@AutoService(AbstractModule.class)
public class MacroModule extends AbstractModule {

private static MacroManager macroManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package tools.redstone.redstonetools.di;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.telemetry.TelemetryClient;
import com.google.inject.AbstractModule;
import tools.redstone.redstonetools.telemetry.TelemetryManager;

@AutoService(AbstractModule.class)
public class TelemetryModule extends AbstractModule {
private static TelemetryClient telemetryClient;
private static TelemetryManager telemetryManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package tools.redstone.redstonetools.di;

import com.google.auto.service.AutoService;
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 {
@Override
protected void configure() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import net.minecraft.server.command.ServerCommandSource;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.arguments.Argument;
import tools.redstone.redstonetools.features.feedback.Feedback;
Expand All @@ -10,6 +12,7 @@
import static tools.redstone.redstonetools.features.arguments.serializers.BigIntegerSerializer.bigInteger;
import static tools.redstone.redstonetools.features.arguments.serializers.NumberBaseSerializer.numberBase;

@AutoService(AbstractFeature.class)
@Feature(name = "Base Convert", description = "Converts a number from one base to another.", command = "base")
public class BaseConvertFeature extends CommandFeature {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.arguments.Argument;
import tools.redstone.redstonetools.features.feedback.Feedback;
Expand All @@ -16,6 +18,7 @@
import static tools.redstone.redstonetools.features.arguments.serializers.IntegerSerializer.integer;
import static tools.redstone.redstonetools.features.arguments.serializers.NumberBaseSerializer.numberBase;

@AutoService(AbstractFeature.class)
@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(
Expand Down Expand Up @@ -62,14 +65,22 @@ protected Feedback execute(ServerCommandSource source) throws CommandSyntaxExcep
return Feedback.invalidUsage("The selection must have 2 axis the same");
}

var onBlockState = onBlock.getValue().getBlockState();

var bits = new StringBuilder();
for (BlockVector3 point = pos1; boundingBox.contains(point); point = point.add(spacingVector)) {
var pos = new BlockPos(point.getBlockX(), point.getBlockY(), point.getBlockZ());
var blockState = source.getWorld().getBlockState(pos);
var actualState = source.getWorld().getBlockState(pos);

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

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

bits.append(blockState.equals(onBlockState) ? 1 : 0);
bits.append(matches ? 1 : 0);
}

if (reverseBits.getValue()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.arguments.Argument;
import tools.redstone.redstonetools.features.feedback.Feedback;
Expand All @@ -21,6 +23,7 @@
import org.jetbrains.annotations.Nullable;
import static tools.redstone.redstonetools.features.arguments.serializers.BlockColorSerializer.blockColor;

@AutoService(AbstractFeature.class)
@Feature(name = "Color Code", description = "Color codes all color-able blocks in your WorldEdit selection.", command = "/colorcode")
public class ColorCodeFeature extends CommandFeature {
public static final Argument<BlockColor> color = Argument
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import com.mojang.datafixers.util.Either;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
Expand All @@ -8,12 +9,14 @@
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtString;
import net.minecraft.server.command.ServerCommandSource;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.feedback.Feedback;
import tools.redstone.redstonetools.mixin.accessors.MinecraftClientAccessor;
import tools.redstone.redstonetools.utils.BlockInfo;
import tools.redstone.redstonetools.utils.BlockStateNbtUtil;

@AutoService(AbstractFeature.class)
@Feature(name = "Copy State", description = "Gives you a copy of the block you're looking at with its BlockState.", command = "copystate")
public class CopyStateFeature extends PickBlockFeature {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.feedback.Feedback;
import tools.redstone.redstonetools.utils.BlockColor;
Expand All @@ -15,6 +17,7 @@

import javax.annotation.Nullable;

@AutoService(AbstractFeature.class)
@Feature(name = "Glass", description = "Converts colored blocks to their glass variant and glass to wool.", command = "glass")
public class GlassFeature extends PickBlockFeature {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.arguments.Argument;
import tools.redstone.redstonetools.features.feedback.Feedback;
Expand All @@ -9,7 +11,7 @@
import static tools.redstone.redstonetools.RedstoneToolsClient.INJECTOR;
import static tools.redstone.redstonetools.features.arguments.serializers.MacroNameSerializer.macroName;


@AutoService(AbstractFeature.class)
@Feature(command = "macro", description = "Allows you to execute a macro", name = "Macro")
public class MacroFeature extends CommandFeature {
public static final Argument<String> macro = Argument.ofType(macroName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.feedback.Feedback;
import tools.redstone.redstonetools.utils.WorldEditUtils;
Expand All @@ -18,6 +20,7 @@
import java.util.ArrayList;
import java.util.List;

@AutoService(AbstractFeature.class)
@Feature(command = "/minsel", description = "Removes all air-only layers from a selection", name = "Minimize Selection")
public class MinSelectionFeature extends CommandFeature {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.arguments.Argument;
import tools.redstone.redstonetools.features.feedback.Feedback;
Expand All @@ -14,6 +16,7 @@
import static tools.redstone.redstonetools.features.arguments.serializers.BoolSerializer.bool;
import static tools.redstone.redstonetools.features.arguments.serializers.FloatSerializer.floatArg;

@AutoService(AbstractFeature.class)
@Feature(name = "Quick TP", description = "Teleports you in the direction you are looking.", command = "quicktp")
public class QuickTpFeature extends CommandFeature {
public static final Argument<Float> distance = Argument
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tools.redstone.redstonetools.features.commands;

import com.google.auto.service.AutoService;
import tools.redstone.redstonetools.features.AbstractFeature;
import tools.redstone.redstonetools.features.Feature;
import tools.redstone.redstonetools.features.arguments.Argument;
import tools.redstone.redstonetools.features.feedback.Feedback;
Expand All @@ -23,7 +25,7 @@
import static tools.redstone.redstonetools.utils.DirectionUtils.directionToBlock;
import static tools.redstone.redstonetools.utils.DirectionUtils.matchDirection;


@AutoService(AbstractFeature.class)
@Feature(name = "RStack", description = "Stacks with custom distance", command = "/rstack")
public class RStackFeature extends CommandFeature {
public static final Argument<Integer> count = Argument
Expand Down
Loading

0 comments on commit 707d387

Please sign in to comment.