Skip to content

Commit

Permalink
Combatify 1.1.8 1.20.5 - hmm
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra-Myers committed Feb 9, 2024
1 parent 1e500be commit 0b5e9ac
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void changeAttributes(ServerPlayer reciever) {
List<Integer> indexes = new ArrayList<>();
Map<Integer, AttributeModifier> modifierMap = new HashMap<>();
for (ClientboundUpdateAttributesPacket.AttributeSnapshot attributeSnapshot : attributes) {
if (attributeSnapshot.attribute() == Attributes.ATTACK_SPEED && Combatify.unmoddedPlayers.contains(reciever.getUUID())) {
if (attributeSnapshot.attribute() == Attributes.ATTACK_SPEED) {
double speed = calculateValue(attributeSnapshot.base(), attributeSnapshot.modifiers(), attributeSnapshot.attribute());
for (double newSpeed = speed - 1.5; newSpeed > 0; newSpeed -= 0.001) {
if (vanillaMath(newSpeed) == CTSMath(speed) * 2) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.atlas.combatify.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import net.atlas.combatify.Combatify;
import net.atlas.combatify.extensions.IUpdateAttributesPacket;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundBundlePacket;
Expand Down Expand Up @@ -28,15 +29,15 @@ public abstract class ServerEntityMixin {
public void modifyAttributes(ServerGamePacketListenerImpl instance, Packet<?> packet, @Local(ordinal = 0, argsOnly = true) ServerPlayer serverPlayer) {
if(packet instanceof ClientboundBundlePacket clientboundBundlePacket)
clientboundBundlePacket.subPackets().forEach(clientGamePacketListenerPacket -> {
if(clientGamePacketListenerPacket instanceof ClientboundUpdateAttributesPacket clientboundUpdateAttributesPacket) {
if(Combatify.unmoddedPlayers.contains(serverPlayer.getUUID()) && clientGamePacketListenerPacket instanceof ClientboundUpdateAttributesPacket clientboundUpdateAttributesPacket) {
((IUpdateAttributesPacket) clientboundUpdateAttributesPacket).changeAttributes(serverPlayer);
}
});
instance.send(packet);
}
@Redirect(method = "sendDirtyEntityData", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerEntity;broadcastAndSend(Lnet/minecraft/network/protocol/Packet;)V"))
@Redirect(method = "sendDirtyEntityData", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerEntity;broadcastAndSend(Lnet/minecraft/network/protocol/Packet;)V", ordinal = 1))
public void modifyAttributes1(ServerEntity instance, Packet<?> packet) {
if(entity instanceof ServerPlayer serverPlayer && packet instanceof ClientboundUpdateAttributesPacket clientboundUpdateAttributesPacket)
if(entity instanceof ServerPlayer serverPlayer && Combatify.unmoddedPlayers.contains(serverPlayer.getUUID()) && packet instanceof ClientboundUpdateAttributesPacket clientboundUpdateAttributesPacket)
((IUpdateAttributesPacket) clientboundUpdateAttributesPacket).changeAttributes(serverPlayer);
broadcastAndSend(packet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void hitreg(CallbackInfo ci) {
@Inject(method = "swing", at = @At(value = "HEAD"), cancellable = true)
public void removeReset(InteractionHand hand, CallbackInfo ci) {
super.swing(hand);
if(Combatify.unmoddedPlayers.contains(getUUID())) {
if (Combatify.unmoddedPlayers.contains(getUUID())) {
if (Combatify.isPlayerAttacking.get(getUUID())) {
handleInteract(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public NetworkingHandler() {
return;
}
Combatify.unmoddedPlayers.add(handler.player.getUUID());
Combatify.isPlayerAttacking.put(handler.player.getUUID(), false);
Combatify.isPlayerAttacking.put(handler.player.getUUID(), true);
Combatify.LOGGER.info("Unmodded player joined: " + handler.player.getUUID());
return;
}
Expand Down

0 comments on commit 0b5e9ac

Please sign in to comment.