forked from Arathain/Tome-Of-Tiamatha
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Arathain#5 from Arathain/buildscript-bork
shit I forgot to change branch in dev env
- Loading branch information
Showing
17 changed files
with
132 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/net/arathain/tot/common/network/packet/RemorsePacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package net.arathain.tot.common.network.packet; | ||
|
||
import net.arathain.tot.TomeOfTiamatha; | ||
import net.arathain.tot.common.init.ToTObjects; | ||
import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl; | ||
import net.minecraft.enchantment.EnchantmentHelper; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityGroup; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.attribute.EntityAttributes; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.Identifier; | ||
import org.quiltmc.qsl.networking.api.PacketByteBufs; | ||
import org.quiltmc.qsl.networking.api.PacketSender; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class RemorsePacket { | ||
public static final Identifier ID = new Identifier(TomeOfTiamatha.MODID, "remorse"); | ||
|
||
public static void send(@Nullable Entity entity) { | ||
PacketByteBuf buf = PacketByteBufs.create(); | ||
|
||
if(entity != null) | ||
buf.writeInt(entity.getId()); | ||
|
||
ClientSidePacketRegistryImpl.INSTANCE.sendToServer(ID, buf); | ||
} | ||
|
||
public static void handle(MinecraftServer server, ServerPlayerEntity player, ServerPlayNetworkHandler network, PacketByteBuf buf, PacketSender sender) { | ||
int entityId = buf.isReadable() ? buf.readInt() : -1; | ||
|
||
server.execute(() -> { | ||
if(player.getStackInHand(Hand.MAIN_HAND).getItem().equals(ToTObjects.REMORSE)) { | ||
float f = (float)player.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE); | ||
float g; | ||
g = EnchantmentHelper.getAttackDamage(player.getMainHandStack(), player.getGroup()); | ||
|
||
float h = player.getAttackCooldownProgress(0.5F); | ||
f *= 0.2F + h * h * 0.8F; | ||
g *= h; | ||
f += g; | ||
player.damage(DamageSource.player(player), f); | ||
} | ||
}); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/net/arathain/tot/mixin/MinecraftClientMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package net.arathain.tot.mixin; | ||
|
||
import net.arathain.tot.common.init.ToTObjects; | ||
import net.arathain.tot.common.item.RemorseItem; | ||
import net.arathain.tot.common.network.packet.RemorsePacket; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.client.option.KeyBind; | ||
import net.minecraft.util.hit.EntityHitResult; | ||
import net.minecraft.util.hit.HitResult; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.swing.text.JTextComponent; | ||
|
||
@Mixin(MinecraftClient.class) | ||
public abstract class MinecraftClientMixin { | ||
@Shadow @Nullable | ||
public ClientPlayerEntity player; | ||
@Shadow protected int attackCooldown; | ||
@Shadow | ||
@Nullable public HitResult crosshairTarget; | ||
@Unique | ||
private boolean attackQueued = false; | ||
|
||
|
||
@Inject(method = "handleInputEvents", at = @At(value = "INVOKE", | ||
target = "Lnet/minecraft/client/MinecraftClient;doAttack()Z", | ||
ordinal = 0 | ||
)) | ||
public void combattweaks$handleAttacking(CallbackInfo info) { | ||
if(player != null) { | ||
if(player.getStackInHand(player.getActiveHand()).isOf(ToTObjects.REMORSE)) { | ||
if(player.getAttackCooldownProgress(0.5F) == 1F && (!player.getItemCooldownManager().isCoolingDown(player.getMainHandStack().getItem())) && crosshairTarget != null) { | ||
RemorsePacket.send(crosshairTarget.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) crosshairTarget).getEntity() : null); | ||
|
||
if(crosshairTarget.getType() == HitResult.Type.BLOCK) | ||
player.resetLastAttackedTicks(); | ||
} | ||
} | ||
} | ||
|
||
if(!info.isCancelled() && attackQueued) | ||
attackQueued = false; | ||
} | ||
} |
Oops, something went wrong.