Compare commits
4 commits
5c1f88b290
...
ac3d92fc97
Author | SHA1 | Date | |
---|---|---|---|
ac3d92fc97 | |||
430b79c162 | |||
22a7d5b036 | |||
38394d5c28 |
4 changed files with 24 additions and 9 deletions
|
@ -9,7 +9,7 @@ yarn_mappings=1.20.2+build.4
|
|||
loader_version=0.14.24
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.0.0
|
||||
mod_version=1.1.1
|
||||
maven_group=ru.octol1ttle.knockdowns
|
||||
archives_base_name=knockdowns
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class KnockdownsClient implements ClientModInitializer {
|
|||
PacketByteBuf buf = PacketByteBufs.create();
|
||||
buf.writeUuid(entity.getUuid());
|
||||
|
||||
ClientPlayNetworking.send(KnockdownsNetworkingConstants.C2S_REQUEST_PLAYER_KNOCKED_DOWN, buf);
|
||||
ClientPlayNetworking.send(KnockdownsNetworkingConstants.C2S_REQUEST_PLAYER_KNOCKED_DOWN, PacketByteBufs.copy(buf));
|
||||
ClientPlayNetworking.send(KnockdownsNetworkingConstants.C2S_REQUEST_PLAYER_REVIVING, buf);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.minecraft.util.ActionResult;
|
|||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.GameRules;
|
||||
import ru.octol1ttle.knockdowns.api.IKnockableDown;
|
||||
import ru.octol1ttle.knockdowns.network.KnockdownsNetworkingConstants;
|
||||
|
||||
|
@ -54,13 +55,18 @@ public class Knockdowns implements ModInitializer {
|
|||
return true;
|
||||
}
|
||||
|
||||
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) entity;
|
||||
// TODO: timer
|
||||
if (!serverPlayer.getWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) {
|
||||
serverPlayer.getInventory().dropAll();
|
||||
}
|
||||
entity.setHealth(1.0f);
|
||||
entity.setInvulnerable(true);
|
||||
entity.setGlowing(true);
|
||||
entity.setAir(entity.getMaxAir());
|
||||
entity.setFireTicks(0);
|
||||
entity.extinguish();
|
||||
entity.setFrozenTicks(0);
|
||||
entity.setOnFire(false);
|
||||
entity.clearStatusEffects();
|
||||
|
||||
knockableDown.knockdowns$setKnockedDown(true);
|
||||
|
@ -69,8 +75,6 @@ public class Knockdowns implements ModInitializer {
|
|||
buf.writeUuid(entity.getUuid());
|
||||
buf.writeBoolean(true);
|
||||
|
||||
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) entity;
|
||||
|
||||
ServerPlayNetworking.send(serverPlayer, KnockdownsNetworkingConstants.S2C_SEND_PLAYER_KNOCKED_DOWN, buf);
|
||||
for (ServerPlayerEntity player : PlayerLookup.tracking(entity)) {
|
||||
ServerPlayNetworking.send(player, KnockdownsNetworkingConstants.S2C_SEND_PLAYER_KNOCKED_DOWN, buf);
|
||||
|
|
|
@ -4,9 +4,12 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
|||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.callback.CallbackInfo;
|
||||
import ru.octol1ttle.knockdowns.api.IKnockableDown;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
|
@ -15,11 +18,9 @@ public abstract class PlayerEntityMixin implements IKnockableDown {
|
|||
private boolean knockedDown;
|
||||
@Unique
|
||||
private boolean beingRevived;
|
||||
@Unique
|
||||
private int reviveAt;
|
||||
|
||||
@ModifyExpressionValue(method = "updatePose", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSwimming()Z"))
|
||||
private boolean isKnockedDown(boolean original) {
|
||||
private boolean enterSwimmingIfKnockedDown(boolean original) {
|
||||
PlayerEntity player = (PlayerEntity)(Object)this;
|
||||
if (!(player instanceof IKnockableDown knockableDown)) {
|
||||
throw new IllegalStateException();
|
||||
|
@ -29,10 +30,20 @@ public abstract class PlayerEntityMixin implements IKnockableDown {
|
|||
}
|
||||
|
||||
@ModifyReturnValue(method = "canFoodHeal", at = @At("RETURN"))
|
||||
private boolean canFoodHeal(boolean original) {
|
||||
private boolean dontHealIfKnockedDown(boolean original) {
|
||||
return original && !this.knockdowns$isKnockedDown();
|
||||
}
|
||||
|
||||
@Inject(method = "readCustomDataFromNbt", at = @At("TAIL"))
|
||||
public void readKnockedDownFromNbt(NbtCompound nbt, CallbackInfo ci) {
|
||||
this.knockedDown = nbt.getBoolean("KnockedDown");
|
||||
}
|
||||
|
||||
@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
|
||||
public void writeKnockedDownToNbt(NbtCompound nbt, CallbackInfo ci) {
|
||||
nbt.putBoolean("KnockedDown", this.knockedDown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean knockdowns$isKnockedDown() {
|
||||
return knockedDown;
|
||||
|
|
Loading…
Add table
Reference in a new issue