-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into duplicate-macro-indicator
- Loading branch information
Showing
5 changed files
with
91 additions
and
13 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/java/tools/redstone/redstonetools/features/commands/AirPlaceReachFeature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package tools.redstone.redstonetools.features.commands; | ||
|
||
import com.google.auto.service.AutoService; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import tools.redstone.redstonetools.RedstoneToolsClient; | ||
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; | ||
import tools.redstone.redstonetools.features.toggleable.AirPlaceFeature; | ||
|
||
import static tools.redstone.redstonetools.features.arguments.serializers.FloatSerializer.floatArg; | ||
|
||
@AutoService(AbstractFeature.class) | ||
@Feature(name = "Air Place", description = "Allows you to place blocks in the air.", command = "airplace") | ||
public class AirPlaceReachFeature extends CommandFeature { | ||
|
||
public float reach = 5.0f; | ||
|
||
public static final Argument<Float> distance = Argument | ||
.ofType(floatArg(5.0f)); | ||
|
||
@Override | ||
protected Feedback execute(ServerCommandSource source) throws CommandSyntaxException { | ||
|
||
reach = distance.getValue(); | ||
|
||
AirPlaceFeature airPlaceFeature = RedstoneToolsClient.INJECTOR.getInstance(AirPlaceFeature.class); | ||
if (!airPlaceFeature.isEnabled()) { | ||
airPlaceFeature.enable(source); | ||
} | ||
|
||
return Feedback.success("Air Place reach set to " + distance.getValue().toString() + " blocks."); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/tools/redstone/redstonetools/mixin/features/AirPlaceServerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package tools.redstone.redstonetools.mixin.features; | ||
|
||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import tools.redstone.redstonetools.RedstoneToolsClient; | ||
import tools.redstone.redstonetools.features.commands.AirPlaceReachFeature; | ||
import tools.redstone.redstonetools.features.toggleable.AirPlaceFeature; | ||
|
||
@Mixin(ServerPlayNetworkHandler.class) | ||
public class AirPlaceServerMixin { | ||
|
||
private final AirPlaceFeature airPlaceFeature = RedstoneToolsClient.INJECTOR.getInstance(AirPlaceFeature.class); | ||
private final AirPlaceReachFeature airPlaceReachFeature = RedstoneToolsClient.INJECTOR.getInstance(AirPlaceReachFeature.class); | ||
|
||
@ModifyConstant(method = "onPlayerInteractBlock", constant = @Constant(doubleValue = 64.0) ) | ||
private double modifyConstant(double originalValue) { | ||
|
||
if (airPlaceFeature.isEnabled()) { | ||
return (airPlaceReachFeature.reach+5) * (airPlaceReachFeature.reach+5); | ||
} else { | ||
return originalValue; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters