Skip to content

Commit

Permalink
Fixed ViaVersion block sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetchnoblade committed Aug 20, 2023
1 parent 6acdcd3 commit 45e354f
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 104 deletions.
19 changes: 15 additions & 4 deletions NightX.iws
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@
</component>
<component name="ChangeListManager">
<list default="true" id="af093b99-5942-419c-869b-8b2d7cb4dd2a" name="変更" comment="">
<change afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinWorld.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/item/MixinItemBlock.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/protocol/AttackFix.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/NightX.iws" beforeDir="false" afterPath="$PROJECT_DIR$/NightX.iws" afterDir="false" />
<change beforePath="$PROJECT_DIR$/downloads.json" beforeDir="false" afterPath="$PROJECT_DIR$/downloads.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/Client.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/Client.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/util/connection/CheckConnection.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/util/connection/CheckConnection.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/features/module/impl/combat/KillAura.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/features/module/impl/combat/KillAura.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLadder.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLadder.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLilyPad.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/block/MixinBlockLilyPad.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/client/MixinMinecraft.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/client/MixinMinecraft.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityLivingBase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/entity/MixinEntityLivingBase.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiDisconnected.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiDisconnected.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiMultiplayer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/aspw/client/injection/forge/mixins/gui/MixinGuiMultiplayer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/protocol/ViaPatcher.kt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/aspw/client/visual/client/GuiProtocolFixer.kt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/client.forge.mixins.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/client.forge.mixins.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/web/beta.txt" beforeDir="false" afterPath="$PROJECT_DIR$/web/beta.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/web/release.txt" beforeDir="false" afterPath="$PROJECT_DIR$/web/release.txt" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
Expand Down Expand Up @@ -49,8 +60,8 @@
<option name="RECENT_TEMPLATES">
<list>
<option value="Interface" />
<option value="Class" />
<option value="Kotlin Class" />
<option value="Class" />
</list>
</option>
</component>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/aspw/client/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import kotlin.concurrent.thread
object Client {

// Client information
private const val isBeta = false
private const val isBeta = true
const val CLIENT_BEST = "NightX"
const val CLIENT_FOLDER = "NightX-Max"
const val CLIENT_VERSION = "Release B62"
const val CLIENT_VERSION = "Beta B63"
const val CLIENT_CREATOR = "As_pw, outaokura"
const val CLIENT_BASE = "https://nightx.skidded.host/s/"
const val CLIENT_WEBSITE = "i4vvayd263"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import net.aspw.client.features.module.impl.targets.AntiBots
import net.aspw.client.features.module.impl.targets.AntiTeams
import net.aspw.client.features.module.impl.visual.Tracers
import net.aspw.client.protocol.Protocol
import net.aspw.client.protocol.ViaPatcher
import net.aspw.client.util.*
import net.aspw.client.util.extensions.getDistanceToEntityBox
import net.aspw.client.util.extensions.getNearestPointBB
Expand Down Expand Up @@ -768,7 +767,7 @@ class KillAura : Module() {
markEntity = entity

// Attack target
if (ViaPatcher.killAuraFix && Protocol.versionSlider.sliderVersion.getName() != "1.8.x")
if (Protocol.versionSlider.sliderVersion.getName() != "1.8.x")
mc.netHandler.addToSendQueue(C02PacketUseEntity(entity, C02PacketUseEntity.Action.ATTACK))

when (swingValue.get().lowercase(Locale.getDefault())) {
Expand All @@ -782,7 +781,7 @@ class KillAura : Module() {
"packet" -> mc.netHandler.addToSendQueue(C0APacketAnimation())
}

if (ViaPatcher.killAuraFix && Protocol.versionSlider.sliderVersion.getName() == "1.8.x")
if (Protocol.versionSlider.sliderVersion.getName() == "1.8.x")
mc.netHandler.addToSendQueue(C02PacketUseEntity(entity, C02PacketUseEntity.Action.ATTACK))

if (checkSprintValue.get())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.aspw.client.injection.forge.mixins.block;

import net.aspw.client.protocol.Protocol;
import net.aspw.client.protocol.ViaPatcher;
import net.minecraft.block.BlockLadder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
Expand All @@ -15,7 +14,7 @@ public abstract class MixinBlockLadder extends MixinBlock {

@ModifyConstant(method = "setBlockBoundsBasedOnState", constant = @Constant(floatValue = 0.125F))
private float ViaVersion_LadderBB(float constant) {
if (ViaPatcher.INSTANCE.getLadderFix() && !Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x"))
if (!Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x"))
return 0.1875F;
return 0.125F;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.aspw.client.injection.forge.mixins.block;

import net.aspw.client.protocol.Protocol;
import net.aspw.client.protocol.ViaPatcher;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockLilyPad;
import net.minecraft.block.state.IBlockState;
Expand All @@ -23,7 +22,7 @@ public abstract class MixinBlockLilyPad extends BlockBush {
*/
@Overwrite
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) {
if (ViaPatcher.INSTANCE.getLilyPadFix() && !Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x"))
if (!Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x"))
return new AxisAlignedBB((double) pos.getX() + 0.0625D, (double) pos.getY() + 0.0D, (double) pos.getZ() + 0.0625D, (double) pos.getX() + 0.9375D, (double) pos.getY() + 0.09375D, (double) pos.getZ() + 0.9375D);
return new AxisAlignedBB((double) pos.getX() + 0.0D, (double) pos.getY() + 0.0D, (double) pos.getZ() + 0.0D, (double) pos.getX() + 1.0D, (double) pos.getY() + 0.015625D, (double) pos.getZ() + 1.0D);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package net.aspw.client.injection.forge.mixins.block;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(World.class)
public abstract class MixinWorld implements IBlockAccess {

/**
* @author As_pw
* @reason Fix Destroy Sounds
*/
@Overwrite
public boolean destroyBlock(BlockPos pos, boolean dropBlock) {
IBlockState iblockstate = Minecraft.getMinecraft().theWorld.getBlockState(pos);
Block block = iblockstate.getBlock();

// Moving playAusSFX out of else-statement to play sound correctly (For some reason block.getMaterial() always returns Material.air on 1.9+ protocols)
// This should also function correctly on 1.8.x protocol, so no need for base version checks
Minecraft.getMinecraft().theWorld.playAuxSFX(2001, pos, Block.getStateId(iblockstate));

if (block.getMaterial() == Material.air) {
return false;
} else {
if (dropBlock) {
block.dropBlockAsItem(Minecraft.getMinecraft().theWorld, pos, iblockstate, 0);
}

return Minecraft.getMinecraft().theWorld.setBlockState(pos, Blocks.air.getDefaultState(), 3);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.aspw.client.features.module.impl.visual.Animations;
import net.aspw.client.features.module.impl.visual.OptiFinePlus;
import net.aspw.client.injection.forge.mixins.accessors.MinecraftForgeClientAccessor;
import net.aspw.client.protocol.AttackFix;
import net.aspw.client.protocol.Protocol;
import net.aspw.client.util.CPSCounter;
import net.aspw.client.util.render.RenderUtils;
Expand All @@ -25,6 +26,7 @@
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.stream.IStream;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.client.MinecraftForgeClient;
Expand Down Expand Up @@ -199,6 +201,14 @@ private void clickMouse(CallbackInfo callbackInfo) {
else if (this.leftClickCounter <= 10 && this.objectMouseOver == null) leftClickCounter = 10;
}

@Redirect(
method = "clickMouse",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/PlayerControllerMP;attackEntity(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/entity/Entity;)V")
)
private void fixAttackOrder_VanillaAttack(PlayerControllerMP instance, EntityPlayer p_attackEntity_1_, Entity p_attackEntity_2_) {
AttackFix.sendFixedAttack(this.thePlayer, this.objectMouseOver.entityHit);
}

@Inject(method = "middleClickMouse", at = @At("HEAD"))
private void middleClickMouse(CallbackInfo ci) {
CPSCounter.registerClick(CPSCounter.MouseButton.MIDDLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.aspw.client.features.module.impl.movement.Flight;
import net.aspw.client.features.module.impl.other.InfinitePitch;
import net.aspw.client.protocol.Protocol;
import net.aspw.client.protocol.ViaPatcher;
import net.aspw.client.util.EntityUtils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
Expand Down Expand Up @@ -364,12 +363,12 @@ private void getCollisionBorderSize(final CallbackInfoReturnable<Float> callback
final HitBox hitBoxes = Objects.requireNonNull(Client.moduleManager.getModule(HitBox.class));

if (hitBoxes.getState() && EntityUtils.isSelected(((Entity) ((Object) this)), true)) {
if (ViaPatcher.INSTANCE.getEntityFix() && !Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x")) {
if (!Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x")) {
callbackInfoReturnable.setReturnValue(hitBoxes.getSizeValue().get());
} else {
callbackInfoReturnable.setReturnValue(0.1F + hitBoxes.getSizeValue().get());
}
} else if (ViaPatcher.INSTANCE.getEntityFix() && !Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x")) {
} else if (!Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x")) {
callbackInfoReturnable.setReturnValue(0.0F);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.aspw.client.features.module.impl.visual.AntiBlind;
import net.aspw.client.features.module.impl.visual.SilentView;
import net.aspw.client.protocol.Protocol;
import net.aspw.client.protocol.ViaPatcher;
import net.aspw.client.util.MovementUtils;
import net.aspw.client.util.RotationUtils;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -273,7 +272,7 @@ private void isPotionActive(Potion p_isPotionActive_1_, final CallbackInfoReturn

@ModifyConstant(method = "onLivingUpdate", constant = @Constant(doubleValue = 0.005D))
private double ViaVersion_MovementThreshold(double constant) {
if (ViaPatcher.INSTANCE.getLivingBaseFix() && !Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x"))
if (!Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x"))
return 0.003D;
return 0.005D;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.aspw.client.util.SessionUtils;
import net.aspw.client.util.misc.RandomUtils;
import net.aspw.client.visual.client.GuiMainMenu;
import net.aspw.client.visual.client.GuiProtocolFixer;
import net.aspw.client.visual.client.GuiProxyManager;
import net.aspw.client.visual.client.altmanager.GuiAltManager;
import net.aspw.client.visual.client.altmanager.menus.GuiLoginProgress;
Expand Down Expand Up @@ -57,7 +56,6 @@ private void initGui(CallbackInfo callbackInfo) {
buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 2 + field_175353_i / 2 + this.fontRendererObj.FONT_HEIGHT + 22, 200, 20, "Reconnect to §7" + ServerUtils.serverData.serverIP));
buttonList.add(new GuiButton(3, this.width / 2 - 100, this.height / 2 + field_175353_i / 2 + this.fontRendererObj.FONT_HEIGHT + 44, 100, 20, "Reconnect with Alt"));
buttonList.add(new GuiButton(4, this.width / 2 + 2, this.height / 2 + field_175353_i / 2 + this.fontRendererObj.FONT_HEIGHT + 44, 98, 20, "Random Cracked"));
buttonList.add(new GuiButton(998, width - 94, 5, 88, 20, "Alt Manager"));
buttonList.add(new GuiButton(999, width - 184, 5, 88, 20, "Protocol Fixer"));
buttonList.add(new GuiButton(1000, 4, height - 24, 68, 20, "Proxy"));
buttonList.add(Protocol.getAsyncVersionSlider());
Expand Down Expand Up @@ -129,9 +127,6 @@ private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) {
case 1000:
mc.displayGuiScreen(new GuiProxyManager((GuiScreen) (Object) this));
break;
case 999:
mc.displayGuiScreen(new GuiProtocolFixer((GuiScreen) (Object) this));
break;
case 998:
mc.displayGuiScreen(new GuiAltManager((GuiScreen) (Object) this));
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.aspw.client.injection.forge.mixins.gui;

import net.aspw.client.protocol.Protocol;
import net.aspw.client.visual.client.GuiProtocolFixer;
import net.aspw.client.visual.client.GuiProxyManager;
import net.aspw.client.visual.client.altmanager.GuiAltManager;
import net.aspw.client.visual.font.Fonts;
Expand All @@ -22,7 +21,6 @@ public abstract class MixinGuiMultiplayer extends MixinGuiScreen {
@Inject(method = "initGui", at = @At("RETURN"))
private void initGui(CallbackInfo callbackInfo) {
buttonList.add(new GuiButton(998, width - 94, 5, 88, 20, "Alt Manager"));
buttonList.add(new GuiButton(999, width - 184, 5, 88, 20, "Protocol Fixer"));
buttonList.add(new GuiButton(1000, 4, height - 24, 68, 20, "Proxy"));
buttonList.add(Protocol.getAsyncVersionSlider());
}
Expand All @@ -41,9 +39,6 @@ private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) {
if (button.id == 1000) {
mc.displayGuiScreen(new GuiProxyManager((GuiScreen) (Object) this));
}
if (button.id == 999) {
mc.displayGuiScreen(new GuiProtocolFixer((GuiScreen) (Object) this));
}
if (button.id == 998) {
mc.displayGuiScreen(new GuiAltManager((GuiScreen) (Object) this));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package net.aspw.client.injection.forge.mixins.item;

import net.aspw.client.protocol.Protocol;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(ItemBlock.class)
public class MixinItemBlock extends Item {

@Shadow
@Final
public Block block;

/**
* @author As_pw
* @reason Fix Block Sounds
*/
@Overwrite
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();

if (!block.isReplaceable(worldIn, pos)) {
pos = pos.offset(side);
}

if (stack.stackSize == 0) {
return false;
} else if (!playerIn.canPlayerEdit(pos, side, stack)) {
return false;
} else if (worldIn.canBlockBePlaced(this.block, pos, false, side, null, stack)) {
int i = this.getMetadata(stack.getMetadata());
IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn);

if (worldIn.setBlockState(pos, iblockstate1, 3)) {
iblockstate1 = worldIn.getBlockState(pos);

if (iblockstate1.getBlock() == this.block) {
ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack);
this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
}

if (!Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x")) {
// Using playSoundAtPos instead of playSoundEffect (I have no understanding as to why playSoundEffect is not functioning properly on 1.9+ protocols)
Minecraft.getMinecraft().theWorld.playSoundAtPos(pos.add(0.5, 0.5, 0.5), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F, false);
} else {
worldIn.playSoundEffect((float) pos.getX() + 0.5F, (float) pos.getY() + 0.5F, (float) pos.getZ() + 0.5F, this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
}

--stack.stackSize;
}

return true;
} else {
return false;
}
}
}
Loading

0 comments on commit 45e354f

Please sign in to comment.