No Interact stuff
This commit is contained in:
@@ -42,6 +42,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
|
|||||||
modules.add(new Glide());
|
modules.add(new Glide());
|
||||||
modules.add(new Lavacast());
|
modules.add(new Lavacast());
|
||||||
modules.add(new NewChunks());
|
modules.add(new NewChunks());
|
||||||
|
modules.add(new NoInteract());
|
||||||
modules.add(new ObsidianFarm());
|
modules.add(new ObsidianFarm());
|
||||||
modules.add(new PacketFly());
|
modules.add(new PacketFly());
|
||||||
modules.add(new Rendering());
|
modules.add(new Rendering());
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package cloudburst.rejects.mixin;
|
||||||
|
|
||||||
|
import cloudburst.rejects.modules.NoInteract;
|
||||||
|
import minegame159.meteorclient.systems.modules.Modules;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(ClientPlayerInteractionManager.class)
|
||||||
|
public class ClientPlayerInteractionManagerMixin {
|
||||||
|
|
||||||
|
@Final @Shadow private MinecraftClient client;
|
||||||
|
|
||||||
|
@Inject(method = "interactBlock", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void onInteractBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> info) {
|
||||||
|
if (Modules.get().get(NoInteract.class).noInteractBlock(client.world.getBlockState(hitResult.getBlockPos()).getBlock()))
|
||||||
|
info.setReturnValue(ActionResult.FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "interactEntity", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void onInteractEntity(PlayerEntity player, Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> info) {
|
||||||
|
if (Modules.get().get(NoInteract.class).noInteractEntity(entity))
|
||||||
|
info.setReturnValue(ActionResult.FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
98
src/main/java/cloudburst/rejects/modules/NoInteract.java
Normal file
98
src/main/java/cloudburst/rejects/modules/NoInteract.java
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package cloudburst.rejects.modules;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
|
||||||
|
import meteordevelopment.orbit.EventHandler;
|
||||||
|
import minegame159.meteorclient.events.game.OpenScreenEvent;
|
||||||
|
import minegame159.meteorclient.settings.BlockListSetting;
|
||||||
|
import minegame159.meteorclient.settings.EntityTypeListSetting;
|
||||||
|
import minegame159.meteorclient.settings.Setting;
|
||||||
|
import minegame159.meteorclient.settings.SettingGroup;
|
||||||
|
import minegame159.meteorclient.systems.modules.Categories;
|
||||||
|
import minegame159.meteorclient.systems.modules.Module;
|
||||||
|
import minegame159.meteorclient.systems.modules.Modules;
|
||||||
|
import net.minecraft.block.*;
|
||||||
|
import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
|
||||||
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NoInteract extends Module {
|
||||||
|
|
||||||
|
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
||||||
|
|
||||||
|
private final Setting<List<Block>> blocks = sgGeneral.add(new BlockListSetting.Builder()
|
||||||
|
.name("blocks")
|
||||||
|
.description("Blocks interactions with certain blocks")
|
||||||
|
.defaultValue(getDefaultBlocks())
|
||||||
|
.filter(this::filterBlocks)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
private final Setting<Object2BooleanMap<EntityType<?>>> entities = sgGeneral.add(new EntityTypeListSetting.Builder()
|
||||||
|
.name("entities")
|
||||||
|
.description("Entities to block interaction with")
|
||||||
|
.defaultValue(new Object2BooleanOpenHashMap<>(0))
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
public NoInteract() {
|
||||||
|
super(Categories.Player, "no-interact", "Blocks interactions with certain types of inputs.");
|
||||||
|
}
|
||||||
|
@EventHandler
|
||||||
|
private void onScreenOpen(OpenScreenEvent event) {
|
||||||
|
if (event.screen == null) return;
|
||||||
|
if (!event.screen.isPauseScreen() && !(event.screen instanceof AbstractInventoryScreen) && (event.screen instanceof HandledScreen)) event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean noInteractBlock(Block block) {
|
||||||
|
return Modules.get().get(this.getClass()).isActive() && blocks.get().contains(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean noInteractEntity(Entity entity) {
|
||||||
|
return Modules.get().get(this.getClass()).isActive() && entities.get().getBoolean(entity.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Block> getDefaultBlocks() {
|
||||||
|
|
||||||
|
ArrayList<Block> defaultBlocks = new ArrayList<>();
|
||||||
|
for (Block block : Registry.BLOCK) {
|
||||||
|
if (filterBlocks(block)) defaultBlocks.add(block);
|
||||||
|
}
|
||||||
|
return defaultBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean filterBlocks(Block block) {
|
||||||
|
return isStorageBlock(block) || isRedstoneBlock(block) ||
|
||||||
|
|
||||||
|
// Others
|
||||||
|
block instanceof RespawnAnchorBlock ||
|
||||||
|
block instanceof BedBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isStorageBlock(Block block) {
|
||||||
|
return block instanceof ChestBlock ||
|
||||||
|
block instanceof EnderChestBlock ||
|
||||||
|
block instanceof AbstractFurnaceBlock ||
|
||||||
|
block instanceof BrewingStandBlock ||
|
||||||
|
block instanceof BarrelBlock ||
|
||||||
|
block instanceof HopperBlock ||
|
||||||
|
block instanceof ShulkerBoxBlock ||
|
||||||
|
block instanceof DispenserBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isRedstoneBlock(Block block) {
|
||||||
|
return block instanceof TrapdoorBlock ||
|
||||||
|
block instanceof DoorBlock ||
|
||||||
|
block instanceof FenceGateBlock ||
|
||||||
|
block instanceof LeverBlock ||
|
||||||
|
block instanceof AbstractButtonBlock ||
|
||||||
|
block instanceof AbstractPressurePlateBlock ||
|
||||||
|
block instanceof RepeaterBlock ||
|
||||||
|
block instanceof ComparatorBlock;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
"package": "cloudburst.rejects.mixin",
|
"package": "cloudburst.rejects.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"ClientPlayerInteractionManagerMixin",
|
||||||
"RecipeManagerMixin"
|
"RecipeManagerMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
|
|||||||
Reference in New Issue
Block a user