├── gradlew ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── resources │ ├── assets │ │ └── icejar │ │ │ └── icon.png │ ├── fabric.mod.json │ └── icejar.mixins.json │ └── java │ └── org │ └── samo_lego │ └── icejar │ ├── mixin │ ├── accessor │ │ ├── AMob.java │ │ ├── ASynchedEntityData.java │ │ ├── AClientboundSectionBlocksUpdatePacket.java │ │ ├── APlayer.java │ │ ├── AServerboundMovePlayerPacket.java │ │ ├── ASignBlockEntity.java │ │ ├── AClientboundLevelChunkWithLightPacket.java │ │ └── ALivingEntity.java │ ├── inventory │ │ ├── SlotMixin_InventoryObserver.java │ │ └── ServerPlayerMixin_InventoryObserver.java │ ├── newchunks │ │ ├── MChunkGenerator_NewChunkMarker.java │ │ ├── MLiquidBlock.java │ │ └── MServerGamePacketListener_ChunkDelayer.java │ ├── fake_data │ │ └── no_fall │ │ │ ├── ServerLevelMixin_SkipNoFallEvent.java │ │ │ ├── LivingEntityMixin_FallObserver.java │ │ │ └── ServerPlayerMixin_NoFallHP.java │ ├── packet │ │ ├── ClientBoundSetEntityDataMixin_HPTagsRemove.java │ │ └── ServerGamePacketListenerImplMixin.java │ ├── MixinConfigs.java │ ├── ServerGamePacketListenerImplMixin_Movement.java │ └── ServerPlayerMixin.java │ ├── util │ ├── ChatColor.java │ ├── DataFaker.java │ └── ActionTypes.java │ ├── check │ ├── inventory │ │ ├── ImpossibleUse.java │ │ └── ItemUseCheck.java │ ├── world │ │ └── block │ │ │ ├── FakeBlockPos.java │ │ │ ├── AirPlace.java │ │ │ ├── ReachBlock.java │ │ │ ├── BlockBreakCheck.java │ │ │ ├── BlockInteractCheck.java │ │ │ ├── ImpossibleBlockAction.java │ │ │ ├── BlockDirection.java │ │ │ ├── BlockFace.java │ │ │ ├── BlockCheck.java │ │ │ └── AutoSign.java │ ├── combat │ │ ├── NoSwing.java │ │ ├── Reach.java │ │ ├── Angle.java │ │ ├── ImpossibleHit.java │ │ ├── Critical.java │ │ └── CombatCheck.java │ ├── movement │ │ ├── Derp.java │ │ ├── cancellable │ │ │ ├── vehicle │ │ │ │ ├── EntityControl.java │ │ │ │ ├── BoatFly.java │ │ │ │ └── CancellableVehicleMovementCheck.java │ │ │ ├── Timer.java │ │ │ ├── WrongRotation.java │ │ │ ├── CancellableMovementCheck.java │ │ │ ├── FastLadder.java │ │ │ ├── NoDeceleration.java │ │ │ └── flight │ │ │ │ └── BasicFlight.java │ │ ├── MovementCheck.java │ │ └── NoFall.java │ ├── CheckCategory.java │ ├── Check.java │ └── CheckType.java │ ├── IceJar.java │ ├── module │ └── NewChunks.java │ ├── command │ └── IceJarCommand.java │ ├── event │ └── EventHandler.java │ ├── casts │ └── IceJarPlayer.java │ └── config │ └── IceConfig.java ├── .gitignore ├── gradle.properties ├── settings.gradle ├── .github └── workflows │ └── build.yml ├── README.md ├── .circleci └── config.yml ├── gradlew.bat └── LICENSE /gradlew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samolego/IceJar/HEAD/gradlew -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samolego/IceJar/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/assets/icejar/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samolego/IceJar/HEAD/src/main/resources/assets/icejar/icon.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # eclipse 9 | 10 | *.launch 11 | 12 | # idea 13 | 14 | .idea/ 15 | *.iml 16 | *.ipr 17 | *.iws 18 | 19 | # vscode 20 | 21 | .settings/ 22 | .vscode/ 23 | bin/ 24 | .classpath 25 | .project 26 | 27 | # macos 28 | 29 | *.DS_Store 30 | 31 | # fabric 32 | 33 | run/ 34 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx1G 3 | # Fabric Properties 4 | minecraft_version=1.19.3 5 | yarn_mappings=1.19.3+build.2 6 | loader_version=0.14.11 7 | #Fabric api 8 | fabric_version=0.68.1+1.19.3 9 | # Mod Properties 10 | mod_version=1.0.0 11 | maven_group=org.samo_lego 12 | archives_base_name=icejar 13 | # Dependencies 14 | c2b_version=1.2.1 15 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/accessor/AMob.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.accessor; 2 | 3 | import net.minecraft.world.entity.Mob; 4 | import net.minecraft.world.entity.ai.goal.GoalSelector; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(Mob.class) 9 | public interface AMob { 10 | @Accessor("goalSelector") 11 | GoalSelector getGoalSelector(); 12 | } 13 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | maven { 8 | name = 'Cotton' 9 | url = 'https://server.bbkr.space/artifactory/libs-release/' 10 | } 11 | maven { url = "https://maven.quiltmc.org/repository/release" } 12 | mavenCentral() 13 | gradlePluginPortal() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/accessor/ASynchedEntityData.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.accessor; 2 | 3 | import net.minecraft.network.syncher.SynchedEntityData; 4 | import net.minecraft.world.entity.Entity; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(SynchedEntityData.class) 9 | public interface ASynchedEntityData { 10 | @Accessor("entity") 11 | Entity getEntity(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/accessor/AClientboundSectionBlocksUpdatePacket.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.accessor; 2 | 3 | import net.minecraft.core.SectionPos; 4 | import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(ClientboundSectionBlocksUpdatePacket.class) 9 | public interface AClientboundSectionBlocksUpdatePacket { 10 | @Accessor("sectionPos") 11 | SectionPos sectionPos(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/accessor/APlayer.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.accessor; 2 | 3 | import net.minecraft.network.syncher.EntityDataAccessor; 4 | import net.minecraft.world.entity.player.Player; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(Player.class) 9 | public interface APlayer { 10 | @Accessor("DATA_PLAYER_ABSORPTION_ID") 11 | static EntityDataAccessor DATA_PLAYER_ABSORPTION_ID() { 12 | throw new AssertionError(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/util/ChatColor.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.util; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | import net.minecraft.network.chat.MutableComponent; 6 | 7 | public class ChatColor { 8 | 9 | /** 10 | * Returns a text for given boolean value. 11 | * @param b boolean value. 12 | * @return text. 13 | */ 14 | public static MutableComponent styleBoolean(boolean b) { 15 | return Component.translatable("gui." + (b ? "yes" : "no")).withStyle(b ? ChatFormatting.GREEN : ChatFormatting.RED); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/accessor/AServerboundMovePlayerPacket.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.accessor; 2 | 3 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.Mutable; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(ServerboundMovePlayerPacket.class) 9 | public interface AServerboundMovePlayerPacket { 10 | @Mutable 11 | @Accessor("onGround") 12 | void setOnGround(boolean onGround); 13 | 14 | @Mutable 15 | @Accessor("xRot") 16 | void setXRot(float xRot); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/accessor/ASignBlockEntity.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.accessor; 2 | 3 | import net.minecraft.world.level.block.entity.SignBlockEntity; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | @Mixin(SignBlockEntity.class) 8 | public interface ASignBlockEntity { 9 | @Accessor("RAW_TEXT_FIELD_NAMES") 10 | static String[] RAW_TEXT_FIELD_NAMES() { 11 | throw new AssertionError(); 12 | } 13 | 14 | @Accessor("FILTERED_TEXT_FIELD_NAMES") 15 | static String[] FILTERED_TEXT_FIELD_NAMES() { 16 | throw new AssertionError(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/accessor/AClientboundLevelChunkWithLightPacket.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.accessor; 2 | 3 | import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; 4 | import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Mutable; 7 | import org.spongepowered.asm.mixin.gen.Accessor; 8 | 9 | @Mixin(ClientboundLevelChunkWithLightPacket.class) 10 | public interface AClientboundLevelChunkWithLightPacket { 11 | @Mutable 12 | @Accessor("chunkData") 13 | void setChunkData(ClientboundLevelChunkPacketData chunkData); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/accessor/ALivingEntity.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.accessor; 2 | 3 | import net.minecraft.network.syncher.EntityDataAccessor; 4 | import net.minecraft.sounds.SoundEvent; 5 | import net.minecraft.world.damagesource.DamageSource; 6 | import net.minecraft.world.entity.LivingEntity; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | import org.spongepowered.asm.mixin.gen.Invoker; 10 | 11 | @Mixin(LivingEntity.class) 12 | public interface ALivingEntity { 13 | @Invoker("getHurtSound") 14 | SoundEvent getHurtSound(DamageSource damageSource); 15 | 16 | @Accessor("DATA_HEALTH_ID") 17 | static EntityDataAccessor DATA_HEALTH_ID() { 18 | throw new AssertionError(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/inventory/ImpossibleUse.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.inventory; 2 | 3 | import net.minecraft.server.level.ServerPlayer; 4 | import net.minecraft.world.InteractionHand; 5 | import net.minecraft.world.item.ItemStack; 6 | import net.minecraft.world.level.Level; 7 | import org.samo_lego.icejar.casts.IceJarPlayer; 8 | import org.samo_lego.icejar.check.CheckType; 9 | 10 | public class ImpossibleUse extends ItemUseCheck { 11 | public ImpossibleUse(ServerPlayer player) { 12 | super(CheckType.INVENTORY_IMPOSSIBLE_ITEM_USE, player); 13 | } 14 | 15 | @Override 16 | public boolean checkItemUse(final Level level, final ItemStack handStack, final InteractionHand hand) { 17 | return !((IceJarPlayer) player).ij$hasOpenGui(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/inventory/SlotMixin_InventoryObserver.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.inventory; 2 | 3 | import net.minecraft.world.entity.player.Player; 4 | import net.minecraft.world.inventory.Slot; 5 | import net.minecraft.world.item.ItemStack; 6 | import org.samo_lego.icejar.casts.IceJarPlayer; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(Slot.class) 13 | public class SlotMixin_InventoryObserver { 14 | 15 | @Inject(method = "onTake", at = @At("TAIL")) 16 | private void onTake(Player player, ItemStack stack, CallbackInfo ci) { 17 | if (player instanceof IceJarPlayer ij) { 18 | ij.ij$setOpenGUI(true); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "icejar", 4 | "version": "${version}", 5 | "name": "IceJar", 6 | "description": "Fabric port of some NoCheatPlus & AntiCheatReloaded checks, additional GolfIV stuff and more.", 7 | "authors": [ 8 | "xaw3ep", 9 | "Lysandr0", 10 | "samo_lego" 11 | ], 12 | "contact": { 13 | "homepage": "https://fabricmc.net/", 14 | "sources": "https://github.com/samolego/IceJar" 15 | }, 16 | 17 | "license": "GNU-GPL-v3.0", 18 | "icon": "assets/icejar/icon.png", 19 | 20 | "environment": "*", 21 | "entrypoints": { 22 | "main": [ 23 | "org.samo_lego.icejar.IceJar::onInitialize" 24 | ] 25 | }, 26 | "mixins": [ 27 | "icejar.mixins.json" 28 | ], 29 | 30 | "depends": { 31 | "fabricloader": ">=0.11.3", 32 | "fabric": "*", 33 | "minecraft": ">=1.19", 34 | "java": ">=17" 35 | }, 36 | "suggests": { 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/FakeBlockPos.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.world.InteractionHand; 7 | import net.minecraft.world.level.Level; 8 | import org.samo_lego.icejar.check.CheckType; 9 | 10 | /** 11 | * Vanilla client always sends {@link net.minecraft.core.BlockPos.MutableBlockPos} for block interactions. 12 | * We simply check if interaction was indeed a mutable one - if not, it's fake. 13 | */ 14 | public class FakeBlockPos extends BlockCheck { 15 | public FakeBlockPos(ServerPlayer player) { 16 | super(CheckType.WORLD_BLOCK_FAKEPOS, player); 17 | } 18 | 19 | @Override 20 | public boolean checkBlockAction(Level level, InteractionHand hand, BlockPos blockPos, Direction direction) { 21 | return !(blockPos instanceof BlockPos.MutableBlockPos); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/combat/NoSwing.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.combat; 2 | 3 | import net.minecraft.server.level.ServerPlayer; 4 | import net.minecraft.world.InteractionHand; 5 | import net.minecraft.world.entity.Entity; 6 | import net.minecraft.world.level.Level; 7 | import net.minecraft.world.phys.EntityHitResult; 8 | import org.samo_lego.icejar.check.CheckType; 9 | 10 | public class NoSwing extends CombatCheck { 11 | private boolean hasSwingedHand; 12 | 13 | public NoSwing(ServerPlayer player) { 14 | super(CheckType.COMBAT_NOSWING, player); 15 | this.hasSwingedHand = true; 16 | } 17 | 18 | @Override 19 | public boolean checkCombat(Level world, InteractionHand hand, Entity targetEntity, EntityHitResult hitResult) { 20 | boolean canHit = this.hasSwingedHand; 21 | this.hasSwingedHand = false; 22 | return canHit; 23 | } 24 | 25 | public void onSwing() { 26 | this.hasSwingedHand = true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/resources/icejar.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "org.samo_lego.icejar.mixin", 5 | "compatibilityLevel": "JAVA_16", 6 | "mixins": [ 7 | "ServerGamePacketListenerImplMixin_Movement", 8 | "ServerPlayerMixin", 9 | "accessor.AClientboundLevelChunkWithLightPacket", 10 | "accessor.AClientboundSectionBlocksUpdatePacket", 11 | "accessor.ALivingEntity", 12 | "accessor.AMob", 13 | "accessor.APlayer", 14 | "accessor.AServerboundMovePlayerPacket", 15 | "accessor.ASignBlockEntity", 16 | "accessor.ASynchedEntityData", 17 | "fake_data.no_fall.LivingEntityMixin_FallObserver", 18 | "fake_data.no_fall.ServerLevelMixin_SkipNoFallEvent", 19 | "fake_data.no_fall.ServerPlayerMixin_NoFallHP", 20 | "inventory.ServerPlayerMixin_InventoryObserver", 21 | "inventory.SlotMixin_InventoryObserver", 22 | "newchunks.MChunkGenerator_NewChunkMarker", 23 | "newchunks.MLiquidBlock", 24 | "newchunks.MServerGamePacketListener_ChunkDelayer", 25 | "packet.ClientBoundSetEntityDataMixin_HPTagsRemove", 26 | "packet.ServerGamePacketListenerImplMixin" 27 | ], 28 | "injectors": { 29 | "defaultRequire": 1 30 | }, 31 | "plugin": "org.samo_lego.icejar.mixin.MixinConfigs" 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/Derp.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | import net.minecraft.network.chat.MutableComponent; 6 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 7 | import net.minecraft.server.level.ServerPlayer; 8 | import org.samo_lego.icejar.check.CheckType; 9 | import org.samo_lego.icejar.mixin.accessor.AServerboundMovePlayerPacket; 10 | 11 | public class Derp extends MovementCheck { 12 | private float xRot; 13 | 14 | public Derp(ServerPlayer player) { 15 | super(CheckType.MOVEMENT_DERP, player); 16 | } 17 | 18 | @Override 19 | public boolean checkMovement(ServerboundMovePlayerPacket packet) { 20 | this.xRot = Math.abs(packet.getXRot(player.getXRot())); 21 | if (packet.hasRotation() && this.xRot > 90) { 22 | ((AServerboundMovePlayerPacket) packet).setXRot(player.getXRot()); 23 | return false; 24 | } 25 | return true; 26 | } 27 | 28 | 29 | @Override 30 | public MutableComponent getAdditionalFlagInfo() { 31 | return Component.translatable("Pitch: ") 32 | .append(Component.literal(String.format("%.2f", this.xRot)).withStyle(ChatFormatting.RED)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/newchunks/MChunkGenerator_NewChunkMarker.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.newchunks; 2 | 3 | import net.minecraft.world.level.ChunkPos; 4 | import net.minecraft.world.level.StructureManager; 5 | import net.minecraft.world.level.WorldGenLevel; 6 | import net.minecraft.world.level.chunk.ChunkAccess; 7 | import net.minecraft.world.level.chunk.ChunkGenerator; 8 | import org.samo_lego.icejar.IceJar; 9 | import org.samo_lego.icejar.module.NewChunks; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 15 | 16 | @Mixin(ChunkGenerator.class) 17 | public class MChunkGenerator_NewChunkMarker { 18 | @Inject(method = "applyBiomeDecoration", 19 | at = @At(value = "INVOKE", 20 | target = "Lnet/minecraft/SharedConstants;debugVoidTerrain(Lnet/minecraft/world/level/ChunkPos;)Z"), 21 | locals = LocalCapture.CAPTURE_FAILHARD) 22 | private void ij_generate(WorldGenLevel worldGenLevel, ChunkAccess chunkAccess, StructureManager structureManager, CallbackInfo ci, ChunkPos chunkPos) { 23 | if (IceJar.getInstance().getConfig().fixes.newChunks) { 24 | NewChunks.addChunk(worldGenLevel.getLevel(), chunkPos); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/AirPlace.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.world.InteractionHand; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.state.BlockState; 9 | import net.minecraft.world.phys.BlockHitResult; 10 | import org.samo_lego.icejar.IceJar; 11 | import org.samo_lego.icejar.check.CheckType; 12 | 13 | public class AirPlace extends BlockInteractCheck { 14 | 15 | public AirPlace(ServerPlayer player) { 16 | super(CheckType.WORLD_BLOCK_PLACE_AIR, player); 17 | } 18 | 19 | @Override 20 | protected boolean checkBlockInteract(Level level, InteractionHand hand, BlockPos blockPos, Direction direction) { 21 | final BlockState state = level.getBlockState(blockPos); 22 | // Check if block is liquid or air 23 | if (state.isAir() || state.getMaterial().isLiquid()) { 24 | final double dist = IceJar.getInstance().getConfig().world.maxBlockReachDistance; 25 | 26 | final BlockHitResult blockHit = (BlockHitResult) player.pick(dist, 0, false); 27 | return blockHit.getType().equals(BlockHitResult.Type.BLOCK); 28 | } 29 | return !state.isAir() && !state.getMaterial().isLiquid(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/CheckCategory.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check; 2 | 3 | import org.samo_lego.icejar.IceJar; 4 | import org.samo_lego.icejar.config.IceConfig; 5 | 6 | import java.util.HashMap; 7 | import java.util.Set; 8 | 9 | public enum CheckCategory { 10 | COMBAT, 11 | ENTITY_INTERACT, 12 | MOVEMENT_IMMUTABLE, // cannot be cancelled (tp-ed back) 13 | INVENTORY, 14 | MOVEMENT_MUTABLE, // allow canceling (tp-ing back) 15 | PACKETS, 16 | VEHICLE_MOVEMENT, 17 | WORLD_BLOCK_BREAK, WORLD_BLOCK_INTERACT; 18 | 19 | public static final HashMap> ALL_CHECKS = new HashMap<>(); 20 | public static HashMap> category2checks = new HashMap<>(); 21 | 22 | public static void reloadEnabledChecks() { 23 | final HashMap checkConfigs = IceJar.getInstance().getConfig().checkConfigs; 24 | category2checks = new HashMap<>(ALL_CHECKS); 25 | for (Set checks : category2checks.values()) { 26 | // Remove disabled checks 27 | checks.removeIf(c -> { 28 | IceConfig.CheckConfig checkConfig = checkConfigs.get(c); 29 | if (checkConfig != null) { 30 | return !checkConfig.enabled; 31 | } 32 | return false; 33 | }); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # Automatically build the project and run any configured tests for every push 2 | # and submitted pull request. This can help catch issues that only occur on 3 | # certain platforms or Java versions, and provides a first line of defence 4 | # against bad commits. 5 | 6 | name: build 7 | on: [pull_request, push] 8 | 9 | jobs: 10 | build: 11 | strategy: 12 | matrix: 13 | # Use these Java versions 14 | java: [ 15 | 17, # Current Java LTS & minimum supported by Minecraft 16 | ] 17 | # and run on both Linux and Windows 18 | os: [ubuntu-20.04, windows-2022] 19 | runs-on: ${{ matrix.os }} 20 | steps: 21 | - name: checkout repository 22 | uses: actions/checkout@v2 23 | - name: validate gradle wrapper 24 | uses: gradle/wrapper-validation-action@v1 25 | - name: setup jdk ${{ matrix.java }} 26 | uses: actions/setup-java@v1 27 | with: 28 | java-version: ${{ matrix.java }} 29 | - name: make gradle wrapper executable 30 | if: ${{ runner.os != 'Windows' }} 31 | run: chmod +x ./gradlew 32 | - name: build 33 | run: ./gradlew build 34 | - name: capture build artifacts 35 | if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS 36 | uses: actions/upload-artifact@v2 37 | with: 38 | name: Artifacts 39 | path: build/libs/ 40 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/ReachBlock.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.network.chat.Component; 7 | import net.minecraft.network.chat.MutableComponent; 8 | import net.minecraft.server.level.ServerPlayer; 9 | import net.minecraft.world.InteractionHand; 10 | import net.minecraft.world.level.Level; 11 | import net.minecraft.world.phys.Vec3; 12 | import org.samo_lego.icejar.IceJar; 13 | import org.samo_lego.icejar.check.CheckType; 14 | 15 | public class ReachBlock extends BlockCheck { 16 | private double distance; 17 | 18 | public ReachBlock(ServerPlayer player) { 19 | super(CheckType.WORLD_BLOCK_REACH, player); 20 | } 21 | 22 | @Override 23 | public boolean checkBlockAction(final Level level, final InteractionHand interactionHand, final BlockPos blockPos, final Direction direction) { 24 | this.distance = player.getEyePosition().distanceTo(Vec3.atCenterOf(blockPos)); 25 | final double maxDist = IceJar.getInstance().getConfig().world.maxBlockReachDistance; 26 | 27 | return this.distance <= maxDist; 28 | } 29 | 30 | @Override 31 | public MutableComponent getAdditionalFlagInfo() { 32 | return Component.literal("Distance: ") 33 | .append(Component.literal(String.format("%.2f", this.distance)).withStyle(ChatFormatting.RED)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IceJar 2 | Port of some [ACR](https://github.com/Rammelkast/AntiCheatReloaded) and [NCP](https://github.com/Updated-NoCheatPlus/NoCheatPlus) anticheat checks to Fabric, 3 | with additional [GolfIV](https://github.com/samolego/GolfIV) & other stuff. 4 | 5 | ## Download 6 | 7 | IceJar has a long way to go and release as stable. 8 | You can however play with it and test it at your own risk. 9 | Download the latest version from [CircleCI](https://app.circleci.com/pipelines/github/samolego/IceJar) 10 | (navigate to latest build and click the "artifacts" tab). 11 | 12 | **Please report false positives for checks that cannot be configured.** 13 | 14 | Also, currently there's no special mod compatibility system, so please avoid 15 | reporting false positives that are a result of mod incompatibility. 16 | 17 | Thanks :) 18 | 19 | ## Features 20 | 21 | * When blocking some sorts of hacks, fake info is sent to player 22 | to make it seem like cheat worked. 23 | * Each check can be configured in config file. 24 | 25 | ## Permissions 26 | 27 | Bypass a check: 28 | `icejar.checks.bypass.` 29 | 30 | Get reports: 31 | `icejar.checks.get_report.` 32 | 33 | *Check types can be found in [CheckType file](./src/main/java/org/samo_lego/icejar/check/CheckType.java). 34 | Make sure to use them in lower-case style.* 35 | 36 | ## License 37 | 38 | This mod inherits the license of NoCheatPlus & AntiCheatReloaded, therefore 39 | it's licensed under the terms of the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html). 40 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/BlockBreakCheck.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.world.InteractionHand; 7 | import net.minecraft.world.InteractionResult; 8 | import net.minecraft.world.entity.player.Player; 9 | import net.minecraft.world.level.Level; 10 | import org.samo_lego.icejar.check.CheckType; 11 | 12 | import static org.samo_lego.icejar.check.CheckCategory.WORLD_BLOCK_BREAK; 13 | 14 | public abstract class BlockBreakCheck extends BlockCheck { 15 | public BlockBreakCheck(CheckType checkType, ServerPlayer player) { 16 | super(checkType, player); 17 | } 18 | 19 | public static InteractionResult performCheck(final Player player, final Level level, final InteractionHand interactionHand, 20 | final BlockPos blockPos, final Direction direction) { 21 | return BlockCheck.performCheck(WORLD_BLOCK_BREAK, player, level, interactionHand, blockPos, direction); 22 | } 23 | 24 | 25 | @Override 26 | public boolean checkBlockAction(final Level level, final InteractionHand hand, final BlockPos blockPos, final Direction direction) { 27 | return this.checkBlockBreak(level, hand, blockPos, direction); 28 | } 29 | 30 | protected abstract boolean checkBlockBreak(final Level level, final InteractionHand hand, final BlockPos blockPos, final Direction direction); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/BlockInteractCheck.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.world.InteractionHand; 7 | import net.minecraft.world.InteractionResult; 8 | import net.minecraft.world.entity.player.Player; 9 | import net.minecraft.world.level.Level; 10 | import net.minecraft.world.phys.BlockHitResult; 11 | import org.samo_lego.icejar.check.CheckType; 12 | 13 | import static org.samo_lego.icejar.check.CheckCategory.WORLD_BLOCK_INTERACT; 14 | 15 | public abstract class BlockInteractCheck extends BlockCheck { 16 | 17 | public BlockInteractCheck(CheckType checkType, ServerPlayer player) { 18 | super(checkType, player); 19 | } 20 | 21 | public static InteractionResult performCheck(final Player player, final Level level, 22 | final InteractionHand interactionHand, final BlockHitResult blockHitResult) { 23 | 24 | return BlockCheck.performCheck(WORLD_BLOCK_INTERACT, player, level, interactionHand, blockHitResult.getBlockPos(), blockHitResult.getDirection()); 25 | } 26 | 27 | @Override 28 | public boolean checkBlockAction(Level level, InteractionHand hand, BlockPos blockPos, Direction direction) { 29 | return this.checkBlockInteract(level, hand, blockPos, direction); 30 | } 31 | 32 | protected abstract boolean checkBlockInteract(Level level, InteractionHand hand, BlockPos blockPos, Direction direction); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/ImpossibleBlockAction.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.network.chat.Component; 6 | import net.minecraft.network.chat.MutableComponent; 7 | import net.minecraft.server.level.ServerPlayer; 8 | import net.minecraft.world.InteractionHand; 9 | import net.minecraft.world.level.Level; 10 | import org.samo_lego.icejar.casts.IceJarPlayer; 11 | import org.samo_lego.icejar.check.CheckType; 12 | 13 | import static org.samo_lego.icejar.util.ChatColor.styleBoolean; 14 | 15 | public class ImpossibleBlockAction extends BlockCheck { 16 | public ImpossibleBlockAction(ServerPlayer player) { 17 | super(CheckType.WORLD_BLOCK_IMPOSSIBLE_ACTION, player); 18 | } 19 | 20 | @Override 21 | public boolean checkBlockAction(Level level, InteractionHand hand, BlockPos blockPos, Direction direction) { 22 | return !((IceJarPlayer) player).ij$hasOpenGui() && 23 | !player.isUsingItem() && 24 | !player.isBlocking(); 25 | } 26 | 27 | @Override 28 | public MutableComponent getAdditionalFlagInfo() { 29 | return Component.literal("GUI open: ") 30 | .append(styleBoolean(((IceJarPlayer) player).ij$hasOpenGui())) 31 | .append("\n") 32 | .append(Component.literal("Using item: ") 33 | .append(styleBoolean(player.isUsingItem()))) 34 | .append("\n") 35 | .append(Component.literal("Blocking: ") 36 | .append(styleBoolean(player.isBlocking()))); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/fake_data/no_fall/ServerLevelMixin_SkipNoFallEvent.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.fake_data.no_fall; 2 | 3 | import net.minecraft.server.level.ServerLevel; 4 | import net.minecraft.world.damagesource.DamageSource; 5 | import net.minecraft.world.entity.Entity; 6 | import org.samo_lego.icejar.casts.IceJarPlayer; 7 | import org.samo_lego.icejar.check.movement.NoFall; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 13 | 14 | import static org.samo_lego.icejar.check.CheckType.MOVEMENT_NOFALL; 15 | 16 | @Mixin(ServerLevel.class) 17 | public class ServerLevelMixin_SkipNoFallEvent { 18 | 19 | /** 20 | * Works together with {@link LivingEntityMixin_FallObserver#skipNoFallDamageEvent(DamageSource, float, CallbackInfoReturnable)} 21 | * @param entity entity to broadcast event for. 22 | * @param state state of the entity. 23 | * @param ci mixin callback info. 24 | */ 25 | @Inject(method = "broadcastEntityEvent", at = @At("HEAD"), cancellable = true) 26 | private void skipNoFallEvent(Entity entity, byte state, CallbackInfo ci) { 27 | if (entity instanceof IceJarPlayer player && player.getCheck(NoFall.class).shouldSkipDamageEvent() && MOVEMENT_NOFALL.isEnabled()) { 28 | final NoFall check = player.getCheck(NoFall.class); 29 | check.setSkipDamageEvent(false); 30 | check.setHasFallen(true); 31 | ci.cancel(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/IceJar.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar; 2 | 3 | import net.fabricmc.loader.api.FabricLoader; 4 | import net.minecraft.server.MinecraftServer; 5 | import org.apache.logging.log4j.LogManager; 6 | import org.apache.logging.log4j.Logger; 7 | import org.samo_lego.icejar.config.IceConfig; 8 | import org.samo_lego.icejar.event.EventHandler; 9 | 10 | import java.io.File; 11 | 12 | import static org.samo_lego.icejar.check.CheckCategory.reloadEnabledChecks; 13 | 14 | public class IceJar { 15 | 16 | public static final String MOD_ID = "icejar"; 17 | 18 | public static final Logger LOGGER = LogManager.getLogger(MOD_ID); 19 | private static IceJar INSTANCE; 20 | private final File configFile; 21 | private final IceConfig config; 22 | private MinecraftServer server; 23 | 24 | public IceJar() { 25 | LOGGER.info("Loading IceJar ..."); 26 | this.configFile = new File(FabricLoader.getInstance().getConfigDir() + "/" + MOD_ID + "/config.json"); 27 | if (!this.configFile.exists()) { 28 | this.configFile.getParentFile().mkdirs(); 29 | } 30 | this.config = IceConfig.loadConfigFile(this.configFile); 31 | 32 | new EventHandler(); 33 | } 34 | 35 | public static void onServerStarted(MinecraftServer server) { 36 | INSTANCE.server = server; 37 | } 38 | 39 | public File getConfigFile() { 40 | return this.configFile; 41 | } 42 | 43 | public MinecraftServer getServer() { 44 | return this.server; 45 | } 46 | 47 | public IceConfig getConfig() { 48 | return this.config; 49 | } 50 | 51 | public static IceJar getInstance() { 52 | return INSTANCE; 53 | } 54 | 55 | public static void onInitialize() { 56 | INSTANCE = new IceJar(); 57 | reloadEnabledChecks(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/inventory/ServerPlayerMixin_InventoryObserver.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.inventory; 2 | 3 | import net.minecraft.server.level.ServerLevel; 4 | import net.minecraft.server.level.ServerPlayer; 5 | import net.minecraft.world.MenuProvider; 6 | import net.minecraft.world.entity.Entity; 7 | import org.samo_lego.icejar.casts.IceJarPlayer; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Unique; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 14 | 15 | import java.util.OptionalInt; 16 | 17 | /** 18 | * Checks whether player has opened an inventory. 19 | */ 20 | @Mixin(ServerPlayer.class) 21 | public class ServerPlayerMixin_InventoryObserver { 22 | 23 | @Unique 24 | private final IceJarPlayer player = (IceJarPlayer) this; 25 | 26 | @Inject(method = "openMenu", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V")) 27 | private void onOpenMenu(MenuProvider menuProvider, CallbackInfoReturnable cir) { 28 | player.ij$setOpenGUI(true); 29 | } 30 | 31 | @Inject(method = "doCloseContainer", at = @At("HEAD")) 32 | private void onCloseMenu(CallbackInfo ci) { 33 | player.ij$setOpenGUI(false); 34 | } 35 | 36 | @Inject(method = "changeDimension", at = @At("HEAD")) 37 | private void onDimensionChange(ServerLevel destination, CallbackInfoReturnable cir) { 38 | player.ij$setOpenGUI(false); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Java Gradle CircleCI 2.0 configuration file 2 | # See: https://circleci.com/docs/2.0/language-java/ 3 | version: 2 4 | 5 | # Define a job to be invoked later in a workflow. 6 | # See: https://circleci.com/docs/2.0/configuration-reference/#jobs 7 | jobs: 8 | build: 9 | # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. 10 | # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor 11 | docker: 12 | # specify the version you desire here 13 | - image: cimg/openjdk:17.0.1 14 | 15 | # Specify service dependencies here if necessary 16 | # CircleCI maintains a library of pre-built images 17 | # documented at https://circleci.com/docs/2.0/circleci-images/ 18 | # - image: circleci/postgres:9.4 19 | 20 | working_directory: ~/repo 21 | 22 | environment: 23 | # Customize the JVM maximum heap limit 24 | JVM_OPTS: -Xmx3200m 25 | TERM: dumb 26 | # Add steps to the job 27 | # See: https://circleci.com/docs/2.0/configuration-reference/#steps 28 | steps: 29 | - checkout 30 | 31 | # Download and cache dependencies 32 | - restore_cache: 33 | keys: 34 | - v1-dependencies-{{ checksum "build.gradle" }} 35 | # fallback to using the latest cache if no exact match is found 36 | - v1-dependencies- 37 | 38 | - run: gradle dependencies 39 | 40 | - save_cache: 41 | paths: 42 | - ~/.gradle 43 | key: v1-dependencies-{{ checksum "build.gradle" }} 44 | 45 | # build fabric 46 | - run: gradle build 47 | - store_artifacts: 48 | path: build/libs/ -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/newchunks/MLiquidBlock.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.newchunks; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.level.Level; 5 | import net.minecraft.world.level.block.Block; 6 | import net.minecraft.world.level.block.LiquidBlock; 7 | import net.minecraft.world.level.block.state.BlockState; 8 | import org.samo_lego.icejar.module.NewChunks; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(LiquidBlock.class) 15 | public class MLiquidBlock { 16 | @Inject(method = "onPlace", 17 | at = @At(value = "INVOKE", 18 | target = "Lnet/minecraft/world/level/Level;scheduleTick(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/material/Fluid;I)V"), 19 | cancellable = true) 20 | private void ij_onPlace(BlockState blockState, Level level, BlockPos blockPos, BlockState blockState2, boolean bl, CallbackInfo ci) { 21 | if (NewChunks.tryFastFluidSpread(level, blockPos, blockState)) { 22 | ci.cancel(); 23 | } 24 | } 25 | 26 | @Inject(method = "neighborChanged", 27 | at = @At(value = "INVOKE", 28 | target = "Lnet/minecraft/world/level/Level;scheduleTick(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/material/Fluid;I)V"), 29 | cancellable = true) 30 | private void ij_neighborChanged(BlockState blockState, Level level, BlockPos blockPos, Block block, BlockPos blockPos2, boolean bl, CallbackInfo ci) { 31 | if (NewChunks.tryFastFluidSpread(level, blockPos, blockState)) { 32 | ci.cancel(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/fake_data/no_fall/LivingEntityMixin_FallObserver.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.fake_data.no_fall; 2 | 3 | import net.minecraft.world.damagesource.DamageSource; 4 | import net.minecraft.world.entity.LivingEntity; 5 | import org.samo_lego.icejar.casts.IceJarPlayer; 6 | import org.samo_lego.icejar.check.movement.NoFall; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Unique; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | 13 | import static org.samo_lego.icejar.check.CheckType.MOVEMENT_NOFALL; 14 | 15 | @Mixin(LivingEntity.class) 16 | public class LivingEntityMixin_FallObserver { 17 | 18 | @Unique 19 | private final LivingEntity self = (LivingEntity) (Object) this; 20 | 21 | /** 22 | * Updates the {@link NoFall} hasFallen value. 23 | * @param source damage source, relevant only if it is {@link DamageSource#FALL} 24 | * @param amount amount of damage to be taken. 25 | * @param cir mixin callback info returnable. 26 | */ 27 | @Inject(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;broadcastEntityEvent(Lnet/minecraft/world/entity/Entity;B)V")) 28 | protected void skipNoFallDamageEvent(DamageSource source, float amount, CallbackInfoReturnable cir) { 29 | if (self instanceof IceJarPlayer player && source == DamageSource.FALL && MOVEMENT_NOFALL.isEnabled()) { 30 | final NoFall check = player.getCheck(NoFall.class); 31 | final boolean noFallEnabled = check.hasNoFall(); 32 | check.setSkipDamageEvent(noFallEnabled); 33 | check.setHasFallen(noFallEnabled); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/packet/ClientBoundSetEntityDataMixin_HPTagsRemove.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.packet; 2 | 3 | import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; 4 | import net.minecraft.network.syncher.SynchedEntityData; 5 | import org.jetbrains.annotations.Nullable; 6 | import org.spongepowered.asm.mixin.Final; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * A simplified version of GolfIV's data remover. 17 | * 18 | * @see GolfIV's Mixin 19 | */ 20 | @Mixin(ClientboundSetEntityDataPacket.class) 21 | public class ClientBoundSetEntityDataMixin_HPTagsRemove { 22 | 23 | @Shadow 24 | @Final 25 | @Nullable 26 | private List> packedItems; 27 | 28 | @Inject(method = "(ILjava/util/List;)V", at = @At("TAIL")) 29 | private void removePlayerHP(int i, List> data, CallbackInfo ci) { 30 | if (this.packedItems != null) { // todo - 1.19.3 31 | /*final Entity entity = IceJar.getInstance().getServer().getEnt 32 | if (entity instanceof ServerPlayer) { 33 | this.packedItems.removeIf((SynchedEntityData.DataItem dataItem) -> { 34 | Object value = dataItem.getAccessor(); 35 | return value == DATA_HEALTH_ID() || value.equals(DATA_PLAYER_ABSORPTION_ID()); 36 | }); 37 | }*/ 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/module/NewChunks.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.module; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.level.ChunkPos; 5 | import net.minecraft.world.level.Level; 6 | import net.minecraft.world.level.block.state.BlockState; 7 | 8 | import java.util.Comparator; 9 | import java.util.Map; 10 | import java.util.Set; 11 | import java.util.concurrent.ConcurrentHashMap; 12 | import java.util.concurrent.ConcurrentSkipListSet; 13 | 14 | public class NewChunks { 15 | private static final Map> NEW_CHUNKS = new ConcurrentHashMap<>(); 16 | 17 | public static void addChunk(Level level, ChunkPos chunkPos) { 18 | NEW_CHUNKS.computeIfAbsent(level, k -> new ConcurrentSkipListSet<>(new ChunkCompare())).add(chunkPos); 19 | } 20 | 21 | public static boolean isNewChunk(Level level, ChunkPos chunkPos) { 22 | return NEW_CHUNKS.containsKey(level) && NEW_CHUNKS.get(level).contains(chunkPos); 23 | } 24 | 25 | public static void removeChunk(Level level, ChunkPos chunkPos) { 26 | if (NEW_CHUNKS.containsKey(level)) { 27 | NEW_CHUNKS.get(level).remove(chunkPos); 28 | } 29 | } 30 | 31 | public static boolean tryFastFluidSpread(Level level, BlockPos blockPos, BlockState blockState) { 32 | if (isNewChunk(level, new ChunkPos(blockPos))) { 33 | // If chunk is new, set lower fluid tick delay 34 | level.scheduleTick(blockPos, blockState.getFluidState().getType(), 0); 35 | 36 | return true; 37 | } 38 | return false; 39 | } 40 | 41 | private static class ChunkCompare implements Comparator { 42 | @Override 43 | public int compare(ChunkPos chunkPos1, ChunkPos chunkPos2) { 44 | if (chunkPos1.x == chunkPos2.x) { 45 | return chunkPos1.z - chunkPos2.z; 46 | } 47 | return chunkPos1.x - chunkPos2.x; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/vehicle/EntityControl.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable.vehicle; 2 | 3 | import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; 4 | import net.minecraft.server.level.ServerPlayer; 5 | import net.minecraft.world.entity.Entity; 6 | import net.minecraft.world.entity.Mob; 7 | import net.minecraft.world.entity.Saddleable; 8 | import net.minecraft.world.entity.animal.horse.Llama; 9 | import org.samo_lego.icejar.IceJar; 10 | import org.samo_lego.icejar.check.CheckType; 11 | import org.samo_lego.icejar.config.IceConfig; 12 | import org.samo_lego.icejar.mixin.accessor.AMob; 13 | 14 | public class EntityControl extends CancellableVehicleMovementCheck { 15 | public EntityControl(ServerPlayer player) { 16 | super(CheckType.VEHICLE_MOVE_ENTITY_CONTROL, player); 17 | } 18 | 19 | @Override 20 | public boolean checkVehicleMovement(ServerboundMoveVehiclePacket packet, Entity vehicle) { 21 | if (vehicle instanceof Saddleable sd && !sd.isSaddled() && sd instanceof Mob mob) { 22 | final float diffY = Math.abs(packet.getYRot() - mob.getYRot()) % 360.0f; 23 | 24 | // We check mob's goals, if they are empty, player shouldn't be controlling it. 25 | // Mob can still be moved by external sources though (e.g. water, lead, etc.) 26 | if (mob instanceof Llama || ((AMob) mob).getGoalSelector().getRunningGoals().findAny().isEmpty()) { 27 | final IceConfig config = IceJar.getInstance().getConfig(); 28 | if (diffY > config.movement.entityControl.diffY) { 29 | if (this.trainModeActive()) { 30 | config.movement.entityControl.diffY = Math.max(diffY, config.movement.entityControl.diffY); 31 | return true; 32 | } 33 | return false; 34 | } 35 | } 36 | } 37 | return true; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/Timer.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable; 2 | 3 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 4 | import net.minecraft.server.level.ServerPlayer; 5 | import org.samo_lego.icejar.IceJar; 6 | import org.samo_lego.icejar.check.CheckType; 7 | import org.samo_lego.icejar.config.IceConfig; 8 | 9 | public class Timer extends CancellableMovementCheck { 10 | private long lastPacketTime; 11 | private long packetRate; 12 | 13 | public Timer(ServerPlayer player) { 14 | super(CheckType.CMOVEMENT_TIMER, player); 15 | } 16 | 17 | @Override 18 | public boolean checkMovement(ServerboundMovePlayerPacket packet) { 19 | if(packet instanceof ServerboundMovePlayerPacket.PosRot || 20 | packet instanceof ServerboundMovePlayerPacket.Rot || 21 | packet.getX(player.getX()) != player.getX() || 22 | packet.getY(player.getY()) != player.getY() || 23 | packet.getZ(player.getZ()) != player.getZ()) { 24 | 25 | final IceConfig config = IceJar.getInstance().getConfig(); 26 | 27 | final long currentPacketTime = System.currentTimeMillis(); 28 | final long lastTime = this.lastPacketTime; 29 | this.lastPacketTime = currentPacketTime; 30 | 31 | if(lastTime != 0) { 32 | this.packetRate += (50 + lastTime - currentPacketTime); 33 | 34 | if (this.trainModeActive()) { 35 | config.movement.timerThreshold = Math.max(config.movement.timerThreshold, this.packetRate); 36 | } else if (this.packetRate > config.movement.timerThreshold) { 37 | this.packetRate = 0; 38 | return false; 39 | } 40 | } 41 | } else { 42 | this.packetRate = 0; 43 | this.lastPacketTime = 0; 44 | } 45 | return true; 46 | } 47 | 48 | public void rebalance() { 49 | this.packetRate -= 50; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/WrongRotation.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | import net.minecraft.network.chat.MutableComponent; 6 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 7 | import net.minecraft.server.level.ServerPlayer; 8 | import net.minecraft.util.Mth; 9 | import org.samo_lego.icejar.IceJar; 10 | import org.samo_lego.icejar.check.CheckType; 11 | 12 | /** 13 | * Checks yaw deltas, if they are too big, it will cancel the movement. 14 | */ 15 | public class WrongRotation extends CancellableMovementCheck { 16 | private double diff; 17 | 18 | public WrongRotation(ServerPlayer player) { 19 | super(CheckType.CMOVEMENT_ROTATION, player); 20 | } 21 | 22 | @Override 23 | public boolean checkMovement(ServerboundMovePlayerPacket packet) { 24 | if (packet.hasRotation() && this.ijp.ij$getLast2Movement() != null) { 25 | final var cfg = IceJar.getInstance().getConfig(); 26 | 27 | final float yaw = this.player.getYRot(); 28 | // wrapDegrees returns an angle between -180 and 180 29 | final float packetYaw = Mth.wrapDegrees(packet.getYRot(yaw)); 30 | // If player turns from yaw -180 to yaw +180, we must account for that as well 31 | final double yawDiff = Math.min(Math.abs(yaw - packetYaw), Math.abs(yaw + packetYaw)); 32 | 33 | if (this.trainModeActive()) { 34 | cfg.movement.maxRotationDiff = Math.max(cfg.movement.maxRotationDiff, yawDiff); 35 | } else { 36 | this.diff = yawDiff; 37 | return yawDiff <= cfg.movement.maxRotationDiff; 38 | } 39 | } 40 | return true; 41 | } 42 | 43 | @Override 44 | public MutableComponent getAdditionalFlagInfo() { 45 | return Component.literal("Rotation difference: ") 46 | .append(Component.literal(String.format("%.2f", this.diff)).withStyle(ChatFormatting.RED)); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/command/IceJarCommand.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.command; 2 | 3 | import com.mojang.brigadier.CommandDispatcher; 4 | import com.mojang.brigadier.context.CommandContext; 5 | import com.mojang.brigadier.tree.LiteralCommandNode; 6 | import net.minecraft.ChatFormatting; 7 | import net.minecraft.commands.CommandBuildContext; 8 | import net.minecraft.commands.CommandSourceStack; 9 | import net.minecraft.commands.Commands; 10 | import net.minecraft.network.chat.Component; 11 | import org.samo_lego.icejar.IceJar; 12 | 13 | import static net.minecraft.commands.Commands.literal; 14 | 15 | public class IceJarCommand { 16 | public static void register(CommandDispatcher dispatcher, CommandBuildContext context, Commands.CommandSelection selection) { 17 | LiteralCommandNode edit = literal("edit").build(); 18 | IceJar.getInstance().getConfig().generateCommand(edit); 19 | dispatcher.register(literal("icejar") 20 | .requires(source -> source.hasPermission(4)) 21 | .then(literal("config") 22 | .then(edit) 23 | .then(literal("reload") 24 | .executes(IceJarCommand::reloadConfig) 25 | ) 26 | .then(literal("save") 27 | .executes(IceJarCommand::saveConfig) 28 | ) 29 | ) 30 | ); 31 | } 32 | 33 | private static int saveConfig(CommandContext context) { 34 | IceJar.getInstance().getConfig().save(); 35 | context.getSource().sendSuccess(Component.translatable("gui.done").withStyle(ChatFormatting.GREEN), true); 36 | 37 | return 1; 38 | } 39 | 40 | 41 | private static int reloadConfig(CommandContext context) { 42 | IceJar.getInstance().getConfig().reload(IceJar.getInstance().getConfigFile()); 43 | context.getSource().sendSuccess(Component.translatable("gui.done").withStyle(ChatFormatting.GREEN), true); 44 | 45 | return 1; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/combat/Reach.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.combat; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | import net.minecraft.network.chat.MutableComponent; 6 | import net.minecraft.server.level.ServerPlayer; 7 | import net.minecraft.world.InteractionHand; 8 | import net.minecraft.world.entity.Entity; 9 | import net.minecraft.world.entity.boss.enderdragon.EnderDragon; 10 | import net.minecraft.world.entity.monster.Giant; 11 | import net.minecraft.world.level.Level; 12 | import net.minecraft.world.phys.EntityHitResult; 13 | import org.samo_lego.icejar.IceJar; 14 | import org.samo_lego.icejar.check.CheckType; 15 | 16 | public class Reach extends CombatCheck { 17 | private float victimDistance; 18 | 19 | public Reach(ServerPlayer player) { 20 | super(CheckType.COMBAT_REACH, player); 21 | } 22 | 23 | @Override 24 | public boolean checkCombat(Level world, InteractionHand hand, Entity targetEntity, EntityHitResult hitResult) { 25 | this.victimDistance = targetEntity.distanceTo(player); 26 | final double maxDist = player.isCreative() ? 27 | CREATIVE_DISTANCE : 28 | getMaxDist(targetEntity); 29 | 30 | return this.victimDistance <= maxDist; 31 | } 32 | 33 | 34 | @Override 35 | public MutableComponent getAdditionalFlagInfo() { 36 | return Component.literal("Distance: ") 37 | .append(Component.literal(String.format("%.2f", this.victimDistance)).withStyle(ChatFormatting.RED)); 38 | } 39 | 40 | /** 41 | * Gets max hit distance for the given entity. 42 | * Method taken from NoCheatPlus. 43 | * 44 | * @param damaged damaged entity. 45 | * @return max distance. 46 | */ 47 | static double getMaxDist(final Entity damaged) { 48 | // Handle the EnderDragon differently. 49 | if (damaged instanceof EnderDragon) 50 | return 6.5D; 51 | else if (damaged instanceof Giant) 52 | return 1.5D; 53 | 54 | return IceJar.getInstance().getConfig().combat.maxSurvivalDistance; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/MovementCheck.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement; 2 | 3 | import me.lucko.fabric.api.permissions.v0.Permissions; 4 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import org.samo_lego.icejar.casts.IceJarPlayer; 7 | import org.samo_lego.icejar.check.Check; 8 | import org.samo_lego.icejar.check.CheckType; 9 | 10 | import java.util.Set; 11 | 12 | import static org.samo_lego.icejar.check.CheckCategory.MOVEMENT_IMMUTABLE; 13 | import static org.samo_lego.icejar.check.CheckCategory.category2checks; 14 | 15 | public abstract class MovementCheck extends Check { 16 | 17 | public MovementCheck(CheckType checkType, ServerPlayer player) { 18 | super(checkType, player); 19 | } 20 | 21 | @Override 22 | public boolean check(Object ... params) { 23 | if (params.length != 1) 24 | throw new IllegalArgumentException("MovementCheck.check() requires 1 parameter"); 25 | return this.checkMovement((ServerboundMovePlayerPacket) params[0]); 26 | } 27 | 28 | public abstract boolean checkMovement(ServerboundMovePlayerPacket packet); 29 | 30 | public static boolean performCheck(ServerPlayer player, ServerboundMovePlayerPacket packet) { 31 | // Loop through all movement checks 32 | final Set checks = category2checks.get(MOVEMENT_IMMUTABLE); 33 | if (checks != null) { 34 | for (CheckType type : checks) { 35 | if (Permissions.check(player, type.getBypassPermission(), false)) continue; 36 | 37 | final MovementCheck check = ((IceJarPlayer) player).getCheck(type); 38 | 39 | // Check movement 40 | if (!check.checkMovement(packet) && check.increaseCheatAttempts() > check.getMaxAttemptsBeforeFlag()) { 41 | check.flag(); 42 | 43 | // Jesus ruberband 44 | if (check instanceof NoFall nf && nf.hasJesus()) 45 | return false; 46 | } 47 | } 48 | } 49 | return true; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/fake_data/no_fall/ServerPlayerMixin_NoFallHP.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.fake_data.no_fall; 2 | 3 | import net.minecraft.server.level.ServerPlayer; 4 | import net.minecraft.world.damagesource.DamageSource; 5 | import org.samo_lego.icejar.casts.IceJarPlayer; 6 | import org.samo_lego.icejar.check.movement.NoFall; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.Unique; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | import static org.samo_lego.icejar.check.CheckType.MOVEMENT_NOFALL; 15 | 16 | @Mixin(ServerPlayer.class) 17 | public class ServerPlayerMixin_NoFallHP { 18 | 19 | @Shadow private float lastSentHealth; 20 | @Shadow private int lastSentFood; 21 | @Shadow private boolean lastFoodSaturationZero; 22 | @Unique private final ServerPlayer ij$player = (ServerPlayer) (Object) this; 23 | 24 | /** 25 | * Skips sending health and food to the client if the player has taken fall damage but is using NoFall. 26 | * @param ci mixin callback info. 27 | */ 28 | @Inject(method = "doTick", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/server/level/ServerPlayer;getHealth()F", ordinal = 0)) 29 | private void setFakedHealth(CallbackInfo ci) { 30 | if (MOVEMENT_NOFALL.isEnabled()) { 31 | final NoFall check = ((IceJarPlayer) ij$player).getCheck(NoFall.class); 32 | if (check.hasFallen()) { 33 | // Damage source is null-ified after about 2 seconds, then we check if no fall is still enabled. 34 | if (ij$player.getLastDamageSource() == DamageSource.FALL || (ij$player.getLastDamageSource() == null && check.hasNoFall())) { 35 | this.lastSentHealth = ij$player.getHealth(); 36 | this.lastSentFood = ij$player.getFoodData().getFoodLevel(); 37 | this.lastFoodSaturationZero = ij$player.getFoodData().getSaturationLevel() == 0.0F; 38 | } else { 39 | check.setHasFallen(false); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/combat/Angle.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.combat; 2 | 3 | import net.minecraft.server.level.ServerPlayer; 4 | import net.minecraft.world.InteractionHand; 5 | import net.minecraft.world.entity.Entity; 6 | import net.minecraft.world.level.Level; 7 | import net.minecraft.world.phys.AABB; 8 | import net.minecraft.world.phys.EntityHitResult; 9 | import org.samo_lego.icejar.check.CheckType; 10 | 11 | /** 12 | * Taken from GolfIV, https://github.com/samolego/GolfIV/blob/61fe5f2e8684ddb2d768d8f2e79af3149c86c830/src/main/java/org/samo_lego/golfiv/event/combat/AngleCheck.java#L24 13 | */ 14 | public class Angle extends CombatCheck{ 15 | 16 | public Angle(ServerPlayer player) { 17 | super(CheckType.COMBAT_ANGLE, player); 18 | } 19 | 20 | @Override 21 | public boolean checkCombat(Level world, InteractionHand hand, Entity targetEntity, EntityHitResult entityHitResult) { 22 | final double victimDistanceSquared = entityHitResult.distanceTo(player); 23 | final double victimDistance = Math.sqrt(victimDistanceSquared); 24 | 25 | // Get NSEW direction 26 | int xOffset = player.getDirection().getStepX(); 27 | int zOffset = player.getDirection().getStepZ(); 28 | 29 | final AABB bBox = targetEntity.getBoundingBox(); 30 | 31 | // Checking if targetEntity is behind player ("dumb" check) 32 | if(xOffset * targetEntity.getX() + bBox.getXsize() / 2 - xOffset * player.getX() < 0 || 33 | zOffset * targetEntity.getZ() + bBox.getZsize() / 2 - zOffset * player.getZ() < 0) { 34 | return false; 35 | } 36 | 37 | // Fine check 38 | final double deltaX = targetEntity.getX() - player.getX(); 39 | final double deltaZ = targetEntity.getZ() - player.getZ(); 40 | 41 | // Get the angle between the player and the targetEntity (in radians) 42 | final double beta = Math.atan2(deltaZ, deltaX) - Math.PI / 2; 43 | final double phi = beta - Math.toRadians(player.getYHeadRot()); 44 | 45 | // Get diagonal distance of target bounding box 46 | final double allowedAttackSpace = Math.sqrt(bBox.getXsize() * bBox.getXsize() + bBox.getZsize() * bBox.getZsize()); 47 | 48 | return Math.abs(victimDistance * Math.sin(phi)) <= allowedAttackSpace / 2 + 0.2D; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/CancellableMovementCheck.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable; 2 | 3 | import me.lucko.fabric.api.permissions.v0.Permissions; 4 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import org.samo_lego.icejar.casts.IceJarPlayer; 7 | import org.samo_lego.icejar.check.CheckType; 8 | import org.samo_lego.icejar.check.movement.MovementCheck; 9 | 10 | import java.util.Set; 11 | 12 | import static org.samo_lego.icejar.check.CheckCategory.MOVEMENT_MUTABLE; 13 | import static org.samo_lego.icejar.check.CheckCategory.category2checks; 14 | 15 | public abstract class CancellableMovementCheck extends MovementCheck { 16 | 17 | public CancellableMovementCheck(CheckType checkType, ServerPlayer player) { 18 | super(checkType, player); 19 | } 20 | 21 | @Override 22 | public boolean check(Object ... params) { 23 | if (params.length != 1) 24 | throw new IllegalArgumentException("MovementCheck.check() requires 1 parameter"); 25 | return this.checkMovement((ServerboundMovePlayerPacket) params[0]); 26 | } 27 | 28 | /** 29 | * Checks whether player has moved correctly. 30 | * @param player player to check. 31 | * @param packet packet containing movement data. 32 | * @return whether player has moved correctly. 33 | */ 34 | public static boolean performCheck(ServerPlayer player, ServerboundMovePlayerPacket packet) { 35 | // Loop through all movement checks 36 | final Set checks = category2checks.get(MOVEMENT_MUTABLE); 37 | if (checks != null) { 38 | for (CheckType type : checks) { 39 | if (Permissions.check(player, type.getBypassPermission(), false)) continue; 40 | 41 | final CancellableMovementCheck check = ((IceJarPlayer) player).getCheck(type); 42 | 43 | // Check movement 44 | if (!check.checkMovement(packet)) { 45 | if (check.increaseCheatAttempts() > check.getMaxAttemptsBeforeFlag()) 46 | check.flag(); 47 | 48 | // Ruberband 49 | return false; 50 | } 51 | } 52 | } 53 | return true; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/util/DataFaker.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.util; 2 | 3 | import net.minecraft.network.protocol.Packet; 4 | import net.minecraft.resources.ResourceKey; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.sounds.SoundEvent; 7 | import net.minecraft.sounds.SoundSource; 8 | import net.minecraft.world.entity.Entity; 9 | import net.minecraft.world.entity.player.Player; 10 | import net.minecraft.world.level.Level; 11 | import net.minecraft.world.phys.Vec3; 12 | import org.jetbrains.annotations.Nullable; 13 | import org.samo_lego.icejar.IceJar; 14 | 15 | public class DataFaker { 16 | private static final float RADIOUS = 32.0f; 17 | 18 | /** 19 | * Sends a packet to everyone in radious of {@link #RADIOUS}. 20 | * @param except the player to not send the packet to. 21 | * @param player the player to send the packet from. 22 | * @param packet the packet to send. 23 | */ 24 | public static void broadcast(@Nullable final Entity except, final ServerPlayer player, final Packet packet) { 25 | broadcast(except, player.getPosition(1), player.getLevel().dimension(), packet); 26 | } 27 | 28 | public static void broadcast(@Nullable final Entity except, final Vec3 pos, final ResourceKey dimension, final Packet packet) { 29 | Player targetPlayer = except instanceof Player ? (Player) except : null; 30 | IceJar.getInstance().getServer().getPlayerList().broadcast(targetPlayer, 31 | pos.x(), 32 | pos.y(), 33 | pos.z(), 34 | RADIOUS, 35 | dimension, 36 | packet); 37 | } 38 | 39 | /** 40 | * Sends sound to world around player. 41 | * @param sound the sound to play. 42 | * @param player the player to play the sound from. 43 | */ 44 | public static void sendSound(final SoundEvent sound, final ServerPlayer player) { 45 | sendSound(sound, player.getPosition(1), player.getLevel(), player.getSoundSource()); 46 | } 47 | 48 | public static void sendSound(final SoundEvent sound, final Vec3 pos, final Level world, final SoundSource source) { 49 | world.playSound(null, 50 | pos.x(), 51 | pos.y(), 52 | pos.z(), 53 | sound, 54 | source, 55 | 1.0f, 56 | 1.0f); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/BlockDirection.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.network.chat.Component; 7 | import net.minecraft.network.chat.MutableComponent; 8 | import net.minecraft.server.level.ServerPlayer; 9 | import net.minecraft.world.InteractionHand; 10 | import net.minecraft.world.level.Level; 11 | import org.samo_lego.icejar.IceJar; 12 | import org.samo_lego.icejar.check.CheckType; 13 | 14 | public class BlockDirection extends BlockCheck { 15 | private Direction blockDirection; 16 | private Direction lookingDirection; 17 | 18 | public BlockDirection(ServerPlayer player) { 19 | super(CheckType.WORLD_BLOCK_DIRECTION, player); 20 | } 21 | 22 | @Override 23 | public boolean checkBlockAction(Level level, InteractionHand hand, BlockPos blockPos, Direction direction) { 24 | // East and West 25 | this.blockDirection = direction; 26 | 27 | // Y deltas 28 | final double deltaY = blockPos.getY() - player.getEyeY(); 29 | 30 | final var cfg = IceJar.getInstance().getConfig().world; 31 | 32 | // Facing down but interacting with up 33 | if (player.getXRot() > 0.0F && (deltaY > cfg.direction || direction.equals(Direction.DOWN))) { 34 | if (this.trainModeActive() && deltaY > cfg.direction) { 35 | cfg.direction = deltaY; 36 | return true; 37 | } 38 | 39 | this.lookingDirection = Direction.DOWN; 40 | return false; 41 | } 42 | 43 | 44 | if (player.getXRot() < 0.0F && (deltaY < -cfg.direction || direction.equals(Direction.UP))) { 45 | if (this.trainModeActive() && deltaY < -cfg.direction) { 46 | cfg.direction = -deltaY; 47 | return true; 48 | } 49 | 50 | this.lookingDirection = Direction.UP; 51 | return false; 52 | } 53 | 54 | return true; 55 | } 56 | 57 | @Override 58 | public MutableComponent getAdditionalFlagInfo() { 59 | return Component.translatable("Looking: %s\nBlock: %s", 60 | Component.literal(this.lookingDirection.getName()).withStyle(ChatFormatting.GREEN), 61 | Component.literal(this.blockDirection.getName()).withStyle(ChatFormatting.RED)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/event/EventHandler.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.event; 2 | 3 | import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; 4 | import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; 5 | import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents; 6 | import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; 7 | import net.fabricmc.fabric.api.event.player.AttackBlockCallback; 8 | import net.fabricmc.fabric.api.event.player.AttackEntityCallback; 9 | import net.fabricmc.fabric.api.event.player.UseBlockCallback; 10 | import net.fabricmc.fabric.api.event.player.UseItemCallback; 11 | import net.minecraft.server.level.ServerLevel; 12 | import net.minecraft.world.level.chunk.LevelChunk; 13 | import org.samo_lego.icejar.IceJar; 14 | import org.samo_lego.icejar.casts.IceJarPlayer; 15 | import org.samo_lego.icejar.check.combat.CombatCheck; 16 | import org.samo_lego.icejar.check.inventory.ItemUseCheck; 17 | import org.samo_lego.icejar.check.world.block.BlockBreakCheck; 18 | import org.samo_lego.icejar.check.world.block.BlockInteractCheck; 19 | import org.samo_lego.icejar.command.IceJarCommand; 20 | import org.samo_lego.icejar.module.NewChunks; 21 | 22 | public class EventHandler { 23 | public EventHandler() { 24 | ServerChunkEvents.CHUNK_LOAD.register(this::onChunkLoad); 25 | 26 | // Register events 27 | AttackBlockCallback.EVENT.register(BlockBreakCheck::performCheck); 28 | UseBlockCallback.EVENT.register(BlockInteractCheck::performCheck); 29 | AttackEntityCallback.EVENT.register(CombatCheck::performCheck); 30 | UseItemCallback.EVENT.register(ItemUseCheck::performCheck); 31 | 32 | CommandRegistrationCallback.EVENT.register(IceJarCommand::register); 33 | ServerLifecycleEvents.SERVER_STARTED.register(IceJar::onServerStarted); 34 | 35 | // Copy data on dimension change etc. 36 | ServerPlayerEvents.COPY_FROM.register((old, newPl, _alive) -> ((IceJarPlayer) newPl).ij$copyFrom((IceJarPlayer) old)); 37 | } 38 | 39 | private void onChunkLoad(ServerLevel serverLevel, LevelChunk levelChunk) { 40 | //System.out.println("Chunk loaded! needs saving: " + levelChunk.isUnsaved() + " is new: " + ((IJChunkAccess) levelChunk).ij_isNewChunk()); 41 | //levelChunk.unpackTicks(); 42 | if (NewChunks.isNewChunk(serverLevel, levelChunk.getPos())) { 43 | System.out.println("Chunk @ " + levelChunk.getPos() + " is new!"); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/vehicle/BoatFly.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable.vehicle; 2 | 3 | import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; 4 | import net.minecraft.server.level.ServerPlayer; 5 | import net.minecraft.world.entity.Entity; 6 | import net.minecraft.world.entity.EntityType; 7 | import net.minecraft.world.phys.AABB; 8 | import net.minecraft.world.phys.Vec3; 9 | import org.samo_lego.icejar.IceJar; 10 | import org.samo_lego.icejar.casts.IceJarPlayer; 11 | import org.samo_lego.icejar.check.CheckType; 12 | import org.samo_lego.icejar.check.movement.NoFall; 13 | 14 | /** 15 | * Can still be improved, as this triggers false positive using e.g. slime block launcher. 16 | */ 17 | public class BoatFly extends CancellableVehicleMovementCheck { 18 | public BoatFly(ServerPlayer player) { 19 | super(CheckType.VEHICLE_MOVE_BOATFLY, player); 20 | } 21 | 22 | @Override 23 | public boolean checkVehicleMovement(ServerboundMoveVehiclePacket packet, Entity vehicle) { 24 | final Vec3 lastVM = ((IceJarPlayer) player).ij$getLastVehicleMovement(); 25 | final Vec3 vm = ((IceJarPlayer) player).ij$getVehicleMovement(); 26 | 27 | if (lastVM == null || vm == null) 28 | return true; 29 | 30 | if (this.trainModeActive()) { 31 | IceJar.getInstance().getConfig().movement.vehicleYThreshold = Math.max(IceJar.getInstance().getConfig().movement.vehicleYThreshold, vm.y() - lastVM.y()); 32 | } 33 | Vec3 nMove = new Vec3(packet.getX(), packet.getY(), packet.getZ()); 34 | final double pDeltaY = vm.y() - lastVM.y(); 35 | final double deltaY = nMove.y() - vm.y(); 36 | 37 | if (/*vm.horizontalDistanceSqr() - lastVM.horizontalDistanceSqr() <= 0.0D ||*/ 38 | /*pDeltaY <= 1E-3 ||*/ 39 | ((pDeltaY < deltaY || 40 | pDeltaY < 0.0D || 41 | deltaY < 0.0D) && 42 | pDeltaY != deltaY) || 43 | player.isFallFlying()) { 44 | return true; 45 | } 46 | 47 | if (vehicle.getType() == EntityType.BOAT) { 48 | final AABB bBox = vehicle.getBoundingBox().expandTowards(0.0D, -(pDeltaY + 0.25D), 0.0D); 49 | 50 | return NoFall.checkOnGround(vehicle, packet.getY() - vehicle.getY(), false) || 51 | vehicle.getLevel().containsAnyLiquid(bBox) || 52 | pDeltaY < deltaY; 53 | } 54 | return true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/FastLadder.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | import net.minecraft.network.chat.MutableComponent; 6 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 7 | import net.minecraft.server.level.ServerPlayer; 8 | import net.minecraft.world.phys.Vec3; 9 | import org.samo_lego.icejar.IceJar; 10 | import org.samo_lego.icejar.casts.IceJarPlayer; 11 | import org.samo_lego.icejar.check.CheckType; 12 | import org.samo_lego.icejar.config.IceConfig; 13 | 14 | public class FastLadder extends CancellableMovementCheck { 15 | private boolean wasClimbing; 16 | private double deltaY; 17 | 18 | public FastLadder(ServerPlayer player) { 19 | super(CheckType.CMOVEMENT_FAST_LADDER, player); 20 | } 21 | 22 | @Override 23 | public boolean checkMovement(ServerboundMovePlayerPacket packet) { 24 | 25 | if (!player.onClimbable() || ((IceJarPlayer) player).ij$aboveLiquid() || player.isFallFlying()) { 26 | this.wasClimbing = false; 27 | return true; 28 | } else if (!this.wasClimbing) { 29 | this.wasClimbing = true; 30 | return true; 31 | } 32 | 33 | final IceConfig cf = IceJar.getInstance().getConfig(); 34 | final double maxUp = cf.movement.ladder.speedUpMax; 35 | final double maxDown = cf.movement.ladder.speedDownMax; 36 | 37 | final Vec3 lastMovement = ((IceJarPlayer) player).ij$getLastMovement(); 38 | 39 | if (lastMovement == null) return true; 40 | 41 | this.deltaY = packet.getY(player.getY()) - lastMovement.y; 42 | 43 | if (this.trainModeActive()) { 44 | if (deltaY > maxUp) { 45 | cf.movement.ladder.speedUpMax = deltaY; 46 | } else if (deltaY < maxDown) { 47 | cf.movement.ladder.speedDownMax = deltaY; 48 | } 49 | 50 | return true; 51 | } 52 | 53 | return !(deltaY > maxUp) && !(deltaY < maxDown); 54 | } 55 | 56 | @Override 57 | public MutableComponent getAdditionalFlagInfo() { 58 | return Component.literal("Direction: ") 59 | .append(Component.translatable("gui." + (this.deltaY < 0 ? "down" : "up")) 60 | .withStyle(ChatFormatting.GREEN)) 61 | .append("\nMovement delta: ") 62 | .append(Component.literal(String.format("%.2f", deltaY)).withStyle(ChatFormatting.RED)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/BlockFace.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.network.chat.Component; 7 | import net.minecraft.network.chat.MutableComponent; 8 | import net.minecraft.server.level.ServerPlayer; 9 | import net.minecraft.world.InteractionHand; 10 | import net.minecraft.world.level.Level; 11 | import org.samo_lego.icejar.check.CheckType; 12 | 13 | public class BlockFace extends BlockCheck { 14 | private Direction blockDirection; 15 | private Direction lookingDirection; 16 | 17 | public BlockFace(ServerPlayer player) { 18 | super(CheckType.WORLD_BLOCK_FACE, player); 19 | } 20 | 21 | @Override 22 | public boolean checkBlockAction(Level level, InteractionHand hand, BlockPos blockPos, Direction direction) { 23 | if (player.getDirection().equals(direction)) { 24 | this.lookingDirection = player.getDirection(); 25 | this.blockDirection = direction; 26 | return false; 27 | } 28 | 29 | // East and West 30 | final double deltaX = blockPos.getX() - player.getX(); 31 | this.blockDirection = direction; 32 | 33 | // Facing W / NW / SW *AND* interacting with W 34 | if (deltaX < -0.7D && direction.equals(Direction.WEST)) { 35 | this.lookingDirection = Direction.WEST; 36 | return false; 37 | } 38 | // Facing E / NE / SE *AND* interacting with E 39 | if (deltaX > 0.7D && direction.equals(Direction.EAST)) { 40 | this.lookingDirection = Direction.EAST; 41 | return false; 42 | } 43 | 44 | // North and South 45 | final double deltaZ = blockPos.getZ() - player.getZ(); 46 | 47 | // Facing N / NE / NW *AND* interacting with N 48 | if (deltaZ < -0.7D && direction.equals(Direction.NORTH)) { 49 | this.lookingDirection = Direction.NORTH; 50 | return false; 51 | } 52 | 53 | if (deltaZ > 0.7D && direction.equals(Direction.SOUTH)) { 54 | this.lookingDirection = Direction.SOUTH; 55 | return false; 56 | } 57 | 58 | return true; 59 | } 60 | 61 | @Override 62 | public MutableComponent getAdditionalFlagInfo() { 63 | return Component.translatable("Looking: %s\nBlock: %s", 64 | Component.literal(this.lookingDirection.getName()).withStyle(ChatFormatting.GREEN), 65 | Component.literal(this.blockDirection.getName()).withStyle(ChatFormatting.RED)); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/vehicle/CancellableVehicleMovementCheck.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable.vehicle; 2 | 3 | import me.lucko.fabric.api.permissions.v0.Permissions; 4 | import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.world.entity.Entity; 7 | import org.samo_lego.icejar.casts.IceJarPlayer; 8 | import org.samo_lego.icejar.check.Check; 9 | import org.samo_lego.icejar.check.CheckType; 10 | 11 | import java.util.Set; 12 | 13 | import static org.samo_lego.icejar.check.CheckCategory.VEHICLE_MOVEMENT; 14 | import static org.samo_lego.icejar.check.CheckCategory.category2checks; 15 | 16 | public abstract class CancellableVehicleMovementCheck extends Check { 17 | 18 | public CancellableVehicleMovementCheck(CheckType checkType, ServerPlayer player) { 19 | super(checkType, player); 20 | } 21 | 22 | @Override 23 | public boolean check(Object ... params) { 24 | if (params.length != 2) 25 | throw new IllegalArgumentException("CancellableVehicleMovementCheck.check() requires 2 parameters"); 26 | return this.checkVehicleMovement((ServerboundMoveVehiclePacket) params[0], (Entity) params[1]); 27 | } 28 | 29 | 30 | /** 31 | * Checks whether player has moved correctly. 32 | * @param player player to check. 33 | * @param packet packet containing movement data. 34 | * @param vehicle vehicle that player is moving. 35 | * @return whether player has moved correctly. 36 | */ 37 | public static boolean performCheck(ServerPlayer player, ServerboundMoveVehiclePacket packet, Entity vehicle) { 38 | // Loop through all movement checks 39 | final Set checks = category2checks.get(VEHICLE_MOVEMENT); 40 | if (checks != null) { 41 | for (CheckType type : checks) { 42 | if (Permissions.check(player, type.getBypassPermission(), false)) continue; 43 | 44 | final CancellableVehicleMovementCheck check = ((IceJarPlayer) player).getCheck(type); 45 | 46 | // Check movement 47 | if (!check.checkVehicleMovement(packet, vehicle)) { 48 | if (check.increaseCheatAttempts() > check.getMaxAttemptsBeforeFlag()) { 49 | check.flag(); 50 | 51 | // Ruberband 52 | return false; 53 | } 54 | } else { 55 | check.decreaseCheatAttempts(); 56 | } 57 | } 58 | } 59 | return true; 60 | } 61 | 62 | public abstract boolean checkVehicleMovement(ServerboundMoveVehiclePacket packet, Entity vehicle); 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/BlockCheck.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import me.lucko.fabric.api.permissions.v0.Permissions; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.server.level.ServerPlayer; 7 | import net.minecraft.world.InteractionHand; 8 | import net.minecraft.world.InteractionResult; 9 | import net.minecraft.world.entity.player.Player; 10 | import net.minecraft.world.level.Level; 11 | import org.samo_lego.icejar.IceJar; 12 | import org.samo_lego.icejar.casts.IceJarPlayer; 13 | import org.samo_lego.icejar.check.Check; 14 | import org.samo_lego.icejar.check.CheckCategory; 15 | import org.samo_lego.icejar.check.CheckType; 16 | 17 | import java.util.Set; 18 | 19 | import static org.samo_lego.icejar.check.CheckCategory.category2checks; 20 | 21 | public abstract class BlockCheck extends Check { 22 | public BlockCheck(CheckType checkType, ServerPlayer player) { 23 | super(checkType, player); 24 | } 25 | 26 | @Override 27 | public boolean check(Object... params) { 28 | if(params.length != 4) 29 | throw new IllegalArgumentException("BlockCheck. check() requires 3 params, got " + params.length); 30 | return this.checkBlockAction((Level) params[0], (InteractionHand) params[1], (BlockPos) params[2], (Direction) params[3]); 31 | } 32 | 33 | public abstract boolean checkBlockAction(final Level level, final InteractionHand hand, final BlockPos blockPos, final Direction direction); 34 | 35 | 36 | public static InteractionResult performCheck(final CheckCategory category, final Player player, final Level level, 37 | final InteractionHand interactionHand, final BlockPos blockPos, Direction direction) { 38 | 39 | // Loop through all block interact checks 40 | final Set checks = category2checks.get(category); 41 | if (checks != null && player instanceof IceJarPlayer ij) { 42 | for (CheckType type : checks) { 43 | if (Permissions.check(player, type.getBypassPermission(), false)) continue; 44 | 45 | final BlockCheck check = ij.getCheck(type); 46 | 47 | // Check 48 | if (!check.checkBlockAction(level, interactionHand, blockPos, direction)) { 49 | if (check.increaseCheatAttempts() > check.getMaxAttemptsBeforeFlag()) 50 | check.flag(); 51 | return IceJar.getInstance().getConfig().debug ? 52 | InteractionResult.PASS : 53 | InteractionResult.FAIL; 54 | } 55 | } 56 | } 57 | return InteractionResult.PASS; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/NoDeceleration.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | import net.minecraft.network.chat.MutableComponent; 6 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 7 | import net.minecraft.server.level.ServerPlayer; 8 | import net.minecraft.util.Mth; 9 | import org.samo_lego.icejar.IceJar; 10 | import org.samo_lego.icejar.check.CheckType; 11 | 12 | 13 | /** 14 | * Checks for invalid deceleration of speed while rotating. 15 | * Doesn't catch strafe. 16 | * Inspired by https://www.youtube.com/watch?v=-SiqszHE9rQ 17 | */ 18 | public class NoDeceleration extends CancellableMovementCheck { 19 | 20 | private double diff; 21 | 22 | public NoDeceleration(ServerPlayer player) { 23 | super(CheckType.CMOVEMENT_NO_DECELERATION, player); 24 | } 25 | 26 | @Override 27 | public boolean checkMovement(ServerboundMovePlayerPacket packet) { 28 | if (packet.hasRotation() && this.ijp.ij$getLast2Movement() != null && !this.player.isPassenger() && !player.isFallFlying()) { 29 | final var cfg = IceJar.getInstance().getConfig(); 30 | 31 | final float yaw = this.player.getYRot(); 32 | // wrapDegrees returns an angle between -180 and 180 33 | final float packetYaw = Mth.wrapDegrees(packet.getYRot(yaw)); 34 | final double yawDiff = Math.abs(yaw - packetYaw); 35 | 36 | // Activate only if yaw difference is bigger than config 37 | if (yawDiff > cfg.movement.speed.minYawDifference) { 38 | final double xzDelta = this.ijp.ij$getMovement().subtract(this.ijp.ij$getLastMovement()).horizontalDistance(); 39 | 40 | // Has player moved enough? 41 | if (xzDelta > 0.15D) { 42 | final double xzDeltaPrev = this.ijp.ij$getLastMovement().subtract(this.ijp.ij$getLast2Movement()).horizontalDistance(); 43 | this.diff = Math.abs(xzDelta - xzDeltaPrev); 44 | 45 | if (this.trainModeActive()) { 46 | cfg.movement.speed.minDeceleration = Math.min(cfg.movement.speed.minDeceleration, diff); 47 | } else { 48 | return this.diff >= cfg.movement.speed.minDeceleration; 49 | } 50 | } 51 | } 52 | } 53 | 54 | return true; 55 | } 56 | 57 | 58 | @Override 59 | public MutableComponent getAdditionalFlagInfo() { 60 | return Component.literal("Deceleration while rotating: ") 61 | .append(Component.literal(String.format("x * 10^-%d", (int) Math.log10(1/(this.diff)))).withStyle(ChatFormatting.RED)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/combat/ImpossibleHit.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.combat; 2 | 3 | import net.minecraft.network.chat.Component; 4 | import net.minecraft.network.chat.MutableComponent; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.world.InteractionHand; 7 | import net.minecraft.world.entity.Entity; 8 | import net.minecraft.world.level.Level; 9 | import net.minecraft.world.phys.BlockHitResult; 10 | import net.minecraft.world.phys.EntityHitResult; 11 | import net.minecraft.world.phys.HitResult; 12 | import org.samo_lego.icejar.casts.IceJarPlayer; 13 | import org.samo_lego.icejar.check.CheckType; 14 | 15 | import static org.samo_lego.icejar.check.combat.Reach.getMaxDist; 16 | import static org.samo_lego.icejar.util.ChatColor.styleBoolean; 17 | 18 | 19 | /** 20 | * A check to see if players try to attack entities while performing something else 21 | * or having obstructions in their way. 22 | * (i.e.: while blocking) 23 | */ 24 | public class ImpossibleHit extends CombatCheck { 25 | private boolean noWall; 26 | 27 | public ImpossibleHit(ServerPlayer player) { 28 | super(CheckType.COMBAT_IMPOSSIBLEHIT, player); 29 | } 30 | 31 | @Override 32 | public boolean checkCombat(Level world, InteractionHand hand, Entity targetEntity, EntityHitResult hitResult) { 33 | // Check if there's a wall in front of the player 34 | final double victimDistance = Math.sqrt(hitResult.distanceTo(player)); 35 | final double dist = player.isCreative() ? 36 | CREATIVE_DISTANCE : 37 | getMaxDist(targetEntity); 38 | 39 | final BlockHitResult blockHit = (BlockHitResult) player.pick(dist, 0, false); 40 | 41 | // Cannot hit targets with a wall in front of them, open gui, using item etc. 42 | this.noWall = blockHit.getType().equals(HitResult.Type.MISS) || 43 | Math.sqrt(blockHit.distanceTo(player)) + 0.5D >= victimDistance || 44 | player.isPassenger(); // ignore players riding other entities 45 | return noWall && 46 | !((IceJarPlayer) player).ij$hasOpenGui() && 47 | !player.isUsingItem() && 48 | !player.isBlocking(); 49 | } 50 | 51 | @Override 52 | public MutableComponent getAdditionalFlagInfo() { 53 | return Component.literal("Wall: ") 54 | .append(styleBoolean(!this.noWall)) 55 | .append("\n") 56 | .append(Component.literal("GUI open: ") 57 | .append(styleBoolean(((IceJarPlayer) player).ij$hasOpenGui()))) 58 | .append("\n") 59 | .append(Component.literal("Using item: ") 60 | .append(styleBoolean(player.isUsingItem()))) 61 | .append("\n") 62 | .append(Component.literal("Blocking: ") 63 | .append(styleBoolean(player.isBlocking()))); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/inventory/ItemUseCheck.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.inventory; 2 | 3 | import me.lucko.fabric.api.permissions.v0.Permissions; 4 | import net.minecraft.server.level.ServerPlayer; 5 | import net.minecraft.world.InteractionHand; 6 | import net.minecraft.world.InteractionResultHolder; 7 | import net.minecraft.world.entity.player.Player; 8 | import net.minecraft.world.item.ItemStack; 9 | import net.minecraft.world.level.Level; 10 | import org.samo_lego.icejar.IceJar; 11 | import org.samo_lego.icejar.casts.IceJarPlayer; 12 | import org.samo_lego.icejar.check.Check; 13 | import org.samo_lego.icejar.check.CheckCategory; 14 | import org.samo_lego.icejar.check.CheckType; 15 | import org.samo_lego.icejar.check.movement.cancellable.Timer; 16 | 17 | import java.util.Set; 18 | 19 | import static org.samo_lego.icejar.check.CheckCategory.category2checks; 20 | import static org.samo_lego.icejar.check.CheckType.CMOVEMENT_TIMER; 21 | 22 | public abstract class ItemUseCheck extends Check { 23 | public ItemUseCheck(CheckType checkType, ServerPlayer player) { 24 | super(checkType, player); 25 | } 26 | 27 | @Override 28 | public boolean check(Object... params) { 29 | if (params.length != 3) 30 | throw new IllegalArgumentException("ItemUse.check(...) requires 3 params, got " + params.length); 31 | return this.checkItemUse((Level) params[0], (ItemStack) params[1], (InteractionHand) params[2]); 32 | } 33 | 34 | public abstract boolean checkItemUse(Level level, ItemStack handStack, InteractionHand hand); 35 | 36 | public static InteractionResultHolder performCheck(final Player player, final Level level, final InteractionHand hand) { 37 | final ItemStack handStack = player.getItemInHand(hand); 38 | 39 | final Set checks = category2checks.get(CheckCategory.INVENTORY); 40 | if (checks != null && player instanceof IceJarPlayer ij) { 41 | 42 | 43 | if (CMOVEMENT_TIMER.isEnabled()) { 44 | // Fixes #2 45 | ((IceJarPlayer) player).getCheck(Timer.class).rebalance(); 46 | } 47 | 48 | for (CheckType type : checks) { 49 | if (Permissions.check(player, type.getBypassPermission(), false)) continue; 50 | 51 | final ItemUseCheck check = ij.getCheck(type); 52 | 53 | // Check 54 | if (!check.checkItemUse(level, handStack, hand)) { 55 | if (check.increaseCheatAttempts() > check.getMaxAttemptsBeforeFlag()) 56 | check.flag(); 57 | 58 | return IceJar.getInstance().getConfig().debug ? 59 | InteractionResultHolder.pass(handStack) : 60 | InteractionResultHolder.fail(handStack); 61 | } 62 | } 63 | } 64 | return InteractionResultHolder.pass(handStack); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/MixinConfigs.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonParser; 5 | import net.fabricmc.loader.api.FabricLoader; 6 | import org.objectweb.asm.tree.ClassNode; 7 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 8 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 9 | 10 | import java.io.File; 11 | import java.io.FileInputStream; 12 | import java.io.IOException; 13 | import java.util.HashSet; 14 | import java.util.List; 15 | import java.util.Scanner; 16 | import java.util.Set; 17 | 18 | import static org.apache.logging.log4j.LogManager.getLogger; 19 | import static org.samo_lego.icejar.IceJar.MOD_ID; 20 | 21 | public class MixinConfigs implements IMixinConfigPlugin { 22 | 23 | private static final Set SKIPPED_MIXINS = new HashSet<>(); 24 | 25 | @Override 26 | public void onLoad(String mixinPackage) { 27 | 28 | } 29 | 30 | @Override 31 | public String getRefMapperConfig() { 32 | return null; 33 | } 34 | 35 | @Override 36 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 37 | return !SKIPPED_MIXINS.contains(mixinClassName); 38 | } 39 | 40 | @Override 41 | public void acceptTargets(Set myTargets, Set otherTargets) { 42 | } 43 | 44 | @Override 45 | public List getMixins() { 46 | return null; 47 | } 48 | 49 | @Override 50 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 51 | } 52 | 53 | @Override 54 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 55 | } 56 | 57 | 58 | static { 59 | String path = FabricLoader.getInstance().getConfigDir() + "/" + MOD_ID + "/skipped_mixins.json"; 60 | getLogger(MOD_ID).info("[IceJar] Loading skipped mixins from " + path); 61 | File file = new File(path); 62 | 63 | if (!file.exists()) { 64 | file.getParentFile().mkdirs(); 65 | 66 | try { 67 | file.createNewFile(); 68 | } catch (IOException e) { 69 | e.printStackTrace(); 70 | } 71 | } else { 72 | // Read file content 73 | try (FileInputStream fis = new FileInputStream(file); 74 | Scanner scanner = new Scanner(fis)) { 75 | StringBuilder sb = new StringBuilder(); 76 | 77 | while (scanner.hasNextLine()) { 78 | sb.append(scanner.nextLine()); 79 | } 80 | 81 | JsonElement jsonElement = JsonParser.parseString(sb.toString()); 82 | 83 | if (jsonElement.isJsonArray()) { 84 | jsonElement.getAsJsonArray().forEach(jsonElement1 -> { 85 | if (jsonElement1.isJsonPrimitive()) { 86 | SKIPPED_MIXINS.add(jsonElement1.getAsString()); 87 | } 88 | }); 89 | } 90 | } catch (IOException e) { 91 | e.printStackTrace(); 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/world/block/AutoSign.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.world.block; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket; 6 | import net.minecraft.server.level.ServerPlayer; 7 | import net.minecraft.world.InteractionHand; 8 | import net.minecraft.world.item.Item; 9 | import net.minecraft.world.item.SignItem; 10 | import net.minecraft.world.level.Level; 11 | import org.samo_lego.icejar.check.CheckType; 12 | 13 | import java.util.HashSet; 14 | import java.util.Set; 15 | 16 | public class AutoSign extends BlockCheck { 17 | 18 | /* From NCP */ 19 | /** Fastest time "possible" estimate for an empty sign. */ 20 | private static final long minEditTime = 150; 21 | /** Minimum time needed to add one extra line (not the first). */ 22 | private static final long minLineTime = 50; 23 | /** Minimum time needed to type a character. */ 24 | private static final long minCharTime = 50; 25 | 26 | private long lastPlacedSign; 27 | final Set chars = new HashSet<>(15 * 4); 28 | 29 | public AutoSign(ServerPlayer player) { 30 | super(CheckType.WORLD_BLOCK_AUTOSIGN, player); 31 | } 32 | 33 | @Override 34 | public boolean checkBlockAction(final Level level, final InteractionHand hand, final BlockPos blockPos, final Direction direction) { 35 | Item item = this.player.getItemInHand(hand).getItem(); 36 | 37 | if (item instanceof SignItem) { 38 | this.lastPlacedSign = System.currentTimeMillis(); 39 | } 40 | 41 | return true; 42 | } 43 | 44 | public boolean allowPlace(ServerboundSignUpdatePacket packet) { 45 | final long now = System.currentTimeMillis(); 46 | final long editTime = now - this.lastPlacedSign; 47 | 48 | final String[] lines = packet.getLines(); 49 | long expected = getExpectedEditTime(lines); 50 | 51 | if (expected > editTime) { 52 | if (this.increaseCheatAttempts() > this.getMaxAttemptsBeforeFlag()) 53 | this.flag(); 54 | 55 | return false; 56 | } 57 | this.decreaseCheatAttempts(); 58 | return true; 59 | } 60 | 61 | 62 | /** 63 | * Gets expected sign edit time depending on lines. 64 | * Taken from NCP. 65 | * 66 | * @param lines sign lines. 67 | * @return expected time. 68 | */ 69 | private long getExpectedEditTime(final String[] lines) { 70 | long expected = minEditTime; 71 | int n = 0; 72 | for (String line : lines){ 73 | if (line != null){ 74 | line = line.trim().toLowerCase(); 75 | if (!line.isEmpty()){ 76 | chars.clear(); 77 | n += 1; 78 | for (final char c : line.toCharArray()){ 79 | chars.add(c); 80 | } 81 | expected += minCharTime * chars.size(); 82 | } 83 | } 84 | } 85 | if (n == 0) { 86 | return 0; 87 | } 88 | if (n > 1){ 89 | expected += minLineTime * n; 90 | } 91 | return expected; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/Check.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check; 2 | 3 | import net.minecraft.network.chat.Component; 4 | import net.minecraft.network.chat.MutableComponent; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import org.samo_lego.icejar.IceJar; 7 | import org.samo_lego.icejar.casts.IceJarPlayer; 8 | import org.samo_lego.icejar.config.IceConfig; 9 | 10 | public abstract class Check { 11 | 12 | protected final CheckType checkType; 13 | protected ServerPlayer player; 14 | protected IceJarPlayer ijp; 15 | private long lastFlagTime; 16 | protected double violationLevel; 17 | protected int cheatAttempts; 18 | 19 | public Check(CheckType checkType, ServerPlayer player) { 20 | this.checkType = checkType; 21 | this.player = player; 22 | this.ijp = (IceJarPlayer) this.player; 23 | } 24 | 25 | public abstract boolean check(Object ... params); 26 | 27 | public CheckType getType() { 28 | return checkType; 29 | } 30 | 31 | public long getCooldown() { 32 | return this.getOptions().cooldown; 33 | } 34 | 35 | public void flag() { 36 | ((IceJarPlayer) this.player).flag(this); 37 | } 38 | 39 | public long getLastFlagTime() { 40 | return this.lastFlagTime; 41 | } 42 | 43 | public void setLastFlagTime(long now) { 44 | this.lastFlagTime = now; 45 | } 46 | 47 | public int getMaxAttemptsBeforeFlag() { 48 | return this.getOptions().attemptsToFlag; 49 | } 50 | 51 | public double getViolationIncrease() { 52 | return this.getOptions().violationIncrease; 53 | } 54 | 55 | public double getViolationLevel() { 56 | return this.violationLevel; 57 | } 58 | 59 | /** 60 | * Gets additional information about check circumstances as a {@link MutableComponent}. 61 | * @return additional information about check circumstances. 62 | */ 63 | public MutableComponent getAdditionalFlagInfo() { 64 | return Component.empty(); 65 | } 66 | 67 | public double increaseViolationLevel() { 68 | this.violationLevel += this.getViolationIncrease(); 69 | return this.violationLevel; 70 | } 71 | 72 | public double getMaxViolationLevel() { 73 | return this.getOptions().maxViolationLevel; 74 | } 75 | 76 | public void executeAction() { 77 | this.getOptions().action.execute(this.player, this); 78 | } 79 | 80 | public IceConfig.CheckConfig getOptions() { 81 | return IceConfig.getCheckOptions(this); 82 | } 83 | 84 | public boolean trainModeActive() { 85 | return this.getOptions().trainMode || IceJar.getInstance().getConfig().trainMode; 86 | } 87 | 88 | public int increaseCheatAttempts() { 89 | if (++this.cheatAttempts > this.getMaxAttemptsBeforeFlag()) { 90 | this.cheatAttempts = this.getMaxAttemptsBeforeFlag() + 1; 91 | } 92 | return this.cheatAttempts; 93 | } 94 | 95 | public void decreaseCheatAttempts() { 96 | if(--this.cheatAttempts < 0) { 97 | this.cheatAttempts = 0; 98 | } 99 | } 100 | 101 | public int getCheatAttempts() { 102 | return this.cheatAttempts; 103 | } 104 | 105 | public void setCheatAttempts(int attempts) { 106 | this.cheatAttempts = attempts; 107 | } 108 | 109 | public void setPlayer(ServerPlayer player) { 110 | this.player = player; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/combat/Critical.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.combat; 2 | 3 | import net.minecraft.network.chat.Component; 4 | import net.minecraft.network.chat.MutableComponent; 5 | import net.minecraft.network.protocol.game.ClientboundAnimatePacket; 6 | import net.minecraft.server.level.ServerPlayer; 7 | import net.minecraft.sounds.SoundEvents; 8 | import net.minecraft.world.InteractionHand; 9 | import net.minecraft.world.effect.MobEffects; 10 | import net.minecraft.world.entity.Entity; 11 | import net.minecraft.world.level.Level; 12 | import net.minecraft.world.level.block.Block; 13 | import net.minecraft.world.level.block.Blocks; 14 | import net.minecraft.world.level.block.state.BlockState; 15 | import net.minecraft.world.phys.EntityHitResult; 16 | import org.jetbrains.annotations.Nullable; 17 | import org.samo_lego.icejar.check.CheckType; 18 | import org.samo_lego.icejar.util.DataFaker; 19 | 20 | public class Critical extends CombatCheck { 21 | 22 | public Critical(ServerPlayer player) { 23 | super(CheckType.COMBAT_CRITICAL, player); 24 | } 25 | 26 | /** 27 | * Checks whether hit was a critical one. 28 | * @return true if hit was a critical one, otherwise false. 29 | */ 30 | private boolean isCritical() { 31 | return player.fallDistance > 0.0f && 32 | !player.isOnGround() && 33 | !player.isPassenger() && 34 | !player.hasEffect(MobEffects.BLINDNESS) && 35 | !player.isInWater() && 36 | !player.onClimbable(); 37 | } 38 | 39 | /** 40 | * Checks whether hit is a valid critical hit. 41 | * @return true if hit is a valid critical hit, otherwise false. 42 | */ 43 | private boolean isValid() { 44 | final BlockState feetState = player.getFeetBlockState(); 45 | final Block block = feetState.getBlock(); 46 | 47 | // Really basic check, detects "packet" mode only 48 | return player.position().y() % 1.0d > 0.001d && 49 | player.position().y() % 0.5d > 0.001d && 50 | 51 | // Blocks that disallow critical hits. 52 | // todo - unhardcode 53 | !block.equals(Blocks.SWEET_BERRY_BUSH) && 54 | !block.equals(Blocks.COBWEB) && 55 | !block.equals(Blocks.POWDER_SNOW); 56 | } 57 | 58 | 59 | /** 60 | * Performs a critical hit check. 61 | * @param _world world the player is in. 62 | * @param hand hand the player is using. 63 | * @param targetEntity entity being hit. 64 | * @param _hitResult hit result. 65 | * @return InteractionResult#PASS if action can continue, otherwise InteractionResult#FAIL. 66 | */ 67 | @Override 68 | public boolean checkCombat(final Level _world, final InteractionHand hand, final Entity targetEntity, final EntityHitResult _hitResult) { 69 | return !this.isCritical() || this.isValid(); 70 | } 71 | 72 | 73 | @Override 74 | public MutableComponent getAdditionalFlagInfo() { 75 | return Component.literal("Standing in: ") 76 | .append(player.getFeetBlockState().getBlock().getName()) 77 | .append("\n") 78 | .append(Component.literal("y mod 1: ") 79 | .append(String.format("%.2f", player.getY() % 1.0d))); 80 | 81 | } 82 | 83 | @Override 84 | protected void sendFakeHitData(final Level _world, final InteractionHand hand, final Entity targetEntity, @Nullable EntityHitResult _hitResult) { 85 | DataFaker.broadcast(targetEntity, player, new ClientboundAnimatePacket(targetEntity, ClientboundAnimatePacket.CRITICAL_HIT)); // Critical hit 86 | 87 | // Sound event for critical hit 88 | DataFaker.sendSound(SoundEvents.PLAYER_ATTACK_CRIT, player); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/cancellable/flight/BasicFlight.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement.cancellable.flight; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | import net.minecraft.network.chat.MutableComponent; 6 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 7 | import net.minecraft.server.level.ServerPlayer; 8 | import net.minecraft.world.effect.MobEffects; 9 | import org.samo_lego.icejar.IceJar; 10 | import org.samo_lego.icejar.check.CheckType; 11 | import org.samo_lego.icejar.check.movement.cancellable.CancellableMovementCheck; 12 | 13 | public class BasicFlight extends CancellableMovementCheck { 14 | private double lastDiffY; 15 | private short airTicks; 16 | private short airTicksBeforeReset; 17 | 18 | boolean lastTickOnGround; 19 | boolean lLastTickOnGround; 20 | 21 | public BasicFlight(ServerPlayer player) { 22 | super(CheckType.CMOVEMENT_BASIC_FLIGHT, player); 23 | this.lastTickOnGround = player.isOnGround(); 24 | this.lLastTickOnGround = player.isOnGround(); 25 | } 26 | 27 | @Override 28 | public boolean checkMovement(ServerboundMovePlayerPacket packet) { 29 | if (!player.isFallFlying() && 30 | !this.lastTickOnGround && !this.lLastTickOnGround && !player.isOnGround() && // Checking ground status 31 | !player.isPassenger() && 32 | !player.getAbilities().flying && 33 | !player.hasEffect(MobEffects.LEVITATION) && 34 | !player.isInWater() && !player.isInLava() && // modded fluids ? how to 35 | !player.onClimbable()) { 36 | 37 | this.lLastTickOnGround = this.lastTickOnGround; 38 | this.lastTickOnGround = player.isOnGround(); 39 | 40 | // Get Y velocity 41 | final double diffY = packet.getY(player.getY()) - player.getY(); 42 | final double lastDiff = this.lastDiffY; 43 | this.lastDiffY = diffY; 44 | 45 | if (diffY < 0.0) { 46 | // Player is falling 47 | // Check if difference is greater than before 48 | if (diffY > lastDiff) { 49 | return false; //todo honey fp 50 | } 51 | } else if (diffY > 0.0) { 52 | // Check if diffY is smaller than the last tick diffY 53 | if (diffY >= lastDiff && lastDiff > 0.0) { 54 | return false; 55 | } 56 | } else { 57 | ++this.airTicks; 58 | if (this.airTicks > IceJar.getInstance().getConfig().movement.maxAirTicks) { 59 | if (this.trainModeActive()) { 60 | IceJar.getInstance().getConfig().movement.maxAirTicks = this.airTicks; 61 | return true; 62 | } 63 | 64 | this.airTicksBeforeReset = this.airTicks; 65 | this.airTicks = 0; 66 | return false; 67 | } 68 | } 69 | 70 | return true; 71 | } 72 | if (this.airTicks > 0) { 73 | --this.airTicks; 74 | } 75 | 76 | this.lastDiffY = 0.0; 77 | 78 | this.lLastTickOnGround = this.lastTickOnGround; 79 | this.lastTickOnGround = player.isOnGround(); 80 | 81 | return true; 82 | } 83 | 84 | 85 | @Override 86 | public MutableComponent getAdditionalFlagInfo() { 87 | return Component.translatable("Y difference: %s\nAir ticks: %s", 88 | Component.literal(String.format("%.2f", this.lastDiffY)).withStyle(ChatFormatting.RED), 89 | Component.literal(String.format("%d", this.airTicksBeforeReset)).withStyle(ChatFormatting.RED)); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/util/ActionTypes.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.util; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | import net.minecraft.network.chat.MutableComponent; 6 | import net.minecraft.server.level.ServerPlayer; 7 | import net.minecraft.server.players.IpBanList; 8 | import net.minecraft.server.players.IpBanListEntry; 9 | import org.apache.logging.log4j.core.lookup.StrSubstitutor; 10 | import org.samo_lego.icejar.IceJar; 11 | import org.samo_lego.icejar.check.Check; 12 | 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Locale; 16 | import java.util.Map; 17 | 18 | public enum ActionTypes { 19 | BAN, 20 | KICK, 21 | NONE; 22 | 23 | private static final MutableComponent icejarPrefix = Component.literal("[IceJar]\n").withStyle(ChatFormatting.AQUA); 24 | 25 | public void execute(ServerPlayer pl, Check failedCheck) { 26 | switch (this) { 27 | case KICK -> this.disconnectInStyle(pl); 28 | case BAN -> this.ban(pl, failedCheck); 29 | default -> {} 30 | } 31 | 32 | if (failedCheck.getOptions().command != null) { 33 | this.executeCommand(pl, failedCheck); 34 | } 35 | } 36 | 37 | public void executeCommand(ServerPlayer player, String command) { 38 | Map valuesMap = new HashMap<>(); 39 | valuesMap.put("player", player.getGameProfile().getName()); 40 | valuesMap.put("uuid", player.getGameProfile().getId().toString()); 41 | valuesMap.put("ip", player.getIpAddress()); 42 | StrSubstitutor sub = new StrSubstitutor(valuesMap); 43 | 44 | player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), 45 | sub.replace(command)); 46 | 47 | } 48 | 49 | private void executeCommand(ServerPlayer player, Check failedCheck) { 50 | Map valuesMap = new HashMap<>(); 51 | valuesMap.put("player", player.getGameProfile().getName()); 52 | valuesMap.put("uuid", player.getGameProfile().getId().toString()); 53 | valuesMap.put("ip", player.getIpAddress()); 54 | valuesMap.put("check", failedCheck.getType().toString().toLowerCase(Locale.ROOT)); 55 | StrSubstitutor sub = new StrSubstitutor(valuesMap); 56 | 57 | player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), 58 | sub.replace(failedCheck.getOptions().command)); 59 | 60 | } 61 | 62 | private void ban(ServerPlayer player, Check failedCheck) { 63 | IpBanList ipBanList = player.getServer().getPlayerList().getIpBans(); 64 | final String ip = player.getIpAddress(); 65 | if (ipBanList.isBanned(ip)) { 66 | List list = player.getServer().getPlayerList().getPlayersWithAddress(ip); 67 | IpBanListEntry ipBanListEntry = new IpBanListEntry(ip, null, player.getGameProfile().getName(), null, "[IceJar] " + failedCheck.getType()); 68 | ipBanList.add(ipBanListEntry); 69 | 70 | final List kickMessages = IceJar.getInstance().getConfig().kickMessages; 71 | final String msg = kickMessages.get(player.getRandom().nextInt(kickMessages.size())); 72 | for (ServerPlayer serverPlayer : list) { 73 | this.disconnectInStyle(serverPlayer, msg); 74 | } 75 | } 76 | } 77 | 78 | private void disconnectInStyle(ServerPlayer player) { 79 | final List kickMessages = IceJar.getInstance().getConfig().kickMessages; 80 | final String msg = kickMessages.get(player.getRandom().nextInt(kickMessages.size())); 81 | player.connection.disconnect(icejarPrefix.copy().append(Component.literal(msg).withStyle(ChatFormatting.GREEN))); 82 | } 83 | 84 | 85 | private void disconnectInStyle(ServerPlayer player, String msg) { 86 | player.connection.disconnect(icejarPrefix.copy().append(Component.literal(msg).withStyle(ChatFormatting.GREEN))); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/movement/NoFall.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.movement; 2 | 3 | import me.lucko.fabric.api.permissions.v0.Permissions; 4 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.world.entity.Entity; 7 | import net.minecraft.world.phys.AABB; 8 | import net.minecraft.world.phys.shapes.VoxelShape; 9 | import org.samo_lego.icejar.casts.IceJarPlayer; 10 | import org.samo_lego.icejar.check.CheckType; 11 | import org.samo_lego.icejar.mixin.accessor.AServerboundMovePlayerPacket; 12 | 13 | import java.util.List; 14 | 15 | import static org.samo_lego.icejar.check.CheckType.SPECIAL_JESUS; 16 | 17 | public class NoFall extends MovementCheck { 18 | 19 | private boolean skipDamageEvent; 20 | private boolean hasFallen; 21 | private boolean hasJesus; 22 | 23 | public NoFall(ServerPlayer player) { 24 | super(CheckType.MOVEMENT_NOFALL, player); 25 | this.skipDamageEvent = false; 26 | } 27 | 28 | @Override 29 | public boolean checkMovement(ServerboundMovePlayerPacket packet) { 30 | boolean pass = true; 31 | final boolean onGround = checkOnGround(this.player, packet.getY(this.player.getY()) - player.getY(), true); 32 | if (packet.isOnGround()) { 33 | ijp.ij$updateGroundStatus(); 34 | ijp.ij$setOnGround(onGround); 35 | 36 | // Player isn't on ground but client packet says it is 37 | if (!ijp.ij$nearGround()) { 38 | this.setJesus(ijp.ij$aboveLiquid() && !Permissions.check(player, SPECIAL_JESUS.getBypassPermission(), false)); 39 | pass = false; 40 | } else { 41 | this.decreaseCheatAttempts(); 42 | } 43 | } 44 | // Prevent anti-hunger by setting the real ground value to packet. 45 | ((AServerboundMovePlayerPacket) packet).setOnGround(onGround); 46 | 47 | return pass; 48 | } 49 | 50 | private void setJesus(boolean onWater) { 51 | this.hasJesus = onWater; 52 | } 53 | 54 | public boolean hasJesus() { 55 | return this.hasJesus; 56 | } 57 | 58 | @Override 59 | public CheckType getType() { 60 | return this.hasJesus() ? SPECIAL_JESUS : this.checkType; 61 | } 62 | 63 | @Override 64 | public void setCheatAttempts(int attempts) { 65 | if (this.hasJesus()) 66 | super.setCheatAttempts(attempts); 67 | } 68 | 69 | @Override 70 | public int increaseCheatAttempts() { 71 | final int max2 = this.getMaxAttemptsBeforeFlag() * 2; 72 | if (++this.cheatAttempts > max2) { 73 | this.cheatAttempts = max2; 74 | } 75 | return this.cheatAttempts; 76 | } 77 | 78 | public void setHasFallen(boolean hasFallen) { 79 | this.hasFallen = hasFallen; 80 | } 81 | 82 | public boolean hasFallen() { 83 | return this.hasFallen; 84 | } 85 | 86 | public boolean hasNoFall() { 87 | return this.getCheatAttempts() > ((double) this.getMaxAttemptsBeforeFlag() / 2); 88 | } 89 | 90 | public boolean shouldSkipDamageEvent() { 91 | return this.skipDamageEvent; 92 | } 93 | 94 | public void setSkipDamageEvent(boolean skipDamageEvent) { 95 | this.skipDamageEvent = skipDamageEvent; 96 | } 97 | 98 | public static boolean checkOnGround(final Entity entity, final double deltaY, boolean checkLiquid) { 99 | final AABB bBox = entity 100 | .getBoundingBox() 101 | .expandTowards(0, -(deltaY + 0.25005D), 0); 102 | 103 | final Iterable collidingBlocks = entity.getLevel().getBlockCollisions(entity, bBox); 104 | 105 | if (collidingBlocks.iterator().hasNext()) { 106 | // Has collision with blocks 107 | return true; 108 | } 109 | 110 | if (checkLiquid && entity instanceof IceJarPlayer pl) { 111 | pl.ij$setAboveLiquid(entity.getLevel().containsAnyLiquid(bBox)); 112 | } 113 | 114 | // No block collisions found, check for entity collisions (e.g. standing on boat) 115 | List collidingEntities = entity.getLevel().getEntityCollisions(entity, bBox); 116 | 117 | return !collidingEntities.isEmpty(); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/packet/ServerGamePacketListenerImplMixin.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.packet; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.nbt.CompoundTag; 5 | import net.minecraft.network.chat.Component; 6 | import net.minecraft.network.protocol.Packet; 7 | import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; 8 | import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket; 9 | import net.minecraft.network.protocol.game.ServerboundSwingPacket; 10 | import net.minecraft.server.level.ServerLevel; 11 | import net.minecraft.server.level.ServerPlayer; 12 | import net.minecraft.server.network.FilteredText; 13 | import net.minecraft.server.network.ServerGamePacketListenerImpl; 14 | import net.minecraft.world.level.block.entity.BlockEntity; 15 | import net.minecraft.world.level.block.entity.SignBlockEntity; 16 | import net.minecraft.world.level.block.state.BlockState; 17 | import org.samo_lego.icejar.casts.IceJarPlayer; 18 | import org.samo_lego.icejar.check.combat.NoSwing; 19 | import org.samo_lego.icejar.check.world.block.AutoSign; 20 | import org.spongepowered.asm.mixin.Mixin; 21 | import org.spongepowered.asm.mixin.Shadow; 22 | import org.spongepowered.asm.mixin.injection.At; 23 | import org.spongepowered.asm.mixin.injection.Inject; 24 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 25 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 26 | 27 | import java.util.List; 28 | import java.util.concurrent.CompletableFuture; 29 | 30 | import static org.samo_lego.icejar.check.CheckType.COMBAT_NOSWING; 31 | import static org.samo_lego.icejar.check.CheckType.WORLD_BLOCK_AUTOSIGN; 32 | import static org.samo_lego.icejar.mixin.accessor.ASignBlockEntity.FILTERED_TEXT_FIELD_NAMES; 33 | import static org.samo_lego.icejar.mixin.accessor.ASignBlockEntity.RAW_TEXT_FIELD_NAMES; 34 | 35 | @Mixin(ServerGamePacketListenerImpl.class) 36 | public abstract class ServerGamePacketListenerImplMixin { 37 | 38 | @Shadow public ServerPlayer player; 39 | 40 | @Shadow public abstract void send(Packet packet); 41 | 42 | @Inject(method = "handleAnimate", at = @At("TAIL")) 43 | private void onHandSwing(ServerboundSwingPacket packet, CallbackInfo ci) { 44 | if (COMBAT_NOSWING.isEnabled()) 45 | ((IceJarPlayer) this.player).getCheck(NoSwing.class).onSwing(); 46 | } 47 | 48 | @Inject(method = "updateSignText", 49 | at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/SignBlockEntity;isEditable()Z"), 50 | locals = LocalCapture.CAPTURE_FAILHARD, 51 | cancellable = true) 52 | private void onSignUpdate(ServerboundSignUpdatePacket packet, List signText, CallbackInfo ci, 53 | ServerLevel level, BlockPos pos, BlockState state, BlockEntity blockEntity) { 54 | if (WORLD_BLOCK_AUTOSIGN.isEnabled()) { 55 | if (!((IceJarPlayer) this.player).getCheck(AutoSign.class).allowPlace(packet)) { 56 | final ClientboundBlockEntityDataPacket fakeData = ClientboundBlockEntityDataPacket.create(blockEntity, be -> { 57 | CompoundTag tag = new CompoundTag(); 58 | 59 | for (int i = 0; i < signText.size(); ++i) { 60 | final var text = signText.get(i); 61 | 62 | if (this.player.isTextFilteringEnabled()) { 63 | String textFiltered = text.filtered(); 64 | tag.putString(FILTERED_TEXT_FIELD_NAMES()[i], Component.Serializer.toJson(Component.literal(textFiltered))); 65 | } else { 66 | String textRaw = text.raw(); 67 | tag.putString(RAW_TEXT_FIELD_NAMES()[i], Component.Serializer.toJson(Component.literal(textRaw))); 68 | } 69 | 70 | } 71 | 72 | tag.putString("Color", ((SignBlockEntity) blockEntity).getColor().getName()); 73 | tag.putBoolean("GlowingText", ((SignBlockEntity) be).hasGlowingText()); 74 | 75 | return tag; 76 | }); 77 | 78 | // Seems like Minecraft sends another update packet after this one, so it's cancelled out. 79 | // todo figure out a way to prevent the second packet / fake it. This is an ugly workaround. 80 | CompletableFuture.runAsync(() -> { 81 | try { 82 | Thread.sleep(100); 83 | } catch (InterruptedException e) { 84 | e.printStackTrace(); 85 | } 86 | this.send(fakeData); 87 | }); 88 | ci.cancel(); 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/newchunks/MServerGamePacketListener_ChunkDelayer.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin.newchunks; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.network.protocol.Packet; 6 | import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; 7 | import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; 8 | import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; 9 | import net.minecraft.server.level.ServerPlayer; 10 | import net.minecraft.server.network.ServerGamePacketListenerImpl; 11 | import net.minecraft.world.level.ChunkPos; 12 | import net.minecraft.world.level.chunk.LevelChunk; 13 | import net.minecraft.world.level.material.FluidState; 14 | import org.samo_lego.icejar.casts.IceJarPlayer; 15 | import org.samo_lego.icejar.mixin.accessor.AClientboundSectionBlocksUpdatePacket; 16 | import org.samo_lego.icejar.module.NewChunks; 17 | import org.spongepowered.asm.mixin.Mixin; 18 | import org.spongepowered.asm.mixin.Shadow; 19 | import org.spongepowered.asm.mixin.Unique; 20 | import org.spongepowered.asm.mixin.injection.At; 21 | import org.spongepowered.asm.mixin.injection.Inject; 22 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 23 | 24 | @Mixin(ServerGamePacketListenerImpl.class) 25 | public abstract class MServerGamePacketListener_ChunkDelayer { 26 | @Unique 27 | private static final Direction[] DIRECTIONS = {Direction.EAST, Direction.WEST, Direction.NORTH, Direction.SOUTH}; 28 | 29 | @Shadow 30 | public abstract ServerPlayer getPlayer(); 31 | 32 | @Shadow 33 | public abstract void send(Packet packet); 34 | 35 | @Inject(method = "send(Lnet/minecraft/network/protocol/Packet;)V", at = @At("HEAD"), cancellable = true) 36 | private void ij_sendPacket(Packet packet, CallbackInfo ci) { 37 | LevelChunk chunk = null; 38 | final var level = getPlayer().getLevel(); 39 | if (packet instanceof ClientboundBlockUpdatePacket blockPacket) { 40 | BlockPos pos = blockPacket.getPos(); 41 | chunk = this.getPlayer().getLevel().getChunkAt(pos); 42 | 43 | // Check possible fluid spreading 44 | FluidState fluidState = chunk.getFluidState(pos); 45 | 46 | if (NewChunks.isNewChunk(level, chunk.getPos()) && !fluidState.isEmpty()) { 47 | // Reset neighbour update delay 48 | for (Direction dir : DIRECTIONS) { 49 | BlockPos neighbourPos = pos.relative(dir, fluidState.getAmount()); 50 | System.out.println("Neighbour pos: " + neighbourPos + " fluid amount: " + fluidState.getAmount()); 51 | 52 | var chunkNeighbour = this.getPlayer().getLevel().getChunkAt(neighbourPos); 53 | if (chunkNeighbour != chunk) { 54 | //((IceJarPlayer) this.getPlayer()).ij_getDelayedPackets().put(chunkNeighbour.getPos(), fluidState.getAmount()); 55 | NewChunks.addChunk(level, chunkNeighbour.getPos()); 56 | } 57 | } 58 | } 59 | } else if (packet instanceof ClientboundLevelChunkWithLightPacket lightPacket) { 60 | chunk = this.getPlayer().getLevel().getChunk(lightPacket.getX(), lightPacket.getZ()); 61 | } else if (packet instanceof ClientboundSectionBlocksUpdatePacket blocksUpdatePacket) { 62 | final var pos = ((AClientboundSectionBlocksUpdatePacket) blocksUpdatePacket).sectionPos(); 63 | chunk = this.getPlayer().getLevel().getChunk(pos.z(), pos.z()); 64 | } 65 | 66 | if (chunk != null && NewChunks.isNewChunk(level, chunk.getPos())) { 67 | // Reset delay 68 | ((IceJarPlayer) this.getPlayer()).ij_getDelayedPackets().put(chunk.getPos(), 2); 69 | ci.cancel(); 70 | } 71 | } 72 | 73 | @Inject(method = "tick", at = @At("RETURN")) 74 | private void ij_onTick(CallbackInfo ci) { 75 | // Send the needed packets 76 | for (var entry : ((IceJarPlayer) this.getPlayer()).ij_getDelayedPackets().entrySet()) { 77 | ChunkPos chunkPos = entry.getKey(); 78 | var delay = entry.getValue(); 79 | 80 | if (delay <= 0) { 81 | // Send the packet 82 | var chunk = this.getPlayer().getLevel().getChunk(chunkPos.x, chunkPos.z); 83 | var packet = new ClientboundLevelChunkWithLightPacket(chunk, chunk.getLevel().getLightEngine(), null, null, true); 84 | 85 | NewChunks.removeChunk(this.getPlayer().getLevel(), chunkPos); 86 | ((IceJarPlayer) this.getPlayer()).ij_getDelayedPackets().remove(chunkPos); 87 | 88 | this.send(packet); 89 | } else { 90 | // Decrease delay 91 | entry.setValue(delay - 1); 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/ServerGamePacketListenerImplMixin_Movement.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin; 2 | 3 | import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket; 4 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 5 | import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; 6 | import net.minecraft.server.level.ServerPlayer; 7 | import net.minecraft.server.network.ServerGamePacketListenerImpl; 8 | import net.minecraft.world.entity.Entity; 9 | import net.minecraft.world.phys.Vec2; 10 | import net.minecraft.world.phys.Vec3; 11 | import org.samo_lego.icejar.IceJar; 12 | import org.samo_lego.icejar.casts.IceJarPlayer; 13 | import org.samo_lego.icejar.check.movement.MovementCheck; 14 | import org.samo_lego.icejar.check.movement.cancellable.CancellableMovementCheck; 15 | import org.samo_lego.icejar.check.movement.cancellable.Timer; 16 | import org.samo_lego.icejar.check.movement.cancellable.vehicle.CancellableVehicleMovementCheck; 17 | import org.spongepowered.asm.mixin.Mixin; 18 | import org.spongepowered.asm.mixin.Shadow; 19 | import org.spongepowered.asm.mixin.Unique; 20 | import org.spongepowered.asm.mixin.injection.At; 21 | import org.spongepowered.asm.mixin.injection.Inject; 22 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 23 | 24 | import java.util.Set; 25 | 26 | import static org.samo_lego.icejar.check.CheckType.CMOVEMENT_TIMER; 27 | 28 | @Mixin(ServerGamePacketListenerImpl.class) 29 | public abstract class ServerGamePacketListenerImplMixin_Movement { 30 | @Shadow 31 | public ServerPlayer player; 32 | @Unique 33 | private Vec3 lastValidSpot; 34 | @Unique 35 | private int ij$validTickCount; 36 | @Unique 37 | private Vec2 lastValidRot; 38 | 39 | @Shadow public abstract void teleport(double x, double y, double z, float yaw, float pitch); 40 | 41 | /** 42 | * Checks the real onGround value of the movement packet. 43 | * 44 | * @param packet player movement packet. 45 | * @param ci callback info. 46 | */ 47 | @Inject(method = "handleMovePlayer", 48 | at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;isPassenger()Z"), 49 | cancellable = true 50 | ) 51 | private void onPlayerMove(ServerboundMovePlayerPacket packet, CallbackInfo ci) { 52 | ((IceJarPlayer) player).ij$setMovement(packet); 53 | ((IceJarPlayer) player).ij$setRotation(packet); 54 | // Movement check only returns false if Jesus hack is active, while CMovementCheck returns false if any check fails. 55 | boolean valid = MovementCheck.performCheck(player, packet) && CancellableMovementCheck.performCheck(player, packet); 56 | 57 | if (!valid && !IceJar.getInstance().getConfig().debug) { 58 | this.ij$validTickCount = 0; 59 | // Teleport to last spot, just don't keep Y value 60 | Vec3 last = this.lastValidSpot; 61 | Vec2 lastRot = this.lastValidRot; 62 | 63 | if (this.lastValidSpot == null || this.lastValidRot == null) { 64 | this.lastValidSpot = new Vec3(player.getX(), player.getY(), player.getZ()); 65 | this.lastValidRot = new Vec2(player.getYRot(), player.getXRot()); 66 | last = this.lastValidSpot; 67 | lastRot = this.lastValidRot; 68 | } 69 | 70 | this.teleport(last.x(), Math.min(packet.getY(player.getY()), last.y()), last.z(), lastRot.x, lastRot.y); 71 | ci.cancel(); 72 | } else { 73 | if (++this.ij$validTickCount >= 50) { 74 | this.lastValidSpot = this.player.position(); 75 | } 76 | } 77 | } 78 | 79 | @Inject(method = "handleMoveVehicle", at = @At(value = "INVOKE", 80 | target = "Lnet/minecraft/world/entity/Entity;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V"), 81 | cancellable = true 82 | ) 83 | private void onVehicleMove(ServerboundMoveVehiclePacket packet, CallbackInfo ci) { 84 | final Entity vh = this.player.getRootVehicle(); 85 | boolean canMove = CancellableVehicleMovementCheck.performCheck(player, packet, vh); 86 | 87 | if (!canMove && !IceJar.getInstance().getConfig().debug) { 88 | //todo 89 | // dismount? 90 | player.stopRiding(); 91 | vh.teleportTo(vh.getX(), vh.getY(), vh.getZ()); 92 | ci.cancel(); 93 | } else { 94 | ((IceJarPlayer) player).ij$setVehicleMovement(packet); 95 | } 96 | } 97 | 98 | @Inject(method = "teleport(DDDFFLjava/util/Set;Z)V", at = @At(value = "TAIL")) 99 | private void onTeleport(double d, double e, double f, float g, float h, 100 | Set set, boolean bl, CallbackInfo ci) { 101 | if (CMOVEMENT_TIMER.isEnabled()) { 102 | ((IceJarPlayer) player).getCheck(Timer.class).rebalance(); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/casts/IceJarPlayer.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.casts; 2 | 3 | 4 | import me.lucko.fabric.api.permissions.v0.Permissions; 5 | import net.minecraft.ChatFormatting; 6 | import net.minecraft.network.chat.ClickEvent; 7 | import net.minecraft.network.chat.Component; 8 | import net.minecraft.network.chat.HoverEvent; 9 | import net.minecraft.network.chat.MutableComponent; 10 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 11 | import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; 12 | import net.minecraft.server.level.ServerPlayer; 13 | import net.minecraft.world.level.ChunkPos; 14 | import net.minecraft.world.phys.Vec2; 15 | import net.minecraft.world.phys.Vec3; 16 | import org.samo_lego.icejar.IceJar; 17 | import org.samo_lego.icejar.check.Check; 18 | import org.samo_lego.icejar.check.CheckType; 19 | 20 | import java.util.Locale; 21 | import java.util.Map; 22 | 23 | public interface IceJarPlayer { 24 | MutableComponent ID = Component.literal("[IJ] ").withStyle(ChatFormatting.AQUA); 25 | void flag(final Check check); 26 | 27 | T getCheck(CheckType type); 28 | T getCheck(Class type); 29 | 30 | void ij$setOpenGUI(boolean open); 31 | boolean ij$hasOpenGui(); 32 | 33 | boolean ij$nearGround(); 34 | 35 | void ij$setOnGround(boolean ij$onGround); 36 | 37 | void ij$updateGroundStatus(); 38 | 39 | void ij$setVehicleMovement(ServerboundMoveVehiclePacket packet); 40 | Vec3 ij$getLastVehicleMovement(); 41 | Vec3 ij$getVehicleMovement(); 42 | 43 | void ij$setMovement(ServerboundMovePlayerPacket packet); 44 | Vec3 ij$getLast2Movement(); 45 | Vec3 ij$getLastMovement(); 46 | Vec3 ij$getMovement(); 47 | 48 | 49 | void ij$setRotation(ServerboundMovePlayerPacket packet); 50 | Vec2 ij$getLast2Rotation(); 51 | Vec2 ij$getLastRotation(); 52 | Vec2 ij$getRotation(); 53 | 54 | void ij$setAboveLiquid(boolean aboveLiquid); 55 | boolean ij$aboveLiquid(); 56 | 57 | void ij$copyFrom(IceJarPlayer oldPlayer); 58 | Map, Check> getCheckMap(); 59 | 60 | double ij$getViolationLevel(); 61 | 62 | static void broadcast(ServerPlayer player, Check failedCheck) { 63 | final String reportMessage = IceJar.getInstance().getConfig().violations.reportMessage; 64 | final CheckType type = failedCheck.getType(); 65 | final MutableComponent additionalInfo = failedCheck.getAdditionalFlagInfo(); 66 | 67 | final MutableComponent report = ID.copy() 68 | .withStyle(s -> s 69 | .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("Disable %s check for %s.", 70 | Component.literal(type.toString().toLowerCase(Locale.ROOT)).withStyle(ChatFormatting.LIGHT_PURPLE), 71 | player.getName().copy().withStyle(ChatFormatting.GREEN)))) 72 | .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/lp user " + player.getGameProfile().getName() + " permission set icejar.checks.bypass." + type.toString().toLowerCase(Locale.ROOT)))) 73 | .append(Component.translatable(reportMessage, 74 | Component.literal(player.getGameProfile().getName()) 75 | .withStyle(ChatFormatting.GOLD), 76 | Component.literal(type.toString().toLowerCase()) 77 | .withStyle(ChatFormatting.YELLOW) 78 | ) 79 | .withStyle(ChatFormatting.GRAY) 80 | .withStyle(s -> s 81 | .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + player.getGameProfile().getId().toString())) 82 | .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("chat.coordinates.tooltip"))) 83 | )) 84 | .append(Component.literal(" (hover)") 85 | .withStyle(ChatFormatting.ITALIC) 86 | .withStyle(ChatFormatting.BLUE) 87 | .withStyle(s -> s 88 | .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, 89 | Component.translatable("Violation level: %s\nCheck violation level: %s", 90 | Component.literal(String.format("%.2f", ((IceJarPlayer) player).ij$getViolationLevel())) 91 | .withStyle(ChatFormatting.GOLD), 92 | Component.literal(String.format("%.2f", failedCheck.getViolationLevel())) 93 | .withStyle(ChatFormatting.YELLOW) 94 | ) 95 | .append(additionalInfo.getString().isEmpty() ? "" : "\n") 96 | .append(additionalInfo) 97 | ) 98 | ) 99 | )); 100 | 101 | player.getServer().getPlayerList().getPlayers().forEach(p -> { 102 | if (Permissions.check(p, type.getReportPermission(), p.hasPermissions(4))) { 103 | p.sendSystemMessage(report); 104 | } 105 | }); 106 | } 107 | 108 | Map ij_getDelayedPackets(); 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/CheckType.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.samo_lego.icejar.IceJar; 5 | import org.samo_lego.icejar.check.combat.Angle; 6 | import org.samo_lego.icejar.check.combat.Critical; 7 | import org.samo_lego.icejar.check.combat.ImpossibleHit; 8 | import org.samo_lego.icejar.check.combat.NoSwing; 9 | import org.samo_lego.icejar.check.combat.Reach; 10 | import org.samo_lego.icejar.check.inventory.ImpossibleUse; 11 | import org.samo_lego.icejar.check.movement.Derp; 12 | import org.samo_lego.icejar.check.movement.NoFall; 13 | import org.samo_lego.icejar.check.movement.cancellable.FastLadder; 14 | import org.samo_lego.icejar.check.movement.cancellable.NoDeceleration; 15 | import org.samo_lego.icejar.check.movement.cancellable.Timer; 16 | import org.samo_lego.icejar.check.movement.cancellable.WrongRotation; 17 | import org.samo_lego.icejar.check.movement.cancellable.flight.BasicFlight; 18 | import org.samo_lego.icejar.check.movement.cancellable.vehicle.BoatFly; 19 | import org.samo_lego.icejar.check.movement.cancellable.vehicle.EntityControl; 20 | import org.samo_lego.icejar.check.world.block.AirPlace; 21 | import org.samo_lego.icejar.check.world.block.AutoSign; 22 | import org.samo_lego.icejar.check.world.block.BlockDirection; 23 | import org.samo_lego.icejar.check.world.block.BlockFace; 24 | import org.samo_lego.icejar.check.world.block.FakeBlockPos; 25 | import org.samo_lego.icejar.check.world.block.ImpossibleBlockAction; 26 | import org.samo_lego.icejar.check.world.block.ReachBlock; 27 | 28 | import java.util.HashSet; 29 | import java.util.Locale; 30 | import java.util.Set; 31 | 32 | import static org.samo_lego.icejar.IceJar.MOD_ID; 33 | import static org.samo_lego.icejar.check.CheckCategory.ALL_CHECKS; 34 | import static org.samo_lego.icejar.check.CheckCategory.COMBAT; 35 | import static org.samo_lego.icejar.check.CheckCategory.ENTITY_INTERACT; 36 | import static org.samo_lego.icejar.check.CheckCategory.INVENTORY; 37 | import static org.samo_lego.icejar.check.CheckCategory.MOVEMENT_IMMUTABLE; 38 | import static org.samo_lego.icejar.check.CheckCategory.MOVEMENT_MUTABLE; 39 | import static org.samo_lego.icejar.check.CheckCategory.VEHICLE_MOVEMENT; 40 | import static org.samo_lego.icejar.check.CheckCategory.WORLD_BLOCK_BREAK; 41 | import static org.samo_lego.icejar.check.CheckCategory.WORLD_BLOCK_INTERACT; 42 | import static org.samo_lego.icejar.check.CheckCategory.category2checks; 43 | 44 | public enum CheckType { 45 | CMOVEMENT_FAST_LADDER(FastLadder.class, MOVEMENT_MUTABLE), 46 | CMOVEMENT_NO_DECELERATION(NoDeceleration.class, MOVEMENT_MUTABLE), 47 | CMOVEMENT_TIMER(Timer.class, MOVEMENT_MUTABLE), 48 | COMBAT_ANGLE(Angle.class, COMBAT), 49 | 50 | COMBAT_CRITICAL(Critical.class, COMBAT), 51 | COMBAT_IMPOSSIBLEHIT(ImpossibleHit.class, COMBAT), 52 | 53 | COMBAT_NOSWING(NoSwing.class, COMBAT), 54 | COMBAT_REACH(Reach.class, Set.of(COMBAT, ENTITY_INTERACT)), 55 | INVENTORY_IMPOSSIBLE_ITEM_USE(ImpossibleUse.class, INVENTORY), 56 | MOVEMENT_DERP(Derp.class, MOVEMENT_IMMUTABLE), 57 | MOVEMENT_NOFALL(NoFall.class, MOVEMENT_IMMUTABLE), 58 | SPECIAL_JESUS, 59 | VEHICLE_MOVE_BOATFLY(BoatFly.class, VEHICLE_MOVEMENT), 60 | WORLD_BLOCK_AUTOSIGN(AutoSign.class, WORLD_BLOCK_INTERACT), 61 | WORLD_BLOCK_DIRECTION(BlockDirection.class, Set.of(WORLD_BLOCK_INTERACT, WORLD_BLOCK_BREAK)), 62 | WORLD_BLOCK_IMPOSSIBLE_ACTION(ImpossibleBlockAction.class, Set.of(WORLD_BLOCK_BREAK, WORLD_BLOCK_INTERACT)), WORLD_BLOCK_PLACE_AIR(AirPlace.class, WORLD_BLOCK_INTERACT), 63 | WORLD_BLOCK_REACH(ReachBlock.class, Set.of(WORLD_BLOCK_BREAK, WORLD_BLOCK_INTERACT)), 64 | CMOVEMENT_ROTATION(WrongRotation.class, MOVEMENT_MUTABLE), 65 | VEHICLE_MOVE_ENTITY_CONTROL(EntityControl.class, VEHICLE_MOVEMENT), 66 | CMOVEMENT_BASIC_FLIGHT(BasicFlight.class, MOVEMENT_MUTABLE), 67 | WORLD_BLOCK_FACE(BlockFace.class, Set.of(WORLD_BLOCK_BREAK, WORLD_BLOCK_INTERACT)), 68 | WORLD_BLOCK_FAKEPOS(FakeBlockPos.class, WORLD_BLOCK_BREAK); 69 | 70 | private final Class checkClass; 71 | 72 | CheckType(Class checkClass, Iterable categories, boolean exclude) { 73 | this.checkClass = checkClass; 74 | 75 | if (!exclude && categories != null) { 76 | categories.forEach(category -> { 77 | category2checks.computeIfAbsent(category, k -> new HashSet<>()).add(this); 78 | ALL_CHECKS.computeIfAbsent(category, k -> new HashSet<>()).add(this); 79 | }); 80 | } 81 | } 82 | 83 | CheckType(Class checkClass, CheckCategory category) { 84 | this(checkClass, Set.of(category), false); 85 | } 86 | 87 | CheckType(Class checkClass, CheckCategory category, boolean exclude) { 88 | this(checkClass, Set.of(category), exclude); 89 | } 90 | 91 | CheckType() { 92 | this(null, (Iterable) null, true); 93 | } 94 | 95 | CheckType(Class reachBlockClass, Set categories) { 96 | this(reachBlockClass, categories, false); 97 | } 98 | 99 | 100 | @Nullable 101 | @SuppressWarnings("unchecked") 102 | public Class getCheckClass() { 103 | return (Class) this.checkClass; 104 | } 105 | 106 | public String getBypassPermission() { 107 | return MOD_ID + ".checks.bypass." + this.toString().toLowerCase(Locale.ROOT); 108 | } 109 | 110 | public String getReportPermission() { 111 | return MOD_ID + ".checks.get_report." + this.toString().toLowerCase(Locale.ROOT); 112 | } 113 | 114 | public String getTrainPermission() { 115 | return MOD_ID + ".checks.train." + this.toString().toLowerCase(Locale.ROOT); 116 | } 117 | 118 | public boolean isEnabled() { 119 | var cfg = IceJar.getInstance().getConfig().checkConfigs.get(this); 120 | 121 | return cfg != null ? cfg.enabled : IceJar.getInstance().getConfig().DEFAULT.enabled; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/check/combat/CombatCheck.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.check.combat; 2 | 3 | import me.lucko.fabric.api.permissions.v0.Permissions; 4 | import net.minecraft.network.protocol.game.ClientboundAnimatePacket; 5 | import net.minecraft.server.level.ServerPlayer; 6 | import net.minecraft.sounds.SoundEvents; 7 | import net.minecraft.world.InteractionHand; 8 | import net.minecraft.world.InteractionResult; 9 | import net.minecraft.world.damagesource.DamageSource; 10 | import net.minecraft.world.entity.Entity; 11 | import net.minecraft.world.entity.LivingEntity; 12 | import net.minecraft.world.entity.MobType; 13 | import net.minecraft.world.entity.decoration.ArmorStand; 14 | import net.minecraft.world.entity.player.Player; 15 | import net.minecraft.world.item.ItemStack; 16 | import net.minecraft.world.item.SwordItem; 17 | import net.minecraft.world.item.enchantment.EnchantmentHelper; 18 | import net.minecraft.world.level.Level; 19 | import net.minecraft.world.phys.EntityHitResult; 20 | import org.jetbrains.annotations.Nullable; 21 | import org.samo_lego.icejar.IceJar; 22 | import org.samo_lego.icejar.casts.IceJarPlayer; 23 | import org.samo_lego.icejar.check.Check; 24 | import org.samo_lego.icejar.check.CheckType; 25 | import org.samo_lego.icejar.mixin.accessor.ALivingEntity; 26 | import org.samo_lego.icejar.util.DataFaker; 27 | 28 | import java.util.Set; 29 | 30 | import static org.samo_lego.icejar.check.CheckCategory.COMBAT; 31 | import static org.samo_lego.icejar.check.CheckCategory.category2checks; 32 | 33 | public abstract class CombatCheck extends Check { 34 | 35 | /** The maximum distance allowed to interact with an entity in creative mode. */ 36 | public static final double CREATIVE_DISTANCE = 6D; 37 | 38 | public CombatCheck(CheckType checkType, ServerPlayer player) { 39 | super(checkType, player); 40 | } 41 | 42 | public abstract boolean checkCombat(final Level world, final InteractionHand hand, final Entity targetEntity, final EntityHitResult hitResult); 43 | 44 | @Override 45 | public boolean check(Object ... params) { 46 | if (params.length != 4) 47 | throw new IllegalArgumentException("CombatCheck.check() requires 4 parameters"); 48 | 49 | return this.checkCombat((Level) params[0], (InteractionHand) params[1], (Entity) params[2], (EntityHitResult) params[3]); 50 | } 51 | 52 | /** 53 | * Performs hit check. 54 | * @param player player that is attacking. 55 | * @param world world the player is in. 56 | * @param hand hand the player is swinging with. 57 | * @param targetEntity entity that was hit. 58 | * @param hitResult hit result. 59 | * @return {@link InteractionResult} of the hit. 60 | */ 61 | public static InteractionResult performCheck(final Player player, final Level world, final InteractionHand hand, final Entity targetEntity, @Nullable EntityHitResult hitResult) { 62 | final Set checks = category2checks.get(COMBAT); 63 | if (player instanceof ServerPlayer pl && checks != null) { 64 | if (hitResult == null) { 65 | hitResult = new EntityHitResult(targetEntity); 66 | } 67 | // Loop through all combat checks 68 | for (CheckType type : checks) { 69 | if (Permissions.check(player, type.getBypassPermission(), false)) continue; 70 | 71 | final CombatCheck check = ((IceJarPlayer) player).getCheck(type); 72 | 73 | // Check the hit 74 | if (!check.checkCombat(world, hand, targetEntity, hitResult)) { 75 | // Hit was fake. Let's pretend we don't know though :) 76 | if (!(targetEntity instanceof ArmorStand) && targetEntity instanceof LivingEntity le) { 77 | // Send "hurt" to everyone but player that was attacked 78 | DataFaker.broadcast(le, pl, new ClientboundAnimatePacket(targetEntity, ClientboundAnimatePacket.HURT)); 79 | 80 | // Play sound 81 | DataFaker.sendSound(((ALivingEntity) le).getHurtSound(DamageSource.playerAttack(pl)), pl); 82 | } 83 | 84 | check.sendFakeHitData(world, hand, targetEntity, hitResult); 85 | 86 | // Figure out damage modifier to know if magic critical hit packet should be sent as well 87 | ItemStack stack = player.getItemInHand(hand); 88 | 89 | float modifier = targetEntity instanceof LivingEntity ? 90 | EnchantmentHelper.getDamageBonus(stack, ((LivingEntity) targetEntity).getMobType()) : 91 | EnchantmentHelper.getDamageBonus(stack, MobType.UNDEFINED); 92 | 93 | modifier *= player.getAttackStrengthScale(0.5F); 94 | 95 | if (modifier > 0.0f) { 96 | player.magicCrit(targetEntity); // Magic Critical hit 97 | 98 | } 99 | 100 | // Flagging 101 | if (check.increaseCheatAttempts() > check.getMaxAttemptsBeforeFlag()) 102 | check.flag(); 103 | 104 | return IceJar.getInstance().getConfig().debug ? InteractionResult.PASS : InteractionResult.FAIL; 105 | } else { 106 | check.decreaseCheatAttempts(); 107 | } 108 | } 109 | } 110 | 111 | return InteractionResult.PASS; 112 | } 113 | 114 | /** 115 | * Sends additional data to the client to make it show the fake hit. 116 | * @param world world the player is in. 117 | * @param hand hand the player is swinging with. 118 | * @param targetEntity entity that was hit. 119 | * @param hitResult hit result. 120 | */ 121 | protected void sendFakeHitData(final Level world, final InteractionHand hand, final Entity targetEntity, @Nullable EntityHitResult hitResult) { 122 | ItemStack itemStack = player.getItemInHand(InteractionHand.MAIN_HAND); 123 | if (itemStack.getItem() instanceof SwordItem) { 124 | // Send sweep attack sound 125 | DataFaker.sendSound(SoundEvents.PLAYER_ATTACK_SWEEP, player); 126 | player.sweepAttack(); 127 | } 128 | DataFaker.sendSound(SoundEvents.PLAYER_ATTACK_STRONG, player); 129 | } 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/mixin/ServerPlayerMixin.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.mixin; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; 5 | import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; 6 | import net.minecraft.server.level.ServerPlayer; 7 | import net.minecraft.util.Mth; 8 | import net.minecraft.world.level.ChunkPos; 9 | import net.minecraft.world.phys.Vec2; 10 | import net.minecraft.world.phys.Vec3; 11 | import org.samo_lego.icejar.IceJar; 12 | import org.samo_lego.icejar.casts.IceJarPlayer; 13 | import org.samo_lego.icejar.check.Check; 14 | import org.samo_lego.icejar.check.CheckType; 15 | import org.samo_lego.icejar.config.IceConfig; 16 | import org.spongepowered.asm.mixin.Mixin; 17 | import org.spongepowered.asm.mixin.Unique; 18 | import org.spongepowered.asm.mixin.injection.At; 19 | import org.spongepowered.asm.mixin.injection.Inject; 20 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 21 | 22 | import java.lang.reflect.InvocationTargetException; 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | import java.util.concurrent.ConcurrentHashMap; 26 | 27 | import static org.samo_lego.icejar.check.CheckCategory.category2checks; 28 | 29 | @Mixin(ServerPlayer.class) 30 | public abstract class ServerPlayerMixin implements IceJarPlayer { 31 | 32 | @Unique 33 | private Map, Check> playerChecks = new HashMap<>(); 34 | @Unique 35 | private final ServerPlayer player = (ServerPlayer) (Object) this; 36 | @Unique 37 | private boolean guiOpen = false; 38 | @Unique 39 | private boolean ij$onGround, wasOnGround, wasLastOnGround, aboveLiquid; 40 | @Unique 41 | private Vec3 vehicleMovement, 42 | lastVehicleMovement, 43 | lastMovement, 44 | movement, 45 | last2Movement; 46 | @Unique 47 | private double violationLevel; 48 | @Unique 49 | private Vec2 rotation, lastRotation, last2Rotation; 50 | @Unique 51 | private final Map delayedChunkPackets = new ConcurrentHashMap<>(); 52 | 53 | @Override 54 | public T getCheck(CheckType checkType) { 55 | return this.getCheck(checkType.getCheckClass()); 56 | } 57 | 58 | @SuppressWarnings("unchecked") 59 | @Override 60 | public T getCheck(Class checkClass) { 61 | T check = (T) this.playerChecks.get(checkClass); 62 | if (check == null) { 63 | // Create new check from type 64 | try { 65 | check = checkClass.getConstructor(ServerPlayer.class).newInstance(this.player); 66 | this.playerChecks.put(checkClass, check); 67 | } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { 68 | e.printStackTrace(); 69 | } 70 | } 71 | 72 | return check; 73 | } 74 | 75 | @Override 76 | public void flag(final Check check) { 77 | // See if cooldown is still active on check 78 | final long now = System.currentTimeMillis(); 79 | final long timeDelta = now - check.getLastFlagTime(); 80 | 81 | if (check.getCooldown() < timeDelta) { 82 | final double prevLvl = check.getViolationLevel(); 83 | final double newLvl = check.increaseViolationLevel(); 84 | final double max = check.getMaxViolationLevel(); 85 | if (newLvl > max && max > 0 && !IceJar.getInstance().getConfig().debug) { 86 | check.executeAction(); 87 | } else { 88 | this.violationLevel += (newLvl - prevLvl) / category2checks.keySet().size(); 89 | final IceConfig config = IceJar.getInstance().getConfig(); 90 | final double maxLevel = config.violations.maxLevel; 91 | 92 | if (this.violationLevel > maxLevel && maxLevel > 0) { 93 | // Execute action for global violation 94 | if (!IceJar.getInstance().getConfig().debug) { 95 | check.executeAction(); 96 | } 97 | 98 | if (config.violations.command != null) { 99 | config.violations.action.executeCommand(this.player, config.violations.command); 100 | } 101 | this.violationLevel = 0; 102 | } 103 | } 104 | 105 | IceJarPlayer.broadcast(this.player, check); 106 | 107 | check.setLastFlagTime(now); 108 | check.setCheatAttempts(0); 109 | } 110 | } 111 | 112 | @Override 113 | public void ij$setOpenGUI(boolean open) { 114 | this.guiOpen = open; 115 | } 116 | 117 | @Override 118 | public boolean ij$hasOpenGui() { 119 | return this.guiOpen; 120 | } 121 | 122 | @Override 123 | public boolean ij$nearGround() { 124 | return this.wasLastOnGround || this.wasOnGround || this.ij$onGround; 125 | } 126 | 127 | @Override 128 | public void ij$setOnGround(boolean ij$onGround) { 129 | this.ij$onGround = ij$onGround; 130 | } 131 | 132 | @Override 133 | public void ij$updateGroundStatus() { 134 | this.wasLastOnGround = this.wasOnGround; 135 | this.wasOnGround = this.ij$onGround; 136 | } 137 | 138 | @Override 139 | public void ij$setVehicleMovement(ServerboundMoveVehiclePacket packet) { 140 | this.lastVehicleMovement = this.vehicleMovement; 141 | this.vehicleMovement = new Vec3(packet.getX(), packet.getY(), packet.getZ()); 142 | } 143 | 144 | @Override 145 | public Vec3 ij$getLastVehicleMovement() { 146 | return lastVehicleMovement; 147 | } 148 | 149 | @Override 150 | public Vec3 ij$getVehicleMovement() { 151 | return vehicleMovement; 152 | } 153 | 154 | @Override 155 | public void ij$setMovement(ServerboundMovePlayerPacket packet) { 156 | this.last2Movement = this.lastMovement; 157 | this.lastMovement = this.movement; 158 | this.movement = new Vec3(packet.getX(this.player.getX()), packet.getY(this.player.getY()), packet.getZ(this.player.getZ())); 159 | } 160 | 161 | @Override 162 | public Vec3 ij$getLast2Movement() { 163 | return this.last2Movement; 164 | } 165 | 166 | @Override 167 | public Vec3 ij$getLastMovement() { 168 | return this.lastMovement; 169 | } 170 | 171 | @Override 172 | public Vec3 ij$getMovement() { 173 | return this.movement; 174 | } 175 | 176 | @Override 177 | public void ij$setAboveLiquid(boolean aboveLiquid) { 178 | this.aboveLiquid = aboveLiquid; 179 | } 180 | 181 | @Override 182 | public boolean ij$aboveLiquid() { 183 | return this.aboveLiquid; 184 | } 185 | 186 | @Override 187 | public void ij$setRotation(ServerboundMovePlayerPacket packet) { 188 | this.last2Rotation = this.lastRotation; 189 | this.lastRotation = this.rotation; 190 | this.rotation = new Vec2(Mth.wrapDegrees(packet.getYRot(this.player.getYRot())) % 360.0f, 191 | Mth.clamp(Mth.wrapDegrees(packet.getXRot(this.player.getXRot())), 192 | -90.0F, 193 | 90.0F) % 194 | 360.0f); 195 | } 196 | 197 | @Override 198 | public Vec2 ij$getLast2Rotation() { 199 | return this.last2Rotation; 200 | } 201 | 202 | @Override 203 | public Vec2 ij$getLastRotation() { 204 | return this.lastRotation; 205 | } 206 | 207 | @Override 208 | public Vec2 ij$getRotation() { 209 | return this.rotation; 210 | } 211 | 212 | @Override 213 | public void ij$copyFrom(IceJarPlayer oldPlayer) { 214 | this.violationLevel = oldPlayer.ij$getViolationLevel(); 215 | this.playerChecks = oldPlayer.getCheckMap(); 216 | this.playerChecks.forEach((checkType, check) -> check.setPlayer(this.player)); 217 | } 218 | 219 | @Override 220 | public Map, Check> getCheckMap() { 221 | return this.playerChecks; 222 | } 223 | 224 | @Override 225 | public double ij$getViolationLevel() { 226 | return this.violationLevel; 227 | } 228 | 229 | @Override 230 | public Map ij_getDelayedPackets() { 231 | return this.delayedChunkPackets; 232 | } 233 | 234 | @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) 235 | private void onSave(CompoundTag nbt, CallbackInfo ci) { 236 | final CompoundTag data = new CompoundTag(); 237 | data.putDouble("violationLevel", this.violationLevel); 238 | nbt.put("IceJar", data); 239 | } 240 | 241 | @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) 242 | private void onLoad(CompoundTag nbt, CallbackInfo ci) { 243 | if (nbt.contains("IceJar")) { 244 | final CompoundTag data = nbt.getCompound("IceJar"); 245 | this.violationLevel = data.getDouble("violationLevel"); 246 | } 247 | } 248 | } 249 | -------------------------------------------------------------------------------- /src/main/java/org/samo_lego/icejar/config/IceConfig.java: -------------------------------------------------------------------------------- 1 | package org.samo_lego.icejar.config; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.google.gson.annotations.SerializedName; 6 | import org.samo_lego.config2brigadier.IBrigadierConfigurator; 7 | import org.samo_lego.config2brigadier.annotation.BrigadierDescription; 8 | import org.samo_lego.icejar.IceJar; 9 | import org.samo_lego.icejar.check.Check; 10 | import org.samo_lego.icejar.check.CheckType; 11 | import org.samo_lego.icejar.util.ActionTypes; 12 | 13 | import java.io.BufferedReader; 14 | import java.io.File; 15 | import java.io.FileInputStream; 16 | import java.io.FileOutputStream; 17 | import java.io.IOException; 18 | import java.io.InputStreamReader; 19 | import java.io.OutputStreamWriter; 20 | import java.io.Writer; 21 | import java.nio.charset.StandardCharsets; 22 | import java.util.ArrayList; 23 | import java.util.Arrays; 24 | import java.util.HashMap; 25 | import java.util.List; 26 | import java.util.Map; 27 | 28 | import static org.samo_lego.icejar.IceJar.MOD_ID; 29 | import static org.samo_lego.icejar.check.CheckCategory.reloadEnabledChecks; 30 | import static org.samo_lego.icejar.check.CheckType.MOVEMENT_NOFALL; 31 | import static org.samo_lego.icejar.check.CheckType.VEHICLE_MOVE_BOATFLY; 32 | import static org.samo_lego.icejar.check.CheckType.WORLD_BLOCK_DIRECTION; 33 | import static org.samo_lego.icejar.check.CheckType.WORLD_BLOCK_PLACE_AIR; 34 | import static org.slf4j.LoggerFactory.getLogger; 35 | 36 | public class IceConfig implements IBrigadierConfigurator { 37 | 38 | 39 | private static final Gson GSON = new GsonBuilder() 40 | .setPrettyPrinting() 41 | .setLenient() 42 | .serializeNulls() 43 | .disableHtmlEscaping() 44 | .create(); 45 | 46 | @SerializedName("default_check_configuration") 47 | public final CheckConfig DEFAULT = new CheckConfig(); 48 | 49 | 50 | public Fixes fixes = new Fixes(); 51 | 52 | public static class Fixes { 53 | @SerializedName("// Whether to make some changes to world generation and fluid spreading to patch 'newChunks' exploit.") 54 | public final String _comment_newChunks = ""; 55 | @BrigadierDescription(defaultOption = "true") 56 | public boolean newChunks = true; 57 | } 58 | 59 | public Combat combat = new Combat(); 60 | 61 | public static class Combat { 62 | @SerializedName("max_survival_distance") 63 | public double maxSurvivalDistance = 5.2D; 64 | } 65 | 66 | 67 | public World world = new World(); 68 | 69 | public static class World { 70 | public double maxBlockReachDistance = 6.0D; 71 | public double direction = 0.8D; 72 | } 73 | 74 | @SerializedName("// Global violation settings") 75 | public final String _comment_violations = ""; 76 | public Violations violations = new Violations(); 77 | 78 | public static class Violations { 79 | @SerializedName("// Maximum violation level from checks, calculated from all violations") 80 | public final String _comment_maxLevel0 = ""; 81 | @SerializedName("// and averaged. Can be -1 as well.") 82 | public final String _comment_maxLevel1 = ""; 83 | @SerializedName("max_level") 84 | public double maxLevel = Math.round(6000.0D / (CheckType.values().length)) / 100.0D; 85 | public ActionTypes action = ActionTypes.KICK; 86 | @SerializedName("punish_command") 87 | public String command = null; 88 | 89 | 90 | @SerializedName("report_message") 91 | public String reportMessage = "%s failed %s check."; 92 | @SerializedName("// Default permission lvl to send reports to, if permission is not set.") 93 | public final String _comment_defaultReportPermissionLevel = ""; 94 | @SerializedName("default_report_permission_lvl") 95 | public int defaultReportPermissionLevel = 4; 96 | } 97 | 98 | public Movement movement = new Movement(); 99 | public static class Movement { 100 | public long timerThreshold = 250L; 101 | public double vehicleYThreshold = 0D; 102 | 103 | public float entityControlDifference = 0.5F; 104 | public EntityControlProperties entityControl = new EntityControlProperties(); 105 | public short maxAirTicks = 10; 106 | 107 | public static class EntityControlProperties { 108 | public double diffY = 0D; 109 | public double diffX = 0D; 110 | } 111 | 112 | public double maxRotationDiff = 110D; 113 | 114 | public Ladder ladder = new Ladder(); 115 | 116 | 117 | public static class Ladder { 118 | public double speedUpMax = 0.12D; 119 | public double speedDownMax = -0.23D; 120 | } 121 | 122 | public Speed speed = new Speed(); 123 | public static class Speed { 124 | public double minYawDifference = 1.5D; 125 | public double minDeceleration = 1.4E-6D; 126 | } 127 | } 128 | 129 | public static class CheckConfig { 130 | public ActionTypes action; 131 | @SerializedName("flag_cooldown") 132 | public long cooldown; 133 | @SerializedName("attempts_to_flag") 134 | public int attemptsToFlag; 135 | @SerializedName("violation_increase") 136 | public double violationIncrease; 137 | @SerializedName("max_violation_level") 138 | public double maxViolationLevel; 139 | public boolean enabled; 140 | @SerializedName("// Command to execute on on flag after ACTION.") 141 | public final String _comment_command0 = ""; 142 | @SerializedName("// Available placeholders: ${player}, ${uuid}, ${ip}, ${check}.") 143 | public final String _comment_command1 = ""; 144 | @SerializedName("punish_command") 145 | public String command; 146 | @SerializedName("train_mode") 147 | public boolean trainMode; 148 | 149 | public CheckConfig() { 150 | this(500, 1, 1, -1, true); 151 | } 152 | public CheckConfig(long cooldown, int attemptsToFlag, double violationIncrease, double maxViolationLevel, boolean enabled) { 153 | this.cooldown = cooldown; 154 | this.attemptsToFlag = attemptsToFlag; 155 | this.violationIncrease = violationIncrease; 156 | this.maxViolationLevel = maxViolationLevel; 157 | this.enabled = enabled; 158 | this.action = ActionTypes.NONE; 159 | this.command = null; 160 | this.trainMode = false; 161 | } 162 | } 163 | 164 | @SerializedName("check_configurations") 165 | public HashMap checkConfigs = new HashMap<>(Map.of( 166 | MOVEMENT_NOFALL, new CheckConfig(500, 5, 1, -1, true), 167 | VEHICLE_MOVE_BOATFLY, new CheckConfig(200, 40, 1, -1, true), 168 | WORLD_BLOCK_PLACE_AIR, new CheckConfig(200, 1, CheckType.values().length / 2.0D, -1, true), 169 | WORLD_BLOCK_DIRECTION, new CheckConfig(200, 1, CheckType.values().length / 2.0D, -1, true) 170 | )); 171 | 172 | 173 | /** 174 | * Which messages should be used when kicking client on cheat attempts. 175 | * Messages are chosen randomly. 176 | */ 177 | @SerializedName("kick_messages") 178 | public List kickMessages = new ArrayList<>(Arrays.asList( 179 | "Only who dares wins!", 180 | "Bad Liar ...", 181 | "No risk it, no biscuit!", 182 | "Playing God? How about no?", 183 | "Who flies high falls low.", 184 | "If you cheat, you only cheat yourself.", 185 | "Hax bad.", 186 | "You better check your client. It seems to be lying.", 187 | "If you have great power, you should\n use it with even greater responsibility." 188 | )); 189 | 190 | @SerializedName("// Whether to 'learn' valid values from the clients connected. E.g. max speed, vehicle speed, etc.") 191 | public final String _comment_trainMode0 = ""; 192 | @SerializedName("// WARNING: Use for testing purposes only. Do not use in production.") 193 | public final String _comment_trainMode1 = ""; 194 | @SerializedName("universal_train_mode") 195 | public boolean trainMode = true; 196 | 197 | @SerializedName("// Whether to still report failed checks but not prevent them.") 198 | public final String _comment_debug = ""; 199 | @SerializedName("universal_debug_mode") 200 | public boolean debug = true; 201 | 202 | /** 203 | * Loads config file. 204 | * 205 | * @param file file to load the language file from. 206 | * @return config object 207 | */ 208 | public static IceConfig loadConfigFile(File file) { 209 | IceConfig config = null; 210 | if (file.exists()) { 211 | try (BufferedReader fileReader = new BufferedReader( 212 | new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8) 213 | )) { 214 | config = GSON.fromJson(fileReader, IceConfig.class); 215 | } catch (IOException e) { 216 | throw new RuntimeException(MOD_ID + " Problem occurred when trying to load config: ", e); 217 | } 218 | } 219 | if (config == null) { 220 | config = new IceConfig(); 221 | } 222 | 223 | for (CheckType checkType : CheckType.values()) { 224 | if (!config.checkConfigs.containsKey(checkType)) { 225 | config.checkConfigs.put(checkType, new CheckConfig()); 226 | } 227 | } 228 | 229 | config.saveConfigFile(file); 230 | 231 | return config; 232 | } 233 | 234 | public static CheckConfig getCheckOptions(CheckType type) { 235 | final IceConfig config = IceJar.getInstance().getConfig(); 236 | return config.checkConfigs.getOrDefault(type, config.DEFAULT); 237 | } 238 | 239 | public static CheckConfig getCheckOptions(Check check) { 240 | return getCheckOptions(check.getType()); 241 | } 242 | 243 | /** 244 | * Saves the config to the given file. 245 | * 246 | * @param file file to save config to 247 | */ 248 | public void saveConfigFile(File file) { 249 | try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) { 250 | GSON.toJson(this, writer); 251 | } catch (IOException e) { 252 | getLogger(MOD_ID).error("Problem occurred when saving config: " + e.getMessage()); 253 | } 254 | } 255 | 256 | /** 257 | * Changes values of current object with reflection, 258 | * in order to keep the same object. 259 | * (that still allows in-game editing) 260 | */ 261 | public void reload(File file) { 262 | IceConfig newConfig = loadConfigFile(file); 263 | this.checkConfigs = newConfig.checkConfigs; // reloading by hand 264 | this.reload(newConfig); 265 | this.save(); 266 | reloadEnabledChecks(); 267 | } 268 | 269 | 270 | @Override 271 | public void save() { 272 | this.saveConfigFile(IceJar.getInstance().getConfigFile()); 273 | } 274 | } 275 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------