Skip to content

Commit

Permalink
Reformat Code
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrix-Shen committed Mar 11, 2023
1 parent 44915c8 commit df9c4c0
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class MixinMinecraft {
),
cancellable = true
)
//#if MC >= 11800
//#if MC > 11701
private void onStartAttack(CallbackInfoReturnable<Boolean> cir) {
//#else
//$$ private void onStartAttack(CallbackInfo cir) {
//$$ private void onStartAttack(CallbackInfo ci) {
//#endif
if (this.hitResult != null && this.player != null) {
Entity entity = ((EntityHitResult) hitResult).getEntity();
Expand All @@ -56,7 +56,11 @@ private void onStartAttack(CallbackInfoReturnable<Boolean> cir) {
String entityName = entity.getName().getString();
if (Configs.disableAttackEntity && Configs.listDisableAttackEntity.stream().anyMatch(s -> entityID.contains(s) || entityName.contains(s))) {
player.swing(InteractionHand.MAIN_HAND);
cir.cancel();
//#if MC > 11701
cir.setReturnValue(false);
//#else
//$$ ci.cancel();
//#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ private void onShouldRender(Entity entity, Frustum frustum, double d, double e,
//#endif
String entityName = entity.getName().getString();
if (Configs.listDisableClientEntityRendering.stream().anyMatch(s -> entityID.contains(s) || entityName.contains(s)) && !(entity instanceof Player)) {
cir.cancel();
cir.setReturnValue(false);
}
}

if ((Configs.disableClientEntityTNTUpdates && entity.getType() == EntityType.TNT)
|| (Configs.disableClientEntityWitherUpdates && entity.getType() == EntityType.WITHER)
|| (Configs.disableClientEntityZombieVillagerUpdates && entity.getType() == EntityType.ZOMBIE_VILLAGER)) {
cir.cancel();
cir.setReturnValue(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ private void onRenderCrystalBeams(EnderDragon enderDragon, float f, float g, Pos
if (Configs.crystalBeamsDisableMode == CrystalBeamsDisableMode.FIXED) {
return;
}
//#if MC >= 11500

//#if MC >= 11500
poseStack.popPose();
super.render(enderDragon, f, g, poseStack, multiBufferSource, i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class MixinGui {
cancellable = true
)
private void onRenderPowderSnowOverlay(ResourceLocation resourceLocation, float f, CallbackInfo ci) {
if (Configs.disableRenderOverlayPowderSnow && resourceLocation == POWDER_SNOW_OUTLINE_LOCATION) {
if (Configs.disableRenderOverlayPowderSnow && resourceLocation.equals(POWDER_SNOW_OUTLINE_LOCATION)) {
ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class MixinGui {
)
//#if MC > 11700
private void onRenderTextureOverlay(ResourceLocation resourceLocation, float f, CallbackInfo ci) {
if (Configs.disableRenderOverlayPumpkin && resourceLocation == PUMPKIN_BLUR_LOCATION) {
if (Configs.disableRenderOverlayPumpkin && resourceLocation.equals(PUMPKIN_BLUR_LOCATION)) {
//#else
//$$ private void onRenderPumpkinOverlay(CallbackInfo ci) {
//$$ if (Configs.disableRenderOverlayPumpkin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
//#endif
import top.hendrixshen.tweakmyclient.config.Configs;
import top.hendrixshen.tweakmyclient.util.MiscUtil;

@Mixin(Entity.class)
public class MixinEntity {
Expand All @@ -37,6 +38,7 @@ private Vec3 onGetStuckSpeedMultiplier(Entity instance) {
}

//#if MC >= 11500
@SuppressWarnings("ConstantConditions")
@Inject(
method = "getBlockSpeedFactor",
at = @At(
Expand All @@ -46,7 +48,7 @@ private Vec3 onGetStuckSpeedMultiplier(Entity instance) {
cancellable = true
)
private void onGetBlockSpeedFactor(CallbackInfoReturnable<Float> cir) {
if (Configs.disableSlowdown && (Object) this instanceof LocalPlayer && cir.getReturnValueF() < 1.0F) {
if (Configs.disableSlowdown && MiscUtil.cast(this) instanceof LocalPlayer && cir.getReturnValueF() < 1.0F) {
cir.setReturnValue(1.0F);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Slice;
import top.hendrixshen.tweakmyclient.config.Configs;
import top.hendrixshen.tweakmyclient.util.MiscUtil;

@Mixin(LivingEntity.class)
public abstract class MixinLivingEntity extends Entity {
public MixinLivingEntity(EntityType<?> entityType, Level level) {
super(entityType, level);
}

@SuppressWarnings("ConstantConditions")
@ModifyVariable(
method = "travel",
at = @At(
Expand All @@ -43,7 +45,7 @@ public MixinLivingEntity(EntityType<?> entityType, Level level) {
ordinal = 0
)
private float onGetFriction(float f) {
if (Configs.disableSlowdown && (Object) this instanceof LocalPlayer && !this.isInWater() && f > 0.6F) {
if (Configs.disableSlowdown && MiscUtil.cast(this) instanceof LocalPlayer && !this.isInWater() && f > 0.6F) {
return 0.6F;
}
return f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import top.hendrixshen.tweakmyclient.config.Configs;
import top.hendrixshen.tweakmyclient.util.MiscUtil;

@Mixin(Player.class)
public abstract class MixinPlayer {
@SuppressWarnings("ConstantConditions")
@Inject(
method = "isSwimming",
at = @At(
Expand All @@ -18,7 +20,7 @@ public abstract class MixinPlayer {
cancellable = true
)
private void isSwimming(CallbackInfoReturnable<Boolean> cir) {
if (Configs.disableSwimming && (Object) this instanceof LocalPlayer) {
if (Configs.disableSwimming && MiscUtil.cast(this) instanceof LocalPlayer) {
cir.setReturnValue(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class MixinMinecraft {
//$$ AutoReconnectUtil.ReconnectTimer = Configs.autoReconnectTimer * 20;
//$$ if (serverData != null) {
//$$ AutoReconnectUtil.setLastServer(serverData);
//$$ }
//$$ }
//$$ }
//#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public boolean checkOpenWaterAround(BlockPos pos) {
return this.calculateOpenWater(pos);
}

@Shadow protected abstract boolean calculateOpenWater(BlockPos blockPos);
@Shadow
protected abstract boolean calculateOpenWater(BlockPos blockPos);
//#endif
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
package top.hendrixshen.tweakmyclient.mixin.patch.disableResourcePackCompatCheck;

import net.minecraft.client.Options;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackRepository;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import top.hendrixshen.tweakmyclient.TweakMyClient;

import java.util.List;
// Disable remove incompatible resource pack.
import java.util.Iterator;
import java.util.Set;

@Mixin(Options.class)
public class MixinOptions {
@Shadow public List<String> incompatibleResourcePacks;

@ModifyArg(
@Inject(
method = "loadSelectedResourcePacks",
at = @At(
value = "INVOKE",
target = "Ljava/util/List;contains(Ljava/lang/Object;)Z",
ordinal = 0,
target = "Ljava/util/Iterator;remove()V",
ordinal = 1,
remap = false
)
),
locals = LocalCapture.CAPTURE_FAILHARD
)
private Object on(Object o) {
this.incompatibleResourcePacks.add((String) o);
TweakMyClient.getLogger().warn("Prevented the removal of incompatible resource pack {} from options", o);
return o;
private void onRemovePack(PackRepository packRepository, CallbackInfo ci, @NotNull Set<String> set, Iterator<String> iterator, String string, @NotNull Pack pack) {
// We forcefully prevent the removal of incompatible resource packages here
// without doing any configuration checks, because at this point Malilib
// has not yet loaded the configuration file.
set.add(pack.getId());
TweakMyClient.getLogger().warn("Prevented the removal of incompatible resource pack {} from options", iterator);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import top.hendrixshen.tweakmyclient.config.Configs;

public class MiscUtil {
public class MiscUtil extends top.hendrixshen.magiclib.util.MiscUtil {
public static VoxelShape linkedBlockAdapter(ClientLevel clientLevel, BlockState blockState, BlockPos blockPos, VoxelShape shape) {
try {
if (blockState.getBlock() instanceof ChestBlock) {
Expand Down

0 comments on commit df9c4c0

Please sign in to comment.