Compare commits

...

6 Commits

5 changed files with 14 additions and 7 deletions

1
.gitignore vendored
View File

@ -20,6 +20,7 @@ build
# other # other
eclipse eclipse
run run
.kotlin
design/ design/
libs/ libs/

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.mixin;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameRules;
import net.neoforged.neoforge.event.EventHooks; import net.neoforged.neoforge.event.EventHooks;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -28,7 +29,7 @@ public class MixinLivingEntity {
at = @At("HEAD"), at = @At("HEAD"),
cancellable = true) cancellable = true)
public void dropExperience(@Nullable Entity killer, CallbackInfo hook) { public void dropExperience(@Nullable Entity killer, CallbackInfo hook) {
if (((Object) this) instanceof Player player && ServerConfig.INSTANCE.getDROP_EXPERIENCE_CAPSULES()) { if (((Object) this) instanceof Player player && ServerConfig.INSTANCE.getDROP_EXPERIENCE_CAPSULES() && !player.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY)) {
hook.cancel(); hook.cancel();
var android = ((IMatteryPlayer) player).getOtmPlayer(); var android = ((IMatteryPlayer) player).getOtmPlayer();

View File

@ -106,10 +106,15 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
if (!status.job.matterValue.isZero) if (!status.job.matterValue.isZero)
status.throttleFast() status.throttleFast()
} else { } else {
status.job.matterValue -= matter.receiveMatter(status.job.matterValue, false) val received = matter.receiveMatter(status.job.matterValue, false)
status.job.matterValue -= received
if (status.job.matterValue.isPositive) if (status.job.matterValue.isPositive) {
status.noMatter() if (received.isPositive)
status.noMatter(1)
else
status.noMatter()
}
} }
} }

View File

@ -17,8 +17,8 @@ object WitheredSkeletonSpawnHandler {
val entity = event.entity val entity = event.entity
if (entity is WitherSkeleton) { if (entity is WitherSkeleton) {
val giveHelmet = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_HELMET_CHANCE val giveHelmet = event.level.otmRandom.nextDouble() < ServerConfig.WITHER_SKELETON_HELMET_CHANCE
val giveSword = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_SWORD_CHANCE val giveSword = event.level.otmRandom.nextDouble() < ServerConfig.WITHER_SKELETON_SWORD_CHANCE
if (giveHelmet) { if (giveHelmet) {
if (!entity.hasItemInSlot(EquipmentSlot.HEAD)) if (!entity.hasItemInSlot(EquipmentSlot.HEAD))

View File

@ -79,7 +79,7 @@ class MatteryFoodData(private var player: Player) : FoodData() {
if (saturationLevel > 0f) { if (saturationLevel > 0f) {
val satisfied = min(saturationLevel.roundToInt(), points) val satisfied = min(saturationLevel.roundToInt(), points)
points -= satisfied points -= satisfied
saturationLevel -= satisfied saturationLevel = max(0f, saturationLevel - satisfied)
} }
foodLevel = max(0, foodLevel - points) foodLevel = max(0, foodLevel - points)