feat: drop items when knocked down
This commit is contained in:
parent
5c1f88b290
commit
38394d5c28
2 changed files with 8 additions and 4 deletions
|
@ -9,7 +9,7 @@ yarn_mappings=1.20.2+build.4
|
||||||
loader_version=0.14.24
|
loader_version=0.14.24
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.0.0
|
mod_version=1.1.0
|
||||||
maven_group=ru.octol1ttle.knockdowns
|
maven_group=ru.octol1ttle.knockdowns
|
||||||
archives_base_name=knockdowns
|
archives_base_name=knockdowns
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.TypedActionResult;
|
import net.minecraft.util.TypedActionResult;
|
||||||
|
import net.minecraft.world.GameRules;
|
||||||
import ru.octol1ttle.knockdowns.api.IKnockableDown;
|
import ru.octol1ttle.knockdowns.api.IKnockableDown;
|
||||||
import ru.octol1ttle.knockdowns.network.KnockdownsNetworkingConstants;
|
import ru.octol1ttle.knockdowns.network.KnockdownsNetworkingConstants;
|
||||||
|
|
||||||
|
@ -54,13 +55,18 @@ public class Knockdowns implements ModInitializer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) entity;
|
||||||
// TODO: timer
|
// TODO: timer
|
||||||
|
if (!serverPlayer.getWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) {
|
||||||
|
serverPlayer.getInventory().dropAll();
|
||||||
|
}
|
||||||
entity.setHealth(1.0f);
|
entity.setHealth(1.0f);
|
||||||
entity.setInvulnerable(true);
|
entity.setInvulnerable(true);
|
||||||
entity.setGlowing(true);
|
entity.setGlowing(true);
|
||||||
entity.setAir(entity.getMaxAir());
|
entity.setAir(entity.getMaxAir());
|
||||||
entity.setFireTicks(0);
|
entity.extinguish();
|
||||||
entity.setFrozenTicks(0);
|
entity.setFrozenTicks(0);
|
||||||
|
entity.setOnFire(false);
|
||||||
entity.clearStatusEffects();
|
entity.clearStatusEffects();
|
||||||
|
|
||||||
knockableDown.knockdowns$setKnockedDown(true);
|
knockableDown.knockdowns$setKnockedDown(true);
|
||||||
|
@ -69,8 +75,6 @@ public class Knockdowns implements ModInitializer {
|
||||||
buf.writeUuid(entity.getUuid());
|
buf.writeUuid(entity.getUuid());
|
||||||
buf.writeBoolean(true);
|
buf.writeBoolean(true);
|
||||||
|
|
||||||
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) entity;
|
|
||||||
|
|
||||||
ServerPlayNetworking.send(serverPlayer, KnockdownsNetworkingConstants.S2C_SEND_PLAYER_KNOCKED_DOWN, buf);
|
ServerPlayNetworking.send(serverPlayer, KnockdownsNetworkingConstants.S2C_SEND_PLAYER_KNOCKED_DOWN, buf);
|
||||||
for (ServerPlayerEntity player : PlayerLookup.tracking(entity)) {
|
for (ServerPlayerEntity player : PlayerLookup.tracking(entity)) {
|
||||||
ServerPlayNetworking.send(player, KnockdownsNetworkingConstants.S2C_SEND_PLAYER_KNOCKED_DOWN, buf);
|
ServerPlayNetworking.send(player, KnockdownsNetworkingConstants.S2C_SEND_PLAYER_KNOCKED_DOWN, buf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue