added recipe commands (works only kinda)
This commit is contained in:
@@ -58,6 +58,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
|
|||||||
commands.add(new SetBlockCommand());
|
commands.add(new SetBlockCommand());
|
||||||
commands.add(new TeleportCommand());
|
commands.add(new TeleportCommand());
|
||||||
commands.add(new TerrainExport());
|
commands.add(new TerrainExport());
|
||||||
|
commands.add(new RecipeCommand());
|
||||||
|
|
||||||
HUD hud = modules.get(HUD.class);
|
HUD hud = modules.get(HUD.class);
|
||||||
hud.elements.add(new AppleHud(hud));
|
hud.elements.add(new AppleHud(hud));
|
||||||
|
|||||||
62
src/main/java/cloudburst/rejects/commands/RecipeCommand.java
Normal file
62
src/main/java/cloudburst/rejects/commands/RecipeCommand.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package cloudburst.rejects.commands;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
|
|
||||||
|
import meteordevelopment.orbit.EventHandler;
|
||||||
|
import minegame159.meteorclient.events.packets.PacketEvent;
|
||||||
|
import minegame159.meteorclient.systems.commands.Command;
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraft.network.packet.c2s.play.RecipeBookDataC2SPacket;
|
||||||
|
import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket;
|
||||||
|
import net.minecraft.network.packet.s2c.play.UnlockRecipesS2CPacket;
|
||||||
|
import net.minecraft.recipe.Recipe;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
|
||||||
|
|
||||||
|
public class RecipeCommand extends Command {
|
||||||
|
|
||||||
|
private final static SimpleCommandExceptionType NO_RECIPES = new SimpleCommandExceptionType(new LiteralText("Couldn't obtain any recipes."));
|
||||||
|
public Iterable<Recipe<?>> recipes = null;
|
||||||
|
|
||||||
|
public RecipeCommand() {
|
||||||
|
super("recipe", "Grants or removes recipes");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||||
|
builder.then(literal("grant").executes(ctx -> {
|
||||||
|
if (recipes == null) throw NO_RECIPES.create();
|
||||||
|
|
||||||
|
List<Identifier> recipeIdentifiers = new ArrayList<>();
|
||||||
|
|
||||||
|
recipes.forEach(recipe -> {
|
||||||
|
recipeIdentifiers.add(recipe.getId());
|
||||||
|
});
|
||||||
|
|
||||||
|
new UnlockRecipesS2CPacket(UnlockRecipesS2CPacket.Action.INIT, recipeIdentifiers, recipeIdentifiers, mc.player.getRecipeBook().getOptions()).apply(mc.getNetworkHandler());
|
||||||
|
new UnlockRecipesS2CPacket(UnlockRecipesS2CPacket.Action.ADD, recipeIdentifiers, recipeIdentifiers, mc.player.getRecipeBook().getOptions()).apply(mc.getNetworkHandler());
|
||||||
|
|
||||||
|
return SINGLE_SUCCESS;
|
||||||
|
}));
|
||||||
|
|
||||||
|
builder.then(literal("revoke").executes(ctx -> {
|
||||||
|
if (recipes == null) throw NO_RECIPES.create();
|
||||||
|
|
||||||
|
List<Identifier> recipeIdentifiers = new ArrayList<>();
|
||||||
|
|
||||||
|
recipes.forEach(recipe -> {
|
||||||
|
recipeIdentifiers.add(recipe.getId());
|
||||||
|
});
|
||||||
|
|
||||||
|
new UnlockRecipesS2CPacket(UnlockRecipesS2CPacket.Action.REMOVE, recipeIdentifiers, recipeIdentifiers, mc.player.getRecipeBook().getOptions()).apply(mc.getNetworkHandler());
|
||||||
|
|
||||||
|
return SINGLE_SUCCESS;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package cloudburst.rejects.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.recipebook.ClientRecipeBook;
|
||||||
|
import net.minecraft.recipe.Recipe;
|
||||||
|
import net.minecraft.recipe.RecipeManager;
|
||||||
|
|
||||||
|
import cloudburst.rejects.commands.RecipeCommand;
|
||||||
|
import minegame159.meteorclient.systems.commands.Commands;
|
||||||
|
|
||||||
|
@Mixin(RecipeManager.class)
|
||||||
|
public class RecipeManagerMixin {
|
||||||
|
@Inject(method = "setRecipes", at = @At(value = "HEAD"))
|
||||||
|
public void setRecipes(Iterable<Recipe<?>> recipes, CallbackInfo ci) {
|
||||||
|
if (Commands.get().get(RecipeCommand.class).recipes == null) {
|
||||||
|
Commands.get().get(RecipeCommand.class).recipes = recipes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
"package": "cloudburst.rejects.mixin",
|
"package": "cloudburst.rejects.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"RecipeManagerMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"Deadmau5FeatureRendererMixin",
|
"Deadmau5FeatureRendererMixin",
|
||||||
|
|||||||
Reference in New Issue
Block a user