Compare commits
No commits in common. "b6b3cbed815d1712a0318bd79aef3781bced0776" and "97c4922765004413ec8e257e27599971f64613ca" have entirely different histories.
b6b3cbed81
...
97c4922765
1
.gitignore
vendored
1
.gitignore
vendored
@ -32,4 +32,3 @@ forge*changelog.txt
|
|||||||
|
|
||||||
shapegen_output.java
|
shapegen_output.java
|
||||||
/runs
|
/runs
|
||||||
/.kotlin
|
|
||||||
|
@ -23,7 +23,7 @@ import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider
|
|||||||
import net.neoforged.neoforge.data.event.GatherDataEvent
|
import net.neoforged.neoforge.data.event.GatherDataEvent
|
||||||
import net.neoforged.neoforge.registries.NeoForgeRegistries
|
import net.neoforged.neoforge.registries.NeoForgeRegistries
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchDataProvider
|
import ru.dbotthepony.mc.otm.android.AndroidResearchDataProvider
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth
|
import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth
|
||||||
import ru.dbotthepony.mc.otm.core.util.WriteOnce
|
import ru.dbotthepony.mc.otm.core.util.WriteOnce
|
||||||
|
@ -4,9 +4,9 @@ import net.minecraft.tags.ItemTags
|
|||||||
import net.minecraft.world.item.Items
|
import net.minecraft.world.item.Items
|
||||||
import net.neoforged.neoforge.common.Tags
|
import net.neoforged.neoforge.common.Tags
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchDescriptions
|
import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchResults
|
import ru.dbotthepony.mc.otm.android.AndroidResearchResults
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchType
|
import ru.dbotthepony.mc.otm.android.AndroidResearchType
|
||||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
|
@ -15,8 +15,8 @@ import net.minecraft.world.item.ItemStack
|
|||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
import net.neoforged.neoforge.common.data.LanguageProvider
|
import net.neoforged.neoforge.common.data.LanguageProvider
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeatureType
|
import ru.dbotthepony.mc.otm.android.AndroidFeatureType
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchType
|
import ru.dbotthepony.mc.otm.android.AndroidResearchType
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.datagen.DataGen
|
import ru.dbotthepony.mc.otm.datagen.DataGen
|
||||||
import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock
|
import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock
|
||||||
|
@ -19,7 +19,7 @@ import net.minecraft.world.level.block.Block
|
|||||||
import net.neoforged.neoforge.common.Tags
|
import net.neoforged.neoforge.common.Tags
|
||||||
import net.neoforged.neoforge.data.event.GatherDataEvent
|
import net.neoforged.neoforge.data.event.GatherDataEvent
|
||||||
import net.neoforged.neoforge.registries.NeoForgeRegistries
|
import net.neoforged.neoforge.registries.NeoForgeRegistries
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.datagen.DataGen
|
import ru.dbotthepony.mc.otm.datagen.DataGen
|
||||||
import java.util.EnumMap
|
import java.util.EnumMap
|
||||||
|
@ -20,7 +20,7 @@ import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.neoforged.neoforge.client.event.RenderPlayerEvent;
|
import net.neoforged.neoforge.client.event.RenderPlayerEvent;
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
||||||
import ru.dbotthepony.mc.otm.player.IMatteryPlayer;
|
import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
51
src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java
Normal file
51
src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.world.Difficulty;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.food.FoodData;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
|
||||||
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
||||||
|
|
||||||
|
@Mixin(FoodData.class)
|
||||||
|
public class FoodDataMixin {
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private int lastFoodLevel;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private int tickTimer;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private int foodLevel;
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private float exhaustionLevel;
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "tick(Lnet/minecraft/world/entity/player/Player;)V",
|
||||||
|
at = @At("HEAD"),
|
||||||
|
remap = false,
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private void tick(Player player, CallbackInfo info) {
|
||||||
|
var it = ((IMatteryPlayer) player).getOtmPlayer();
|
||||||
|
|
||||||
|
if (it.isAndroid()) {
|
||||||
|
info.cancel();
|
||||||
|
|
||||||
|
// полностью подменяем логику если андроид
|
||||||
|
lastFoodLevel = foodLevel;
|
||||||
|
|
||||||
|
if (player.level().getDifficulty() == Difficulty.PEACEFUL) {
|
||||||
|
exhaustionLevel = 0f;
|
||||||
|
} else {
|
||||||
|
tickTimer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// не обновляем уровень истощения ибо он обнуляется логикой внутри MatteryPlayerCapability
|
||||||
|
// а так же не регенерируем
|
||||||
|
// ну и не получаем урон от "голодания"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.neoforged.fml.ModList;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import ru.dbotthepony.mc.otm.core.IMatteryLevel;
|
|
||||||
import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource;
|
|
||||||
|
|
||||||
@Mixin(Level.class)
|
|
||||||
public abstract class LevelMixin implements IMatteryLevel {
|
|
||||||
private final RandomSource otm_random = ModList.get().isLoaded("better_random") ? null : new GJRAND64RandomSource();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable RandomSource getOtmRandom() {
|
|
||||||
return otm_random;
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,8 +7,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import ru.dbotthepony.mc.otm.player.IMatteryPlayer;
|
import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
|
||||||
import ru.dbotthepony.mc.otm.core.IMatteryLevel;
|
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MSoundEvents;
|
import ru.dbotthepony.mc.otm.registry.game.MSoundEvents;
|
||||||
|
|
||||||
@Mixin(AbstractHurtingProjectile.class)
|
@Mixin(AbstractHurtingProjectile.class)
|
||||||
@ -25,7 +24,7 @@ public class MixinAbstractHurtingProjectile {
|
|||||||
AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this;
|
AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this;
|
||||||
|
|
||||||
if (cap.isAndroid() && proj.getOwner() != entity) {
|
if (cap.isAndroid() && proj.getOwner() != entity) {
|
||||||
entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + ((IMatteryLevel) entity.level()).getOtmRandom().nextFloat() * 0.1f);
|
entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level().getRandom().nextFloat() * 0.1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import ru.dbotthepony.mc.otm.player.IMatteryPlayer;
|
import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer;
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ 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;
|
||||||
@ -11,7 +10,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
|||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import ru.dbotthepony.mc.otm.player.IMatteryPlayer;
|
import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
|
||||||
import ru.dbotthepony.mc.otm.config.ServerConfig;
|
import ru.dbotthepony.mc.otm.config.ServerConfig;
|
||||||
import ru.dbotthepony.mc.otm.core.util.ExperienceUtilsKt;
|
import ru.dbotthepony.mc.otm.core.util.ExperienceUtilsKt;
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MItems;
|
import ru.dbotthepony.mc.otm.registry.game.MItems;
|
||||||
@ -29,7 +28,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() && !player.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY)) {
|
if (((Object) this) instanceof Player player && ServerConfig.INSTANCE.getDROP_EXPERIENCE_CAPSULES()) {
|
||||||
hook.cancel();
|
hook.cancel();
|
||||||
|
|
||||||
var android = ((IMatteryPlayer) player).getOtmPlayer();
|
var android = ((IMatteryPlayer) player).getOtmPlayer();
|
||||||
|
@ -6,7 +6,7 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer;
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer;
|
||||||
|
|
||||||
@Mixin(Minecraft.class)
|
@Mixin(Minecraft.class)
|
||||||
public class MixinMinecraft {
|
public class MixinMinecraft {
|
||||||
|
@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.mixin;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.food.FoodData;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -12,17 +12,15 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import ru.dbotthepony.mc.otm.player.IMatteryPlayer;
|
import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryFoodData;
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer;
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Mixin(Player.class)
|
@Mixin(Player.class)
|
||||||
public abstract class MixinPlayer implements IMatteryPlayer {
|
public class MixinPlayer implements IMatteryPlayer {
|
||||||
private Player otmSelf() {
|
private Player otmSelf() {
|
||||||
return (Player) (Object) this;
|
return (Player) (Object) this;
|
||||||
}
|
}
|
||||||
@ -89,15 +87,4 @@ public abstract class MixinPlayer implements IMatteryPlayer {
|
|||||||
private void readAdditionalSaveData(CompoundTag data, CallbackInfo ci) {
|
private void readAdditionalSaveData(CompoundTag data, CallbackInfo ci) {
|
||||||
otmPlayer.deserializeNBT(data.getCompound("overdrive_that_matters_player"), otmSelf().registryAccess());
|
otmPlayer.deserializeNBT(data.getCompound("overdrive_that_matters_player"), otmSelf().registryAccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow
|
|
||||||
protected FoodData foodData;
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "<init>",
|
|
||||||
at = @At("TAIL")
|
|
||||||
)
|
|
||||||
private void ctorMix(Level level, BlockPos pos, float yRot, GameProfile gameProfile, CallbackInfo info) {
|
|
||||||
foodData = new MatteryFoodData(otmSelf());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ val isPaused: Boolean get() {
|
|||||||
return isPausedImpl
|
return isPausedImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun recordClientThread() {
|
fun recordClientThread() {
|
||||||
clientThreads.add(Thread.currentThread())
|
clientThreads.add(Thread.currentThread())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,19 +186,19 @@ var SERVER_IS_LIVE = false
|
|||||||
|
|
||||||
private val LOGGER = LogManager.getLogger()
|
private val LOGGER = LogManager.getLogger()
|
||||||
|
|
||||||
internal fun onServerTickPre(event: ServerTickEvent.Pre) {
|
fun onServerTickPre(event: ServerTickEvent.Pre) {
|
||||||
preServerTick.tick()
|
preServerTick.tick()
|
||||||
serverThreads.add(Thread.currentThread())
|
serverThreads.add(Thread.currentThread())
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onServerTickPost(event: ServerTickEvent.Post) {
|
fun onServerTickPost(event: ServerTickEvent.Post) {
|
||||||
postServerTick.tick()
|
postServerTick.tick()
|
||||||
// чтоб не плодить кучу подписчиков, вызовем напрямую отсюда
|
// чтоб не плодить кучу подписчиков, вызовем напрямую отсюда
|
||||||
GraphNodeList.tick()
|
GraphNodeList.tick()
|
||||||
AbstractProfiledStorage.onServerPostTick()
|
AbstractProfiledStorage.onServerPostTick()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onLevelTickPre(event: LevelTickEvent.Pre) {
|
fun onLevelTickPre(event: LevelTickEvent.Pre) {
|
||||||
preWorldTick[event.level]?.tick()
|
preWorldTick[event.level]?.tick()
|
||||||
|
|
||||||
if (event.level.isClientSide) {
|
if (event.level.isClientSide) {
|
||||||
@ -208,7 +208,7 @@ internal fun onLevelTickPre(event: LevelTickEvent.Pre) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onLevelTickPost(event: LevelTickEvent.Post) {
|
fun onLevelTickPost(event: LevelTickEvent.Post) {
|
||||||
postWorldTick[event.level]?.tick()
|
postWorldTick[event.level]?.tick()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ private fun clear() {
|
|||||||
postWorldTick.clear()
|
postWorldTick.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onServerStarting(event: ServerAboutToStartEvent) {
|
fun onServerStarting(event: ServerAboutToStartEvent) {
|
||||||
clear()
|
clear()
|
||||||
SERVER_IS_LIVE = true
|
SERVER_IS_LIVE = true
|
||||||
_server = event.server
|
_server = event.server
|
||||||
@ -318,13 +318,13 @@ internal fun onServerStarting(event: ServerAboutToStartEvent) {
|
|||||||
serverCounter.incrementAndGet()
|
serverCounter.incrementAndGet()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onServerStopping(event: ServerStoppingEvent) {
|
fun onServerStopping(event: ServerStoppingEvent) {
|
||||||
clear()
|
clear()
|
||||||
SERVER_IS_LIVE = false
|
SERVER_IS_LIVE = false
|
||||||
serverCounter.incrementAndGet()
|
serverCounter.incrementAndGet()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onServerStopped(event: ServerStoppedEvent) {
|
fun onServerStopped(event: ServerStoppedEvent) {
|
||||||
if (SERVER_IS_LIVE) {
|
if (SERVER_IS_LIVE) {
|
||||||
LOGGER.fatal("ServerStoppingEvent did not fire. If server has crashed this is normal. However, if server finished it's work 'gracefully' this is a bug!")
|
LOGGER.fatal("ServerStoppingEvent did not fire. If server has crashed this is normal. However, if server finished it's work 'gracefully' this is a bug!")
|
||||||
|
|
||||||
|
@ -6,15 +6,16 @@ import net.neoforged.bus.api.EventPriority
|
|||||||
import net.neoforged.fml.common.Mod
|
import net.neoforged.fml.common.Mod
|
||||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent
|
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchDescription
|
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchDescriptions
|
import ru.dbotthepony.mc.otm.android.AndroidResearchDescription
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager
|
import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchResult
|
import ru.dbotthepony.mc.otm.android.AndroidResearchManager
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchResults
|
import ru.dbotthepony.mc.otm.android.AndroidResearchResult
|
||||||
import ru.dbotthepony.mc.otm.player.android.feature.EnderTeleporterFeature
|
import ru.dbotthepony.mc.otm.android.AndroidResearchResults
|
||||||
|
import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.drive.DrivePool
|
import ru.dbotthepony.mc.otm.capability.drive.DrivePool
|
||||||
import ru.dbotthepony.mc.otm.client.AndroidAbilityKeyMapping
|
import ru.dbotthepony.mc.otm.client.AndroidAbilityKeyMapping
|
||||||
import ru.dbotthepony.mc.otm.client.AndroidMenuKeyMapping
|
import ru.dbotthepony.mc.otm.client.AndroidMenuKeyMapping
|
||||||
@ -43,7 +44,7 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer
|
|||||||
import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded
|
import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded
|
||||||
import ru.dbotthepony.mc.otm.compat.curios.onCuriosSlotModifiersUpdated
|
import ru.dbotthepony.mc.otm.compat.curios.onCuriosSlotModifiersUpdated
|
||||||
import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu
|
import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.config.CablesConfig
|
import ru.dbotthepony.mc.otm.config.CablesConfig
|
||||||
import ru.dbotthepony.mc.otm.config.ClientConfig
|
import ru.dbotthepony.mc.otm.config.ClientConfig
|
||||||
import ru.dbotthepony.mc.otm.config.ExopackConfig
|
import ru.dbotthepony.mc.otm.config.ExopackConfig
|
||||||
@ -157,6 +158,7 @@ object OverdriveThatMatters {
|
|||||||
MOD_BUS.addListener(EventPriority.NORMAL, TritaniumArmorModel::register)
|
MOD_BUS.addListener(EventPriority.NORMAL, TritaniumArmorModel::register)
|
||||||
MOD_BUS.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register)
|
MOD_BUS.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register)
|
||||||
MOD_BUS.addListener(EventPriority.NORMAL, BreadMonsterModel::register)
|
MOD_BUS.addListener(EventPriority.NORMAL, BreadMonsterModel::register)
|
||||||
|
MOD_BUS.addListener(EventPriority.NORMAL, MCreativeTabs::register)
|
||||||
|
|
||||||
MOD_BUS.addListener(EventPriority.NORMAL, BatteryBankRenderer.Companion::onRegisterAdditionalModels)
|
MOD_BUS.addListener(EventPriority.NORMAL, BatteryBankRenderer.Companion::onRegisterAdditionalModels)
|
||||||
MOD_BUS.addListener(EventPriority.NORMAL, MatterBatteryBankRenderer.Companion::onRegisterAdditionalModels)
|
MOD_BUS.addListener(EventPriority.NORMAL, MatterBatteryBankRenderer.Companion::onRegisterAdditionalModels)
|
||||||
@ -173,7 +175,7 @@ object OverdriveThatMatters {
|
|||||||
ClientConfig.register(container)
|
ClientConfig.register(container)
|
||||||
ServerConfig.register(container)
|
ServerConfig.register(container)
|
||||||
CablesConfig.register(container)
|
CablesConfig.register(container)
|
||||||
PlayerConfig.register(container)
|
AndroidConfig.register(container)
|
||||||
ExopackConfig.register(container)
|
ExopackConfig.register(container)
|
||||||
ItemsConfig.register(container)
|
ItemsConfig.register(container)
|
||||||
MachinesConfig.register(container)
|
MachinesConfig.register(container)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.Camera
|
import net.minecraft.client.Camera
|
||||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent
|
import net.neoforged.neoforge.client.event.RenderLevelStageEvent
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||||
|
|
||||||
abstract class AndroidActiveFeature(type: AndroidFeatureType<*>, android: MatteryPlayer) : AndroidSwitchableFeature(type, android) {
|
abstract class AndroidActiveFeature(type: AndroidFeatureType<*>, android: MatteryPlayer) : AndroidSwitchableFeature(type, android) {
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import net.minecraft.core.HolderLookup
|
import net.minecraft.core.HolderLookup
|
||||||
import net.minecraft.nbt.CompoundTag
|
import net.minecraft.nbt.CompoundTag
|
||||||
@ -7,7 +7,7 @@ import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent
|
|||||||
import ru.dbotthepony.mc.otm.network.syncher.SynchableGroup
|
import ru.dbotthepony.mc.otm.network.syncher.SynchableGroup
|
||||||
import ru.dbotthepony.kommons.util.getValue
|
import ru.dbotthepony.kommons.util.getValue
|
||||||
import ru.dbotthepony.kommons.util.setValue
|
import ru.dbotthepony.kommons.util.setValue
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||||
|
|
||||||
abstract class AndroidFeature(val type: AndroidFeatureType<*>, val android: MatteryPlayer) : INBTSerializable<CompoundTag> {
|
abstract class AndroidFeature(val type: AndroidFeatureType<*>, val android: MatteryPlayer) : INBTSerializable<CompoundTag> {
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.network.chat.ComponentContents
|
import net.minecraft.network.chat.ComponentContents
|
||||||
import net.minecraft.network.chat.MutableComponent
|
import net.minecraft.network.chat.MutableComponent
|
||||||
import net.minecraft.network.chat.contents.TranslatableContents
|
import net.minecraft.network.chat.contents.TranslatableContents
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.core.getKeyNullable
|
import ru.dbotthepony.mc.otm.core.getKeyNullable
|
||||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.core.HolderLookup
|
import net.minecraft.core.HolderLookup
|
||||||
@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.network.syncher.SynchableGroup
|
|||||||
import ru.dbotthepony.kommons.util.getValue
|
import ru.dbotthepony.kommons.util.getValue
|
||||||
import ru.dbotthepony.kommons.util.setValue
|
import ru.dbotthepony.kommons.util.setValue
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.awareItemsStream
|
import ru.dbotthepony.mc.otm.capability.awareItemsStream
|
||||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import com.mojang.serialization.Codec
|
import com.mojang.serialization.Codec
|
||||||
import com.mojang.serialization.MapCodec
|
import com.mojang.serialization.MapCodec
|
||||||
@ -9,7 +9,7 @@ import net.minecraft.network.chat.ComponentSerialization
|
|||||||
import net.neoforged.bus.api.IEventBus
|
import net.neoforged.bus.api.IEventBus
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.client.ShiftPressedCond
|
import ru.dbotthepony.mc.otm.client.ShiftPressedCond
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.core.util.formatPower
|
import ru.dbotthepony.mc.otm.core.util.formatPower
|
||||||
@ -23,82 +23,41 @@ object AndroidResearchDescriptions {
|
|||||||
registrar.register("plain") { PlainAndroidResearchDescription }
|
registrar.register("plain") { PlainAndroidResearchDescription }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun register(bus: IEventBus) {
|
fun register(bus: IEventBus) {
|
||||||
registrar.register(bus)
|
registrar.register(bus)
|
||||||
}
|
}
|
||||||
|
|
||||||
val ENDER_TELEPORTER: AndroidResearchDescription.Singleton by registrar.register("ender_teleporter") {
|
val ENDER_TELEPORTER: AndroidResearchDescription.Singleton by registrar.register("ender_teleporter") {
|
||||||
AndroidResearchDescription.singleton {
|
AndroidResearchDescription.singleton {
|
||||||
TranslatableComponent(
|
TranslatableComponent("otm.gui.power_cost_per_use", AndroidConfig.EnderTeleporter.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) }
|
||||||
"otm.gui.power_cost_per_use",
|
|
||||||
PlayerConfig.EnderTeleporter.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy()
|
|
||||||
.withStyle(ChatFormatting.YELLOW)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val FALL_DAMPENERS: AndroidResearchDescription.Leveled by registrar.register("fall_dampeners") {
|
val FALL_DAMPENERS: AndroidResearchDescription.Leveled by registrar.register("fall_dampeners") {
|
||||||
AndroidResearchDescription.Leveled { _, list, level ->
|
AndroidResearchDescription.Leveled { _, list, level ->
|
||||||
list.add(
|
list.add(TranslatableComponent("otm.fall_dampeners.description",
|
||||||
TranslatableComponent(
|
TextComponent("%.1f".format((AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * level).toFloat().coerceIn(0f, 1f) * 100f)).withStyle(ChatFormatting.YELLOW),
|
||||||
"otm.fall_dampeners.description",
|
TextComponent("%.1f".format((AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * level).toFloat())).withStyle(ChatFormatting.YELLOW),
|
||||||
TextComponent(
|
)) }
|
||||||
"%.1f".format(
|
|
||||||
(PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * level).toFloat().coerceIn(0f, 1f) * 100f
|
|
||||||
)
|
|
||||||
).withStyle(ChatFormatting.YELLOW),
|
|
||||||
TextComponent("%.1f".format((PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * level).toFloat())).withStyle(
|
|
||||||
ChatFormatting.YELLOW
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val SWIM_BOOSTERS: AndroidResearchDescription.Leveled by registrar.register("swim_boosters") {
|
val SWIM_BOOSTERS: AndroidResearchDescription.Leveled by registrar.register("swim_boosters") {
|
||||||
AndroidResearchDescription.Leveled { _, list, level ->
|
AndroidResearchDescription.Leveled { _, list, level ->
|
||||||
list.add(
|
list.add(TranslatableComponent(
|
||||||
TranslatableComponent(
|
"android_research.overdrive_that_matters.swim_boosters.description",
|
||||||
"android_research.overdrive_that_matters.swim_boosters.description",
|
TextComponent("%.1f".format(AndroidConfig.SWIM_BOOSTERS * (1 + level) * 100.0)).withStyle(ChatFormatting.YELLOW)
|
||||||
TextComponent("%.1f".format(PlayerConfig.SWIM_BOOSTERS * (1 + level) * 100.0)).withStyle(
|
)) }
|
||||||
ChatFormatting.YELLOW
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val ITEM_MAGNET: AndroidResearchDescription.Singleton by registrar.register("item_magnet") {
|
val ITEM_MAGNET: AndroidResearchDescription.Singleton by registrar.register("item_magnet") {
|
||||||
AndroidResearchDescription.singleton {
|
AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_tick", AndroidConfig.Magnet.POWER_DRAW.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) }
|
||||||
TranslatableComponent(
|
|
||||||
"otm.gui.power_cost_per_tick",
|
|
||||||
PlayerConfig.Magnet.POWER_DRAW.formatPower(
|
|
||||||
formatAsReadable = ShiftPressedCond
|
|
||||||
).copy().withStyle(ChatFormatting.YELLOW)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val JUMP_BOOST: AndroidResearchDescription.Singleton by registrar.register("jump_boost") {
|
val JUMP_BOOST: AndroidResearchDescription.Singleton by registrar.register("jump_boost") {
|
||||||
AndroidResearchDescription.singleton {
|
AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_use", AndroidConfig.JumpBoost.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) }
|
||||||
TranslatableComponent(
|
|
||||||
"otm.gui.power_cost_per_use",
|
|
||||||
PlayerConfig.JumpBoost.ENERGY_COST.formatPower(
|
|
||||||
formatAsReadable = ShiftPressedCond
|
|
||||||
).copy().withStyle(ChatFormatting.YELLOW)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val SHOCKWAVE: AndroidResearchDescription.Singleton by registrar.register("shockwave") {
|
val SHOCKWAVE: AndroidResearchDescription.Singleton by registrar.register("shockwave") {
|
||||||
AndroidResearchDescription.singleton {
|
AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_use", AndroidConfig.Shockwave.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) }
|
||||||
TranslatableComponent(
|
|
||||||
"otm.gui.power_cost_per_use",
|
|
||||||
PlayerConfig.Shockwave.ENERGY_COST.formatPower(
|
|
||||||
formatAsReadable = ShiftPressedCond
|
|
||||||
).copy().withStyle(ChatFormatting.YELLOW)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +108,7 @@ interface AndroidResearchDescription {
|
|||||||
registry.byNameCodec().dispatch({ it.type }, { it.codec })
|
registry.byNameCodec().dispatch({ it.type }, { it.codec })
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun register(bus: IEventBus) {
|
fun register(bus: IEventBus) {
|
||||||
bus.addListener(delegate::build)
|
bus.addListener(delegate::build)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +138,7 @@ object PlainAndroidResearchDescription : AndroidResearchDescription.Type<PlainAn
|
|||||||
RecordCodecBuilder.mapCodec {
|
RecordCodecBuilder.mapCodec {
|
||||||
it.group(
|
it.group(
|
||||||
ComponentSerialization.CODEC.fieldOf("line").forGetter { it.line }
|
ComponentSerialization.CODEC.fieldOf("line").forGetter { it.line }
|
||||||
).apply(it, PlainAndroidResearchDescription::Instance)
|
).apply(it, ::Instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap
|
import com.google.common.collect.ImmutableMap
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
@ -23,7 +23,8 @@ import ru.dbotthepony.mc.otm.MINECRAFT_SERVER
|
|||||||
import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER
|
import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.SERVER_IS_LIVE
|
import ru.dbotthepony.mc.otm.SERVER_IS_LIVE
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.core.fromJsonStrict
|
import ru.dbotthepony.mc.otm.core.fromJsonStrict
|
||||||
import ru.dbotthepony.mc.otm.core.fromNetwork
|
import ru.dbotthepony.mc.otm.core.fromNetwork
|
||||||
@ -93,11 +94,11 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun reloadEvent(event: AddReloadListenerEvent) {
|
fun reloadEvent(event: AddReloadListenerEvent) {
|
||||||
event.addListener(this)
|
event.addListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun syncEvent(event: OnDatapackSyncEvent) {
|
fun syncEvent(event: OnDatapackSyncEvent) {
|
||||||
val packet = SyncPacket(researchMap.values)
|
val packet = SyncPacket(researchMap.values)
|
||||||
|
|
||||||
if (event.player != null) {
|
if (event.player != null) {
|
||||||
@ -108,10 +109,7 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s
|
|||||||
}
|
}
|
||||||
|
|
||||||
val SYNC_TYPE = CustomPacketPayload.Type<SyncPacket>(ResourceLocation(OverdriveThatMatters.MOD_ID, "research_sync"))
|
val SYNC_TYPE = CustomPacketPayload.Type<SyncPacket>(ResourceLocation(OverdriveThatMatters.MOD_ID, "research_sync"))
|
||||||
val SYNC_CODEC: StreamCodec<FriendlyByteBuf, SyncPacket> = StreamCodec.ofMember(
|
val SYNC_CODEC: StreamCodec<FriendlyByteBuf, SyncPacket> = StreamCodec.ofMember(SyncPacket::write, ::readSyncPacket)
|
||||||
SyncPacket::write,
|
|
||||||
AndroidResearchManager::readSyncPacket
|
|
||||||
)
|
|
||||||
|
|
||||||
class SyncPacket(val collection: Collection<AndroidResearchType>) : CustomPacketPayload {
|
class SyncPacket(val collection: Collection<AndroidResearchType>) : CustomPacketPayload {
|
||||||
fun write(buff: FriendlyByteBuf) {
|
fun write(buff: FriendlyByteBuf) {
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import com.mojang.serialization.Codec
|
import com.mojang.serialization.Codec
|
||||||
import com.mojang.serialization.MapCodec
|
import com.mojang.serialization.MapCodec
|
||||||
@ -16,8 +16,8 @@ object AndroidResearchResults {
|
|||||||
private val registrar = MDeferredRegister(AndroidResearchResult.registryKey, OverdriveThatMatters.MOD_ID)
|
private val registrar = MDeferredRegister(AndroidResearchResult.registryKey, OverdriveThatMatters.MOD_ID)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
registrar.register("feature") { AndroidResearchResult.Feature }
|
registrar.register("feature") { AndroidResearchResult.Feature.Companion }
|
||||||
registrar.register("feature_level") { AndroidResearchResult.FeatureLevel }
|
registrar.register("feature_level") { AndroidResearchResult.FeatureLevel.Companion }
|
||||||
}
|
}
|
||||||
|
|
||||||
private object NanobotsArmorStrength : AndroidResearchResult.Singleton<NanobotsArmorStrength> {
|
private object NanobotsArmorStrength : AndroidResearchResult.Singleton<NanobotsArmorStrength> {
|
||||||
@ -55,7 +55,7 @@ object AndroidResearchResults {
|
|||||||
val NANOBOTS_ARMOR_STRENGTH: AndroidResearchResult.Singleton<*> by registrar.register("nanobots_armor_strength") { NanobotsArmorStrength }
|
val NANOBOTS_ARMOR_STRENGTH: AndroidResearchResult.Singleton<*> by registrar.register("nanobots_armor_strength") { NanobotsArmorStrength }
|
||||||
val NANOBOTS_ARMOR_SPEED: AndroidResearchResult.Singleton<*> by registrar.register("nanobots_armor_speed") { NanobotsArmorSpeed }
|
val NANOBOTS_ARMOR_SPEED: AndroidResearchResult.Singleton<*> by registrar.register("nanobots_armor_speed") { NanobotsArmorSpeed }
|
||||||
|
|
||||||
internal fun register(bus: IEventBus) {
|
fun register(bus: IEventBus) {
|
||||||
registrar.register(bus)
|
registrar.register(bus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ interface AndroidResearchResult {
|
|||||||
it.group(
|
it.group(
|
||||||
ResourceLocation.CODEC.fieldOf("id").forGetter(Feature::id),
|
ResourceLocation.CODEC.fieldOf("id").forGetter(Feature::id),
|
||||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(Feature::optional)
|
Codec.BOOL.optionalFieldOf("optional", false).forGetter(Feature::optional)
|
||||||
).apply(it, AndroidResearchResult::Feature)
|
).apply(it, ::Feature)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,8 +99,7 @@ interface AndroidResearchResult {
|
|||||||
/**
|
/**
|
||||||
* Increases level of specific android feature [id] by specified amount [levels]
|
* Increases level of specific android feature [id] by specified amount [levels]
|
||||||
*/
|
*/
|
||||||
class FeatureLevel(val id: ResourceLocation, val optional: Boolean = false, val levels: Int = 1) :
|
class FeatureLevel(val id: ResourceLocation, val optional: Boolean = false, val levels: Int = 1) : AndroidResearchResult {
|
||||||
AndroidResearchResult {
|
|
||||||
val feature = MRegistry.ANDROID_FEATURES.get(id) ?: if (optional) null else throw NoSuchElementException("Unknown android feature $id")
|
val feature = MRegistry.ANDROID_FEATURES.get(id) ?: if (optional) null else throw NoSuchElementException("Unknown android feature $id")
|
||||||
|
|
||||||
override val type: Type<*>
|
override val type: Type<*>
|
||||||
@ -133,7 +132,7 @@ interface AndroidResearchResult {
|
|||||||
ResourceLocation.CODEC.fieldOf("id").forGetter(FeatureLevel::id),
|
ResourceLocation.CODEC.fieldOf("id").forGetter(FeatureLevel::id),
|
||||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(FeatureLevel::optional),
|
Codec.BOOL.optionalFieldOf("optional", false).forGetter(FeatureLevel::optional),
|
||||||
Codec.INT.optionalFieldOf("levels", 1).forGetter(FeatureLevel::levels),
|
Codec.INT.optionalFieldOf("levels", 1).forGetter(FeatureLevel::levels),
|
||||||
).apply(it, AndroidResearchResult::FeatureLevel)
|
).apply(it, ::FeatureLevel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +161,7 @@ interface AndroidResearchResult {
|
|||||||
registry.byNameCodec().dispatch({ it.type }, { it.codec })
|
registry.byNameCodec().dispatch({ it.type }, { it.codec })
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun register(bus: IEventBus) {
|
fun register(bus: IEventBus) {
|
||||||
bus.addListener(delegate::build)
|
bus.addListener(delegate::build)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
@ -131,10 +131,10 @@ class AndroidResearchType(
|
|||||||
it.group(
|
it.group(
|
||||||
ResourceLocation.CODEC.fieldOf("id").forGetter(Reference::id),
|
ResourceLocation.CODEC.fieldOf("id").forGetter(Reference::id),
|
||||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(Reference::optional)
|
Codec.BOOL.optionalFieldOf("optional", false).forGetter(Reference::optional)
|
||||||
).apply(it, AndroidResearchType::Reference)
|
).apply(it, ::Reference)
|
||||||
})
|
})
|
||||||
.xmap(
|
.xmap(
|
||||||
{ c -> c.map(AndroidResearchType::Reference, Function.identity()) },
|
{ c -> c.map(::Reference, Function.identity()) },
|
||||||
{ c -> if (c.optional) Either.right(c) else Either.left(c.id) }
|
{ c -> if (c.optional) Either.right(c) else Either.left(c.id) }
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel
|
import net.minecraft.client.multiplayer.ClientLevel
|
||||||
import net.minecraft.core.HolderLookup
|
import net.minecraft.core.HolderLookup
|
||||||
@ -7,7 +7,7 @@ import net.minecraft.server.level.ServerPlayer
|
|||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.kommons.util.getValue
|
import ru.dbotthepony.kommons.util.getValue
|
||||||
import ru.dbotthepony.kommons.util.setValue
|
import ru.dbotthepony.kommons.util.setValue
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes
|
import net.minecraft.world.entity.ai.attributes.Attributes
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeature
|
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem
|
import com.mojang.blaze3d.systems.RenderSystem
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
@ -25,16 +25,16 @@ import net.neoforged.neoforge.event.entity.living.LivingDeathEvent
|
|||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER
|
import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidActiveFeature
|
import ru.dbotthepony.mc.otm.android.AndroidActiveFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||||
import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType
|
import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType
|
||||||
import ru.dbotthepony.mc.otm.client.render.sprites.sprite
|
import ru.dbotthepony.mc.otm.client.render.sprites.sprite
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.core.genericPositions
|
import ru.dbotthepony.mc.otm.core.genericPositions
|
||||||
import ru.dbotthepony.mc.otm.core.holder
|
import ru.dbotthepony.mc.otm.core.holder
|
||||||
@ -49,7 +49,7 @@ import ru.dbotthepony.mc.otm.core.math.rotateXDegrees
|
|||||||
import ru.dbotthepony.mc.otm.core.math.rotateYDegrees
|
import ru.dbotthepony.mc.otm.core.math.rotateYDegrees
|
||||||
import ru.dbotthepony.mc.otm.core.math.shortestDistanceBetween
|
import ru.dbotthepony.mc.otm.core.math.shortestDistanceBetween
|
||||||
import ru.dbotthepony.mc.otm.core.math.times
|
import ru.dbotthepony.mc.otm.core.math.times
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.milliTime
|
import ru.dbotthepony.mc.otm.milliTime
|
||||||
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
||||||
import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger
|
import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger
|
||||||
@ -61,10 +61,10 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
override val maxCooldown: Int
|
override val maxCooldown: Int
|
||||||
get() = PlayerConfig.EnderTeleporter.COOLDOWN
|
get() = AndroidConfig.EnderTeleporter.COOLDOWN
|
||||||
|
|
||||||
private fun canUse(): Boolean {
|
private fun canUse(): Boolean {
|
||||||
return !isOnCooldown && android.androidEnergy.extractEnergyExact(PlayerConfig.EnderTeleporter.ENERGY_COST, true)
|
return !isOnCooldown && android.androidEnergy.extractEnergyExact(AndroidConfig.EnderTeleporter.ENERGY_COST, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isValidGround(blockPos: BlockPos): Boolean {
|
private fun isValidGround(blockPos: BlockPos): Boolean {
|
||||||
@ -113,14 +113,14 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun tryToPhaseThroughWall(blockPos: BlockPos, normal: Vec3i): TraceResult? {
|
private fun tryToPhaseThroughWall(blockPos: BlockPos, normal: Vec3i): TraceResult? {
|
||||||
val phasedBlocks = ArrayList<BlockPos>(PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE)
|
val phasedBlocks = ArrayList<BlockPos>(AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE)
|
||||||
phasedBlocks.add(blockPos)
|
phasedBlocks.add(blockPos)
|
||||||
|
|
||||||
for (extend in 1 .. PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) {
|
for (extend in 1 .. AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) {
|
||||||
val pos = blockPos + normal * extend
|
val pos = blockPos + normal * extend
|
||||||
|
|
||||||
if (isAirGap(pos)) {
|
if (isAirGap(pos)) {
|
||||||
for (y in 0 .. PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE - extend) {
|
for (y in 0 .. AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE - extend) {
|
||||||
val newPos = BlockPos(pos.x, pos.y - y, pos.z)
|
val newPos = BlockPos(pos.x, pos.y - y, pos.z)
|
||||||
|
|
||||||
if (isValidPosition(newPos)) {
|
if (isValidPosition(newPos)) {
|
||||||
@ -143,7 +143,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
|
|
||||||
val result = ply.level().clip(ClipContext(
|
val result = ply.level().clip(ClipContext(
|
||||||
headPosition,
|
headPosition,
|
||||||
headPosition + aimVector * (PlayerConfig.EnderTeleporter.MAX_DISTANCE * 2.0),
|
headPosition + aimVector * (AndroidConfig.EnderTeleporter.MAX_DISTANCE * 2.0),
|
||||||
ClipContext.Block.COLLIDER,
|
ClipContext.Block.COLLIDER,
|
||||||
ClipContext.Fluid.NONE,
|
ClipContext.Fluid.NONE,
|
||||||
ply
|
ply
|
||||||
@ -159,7 +159,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
!ply.isShiftKeyDown &&
|
!ply.isShiftKeyDown &&
|
||||||
result.direction == Direction.UP &&
|
result.direction == Direction.UP &&
|
||||||
isValidPosition(result.blockPos.above()) &&
|
isValidPosition(result.blockPos.above()) &&
|
||||||
shortestDistanceBetween(testPositions, result.blockPos.above().asVector()) <= PlayerConfig.EnderTeleporter.MAX_DISTANCE
|
shortestDistanceBetween(testPositions, result.blockPos.above().asVector()) <= AndroidConfig.EnderTeleporter.MAX_DISTANCE
|
||||||
) {
|
) {
|
||||||
return TraceResult(result.blockPos.above())
|
return TraceResult(result.blockPos.above())
|
||||||
}
|
}
|
||||||
@ -217,14 +217,14 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
if (!isAirGap(pos)) {
|
if (!isAirGap(pos)) {
|
||||||
phasedBlocks++
|
phasedBlocks++
|
||||||
|
|
||||||
if (phasedBlocks >= PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) {
|
if (phasedBlocks >= AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
phasedBlocksList.add(pos)
|
phasedBlocksList.add(pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shortestDistanceBetween(testPositions, pos.asVector()) > PlayerConfig.EnderTeleporter.MAX_DISTANCE) {
|
if (shortestDistanceBetween(testPositions, pos.asVector()) > AndroidConfig.EnderTeleporter.MAX_DISTANCE) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,14 +271,14 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
if (!isAirGap(pos)) {
|
if (!isAirGap(pos)) {
|
||||||
phasedBlocks++
|
phasedBlocks++
|
||||||
|
|
||||||
if (phasedBlocks >= PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) {
|
if (phasedBlocks >= AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
phasedBlocksList.add(pos)
|
phasedBlocksList.add(pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shortestDistanceBetween(testPositions, pos.asVector()) > PlayerConfig.EnderTeleporter.MAX_DISTANCE) {
|
if (shortestDistanceBetween(testPositions, pos.asVector()) > AndroidConfig.EnderTeleporter.MAX_DISTANCE) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,17 +303,17 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
val event = EventHooks.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
|
val event = EventHooks.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
|
||||||
|
|
||||||
if (event.isCanceled) {
|
if (event.isCanceled) {
|
||||||
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level().otmRandom.nextLong()))
|
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level().random.nextLong()))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
putOnCooldown()
|
putOnCooldown()
|
||||||
lastTeleport = ply.server!!.tickCount
|
lastTeleport = ply.server!!.tickCount
|
||||||
android.androidEnergy.extractEnergy(PlayerConfig.EnderTeleporter.ENERGY_COST, false)
|
android.androidEnergy.extractEnergy(AndroidConfig.EnderTeleporter.ENERGY_COST, false)
|
||||||
|
|
||||||
ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level().otmRandom.nextFloat() * 0.4f)
|
ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level().random.nextFloat() * 0.4f)
|
||||||
ply.teleportTo(event.targetX, event.targetY, event.targetZ)
|
ply.teleportTo(event.targetX, event.targetY, event.targetZ)
|
||||||
ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level().otmRandom.nextFloat() * 0.4f)
|
ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level().random.nextFloat() * 0.4f)
|
||||||
|
|
||||||
ply.deltaMovement = Vector(0.0, 0.0, 0.0)
|
ply.deltaMovement = Vector(0.0, 0.0, 0.0)
|
||||||
ply.resetFallDistance()
|
ply.resetFallDistance()
|
||||||
@ -392,7 +392,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
|
|
||||||
val SPRITE = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/item/black_hole.png").sprite(0f, 0f, 16f, 16f, 16f, 16f)
|
val SPRITE = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/item/black_hole.png").sprite(0f, 0f, 16f, 16f, 16f, 16f)
|
||||||
|
|
||||||
internal fun onEntityDeath(event: LivingDeathEvent) {
|
fun onEntityDeath(event: LivingDeathEvent) {
|
||||||
val android = event.entity.matteryPlayer ?: return
|
val android = event.entity.matteryPlayer ?: return
|
||||||
val server = NULLABLE_MINECRAFT_SERVER ?: return
|
val server = NULLABLE_MINECRAFT_SERVER ?: return
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes
|
import net.minecraft.world.entity.ai.attributes.Attributes
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeature
|
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent
|
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeature
|
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.core.isFall
|
import ru.dbotthepony.mc.otm.core.isFall
|
||||||
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
||||||
import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger
|
import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger
|
||||||
@ -12,8 +12,8 @@ import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger
|
|||||||
class FallDampenersFeature(capability: MatteryPlayer) : AndroidFeature(AndroidFeatures.FALL_DAMPENERS, capability) {
|
class FallDampenersFeature(capability: MatteryPlayer) : AndroidFeature(AndroidFeatures.FALL_DAMPENERS, capability) {
|
||||||
override fun onHurt(event: LivingIncomingDamageEvent) {
|
override fun onHurt(event: LivingIncomingDamageEvent) {
|
||||||
if (event.source.isFall) {
|
if (event.source.isFall) {
|
||||||
val reduction = (PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * (level + 1)).toFloat().coerceIn(0f, 1f)
|
val reduction = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * (level + 1)).toFloat().coerceIn(0f, 1f)
|
||||||
val flat = (PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * (level + 1)).toFloat().coerceIn(0f, Float.MAX_VALUE)
|
val flat = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * (level + 1)).toFloat().coerceIn(0f, Float.MAX_VALUE)
|
||||||
|
|
||||||
val old = event.amount
|
val old = event.amount
|
||||||
event.amount = ((event.amount - flat) * (1f - reduction)).coerceAtLeast(0f)
|
event.amount = ((event.amount - flat) * (1f - reduction)).coerceAtLeast(0f)
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel
|
import net.minecraft.client.multiplayer.ClientLevel
|
||||||
import net.minecraft.network.FriendlyByteBuf
|
import net.minecraft.network.FriendlyByteBuf
|
||||||
@ -11,9 +11,9 @@ import net.neoforged.neoforge.network.PacketDistributor
|
|||||||
import net.neoforged.neoforge.network.handling.IPayloadContext
|
import net.neoforged.neoforge.network.handling.IPayloadContext
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature
|
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
@ -60,10 +60,7 @@ class ItemEntityDataPacket(val itemUUID: Int, val owner: UUID? = null, val age:
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TYPE = CustomPacketPayload.Type<ItemEntityDataPacket>(ResourceLocation(OverdriveThatMatters.MOD_ID, "item_entity_data"))
|
val TYPE = CustomPacketPayload.Type<ItemEntityDataPacket>(ResourceLocation(OverdriveThatMatters.MOD_ID, "item_entity_data"))
|
||||||
val CODEC: StreamCodec<FriendlyByteBuf, ItemEntityDataPacket> = StreamCodec.ofMember(
|
val CODEC: StreamCodec<FriendlyByteBuf, ItemEntityDataPacket> = StreamCodec.ofMember(ItemEntityDataPacket::write, ::read)
|
||||||
ItemEntityDataPacket::write,
|
|
||||||
Companion::read
|
|
||||||
)
|
|
||||||
|
|
||||||
fun read(buff: FriendlyByteBuf): ItemEntityDataPacket {
|
fun read(buff: FriendlyByteBuf): ItemEntityDataPacket {
|
||||||
return ItemEntityDataPacket(buff.readVarInt(), if (buff.readBoolean()) buff.readUUID() else null, buff.readVarInt(), buff.readVarInt(), buff.readBoolean())
|
return ItemEntityDataPacket(buff.readVarInt(), if (buff.readBoolean()) buff.readUUID() else null, buff.readVarInt(), buff.readVarInt(), buff.readBoolean())
|
||||||
@ -79,13 +76,13 @@ class ItemMagnetFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(An
|
|||||||
private val clientPredicate = Predicate<Entity> { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } }
|
private val clientPredicate = Predicate<Entity> { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } }
|
||||||
|
|
||||||
private fun doTick(server: Boolean) {
|
private fun doTick(server: Boolean) {
|
||||||
if (ply.isSpectator || server && !android.androidEnergy.extractEnergyExact(PlayerConfig.Magnet.POWER_DRAW, true)) {
|
if (ply.isSpectator || server && !android.androidEnergy.extractEnergyExact(AndroidConfig.Magnet.POWER_DRAW, true)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val entities = ply.level().getEntitiesInEllipsoid(
|
val entities = ply.level().getEntitiesInEllipsoid(
|
||||||
ply.position,
|
ply.position,
|
||||||
Vector(PlayerConfig.Magnet.RADIUS_HORIZONTAL, PlayerConfig.Magnet.RADIUS_VERTICAL, PlayerConfig.Magnet.RADIUS_HORIZONTAL),
|
Vector(AndroidConfig.Magnet.RADIUS_HORIZONTAL, AndroidConfig.Magnet.RADIUS_VERTICAL, AndroidConfig.Magnet.RADIUS_HORIZONTAL),
|
||||||
if (server) Predicate<Entity> { it is ItemEntity } else clientPredicate
|
if (server) Predicate<Entity> { it is ItemEntity } else clientPredicate
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -104,7 +101,7 @@ class ItemMagnetFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(An
|
|||||||
if (data.position.distanceToSqr(ent.position) < 1.0) {
|
if (data.position.distanceToSqr(ent.position) < 1.0) {
|
||||||
data.ticksSinceActivity++
|
data.ticksSinceActivity++
|
||||||
} else {
|
} else {
|
||||||
if (!android.androidEnergy.extractEnergyExact(PlayerConfig.Magnet.POWER_DRAW, false)) {
|
if (!android.androidEnergy.extractEnergyExact(AndroidConfig.Magnet.POWER_DRAW, false)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +117,7 @@ class ItemMagnetFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(An
|
|||||||
override fun tickClient() {
|
override fun tickClient() {
|
||||||
super.tickClient()
|
super.tickClient()
|
||||||
|
|
||||||
if (!ply.isSpectator && isActive && android.androidEnergy.extractEnergyExact(PlayerConfig.Magnet.POWER_DRAW, true)) {
|
if (!ply.isSpectator && isActive && android.androidEnergy.extractEnergyExact(AndroidConfig.Magnet.POWER_DRAW, true)) {
|
||||||
doTick(false)
|
doTick(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.minecraft.sounds.SoundSource
|
import net.minecraft.sounds.SoundSource
|
||||||
@ -6,12 +6,12 @@ import net.neoforged.neoforge.network.PacketDistributor
|
|||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.kommons.util.getValue
|
import ru.dbotthepony.kommons.util.getValue
|
||||||
import ru.dbotthepony.kommons.util.setValue
|
import ru.dbotthepony.kommons.util.setValue
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature
|
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.config.ClientConfig
|
import ru.dbotthepony.mc.otm.config.ClientConfig
|
||||||
import ru.dbotthepony.mc.otm.core.math.Vector
|
import ru.dbotthepony.mc.otm.core.math.Vector
|
||||||
import ru.dbotthepony.mc.otm.core.math.plus
|
import ru.dbotthepony.mc.otm.core.math.plus
|
||||||
@ -24,7 +24,7 @@ class JumpBoostFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
private var tickCooldownClient = false
|
private var tickCooldownClient = false
|
||||||
|
|
||||||
override val maxCooldown: Int
|
override val maxCooldown: Int
|
||||||
get() = (PlayerConfig.JumpBoost.BASE_COOLDOWN - PlayerConfig.JumpBoost.COOLDOWN_REDUCTION * level).coerceAtLeast(0)
|
get() = (AndroidConfig.JumpBoost.BASE_COOLDOWN - AndroidConfig.JumpBoost.COOLDOWN_REDUCTION * level).coerceAtLeast(0)
|
||||||
|
|
||||||
override var cooldown by syncher.int(setter = setter@{ access, value ->
|
override var cooldown by syncher.int(setter = setter@{ access, value ->
|
||||||
access.accept(value)
|
access.accept(value)
|
||||||
@ -46,8 +46,8 @@ class JumpBoostFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
val old = lastGround
|
val old = lastGround
|
||||||
lastGround = ply.onGround()
|
lastGround = ply.onGround()
|
||||||
|
|
||||||
if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(PlayerConfig.JumpBoost.ENERGY_COST, true)) {
|
if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, true)) {
|
||||||
ply.deltaMovement += Vector(0.0, PlayerConfig.JumpBoost.POWER * (level + 1) / 20.0, 0.0)
|
ply.deltaMovement += Vector(0.0, AndroidConfig.JumpBoost.POWER * (level + 1) / 20.0, 0.0)
|
||||||
putOnCooldown()
|
putOnCooldown()
|
||||||
PacketDistributor.sendToServer(TriggerJumpBoostPacket)
|
PacketDistributor.sendToServer(TriggerJumpBoostPacket)
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.world.entity.LivingEntity
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes
|
import net.minecraft.world.entity.ai.attributes.Attributes
|
||||||
import net.minecraft.world.entity.player.Player
|
import net.minecraft.world.entity.player.Player
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeature
|
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ class LimbOverclockingFeature(android: MatteryPlayer) : AndroidFeature(AndroidFe
|
|||||||
|
|
||||||
if (speed != null) {
|
if (speed != null) {
|
||||||
speed.removeModifier(MODIFIER_ID)
|
speed.removeModifier(MODIFIER_ID)
|
||||||
speed.addPermanentModifier(AttributeModifier(MODIFIER_ID, (level + 1) * 0.08, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL))
|
speed.addPermanentModifier(AttributeModifier(MODIFIER_ID,(level + 1) * 0.08, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL))
|
||||||
}
|
}
|
||||||
|
|
||||||
val attackSpeed = ply.getAttribute(Attributes.ATTACK_SPEED)
|
val attackSpeed = ply.getAttribute(Attributes.ATTACK_SPEED)
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.core.HolderLookup
|
import net.minecraft.core.HolderLookup
|
||||||
import net.minecraft.nbt.CompoundTag
|
import net.minecraft.nbt.CompoundTag
|
||||||
@ -7,8 +7,8 @@ import net.minecraft.tags.DamageTypeTags
|
|||||||
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent
|
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent
|
||||||
import ru.dbotthepony.kommons.util.getValue
|
import ru.dbotthepony.kommons.util.getValue
|
||||||
import ru.dbotthepony.kommons.util.setValue
|
import ru.dbotthepony.kommons.util.setValue
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeature
|
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||||
import ru.dbotthepony.mc.otm.core.isBypassArmor
|
import ru.dbotthepony.mc.otm.core.isBypassArmor
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
@ -1,13 +1,13 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.core.HolderLookup
|
import net.minecraft.core.HolderLookup
|
||||||
import net.minecraft.nbt.CompoundTag
|
import net.minecraft.nbt.CompoundTag
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.minecraft.world.level.GameRules
|
import net.minecraft.world.level.GameRules
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent
|
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeature
|
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
||||||
import ru.dbotthepony.mc.otm.registry.StatNames
|
import ru.dbotthepony.mc.otm.registry.StatNames
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||||
@ -21,16 +21,16 @@ class NanobotsRegenerationFeature(android: MatteryPlayer) : AndroidFeature(Andro
|
|||||||
if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||||
ticksPassed++
|
ticksPassed++
|
||||||
|
|
||||||
val waitTime = PlayerConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { PlayerConfig.NanobotsRegeneration.COOLDOWN.last() }
|
val waitTime = AndroidConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { AndroidConfig.NanobotsRegeneration.COOLDOWN.last() }
|
||||||
|
|
||||||
if (ticksPassed > waitTime) {
|
if (ticksPassed > waitTime) {
|
||||||
val missingHealth = (ply.maxHealth - ply.health).coerceAtMost(2f)
|
val missingHealth = (ply.maxHealth - ply.health).coerceAtMost(2f)
|
||||||
val power = PlayerConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT * missingHealth
|
val power = AndroidConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT * missingHealth
|
||||||
val extracted = android.androidEnergy.extractEnergy(power, false)
|
val extracted = android.androidEnergy.extractEnergy(power, false)
|
||||||
|
|
||||||
if (extracted.isPositive) {
|
if (extracted.isPositive) {
|
||||||
healTicks = (healTicks + 1).coerceAtMost(level)
|
healTicks = (healTicks + 1).coerceAtMost(level)
|
||||||
val healed = (extracted / PlayerConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT).toFloat()
|
val healed = (extracted / AndroidConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT).toFloat()
|
||||||
ply.heal(healed)
|
ply.heal(healed)
|
||||||
(ply as ServerPlayer?)?.awardStat(StatNames.HEALTH_REGENERATED, (healed * 10f).roundToInt())
|
(ply as ServerPlayer?)?.awardStat(StatNames.HEALTH_REGENERATED, (healed * 10f).roundToInt())
|
||||||
ticksPassed = 0
|
ticksPassed = 0
|
@ -1,14 +1,14 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance
|
import net.minecraft.world.effect.MobEffectInstance
|
||||||
import net.minecraft.world.effect.MobEffects
|
import net.minecraft.world.effect.MobEffects
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature
|
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
||||||
|
|
||||||
class NightVisionFeature(android: MatteryPlayer) : AndroidSwitchableFeature(AndroidFeatures.NIGHT_VISION, android) {
|
class NightVisionFeature(android: MatteryPlayer) : AndroidSwitchableFeature(AndroidFeatures.NIGHT_VISION, android) {
|
||||||
@ -19,7 +19,7 @@ class NightVisionFeature(android: MatteryPlayer) : AndroidSwitchableFeature(Andr
|
|||||||
if (isActive) {
|
if (isActive) {
|
||||||
val effect = android.ply.activeEffectsMap[MobEffects.NIGHT_VISION]
|
val effect = android.ply.activeEffectsMap[MobEffects.NIGHT_VISION]
|
||||||
|
|
||||||
if ((effect == null || effect.duration < 220) && (ply.isSpectator || android.androidEnergy.extractEnergyExact(PlayerConfig.NIGHT_VISION_POWER_DRAW, false))) {
|
if ((effect == null || effect.duration < 220) && (ply.isSpectator || android.androidEnergy.extractEnergyExact(AndroidConfig.NIGHT_VISION_POWER_DRAW, false))) {
|
||||||
android.ply.addEffect(MobEffectInstance(MobEffects.NIGHT_VISION, 220, 0, false, false))
|
android.ply.addEffect(MobEffectInstance(MobEffects.NIGHT_VISION, 220, 0, false, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
@ -7,12 +7,12 @@ import net.minecraft.world.entity.Entity
|
|||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.world.entity.LivingEntity
|
||||||
import net.minecraft.world.entity.monster.warden.Warden
|
import net.minecraft.world.entity.monster.warden.Warden
|
||||||
import net.neoforged.neoforge.network.PacketDistributor
|
import net.neoforged.neoforge.network.PacketDistributor
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature
|
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.core.damageType
|
import ru.dbotthepony.mc.otm.core.damageType
|
||||||
import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
|
import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
|
||||||
import ru.dbotthepony.mc.otm.core.getExplosionResistance
|
import ru.dbotthepony.mc.otm.core.getExplosionResistance
|
||||||
@ -37,7 +37,7 @@ import kotlin.math.roundToInt
|
|||||||
|
|
||||||
class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(AndroidFeatures.SHOCKWAVE, capability) {
|
class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(AndroidFeatures.SHOCKWAVE, capability) {
|
||||||
override val maxCooldown: Int
|
override val maxCooldown: Int
|
||||||
get() = PlayerConfig.Shockwave.COOLDOWN
|
get() = AndroidConfig.Shockwave.COOLDOWN
|
||||||
|
|
||||||
private var wasMidair = false
|
private var wasMidair = false
|
||||||
private var highestSpeed = 0.0
|
private var highestSpeed = 0.0
|
||||||
@ -52,18 +52,18 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
isActive &&
|
isActive &&
|
||||||
ply.isShiftKeyDown &&
|
ply.isShiftKeyDown &&
|
||||||
!isOnCooldown &&
|
!isOnCooldown &&
|
||||||
android.androidEnergy.extractEnergyExact(PlayerConfig.Shockwave.ENERGY_COST, true) &&
|
android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, true) &&
|
||||||
ply.deltaMovement.y < -0.01 &&
|
ply.deltaMovement.y < -0.01 &&
|
||||||
creativeFlightTicks == 0
|
creativeFlightTicks == 0
|
||||||
) {
|
) {
|
||||||
ply.deltaMovement += Vector(0.0, -PlayerConfig.Shockwave.ACCELERATION / 20.0, 0.0)
|
ply.deltaMovement += Vector(0.0, -AndroidConfig.Shockwave.ACCELERATION / 20.0, 0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
ticker(true)
|
ticker(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shockwave() {
|
fun shockwave() {
|
||||||
if (ply.isSpectator || isOnCooldown || !android.androidEnergy.extractEnergyExact(PlayerConfig.Shockwave.ENERGY_COST, false)) {
|
if (ply.isSpectator || isOnCooldown || !android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, false)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,14 +86,14 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
// TODO: raycasting
|
// TODO: raycasting
|
||||||
val entities = ply.level().getEntitiesInEllipsoid(
|
val entities = ply.level().getEntitiesInEllipsoid(
|
||||||
ply.position,
|
ply.position,
|
||||||
Vector(PlayerConfig.Shockwave.RADIUS_HORIZONTAL, PlayerConfig.Shockwave.RADIUS_VERTICAL, PlayerConfig.Shockwave.RADIUS_HORIZONTAL),
|
Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL, AndroidConfig.Shockwave.RADIUS_VERTICAL, AndroidConfig.Shockwave.RADIUS_HORIZONTAL),
|
||||||
except = ply,
|
except = ply,
|
||||||
) { (it !is LivingEntity || !it.isSpectator && it.isAlive) }
|
) { (it !is LivingEntity || !it.isSpectator && it.isAlive) }
|
||||||
|
|
||||||
val wardens = ply.level().getEntitiesInEllipsoid(
|
val wardens = ply.level().getEntitiesInEllipsoid(
|
||||||
Warden::class.java,
|
Warden::class.java,
|
||||||
ply.position,
|
ply.position,
|
||||||
Vector(PlayerConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, PlayerConfig.Shockwave.RADIUS_VERTICAL_WARDEN, PlayerConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN),
|
Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, AndroidConfig.Shockwave.RADIUS_VERTICAL_WARDEN, AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN),
|
||||||
) { true }
|
) { true }
|
||||||
|
|
||||||
val seen = ReferenceArraySet<Entity>()
|
val seen = ReferenceArraySet<Entity>()
|
||||||
@ -103,7 +103,7 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
val multiplier = (1.0 - distanceMultiplier).pow(0.5)
|
val multiplier = (1.0 - distanceMultiplier).pow(0.5)
|
||||||
|
|
||||||
val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
||||||
val damage = multiplier.toFloat() * PlayerConfig.Shockwave.DAMAGE.toFloat() * PlayerConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat()
|
val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat()
|
||||||
entity.hurt(source, damage)
|
entity.hurt(source, damage)
|
||||||
entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0)
|
entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0)
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
// don't hurt items, arrows, etc etc
|
// don't hurt items, arrows, etc etc
|
||||||
if (entity is LivingEntity) {
|
if (entity is LivingEntity) {
|
||||||
val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
||||||
val damage = multiplier.toFloat() * PlayerConfig.Shockwave.DAMAGE.toFloat()
|
val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat()
|
||||||
entity.hurt(source, damage)
|
entity.hurt(source, damage)
|
||||||
entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0)
|
entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0)
|
||||||
|
|
||||||
@ -132,10 +132,10 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlayerConfig.Shockwave.BREAK_BLOCKS) {
|
if (AndroidConfig.Shockwave.BREAK_BLOCKS) {
|
||||||
val rounded = ply.position.roundToIntVector()
|
val rounded = ply.position.roundToIntVector()
|
||||||
|
|
||||||
for (blockPos in getEllipsoidBlockPositions(PlayerConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), PlayerConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), PlayerConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) {
|
for (blockPos in getEllipsoidBlockPositions(AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) {
|
||||||
val newBlockPos = blockPos + rounded
|
val newBlockPos = blockPos + rounded
|
||||||
|
|
||||||
val blockState = ply.level().getBlockState(newBlockPos)
|
val blockState = ply.level().getBlockState(newBlockPos)
|
||||||
@ -168,7 +168,7 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
!ply.isSpectator &&
|
!ply.isSpectator &&
|
||||||
isActive &&
|
isActive &&
|
||||||
!isOnCooldown &&
|
!isOnCooldown &&
|
||||||
android.androidEnergy.extractEnergyExact(PlayerConfig.Shockwave.ENERGY_COST, true) &&
|
android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, true) &&
|
||||||
creativeFlightTicks == 0
|
creativeFlightTicks == 0
|
||||||
) {
|
) {
|
||||||
val old = wasMidair
|
val old = wasMidair
|
||||||
@ -178,7 +178,7 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
highestSpeed = (-ply.deltaMovement.y).coerceAtLeast(highestSpeed)
|
highestSpeed = (-ply.deltaMovement.y).coerceAtLeast(highestSpeed)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old != wasMidair && !wasMidair && PlayerConfig.Shockwave.TERMINAL_VELOCITY <= (highestSpeed * 20.0) && ply.isShiftKeyDown) {
|
if (old != wasMidair && !wasMidair && AndroidConfig.Shockwave.TERMINAL_VELOCITY <= (highestSpeed * 20.0) && ply.isShiftKeyDown) {
|
||||||
if (isClient) {
|
if (isClient) {
|
||||||
// I HATE SELF-UPDATING PLAYERS
|
// I HATE SELF-UPDATING PLAYERS
|
||||||
// I HATE SELF-UPDATING PLAYERS
|
// I HATE SELF-UPDATING PLAYERS
|
@ -1,9 +1,9 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes
|
import net.minecraft.world.entity.ai.attributes.Attributes
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature
|
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
@ -1,12 +1,12 @@
|
|||||||
package ru.dbotthepony.mc.otm.player.android.feature
|
package ru.dbotthepony.mc.otm.android.feature
|
||||||
|
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier
|
||||||
import net.neoforged.neoforge.common.NeoForgeMod
|
import net.neoforged.neoforge.common.NeoForgeMod
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature
|
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
@ -20,7 +20,7 @@ class SwimBoostersFeature(android: MatteryPlayer) : AndroidSwitchableFeature(And
|
|||||||
val attr = ply.getAttribute(NeoForgeMod.SWIM_SPEED) ?: return
|
val attr = ply.getAttribute(NeoForgeMod.SWIM_SPEED) ?: return
|
||||||
|
|
||||||
attr.removeModifier(MODIFIER_ID)
|
attr.removeModifier(MODIFIER_ID)
|
||||||
attr.addPermanentModifier(AttributeModifier(MODIFIER_ID, (level + 1) * PlayerConfig.SWIM_BOOSTERS, AttributeModifier.Operation.ADD_VALUE))
|
attr.addPermanentModifier(AttributeModifier(MODIFIER_ID, (level + 1) * AndroidConfig.SWIM_BOOSTERS, AttributeModifier.Operation.ADD_VALUE))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun removeModifiers() {
|
override fun removeModifiers() {
|
@ -633,18 +633,18 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onLevelUnload(event: LevelEvent.Unload) {
|
fun onLevelUnload(event: LevelEvent.Unload) {
|
||||||
val level = event.level as? ServerLevel ?: return
|
val level = event.level as? ServerLevel ?: return
|
||||||
playerMap.remove(level)
|
playerMap.remove(level)
|
||||||
tickingMap.remove(level)
|
tickingMap.remove(level)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onServerStopping(event: ServerStoppingEvent) {
|
fun onServerStopping(event: ServerStoppingEvent) {
|
||||||
playerMap.clear()
|
playerMap.clear()
|
||||||
tickingMap.clear()
|
tickingMap.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun postLevelTick(event: LevelTickEvent.Post) {
|
fun postLevelTick(event: LevelTickEvent.Post) {
|
||||||
val level = event.level as? ServerLevel ?: return
|
val level = event.level as? ServerLevel ?: return
|
||||||
|
|
||||||
tickingMap[level]?.forEach {
|
tickingMap[level]?.forEach {
|
||||||
@ -663,14 +663,14 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onWatch(event: ChunkWatchEvent.Watch) {
|
fun onWatch(event: ChunkWatchEvent.Watch) {
|
||||||
playerMap
|
playerMap
|
||||||
.computeIfAbsent(event.level) { Long2ObjectOpenHashMap() }
|
.computeIfAbsent(event.level) { Long2ObjectOpenHashMap() }
|
||||||
.computeIfAbsent(event.pos.toLong(), Long2ObjectFunction { ChunkSubscribers(event.level, it) })
|
.computeIfAbsent(event.pos.toLong(), Long2ObjectFunction { ChunkSubscribers(event.level, it) })
|
||||||
.subscribe(event.player)
|
.subscribe(event.player)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onForget(event: ChunkWatchEvent.UnWatch) {
|
fun onForget(event: ChunkWatchEvent.UnWatch) {
|
||||||
val levelMap = playerMap[event.level] ?: return
|
val levelMap = playerMap[event.level] ?: return
|
||||||
val subs = levelMap.get(event.pos.toLong()) ?: return
|
val subs = levelMap.get(event.pos.toLong()) ?: return
|
||||||
|
|
||||||
@ -679,7 +679,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun playerDisconnected(event: PlayerEvent.PlayerLoggedOutEvent) {
|
fun playerDisconnected(event: PlayerEvent.PlayerLoggedOutEvent) {
|
||||||
for (tree in playerMap.values) {
|
for (tree in playerMap.values) {
|
||||||
tree.values.removeIf {
|
tree.values.removeIf {
|
||||||
it.unsubscribe(event.entity as ServerPlayer)
|
it.unsubscribe(event.entity as ServerPlayer)
|
||||||
|
@ -44,7 +44,7 @@ import ru.dbotthepony.mc.otm.core.math.getSphericalBlockPositions
|
|||||||
import ru.dbotthepony.mc.otm.core.math.times
|
import ru.dbotthepony.mc.otm.core.math.times
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.map
|
import ru.dbotthepony.mc.otm.core.nbt.map
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.isClient
|
import ru.dbotthepony.mc.otm.isClient
|
||||||
import ru.dbotthepony.mc.otm.matter.MatterManager
|
import ru.dbotthepony.mc.otm.matter.MatterManager
|
||||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||||
@ -271,7 +271,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
|
|||||||
}
|
}
|
||||||
|
|
||||||
// шанс 1% что черная дыра потеряет 0.1 MtU каждую секунду * силу гравитации дыры ^ -1
|
// шанс 1% что черная дыра потеряет 0.1 MtU каждую секунду * силу гравитации дыры ^ -1
|
||||||
if (level.otmRandom.nextDouble() < 0.01 * 0.05 * (1 / gravitationStrength)) {
|
if (level.random.nextDouble() < 0.01 * 0.05 * (1 / gravitationStrength)) {
|
||||||
this.mass += HAWKING_MASS_LOSE_STEP
|
this.mass += HAWKING_MASS_LOSE_STEP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.core.math.times
|
|||||||
import ru.dbotthepony.mc.otm.core.multiblock.BlockEntityTag
|
import ru.dbotthepony.mc.otm.core.multiblock.BlockEntityTag
|
||||||
import ru.dbotthepony.mc.otm.core.multiblock.MultiblockStatus
|
import ru.dbotthepony.mc.otm.core.multiblock.MultiblockStatus
|
||||||
import ru.dbotthepony.mc.otm.core.multiblock.shapedMultiblock
|
import ru.dbotthepony.mc.otm.core.multiblock.shapedMultiblock
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.core.util.InvalidableLazy
|
import ru.dbotthepony.mc.otm.core.util.InvalidableLazy
|
||||||
import ru.dbotthepony.mc.otm.menu.tech.BlackHoleGeneratorMenu
|
import ru.dbotthepony.mc.otm.menu.tech.BlackHoleGeneratorMenu
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||||
@ -86,8 +86,8 @@ class BlackHoleGeneratorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
multiblock?.blockEntities(MatterHatchBlockEntity.INPUT_TAG)?.iterator()?.map { it.matter }?.toList() ?: listOf()
|
multiblock?.blockEntities(MatterHatchBlockEntity.INPUT_TAG)?.iterator()?.map { it.matter }?.toList() ?: listOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
val energy = CombinedProfiledEnergyStorage(FlowDirection.NONE, energyTarget::value, { level?.otmRandom })
|
val energy = CombinedProfiledEnergyStorage(FlowDirection.NONE, energyTarget::value, { level?.random })
|
||||||
val matter = CombinedProfiledMatterStorage(FlowDirection.NONE, matterTarget::value, { level?.otmRandom })
|
val matter = CombinedProfiledMatterStorage(FlowDirection.NONE, matterTarget::value, { level?.random })
|
||||||
|
|
||||||
enum class Mode(val label: Component, val tooltip: Component) {
|
enum class Mode(val label: Component, val tooltip: Component) {
|
||||||
TARGET_MASS(TranslatableComponent("otm.gui.black_hole_generator.sustain.mode"), TranslatableComponent("otm.gui.black_hole_generator.sustain.desc")),
|
TARGET_MASS(TranslatableComponent("otm.gui.black_hole_generator.sustain.mode"), TranslatableComponent("otm.gui.black_hole_generator.sustain.desc")),
|
||||||
|
@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.core.collect.map
|
|||||||
import ru.dbotthepony.mc.otm.core.collect.reduce
|
import ru.dbotthepony.mc.otm.core.collect.reduce
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.math.RelativeSide
|
import ru.dbotthepony.mc.otm.core.math.RelativeSide
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.core.shuffle
|
import ru.dbotthepony.mc.otm.core.shuffle
|
||||||
import ru.dbotthepony.mc.otm.graph.GraphNodeList
|
import ru.dbotthepony.mc.otm.graph.GraphNodeList
|
||||||
import ru.dbotthepony.mc.otm.onceServer
|
import ru.dbotthepony.mc.otm.onceServer
|
||||||
@ -627,7 +627,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun receiveEnergy(howMuch: Decimal, simulate: Boolean, fromNode: EnergyCableBlockEntity.Node, fromSide: RelativeSide): Decimal {
|
fun receiveEnergy(howMuch: Decimal, simulate: Boolean, fromNode: EnergyCableBlockEntity.Node, fromSide: RelativeSide): Decimal {
|
||||||
livelyNodesList.shuffle(fromNode.blockEntity.level!!.otmRandom)
|
livelyNodesList.shuffle(fromNode.blockEntity.level!!.random)
|
||||||
|
|
||||||
val itr = livelyNodesList.iterator()
|
val itr = livelyNodesList.iterator()
|
||||||
var received = Decimal.ZERO
|
var received = Decimal.ZERO
|
||||||
|
@ -32,7 +32,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity
|
|||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu
|
import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MSoundEvents
|
import ru.dbotthepony.mc.otm.registry.game.MSoundEvents
|
||||||
@ -71,7 +71,7 @@ class CargoCrateBlockEntity(
|
|||||||
|
|
||||||
if (interactingPlayers++ == 0 && level != null && !isRemoved && level.getBlockState(blockPos).block is CargoCrateBlock) {
|
if (interactingPlayers++ == 0 && level != null && !isRemoved && level.getBlockState(blockPos).block is CargoCrateBlock) {
|
||||||
level.setBlock(blockPos, blockState.setValue(CargoCrateBlock.IS_OPEN, true), Block.UPDATE_CLIENTS)
|
level.setBlock(blockPos, blockState.setValue(CargoCrateBlock.IS_OPEN, true), Block.UPDATE_CLIENTS)
|
||||||
level.playSound(null, blockPos, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level.otmRandom.nextFloat() * 0.2f)
|
level.playSound(null, blockPos, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level.random.nextFloat() * 0.2f)
|
||||||
level.gameEvent(GameEvent.CONTAINER_OPEN, blockPos, GameEvent.Context.of(blockState))
|
level.gameEvent(GameEvent.CONTAINER_OPEN, blockPos, GameEvent.Context.of(blockState))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class DevChestBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB
|
|||||||
return cache
|
return cache
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun mappingsChanged(event: IdMappingEvent) {
|
fun mappingsChanged(event: IdMappingEvent) {
|
||||||
cache.clear()
|
cache.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.config.MachinesConfig
|
|||||||
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.data.codec.DecimalCodec
|
import ru.dbotthepony.mc.otm.data.codec.DecimalCodec
|
||||||
import ru.dbotthepony.mc.otm.data.codec.minRange
|
import ru.dbotthepony.mc.otm.data.codec.minRange
|
||||||
import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode
|
import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode
|
||||||
@ -106,15 +106,10 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
|
|||||||
if (!status.job.matterValue.isZero)
|
if (!status.job.matterValue.isZero)
|
||||||
status.throttleFast()
|
status.throttleFast()
|
||||||
} else {
|
} else {
|
||||||
val received = matter.receiveMatter(status.job.matterValue, false)
|
status.job.matterValue -= matter.receiveMatter(status.job.matterValue, false)
|
||||||
status.job.matterValue -= received
|
|
||||||
|
|
||||||
if (status.job.matterValue.isPositive) {
|
if (status.job.matterValue.isPositive)
|
||||||
if (received.isPositive)
|
status.noMatter()
|
||||||
status.noMatter(1)
|
|
||||||
else
|
|
||||||
status.noMatter()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +126,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
|
|||||||
|
|
||||||
return JobContainer.success(
|
return JobContainer.success(
|
||||||
DecomposerJob(
|
DecomposerJob(
|
||||||
(level?.otmRandom?.nextDouble() ?: 1.0) <= 0.2 * upgrades.failureMultiplier,
|
(level?.random?.nextDouble() ?: 1.0) <= 0.2 * upgrades.failureMultiplier,
|
||||||
matter.matter,
|
matter.matter,
|
||||||
matter.complexity * MachinesConfig.MATTER_DECOMPOSER.workTimeMultiplier
|
matter.complexity * MachinesConfig.MATTER_DECOMPOSER.workTimeMultiplier
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.container.HandlerFilter
|
|||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.container.UpgradeContainer
|
import ru.dbotthepony.mc.otm.container.UpgradeContainer
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.core.registryName
|
import ru.dbotthepony.mc.otm.core.registryName
|
||||||
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
|
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
|
||||||
import ru.dbotthepony.mc.otm.matter.IMatterValue
|
import ru.dbotthepony.mc.otm.matter.IMatterValue
|
||||||
@ -264,7 +264,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failureChance * upgrades.failureMultiplier <= 0.0 || level!!.otmRandom.nextDouble() >= failureChance * upgrades.failureMultiplier)
|
if (failureChance * upgrades.failureMultiplier <= 0.0 || level!!.random.nextDouble() >= failureChance * upgrades.failureMultiplier)
|
||||||
repairProgress += progressPerTick
|
repairProgress += progressPerTick
|
||||||
|
|
||||||
energy.extractEnergy(energyConsumption * (progressPerTick / thisProgressPerTick), false)
|
energy.extractEnergy(energyConsumption * (progressPerTick / thisProgressPerTick), false)
|
||||||
|
@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.config.MachinesConfig
|
|||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.graph.matter.MatterGraph
|
import ru.dbotthepony.mc.otm.graph.matter.MatterGraph
|
||||||
import ru.dbotthepony.mc.otm.item.matter.MatterDustItem
|
import ru.dbotthepony.mc.otm.item.matter.MatterDustItem
|
||||||
import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu
|
import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu
|
||||||
@ -117,7 +117,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
|||||||
stack.shrink(1)
|
stack.shrink(1)
|
||||||
container.setChanged(0)
|
container.setChanged(0)
|
||||||
|
|
||||||
val actualMatter = dustMatter.matter * (0.4 + level!!.otmRandom.nextDouble() * 0.6)
|
val actualMatter = dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6)
|
||||||
|
|
||||||
return JobContainer.success(
|
return JobContainer.success(
|
||||||
RecyclerJob(
|
RecyclerJob(
|
||||||
|
@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.config.MachinesConfig
|
|||||||
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.data.codec.DecimalCodec
|
import ru.dbotthepony.mc.otm.data.codec.DecimalCodec
|
||||||
import ru.dbotthepony.mc.otm.data.codec.minRange
|
import ru.dbotthepony.mc.otm.data.codec.minRange
|
||||||
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
|
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
|
||||||
@ -184,7 +184,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
|||||||
task = allocation.task.id,
|
task = allocation.task.id,
|
||||||
matterValue = matter.matter,
|
matterValue = matter.matter,
|
||||||
pattern = Optional.ofNullable(allocation.pattern),
|
pattern = Optional.ofNullable(allocation.pattern),
|
||||||
asDust = (level?.otmRandom?.nextDouble() ?: 1.0) * upgrades.failureMultiplier > (allocation.pattern?.researchPercent ?: 2.0),
|
asDust = (level?.random?.nextDouble() ?: 1.0) * upgrades.failureMultiplier > (allocation.pattern?.researchPercent ?: 2.0),
|
||||||
ticks = ticks,
|
ticks = ticks,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
|||||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
|
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
|
||||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets8
|
import ru.dbotthepony.mc.otm.client.render.Widgets8
|
||||||
|
@ -35,7 +35,7 @@ import ru.dbotthepony.mc.otm.container.balance
|
|||||||
import ru.dbotthepony.mc.otm.core.collect.filter
|
import ru.dbotthepony.mc.otm.core.collect.filter
|
||||||
import ru.dbotthepony.mc.otm.core.collect.maybe
|
import ru.dbotthepony.mc.otm.core.collect.maybe
|
||||||
import ru.dbotthepony.mc.otm.core.immutableList
|
import ru.dbotthepony.mc.otm.core.immutableList
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
|
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
|
||||||
import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe
|
import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe
|
||||||
import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe
|
import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe
|
||||||
@ -153,7 +153,7 @@ sealed class AbstractPoweredFurnaceBlockEntity<P : AbstractCookingRecipe, S : Ma
|
|||||||
recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess),
|
recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess),
|
||||||
recipe.workTime * config.workTimeMultiplier,
|
recipe.workTime * config.workTimeMultiplier,
|
||||||
config.energyConsumption * toProcess,
|
config.energyConsumption * toProcess,
|
||||||
experience = recipe.experience.sample(level.otmRandom) * toProcess))
|
experience = recipe.experience.sample(level.random) * toProcess))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection
|
|||||||
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.ProxiedEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.ProxiedEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
||||||
import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
|
import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.core.shuffle
|
import ru.dbotthepony.mc.otm.core.shuffle
|
||||||
import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu
|
import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||||
@ -58,7 +58,7 @@ class AndroidChargerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma
|
|||||||
|
|
||||||
val ents = level.getEntitiesInEllipsoid(blockPos.center, Vec3(MachinesConfig.AndroidCharger.RADIUS_WIDTH, MachinesConfig.AndroidCharger.RADIUS_HEIGHT, MachinesConfig.AndroidCharger.RADIUS_WIDTH)) { it is Player }
|
val ents = level.getEntitiesInEllipsoid(blockPos.center, Vec3(MachinesConfig.AndroidCharger.RADIUS_WIDTH, MachinesConfig.AndroidCharger.RADIUS_HEIGHT, MachinesConfig.AndroidCharger.RADIUS_WIDTH)) { it is Player }
|
||||||
|
|
||||||
ents.shuffle(level.otmRandom)
|
ents.shuffle(level.random)
|
||||||
|
|
||||||
for ((ent) in ents) {
|
for ((ent) in ents) {
|
||||||
val ply = (ent as Player).matteryPlayer
|
val ply = (ent as Player).matteryPlayer
|
||||||
|
@ -13,11 +13,11 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.capability.moveEnergy
|
import ru.dbotthepony.mc.otm.capability.moveEnergy
|
||||||
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.core.shuffle
|
import ru.dbotthepony.mc.otm.core.shuffle
|
||||||
import ru.dbotthepony.mc.otm.core.util.countingLazy
|
import ru.dbotthepony.mc.otm.core.util.countingLazy
|
||||||
import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu
|
import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu
|
||||||
@ -90,7 +90,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Ma
|
|||||||
val y = blockPos.y.toDouble()
|
val y = blockPos.y.toDouble()
|
||||||
val z = blockPos.z.toDouble()
|
val z = blockPos.z.toDouble()
|
||||||
|
|
||||||
for (ent in level.getEntitiesOfClass(ServerPlayer::class.java, AABB(x, y, z, x + 1.0, y + 2.0, z + 1.0)).shuffle(level.otmRandom)) {
|
for (ent in level.getEntitiesOfClass(ServerPlayer::class.java, AABB(x, y, z, x + 1.0, y + 2.0, z + 1.0)).shuffle(level.random)) {
|
||||||
if (ent.matteryPlayer.isAndroid)
|
if (ent.matteryPlayer.isAndroid)
|
||||||
moveEnergy(energy, ent.matteryPlayer.androidEnergy, amount = energy.batteryLevel, simulate = false, ignoreFlowRestrictions = true)
|
moveEnergy(energy, ent.matteryPlayer.androidEnergy, amount = energy.batteryLevel, simulate = false, ignoreFlowRestrictions = true)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import ru.dbotthepony.mc.otm.container.HandlerFilter
|
|||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||||
import ru.dbotthepony.mc.otm.core.immutableList
|
import ru.dbotthepony.mc.otm.core.immutableList
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.core.shuffle
|
import ru.dbotthepony.mc.otm.core.shuffle
|
||||||
import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu
|
import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||||
@ -60,7 +60,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
|||||||
if (!howMuch.isPositive)
|
if (!howMuch.isPositive)
|
||||||
return Decimal.ZERO
|
return Decimal.ZERO
|
||||||
|
|
||||||
containerSlotIndices.shuffle(level!!.otmRandom)
|
containerSlotIndices.shuffle(level!!.random)
|
||||||
var summ = Decimal.ZERO
|
var summ = Decimal.ZERO
|
||||||
var remaining = howMuch
|
var remaining = howMuch
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.core.math.RelativeSide
|
|||||||
import ru.dbotthepony.mc.otm.core.multiblock.BlockEntityTag
|
import ru.dbotthepony.mc.otm.core.multiblock.BlockEntityTag
|
||||||
import ru.dbotthepony.mc.otm.core.multiblock.IMultiblockAccess
|
import ru.dbotthepony.mc.otm.core.multiblock.IMultiblockAccess
|
||||||
import ru.dbotthepony.mc.otm.core.multiblock.IMultiblockListener
|
import ru.dbotthepony.mc.otm.core.multiblock.IMultiblockListener
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.core.util.InvalidableLazy
|
import ru.dbotthepony.mc.otm.core.util.InvalidableLazy
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class EnergyInterfaceBlockEntity(
|
|||||||
multiblocks.keys.iterator().flatMap { it.blockEntities(TARGET).iterator() }.map { it.energyInterfaceTarget }.toList()
|
multiblocks.keys.iterator().flatMap { it.blockEntities(TARGET).iterator() }.map { it.energyInterfaceTarget }.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
val energy = CombinedProfiledEnergyStorage(FlowDirection.input(isInput), targets::value, { level?.otmRandom })
|
val energy = CombinedProfiledEnergyStorage(FlowDirection.input(isInput), targets::value, { level?.random })
|
||||||
|
|
||||||
override fun onAddedToMultiblock(multiblock: IMultiblockAccess) {
|
override fun onAddedToMultiblock(multiblock: IMultiblockAccess) {
|
||||||
check(!isRemoved) { "Block was removed" }
|
check(!isRemoved) { "Block was removed" }
|
||||||
|
@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer
|
|||||||
import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
|
import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
|
||||||
import ru.dbotthepony.mc.otm.core.lookupOrThrow
|
import ru.dbotthepony.mc.otm.core.lookupOrThrow
|
||||||
import ru.dbotthepony.mc.otm.core.math.Vector
|
import ru.dbotthepony.mc.otm.core.math.Vector
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.core.util.countingLazy
|
import ru.dbotthepony.mc.otm.core.util.countingLazy
|
||||||
import ru.dbotthepony.mc.otm.item.consumables.EssenceCapsuleItem
|
import ru.dbotthepony.mc.otm.item.consumables.EssenceCapsuleItem
|
||||||
import ru.dbotthepony.mc.otm.item.EssenceServoItem
|
import ru.dbotthepony.mc.otm.item.EssenceServoItem
|
||||||
@ -173,7 +173,7 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma
|
|||||||
|
|
||||||
val diff = dmgPerExp - repairPoints.toFloat()
|
val diff = dmgPerExp - repairPoints.toFloat()
|
||||||
if (diff > 0f) {
|
if (diff > 0f) {
|
||||||
repairPoints += if ((level?.otmRandom?.nextFloat() ?: 1f) <= diff) 1 else 0
|
repairPoints += if ((level?.random?.nextFloat() ?: 1f) <= diff) 1 else 0
|
||||||
}
|
}
|
||||||
|
|
||||||
experienceStored -= 1
|
experienceStored -= 1
|
||||||
@ -202,7 +202,7 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma
|
|||||||
|
|
||||||
level!!.playSound(null, ent.x, ent.y, ent.z,
|
level!!.playSound(null, ent.x, ent.y, ent.z,
|
||||||
SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.BLOCKS,
|
SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.BLOCKS,
|
||||||
0.1F, 0.5F + level!!.otmRandom.nextFloat() * 0.25F
|
0.1F, 0.5F + level!!.random.nextFloat() * 0.25F
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.container.HandlerFilter
|
|||||||
import ru.dbotthepony.mc.otm.container.balance
|
import ru.dbotthepony.mc.otm.container.balance
|
||||||
import ru.dbotthepony.mc.otm.core.collect.filter
|
import ru.dbotthepony.mc.otm.core.collect.filter
|
||||||
import ru.dbotthepony.mc.otm.core.collect.maybe
|
import ru.dbotthepony.mc.otm.core.collect.maybe
|
||||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
|
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MRecipes
|
import ru.dbotthepony.mc.otm.registry.game.MRecipes
|
||||||
@ -90,7 +90,7 @@ class PlatePressBlockEntity(
|
|||||||
recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess),
|
recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess),
|
||||||
recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier,
|
recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier,
|
||||||
MachinesConfig.PLATE_PRESS.energyConsumption * toProcess,
|
MachinesConfig.PLATE_PRESS.energyConsumption * toProcess,
|
||||||
experience = recipe.experience.sample(level.otmRandom) * toProcess))
|
experience = recipe.experience.sample(level.random) * toProcess))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tick() {
|
override fun tick() {
|
||||||
|
@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.block.MatteryBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.addSimpleDescription
|
import ru.dbotthepony.mc.otm.block.addSimpleDescription
|
||||||
import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.capability
|
|||||||
import com.google.common.collect.Streams
|
import com.google.common.collect.Streams
|
||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.world.entity.LivingEntity
|
||||||
import net.minecraft.world.entity.player.Player
|
import net.minecraft.world.entity.player.Player
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities
|
import net.neoforged.neoforge.capabilities.Capabilities
|
||||||
@ -33,11 +34,13 @@ import ru.dbotthepony.mc.otm.core.collect.map
|
|||||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.util.formatFluidLevel
|
import ru.dbotthepony.mc.otm.core.util.formatFluidLevel
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
|
||||||
import java.util.stream.Stream
|
import java.util.stream.Stream
|
||||||
|
|
||||||
private val LOGGER = LogManager.getLogger()
|
private val LOGGER = LogManager.getLogger()
|
||||||
|
|
||||||
|
val Player.matteryPlayer: MatteryPlayer get() = (this as IMatteryPlayer).otmPlayer
|
||||||
|
val LivingEntity.matteryPlayer: MatteryPlayer? get() = (this as? IMatteryPlayer)?.otmPlayer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does a checked energy receive, calls [IMatteryEnergyStorage.receiveEnergyChecked] if possible
|
* Does a checked energy receive, calls [IMatteryEnergyStorage.receiveEnergyChecked] if possible
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player
|
package ru.dbotthepony.mc.otm.capability
|
||||||
|
|
||||||
interface IMatteryPlayer {
|
interface IMatteryPlayer {
|
||||||
// since new capabilities dont get to live through getCapability calls by design
|
// since new capabilities dont get to live through getCapability calls by design
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.player
|
package ru.dbotthepony.mc.otm.capability
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem
|
import com.mojang.blaze3d.systems.RenderSystem
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
@ -20,19 +20,22 @@ import net.minecraft.server.level.ServerLevel
|
|||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.minecraft.tags.TagKey
|
import net.minecraft.tags.TagKey
|
||||||
import net.minecraft.world.Container
|
import net.minecraft.world.Container
|
||||||
|
import net.minecraft.world.Difficulty
|
||||||
|
import net.minecraft.world.damagesource.DamageSource
|
||||||
import net.minecraft.world.effect.MobEffect
|
import net.minecraft.world.effect.MobEffect
|
||||||
|
import net.minecraft.world.effect.MobEffectInstance
|
||||||
import net.minecraft.world.effect.MobEffects
|
import net.minecraft.world.effect.MobEffects
|
||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.world.entity.LivingEntity
|
||||||
import net.minecraft.world.entity.boss.wither.WitherBoss
|
import net.minecraft.world.entity.boss.wither.WitherBoss
|
||||||
import net.minecraft.world.entity.player.Inventory
|
import net.minecraft.world.entity.player.Inventory
|
||||||
import net.minecraft.world.entity.player.Player
|
import net.minecraft.world.entity.player.Player
|
||||||
import net.minecraft.world.food.FoodProperties
|
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import net.minecraft.world.item.ProjectileWeaponItem
|
import net.minecraft.world.item.ProjectileWeaponItem
|
||||||
import net.minecraft.world.item.crafting.RecipeManager
|
import net.minecraft.world.item.crafting.RecipeManager
|
||||||
import net.minecraft.world.item.crafting.RecipeType
|
import net.minecraft.world.item.crafting.RecipeType
|
||||||
import net.minecraft.world.item.crafting.SingleRecipeInput
|
import net.minecraft.world.item.crafting.SingleRecipeInput
|
||||||
|
import net.minecraft.world.level.GameRules
|
||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
import net.minecraft.world.phys.Vec3
|
import net.minecraft.world.phys.Vec3
|
||||||
import net.neoforged.bus.api.Event
|
import net.neoforged.bus.api.Event
|
||||||
@ -56,23 +59,22 @@ import ru.dbotthepony.kommons.util.getValue
|
|||||||
import ru.dbotthepony.kommons.util.setValue
|
import ru.dbotthepony.kommons.util.setValue
|
||||||
import ru.dbotthepony.kommons.util.value
|
import ru.dbotthepony.kommons.util.value
|
||||||
import ru.dbotthepony.mc.otm.*
|
import ru.dbotthepony.mc.otm.*
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeature
|
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeatureType
|
import ru.dbotthepony.mc.otm.android.AndroidFeatureType
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearch
|
import ru.dbotthepony.mc.otm.android.AndroidResearch
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager
|
import ru.dbotthepony.mc.otm.android.AndroidResearchManager
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchType
|
import ru.dbotthepony.mc.otm.android.AndroidResearchType
|
||||||
import ru.dbotthepony.mc.otm.block.entity.ItemJob
|
import ru.dbotthepony.mc.otm.block.entity.ItemJob
|
||||||
import ru.dbotthepony.mc.otm.block.entity.JobContainer
|
import ru.dbotthepony.mc.otm.block.entity.JobContainer
|
||||||
import ru.dbotthepony.mc.otm.block.entity.JobStatus
|
import ru.dbotthepony.mc.otm.block.entity.JobStatus
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop
|
import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop
|
||||||
import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade
|
|
||||||
import ru.dbotthepony.mc.otm.capability.energy
|
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.BatteryBackedEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.BatteryBackedEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.capability.receiveEnergy
|
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||||
|
import ru.dbotthepony.mc.otm.capability.energy.receiveEnergyExact
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.config.ExopackConfig
|
import ru.dbotthepony.mc.otm.config.ExopackConfig
|
||||||
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
||||||
import ru.dbotthepony.mc.otm.container.DynamicallyProxiedContainer
|
import ru.dbotthepony.mc.otm.container.DynamicallyProxiedContainer
|
||||||
@ -430,6 +432,8 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
|
|
||||||
private var shouldPlaySound = false
|
private var shouldPlaySound = false
|
||||||
private val research = IdentityHashMap<AndroidResearchType, AndroidResearch>()
|
private val research = IdentityHashMap<AndroidResearchType, AndroidResearch>()
|
||||||
|
private var nextDischargeHurt = 20
|
||||||
|
private var nextHealTick = 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns if player is an Android or will become one on death/sleep/etc
|
* This returns if player is an Android or will become one on death/sleep/etc
|
||||||
@ -528,7 +532,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
override fun onJobTick(status: JobStatus<ItemJob>) {
|
override fun onJobTick(status: JobStatus<ItemJob>) {
|
||||||
super.onJobTick(status)
|
super.onJobTick(status)
|
||||||
|
|
||||||
if (isExopackVisible && ply.level().otmRandom.nextFloat() <= 0.05f) {
|
if (isExopackVisible && ply.level().random.nextFloat() <= 0.05f) {
|
||||||
PacketDistributor.sendToPlayersTrackingEntityAndSelf(ply, ExopackSmokePacket(ply.uuid))
|
PacketDistributor.sendToPlayersTrackingEntityAndSelf(ply, ExopackSmokePacket(ply.uuid))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -553,10 +557,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
/**
|
/**
|
||||||
* [IMatteryEnergyStorage] instance, representing Android' battery charge
|
* [IMatteryEnergyStorage] instance, representing Android' battery charge
|
||||||
*/
|
*/
|
||||||
val androidEnergy = BatteryBackedEnergyStorage(ply, syncher, PlayerConfig.ANDROID_MAX_ENERGY, PlayerConfig.ANDROID_MAX_ENERGY, true)
|
val androidEnergy = BatteryBackedEnergyStorage(ply, syncher, AndroidConfig.ANDROID_MAX_ENERGY, AndroidConfig.ANDROID_MAX_ENERGY, true)
|
||||||
|
|
||||||
val androidHasEnergy: Boolean
|
|
||||||
get() = androidEnergy.batteryLevel > Decimal.TEN
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [IMatteryEnergyStorage] instance, representing Exopack battery charge
|
* [IMatteryEnergyStorage] instance, representing Exopack battery charge
|
||||||
@ -579,6 +580,8 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
savetables.bool(::isExopackCraftingUpgraded, "isExoSuitCraftingUpgraded")
|
savetables.bool(::isExopackCraftingUpgraded, "isExoSuitCraftingUpgraded")
|
||||||
savetables.bool(::isExopackEnderAccessInstalled, "isExopackEnderAccessUpgraded")
|
savetables.bool(::isExopackEnderAccessInstalled, "isExopackEnderAccessUpgraded")
|
||||||
savetables.bool(::acceptExopackChargeFromWirelessCharger)
|
savetables.bool(::acceptExopackChargeFromWirelessCharger)
|
||||||
|
savetables.int(::nextDischargeHurt)
|
||||||
|
savetables.int(::nextHealTick)
|
||||||
|
|
||||||
savetables.vector(::lastLiquidPosition)
|
savetables.vector(::lastLiquidPosition)
|
||||||
savetables.codec(::lastDimension, ResourceLocation.CODEC)
|
savetables.codec(::lastDimension, ResourceLocation.CODEC)
|
||||||
@ -652,8 +655,8 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
shouldPlaySound = false
|
shouldPlaySound = false
|
||||||
iteration = 0
|
iteration = 0
|
||||||
deathLog.clear()
|
deathLog.clear()
|
||||||
androidEnergy.batteryLevel = PlayerConfig.ANDROID_MAX_ENERGY
|
androidEnergy.batteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
||||||
androidEnergy.maxBatteryLevel = PlayerConfig.ANDROID_MAX_ENERGY
|
androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
||||||
|
|
||||||
lastLiquidPosition = ply.position()
|
lastLiquidPosition = ply.position()
|
||||||
wasInLiquid = false
|
wasInLiquid = false
|
||||||
@ -707,7 +710,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
iteration = 0
|
iteration = 0
|
||||||
deathLog.clear()
|
deathLog.clear()
|
||||||
androidEnergy.batteryLevel = Decimal.ZERO
|
androidEnergy.batteryLevel = Decimal.ZERO
|
||||||
androidEnergy.maxBatteryLevel = PlayerConfig.ANDROID_MAX_ENERGY
|
androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
||||||
dropBattery()
|
dropBattery()
|
||||||
|
|
||||||
lastLiquidPosition = ply.position()
|
lastLiquidPosition = ply.position()
|
||||||
@ -1206,6 +1209,81 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
|
|
||||||
lastLiquidPosition = ply.position
|
lastLiquidPosition = ply.position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val stats = ply.foodData
|
||||||
|
val fourTimesTheHunger = AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * 4
|
||||||
|
|
||||||
|
// истощение
|
||||||
|
if (stats.exhaustionLevel > 0f) {
|
||||||
|
val extracted = androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false)
|
||||||
|
stats.setExhaustion(stats.exhaustionLevel - (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Обычный голод
|
||||||
|
while (
|
||||||
|
stats.foodLevel < 18 &&
|
||||||
|
androidEnergy.batteryLevel >= fourTimesTheHunger &&
|
||||||
|
androidEnergy.extractEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)
|
||||||
|
) {
|
||||||
|
stats.foodLevel++
|
||||||
|
}
|
||||||
|
|
||||||
|
// "поглощение" излишек голода, как при мирном режиме, так и при поедании обычной еды
|
||||||
|
if (AndroidConfig.REGENERATE_ENERGY) {
|
||||||
|
while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT / 2, false)) {
|
||||||
|
stats.foodLevel--
|
||||||
|
}
|
||||||
|
} else if (ply.level().difficulty != Difficulty.PEACEFUL) {
|
||||||
|
stats.foodLevel = stats.foodLevel.coerceAtMost(18)
|
||||||
|
}
|
||||||
|
|
||||||
|
val foodLevel = stats.foodLevel.toFloat()
|
||||||
|
|
||||||
|
// насыщение
|
||||||
|
if (stats.saturationLevel < foodLevel && androidEnergy.batteryLevel >= fourTimesTheHunger) {
|
||||||
|
val extracted = androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (foodLevel - stats.saturationLevel), false)
|
||||||
|
stats.setSaturation(stats.saturationLevel + (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
|
if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level().difficulty != Difficulty.PEACEFUL) {
|
||||||
|
if (stats.saturationLevel > 1f) {
|
||||||
|
if (androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) {
|
||||||
|
stats.setSaturation(stats.saturationLevel - 1f)
|
||||||
|
}
|
||||||
|
} else if (stats.saturationLevel > 0f) {
|
||||||
|
val received = androidEnergy.receiveEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * stats.saturationLevel, false)
|
||||||
|
stats.setSaturation(stats.saturationLevel - (received / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat())
|
||||||
|
} else if (stats.foodLevel > 0) {
|
||||||
|
// так как голод не тикает для андроидов, "умереть с голоду" мы не можем
|
||||||
|
// но со стороны будет выглядеть как будто мы умираем с голода
|
||||||
|
if (androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) {
|
||||||
|
stats.foodLevel--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (androidEnergy.batteryLevel <= Decimal.TEN) {
|
||||||
|
if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level().registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) {
|
||||||
|
nextDischargeHurt = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
val effect = ply.activeEffectsMap[MobEffects.MOVEMENT_SLOWDOWN]
|
||||||
|
|
||||||
|
if (effect == null || effect.duration < 40 || effect.amplifier < 2) {
|
||||||
|
ply.addEffect(MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, effect?.duration?.coerceAtLeast(60) ?: 60, effect?.amplifier?.coerceAtLeast(2) ?: 2, false, false))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nextDischargeHurt = 20
|
||||||
|
|
||||||
|
if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||||
|
if (--nextHealTick <= 0) {
|
||||||
|
nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||||
|
ply.heal(1f)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (feature in featureMap.values) {
|
for (feature in featureMap.values) {
|
||||||
@ -1319,7 +1397,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
|
|
||||||
pos.mul(RenderSystem.getProjectionMatrix())
|
pos.mul(RenderSystem.getProjectionMatrix())
|
||||||
pos.mul(poseStack.last().pose())
|
pos.mul(poseStack.last().pose())
|
||||||
makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level().otmRandom, ply.level())
|
makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level().random, ply.level())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1340,7 +1418,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
|
|
||||||
val ANDROID_IMMUNE_EFFECTS: TagKey<MobEffect> = TagKey.create(BuiltInRegistries.MOB_EFFECT.key(), ResourceLocation(OverdriveThatMatters.MOD_ID, "android_immune_effects"))
|
val ANDROID_IMMUNE_EFFECTS: TagKey<MobEffect> = TagKey.create(BuiltInRegistries.MOB_EFFECT.key(), ResourceLocation(OverdriveThatMatters.MOD_ID, "android_immune_effects"))
|
||||||
|
|
||||||
internal fun onPlayerTickPre(event: PlayerTickEvent.Pre) {
|
fun onPlayerTickPre(event: PlayerTickEvent.Pre) {
|
||||||
val ent = event.entity
|
val ent = event.entity
|
||||||
|
|
||||||
if (!ent.level().isClientSide) {
|
if (!ent.level().isClientSide) {
|
||||||
@ -1348,7 +1426,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onPlayerTickPost(event: PlayerTickEvent.Pre) {
|
fun onPlayerTickPost(event: PlayerTickEvent.Pre) {
|
||||||
val ent = event.entity
|
val ent = event.entity
|
||||||
|
|
||||||
if (ent.level().isClientSide) {
|
if (ent.level().isClientSide) {
|
||||||
@ -1358,7 +1436,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun isMobEffectApplicable(event: MobEffectEvent.Applicable) {
|
fun isMobEffectApplicable(event: MobEffectEvent.Applicable) {
|
||||||
event.entity.matteryPlayer?.let {
|
event.entity.matteryPlayer?.let {
|
||||||
if (it.isAndroid && BuiltInRegistries.MOB_EFFECT.getOrCreateTag(ANDROID_IMMUNE_EFFECTS).any { it == event.effectInstance?.effect }) {
|
if (it.isAndroid && BuiltInRegistries.MOB_EFFECT.getOrCreateTag(ANDROID_IMMUNE_EFFECTS).any { it == event.effectInstance?.effect }) {
|
||||||
event.result = MobEffectEvent.Applicable.Result.DO_NOT_APPLY
|
event.result = MobEffectEvent.Applicable.Result.DO_NOT_APPLY
|
||||||
@ -1366,18 +1444,18 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onHurtEvent(event: LivingIncomingDamageEvent) {
|
fun onHurtEvent(event: LivingIncomingDamageEvent) {
|
||||||
event.entity.matteryPlayer?.onHurt(event)
|
event.entity.matteryPlayer?.onHurt(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) {
|
fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) {
|
||||||
onceServer {
|
onceServer {
|
||||||
event.entity.matteryPlayer.invalidateNetworkState()
|
event.entity.matteryPlayer.invalidateNetworkState()
|
||||||
event.entity.matteryPlayer.recreateExoPackMenu()
|
event.entity.matteryPlayer.recreateExoPackMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onPlayerDeath(event: LivingDeathEvent) {
|
fun onPlayerDeath(event: LivingDeathEvent) {
|
||||||
val ply = event.entity as? Player ?: return
|
val ply = event.entity as? Player ?: return
|
||||||
|
|
||||||
if (ply.matteryPlayer.lastDeathTick != ply.tickCount) {
|
if (ply.matteryPlayer.lastDeathTick != ply.tickCount) {
|
||||||
@ -1394,15 +1472,15 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
ply.matteryPlayer.shouldSendIteration = true
|
ply.matteryPlayer.shouldSendIteration = true
|
||||||
ply.matteryPlayer.deathLog.addLast(ply.tickCount to ply.combatTracker.deathMessage)
|
ply.matteryPlayer.deathLog.addLast(ply.tickCount to ply.combatTracker.deathMessage)
|
||||||
|
|
||||||
if (ply.matteryPlayer.androidEnergy.batteryLevel < PlayerConfig.ANDROID_MAX_ENERGY * Decimal("0.2"))
|
if (ply.matteryPlayer.androidEnergy.batteryLevel < AndroidConfig.ANDROID_MAX_ENERGY * Decimal("0.2"))
|
||||||
ply.matteryPlayer.androidEnergy.batteryLevel = PlayerConfig.ANDROID_MAX_ENERGY * Decimal("0.2") // если смерть была от разряда батареи, то предотвращаем софтлок
|
ply.matteryPlayer.androidEnergy.batteryLevel = AndroidConfig.ANDROID_MAX_ENERGY * Decimal("0.2") // если смерть была от разряда батареи, то предотвращаем софтлок
|
||||||
|
|
||||||
while (ply.matteryPlayer.deathLog.size > 6) {
|
while (ply.matteryPlayer.deathLog.size > 6) {
|
||||||
ply.matteryPlayer.deathLog.removeFirst()
|
ply.matteryPlayer.deathLog.removeFirst()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onPlayerCloneEvent(event: PlayerEvent.Clone) {
|
fun onPlayerCloneEvent(event: PlayerEvent.Clone) {
|
||||||
val it = event.entity.matteryPlayer
|
val it = event.entity.matteryPlayer
|
||||||
val original = event.original.matteryPlayer
|
val original = event.original.matteryPlayer
|
||||||
|
|
||||||
@ -1430,7 +1508,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
|
|
||||||
private val LOGGER = LogManager.getLogger()
|
private val LOGGER = LogManager.getLogger()
|
||||||
|
|
||||||
internal fun onPlayerSpawnPhantoms(event: PlayerSpawnPhantomsEvent) {
|
fun onPlayerSpawnPhantoms(event: PlayerSpawnPhantomsEvent) {
|
||||||
if (event.entity.matteryPlayer.isAndroid) {
|
if (event.entity.matteryPlayer.isAndroid) {
|
||||||
event.result = PlayerSpawnPhantomsEvent.Result.DENY
|
event.result = PlayerSpawnPhantomsEvent.Result.DENY
|
||||||
}
|
}
|
||||||
@ -1440,14 +1518,14 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
* hooked into LivingEntity through coremod script
|
* hooked into LivingEntity through coremod script
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun addEatEffectHook(iterator: Iterator<FoodProperties.PossibleEffect>, entity: LivingEntity): Iterator<FoodProperties.PossibleEffect> {
|
fun addEatEffectHook(iterator: Iterator<com.mojang.datafixers.util.Pair<MobEffectInstance, Float>>, entity: LivingEntity): Iterator<com.mojang.datafixers.util.Pair<MobEffectInstance, Float>> {
|
||||||
if (entity !is Player) {
|
if (entity !is Player) {
|
||||||
return iterator
|
return iterator
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.matteryPlayer.isAndroid) {
|
if (entity.matteryPlayer.isAndroid) {
|
||||||
return iterator.filter {
|
return iterator.filter {
|
||||||
it.effect().effect != MobEffects.HUNGER
|
it.first.effect != MobEffects.HUNGER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1531,7 +1609,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
PacketDistributor.sendToServer(PickItemFromInventoryPacket(targetSlot, itemSlot))
|
PacketDistributor.sendToServer(PickItemFromInventoryPacket(targetSlot, itemSlot))
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onStartTracking(event: PlayerEvent.StartTracking) {
|
fun onStartTracking(event: PlayerEvent.StartTracking) {
|
||||||
if (event.target is ServerPlayer) {
|
if (event.target is ServerPlayer) {
|
||||||
(event.target as ServerPlayer).matteryPlayer.let {
|
(event.target as ServerPlayer).matteryPlayer.let {
|
||||||
it.remoteSynchers[event.entity as ServerPlayer] = it.publicSyncher.Remote()
|
it.remoteSynchers[event.entity as ServerPlayer] = it.publicSyncher.Remote()
|
||||||
@ -1539,7 +1617,7 @@ class MatteryPlayer(val ply: Player) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onStopTracking(event: PlayerEvent.StopTracking) {
|
fun onStopTracking(event: PlayerEvent.StopTracking) {
|
||||||
if (event.target is ServerPlayer) {
|
if (event.target is ServerPlayer) {
|
||||||
(event.target as ServerPlayer).matteryPlayer.remoteSynchers.remove(event.entity as ServerPlayer)
|
(event.target as ServerPlayer).matteryPlayer.remoteSynchers.remove(event.entity as ServerPlayer)
|
||||||
}
|
}
|
@ -118,7 +118,7 @@ object DrivePool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onWorldSave(event: LevelEvent.Save) {
|
fun onWorldSave(event: LevelEvent.Save) {
|
||||||
writeBacklog(event.level.server!!.registryAccess())
|
writeBacklog(event.level.server!!.registryAccess())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ import net.neoforged.neoforge.client.event.RenderLevelStageEvent
|
|||||||
import net.neoforged.neoforge.client.settings.KeyConflictContext
|
import net.neoforged.neoforge.client.settings.KeyConflictContext
|
||||||
import net.neoforged.neoforge.network.PacketDistributor
|
import net.neoforged.neoforge.network.PacketDistributor
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidActiveFeature
|
import ru.dbotthepony.mc.otm.android.AndroidActiveFeature
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||||
import ru.dbotthepony.mc.otm.client.render.is3DContext
|
import ru.dbotthepony.mc.otm.client.render.is3DContext
|
||||||
@ -46,7 +46,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onRenderGuiEvent(event: RenderGuiEvent.Post) {
|
fun onRenderGuiEvent(event: RenderGuiEvent.Post) {
|
||||||
if (!isDown) {
|
if (!isDown) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onRenderLevel(event: RenderLevelStageEvent) {
|
fun onRenderLevel(event: RenderLevelStageEvent) {
|
||||||
if (!isDown) {
|
if (!isDown) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun register(event: RegisterKeyMappingsEvent) {
|
fun register(event: RegisterKeyMappingsEvent) {
|
||||||
event.register(this)
|
event.register(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,12 @@ import net.neoforged.neoforge.client.event.RenderGuiEvent
|
|||||||
import net.neoforged.neoforge.client.settings.KeyConflictContext
|
import net.neoforged.neoforge.client.settings.KeyConflictContext
|
||||||
import net.neoforged.neoforge.network.PacketDistributor
|
import net.neoforged.neoforge.network.PacketDistributor
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidFeature
|
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature
|
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||||
|
import ru.dbotthepony.mc.otm.client.render.drawArc
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.core.math.angleDifference
|
import ru.dbotthepony.mc.otm.core.math.angleDifference
|
||||||
import ru.dbotthepony.mc.otm.core.math.normalizeAngle
|
import ru.dbotthepony.mc.otm.core.math.normalizeAngle
|
||||||
@ -94,7 +95,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onMouseClick(event: InputEvent.MouseButton.Pre) {
|
fun onMouseClick(event: InputEvent.MouseButton.Pre) {
|
||||||
// fix binding wheel menu to mouse button not calling back setIsDown(false)
|
// fix binding wheel menu to mouse button not calling back setIsDown(false)
|
||||||
if (isDown && event.action == 0 && key.type == InputConstants.Type.MOUSE && InputConstants.Type.MOUSE.getOrCreate(event.button) == key) {
|
if (isDown && event.action == 0 && key.type == InputConstants.Type.MOUSE && InputConstants.Type.MOUSE.getOrCreate(event.button) == key) {
|
||||||
isDown = false
|
isDown = false
|
||||||
@ -311,7 +312,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
|||||||
const val COOLDOWN_ICON_SIZE = 18f
|
const val COOLDOWN_ICON_SIZE = 18f
|
||||||
const val COOLDOWN_ICON_MARGIN = 12f
|
const val COOLDOWN_ICON_MARGIN = 12f
|
||||||
|
|
||||||
internal fun onRenderGuiEvent(event: RenderGuiEvent.Post) {
|
fun onRenderGuiEvent(event: RenderGuiEvent.Post) {
|
||||||
if (!grabbedInput) {
|
if (!grabbedInput) {
|
||||||
lastRender = milliTimeD
|
lastRender = milliTimeD
|
||||||
renderRegular(event)
|
renderRegular(event)
|
||||||
@ -325,7 +326,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun register(event: RegisterKeyMappingsEvent) {
|
fun register(event: RegisterKeyMappingsEvent) {
|
||||||
event.register(this)
|
event.register(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ import net.neoforged.neoforge.client.event.ScreenEvent
|
|||||||
import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent
|
import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent
|
||||||
import net.neoforged.neoforge.network.PacketDistributor
|
import net.neoforged.neoforge.network.PacketDistributor
|
||||||
import ru.dbotthepony.mc.otm.config.ClientConfig
|
import ru.dbotthepony.mc.otm.config.ClientConfig
|
||||||
import ru.dbotthepony.mc.otm.player.android.feature.JumpBoostFeature
|
import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||||
import ru.dbotthepony.mc.otm.client.screen.ExopackInventoryScreen
|
import ru.dbotthepony.mc.otm.client.screen.ExopackInventoryScreen
|
||||||
@ -38,7 +38,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
|||||||
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures
|
||||||
import java.util.WeakHashMap
|
import java.util.WeakHashMap
|
||||||
|
|
||||||
internal fun onMovementInputUpdate(event: MovementInputUpdateEvent) {
|
fun onMovementInputUpdate(event: MovementInputUpdateEvent) {
|
||||||
val ply = event.entity
|
val ply = event.entity
|
||||||
val input = event.input
|
val input = event.input
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ private fun exosuitInventoryLogic(screen: Screen, addListener: (GuiEventListener
|
|||||||
scrollbar.scroll = inventoryScroll
|
scrollbar.scroll = inventoryScroll
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onMouseDragged(event: ScreenEvent.MouseDragged.Pre) {
|
fun onMouseDragged(event: ScreenEvent.MouseDragged.Pre) {
|
||||||
val screen = minecraft.screen as? AbstractContainerScreen<*> ?: return
|
val screen = minecraft.screen as? AbstractContainerScreen<*> ?: return
|
||||||
|
|
||||||
if (screen is MatteryScreen<*>)
|
if (screen is MatteryScreen<*>)
|
||||||
@ -214,7 +214,7 @@ internal fun onMouseDragged(event: ScreenEvent.MouseDragged.Pre) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onMouseScrolled(event: ScreenEvent.MouseScrolled.Pre) {
|
fun onMouseScrolled(event: ScreenEvent.MouseScrolled.Pre) {
|
||||||
val screen = minecraft.screen as? AbstractContainerScreen<*> ?: return
|
val screen = minecraft.screen as? AbstractContainerScreen<*> ?: return
|
||||||
|
|
||||||
if (screen is MatteryScreen<*>)
|
if (screen is MatteryScreen<*>)
|
||||||
@ -242,7 +242,7 @@ internal fun onMouseScrolled(event: ScreenEvent.MouseScrolled.Pre) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onPostScreenInit(event: ScreenEvent.Init.Post) {
|
fun onPostScreenInit(event: ScreenEvent.Init.Post) {
|
||||||
if (!LOGGED_IN) return
|
if (!LOGGED_IN) return
|
||||||
inventoryLogic(event)
|
inventoryLogic(event)
|
||||||
onceClient {
|
onceClient {
|
||||||
@ -250,7 +250,7 @@ internal fun onPostScreenInit(event: ScreenEvent.Init.Post) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onScreenOpen(event: ScreenEvent.Opening) {
|
fun onScreenOpen(event: ScreenEvent.Opening) {
|
||||||
if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) {
|
if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ private val TOOLTIP_TAG_DISPLAY_HELP = TranslatableComponent("otm.gui.debug.tags
|
|||||||
private val TOOLTIP_TAG_DISPLAY_ITEM_TITLE = TranslatableComponent("otm.gui.debug.tags.item.title").withStyle(ChatFormatting.DARK_GRAY)
|
private val TOOLTIP_TAG_DISPLAY_ITEM_TITLE = TranslatableComponent("otm.gui.debug.tags.item.title").withStyle(ChatFormatting.DARK_GRAY)
|
||||||
private val TOOLTIP_TAG_DISPLAY_BLOCK_TITLE = TranslatableComponent("otm.gui.debug.tags.block.title").withStyle(ChatFormatting.DARK_GRAY)
|
private val TOOLTIP_TAG_DISPLAY_BLOCK_TITLE = TranslatableComponent("otm.gui.debug.tags.block.title").withStyle(ChatFormatting.DARK_GRAY)
|
||||||
|
|
||||||
internal fun tooltipEvent(event: ItemTooltipEvent) {
|
fun tooltipEvent(event: ItemTooltipEvent) {
|
||||||
if (event.flags.isAdvanced && ClientConfig.Tooltip.DISPLAY_TAGS && !event.itemStack.isEmpty) {
|
if (event.flags.isAdvanced && ClientConfig.Tooltip.DISPLAY_TAGS && !event.itemStack.isEmpty) {
|
||||||
val itemTags = ArrayList<TagKey<Item>>()
|
val itemTags = ArrayList<TagKey<Item>>()
|
||||||
if (event.itemStack.tags.count() > 0) {
|
if (event.itemStack.tags.count() > 0) {
|
||||||
|
@ -33,7 +33,7 @@ private inline fun check(cond: Boolean, error: () -> String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun createCursors() {
|
fun createCursors() {
|
||||||
ARROW_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR)
|
ARROW_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR)
|
||||||
BEAM_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_IBEAM_CURSOR)
|
BEAM_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_IBEAM_CURSOR)
|
||||||
HAND_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_POINTING_HAND_CURSOR)
|
HAND_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_POINTING_HAND_CURSOR)
|
||||||
@ -60,7 +60,7 @@ enum class CursorType(val pointer: LongSupplier) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onClientPostRender(event: RenderFrameEvent.Post) {
|
fun onClientPostRender(event: RenderFrameEvent.Post) {
|
||||||
if (MODIFIED_CURSOR_FRAMES-- <= 0 && MODIFIED_CURSOR) {
|
if (MODIFIED_CURSOR_FRAMES-- <= 0 && MODIFIED_CURSOR) {
|
||||||
GLFW.glfwSetCursor(minecraft.window.window, ARROW_CURSOR)
|
GLFW.glfwSetCursor(minecraft.window.window, ARROW_CURSOR)
|
||||||
MODIFIED_CURSOR = false
|
MODIFIED_CURSOR = false
|
||||||
@ -116,22 +116,22 @@ fun tickWhileClientPre(condition: () -> Boolean, ticker: () -> Unit) {
|
|||||||
tickClientPre(IConditionalTickable.wrap(condition, ticker))
|
tickClientPre(IConditionalTickable.wrap(condition, ticker))
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onClientTickPre(event: ClientTickEvent.Pre) {
|
fun onClientTickPre(event: ClientTickEvent.Pre) {
|
||||||
preTickList.tick()
|
preTickList.tick()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onClientTickPost(event: ClientTickEvent.Post) {
|
fun onClientTickPost(event: ClientTickEvent.Post) {
|
||||||
postTickList.tick()
|
postTickList.tick()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onClientDisconnected(event: ClientPlayerNetworkEvent.LoggingOut) {
|
fun onClientDisconnected(event: ClientPlayerNetworkEvent.LoggingOut) {
|
||||||
LOGGED_IN = false
|
LOGGED_IN = false
|
||||||
|
|
||||||
preTickList.clear()
|
preTickList.clear()
|
||||||
postTickList.clear()
|
postTickList.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onClientConnected(event: ClientPlayerNetworkEvent.LoggingIn) {
|
fun onClientConnected(event: ClientPlayerNetworkEvent.LoggingIn) {
|
||||||
LOGGED_IN = true
|
LOGGED_IN = true
|
||||||
|
|
||||||
preTickList.clear()
|
preTickList.clear()
|
||||||
|
@ -23,10 +23,10 @@ import net.neoforged.neoforge.client.event.RenderGuiLayerEvent
|
|||||||
import net.neoforged.neoforge.client.event.ScreenEvent
|
import net.neoforged.neoforge.client.event.ScreenEvent
|
||||||
import net.neoforged.neoforge.client.gui.VanillaGuiLayers
|
import net.neoforged.neoforge.client.gui.VanillaGuiLayers
|
||||||
import net.neoforged.neoforge.common.ItemAbilities
|
import net.neoforged.neoforge.common.ItemAbilities
|
||||||
import ru.dbotthepony.mc.otm.player.android.feature.NanobotsArmorFeature
|
import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.*
|
import ru.dbotthepony.mc.otm.client.render.*
|
||||||
import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas
|
import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas
|
||||||
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
|
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
|
||||||
@ -48,7 +48,7 @@ object MatteryGUI {
|
|||||||
|
|
||||||
private val buttonShaker = Random()
|
private val buttonShaker = Random()
|
||||||
|
|
||||||
internal fun onScreenRender(event: ScreenEvent.Render.Pre) {
|
fun onScreenRender(event: ScreenEvent.Render.Pre) {
|
||||||
val screen = minecraft.screen as? InBedChatScreen
|
val screen = minecraft.screen as? InBedChatScreen
|
||||||
|
|
||||||
if (screen == null || (screen.leaveBedButton as Button?) == null) {
|
if (screen == null || (screen.leaveBedButton as Button?) == null) {
|
||||||
@ -80,7 +80,7 @@ object MatteryGUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onOpenGUIEvent(event: ScreenEvent.Opening) {
|
fun onOpenGUIEvent(event: ScreenEvent.Opening) {
|
||||||
originalBedButtonX = -1
|
originalBedButtonX = -1
|
||||||
originalBedButtonY = -1
|
originalBedButtonY = -1
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ object MatteryGUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onLayerRenderEvent(event: RenderGuiLayerEvent.Pre) {
|
fun onLayerRenderEvent(event: RenderGuiLayerEvent.Pre) {
|
||||||
if (minecraft.player?.matteryPlayer?.isAndroid == true) {
|
if (minecraft.player?.matteryPlayer?.isAndroid == true) {
|
||||||
if (event.name == VanillaGuiLayers.FOOD_LEVEL
|
if (event.name == VanillaGuiLayers.FOOD_LEVEL
|
||||||
|| event.name == VanillaGuiLayers.AIR_LEVEL
|
|| event.name == VanillaGuiLayers.AIR_LEVEL
|
||||||
@ -105,7 +105,7 @@ object MatteryGUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun registerGuiLayers(event: RegisterGuiLayersEvent) {
|
fun registerGuiLayers(event: RegisterGuiLayersEvent) {
|
||||||
event.registerBelow(VanillaGuiLayers.FOOD_LEVEL, loc("android_energy_bar"), AndroidEnergyBarLayer())
|
event.registerBelow(VanillaGuiLayers.FOOD_LEVEL, loc("android_energy_bar"), AndroidEnergyBarLayer())
|
||||||
event.registerBelow(VanillaGuiLayers.PLAYER_HEALTH, loc("android_health_bar"), AndroidHealthBarLayer())
|
event.registerBelow(VanillaGuiLayers.PLAYER_HEALTH, loc("android_health_bar"), AndroidHealthBarLayer())
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal
|
|||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
object MatteryTooltipComponents {
|
object MatteryTooltipComponents {
|
||||||
internal fun gatherComponents(event: RenderTooltipEvent.GatherComponents) {
|
fun gatherComponents(event: RenderTooltipEvent.GatherComponents) {
|
||||||
val energyCap = event.itemStack.getCapability(MatteryCapability.ITEM_ENERGY)
|
val energyCap = event.itemStack.getCapability(MatteryCapability.ITEM_ENERGY)
|
||||||
if (energyCap != null && energyCap.maxBatteryLevel > Decimal.ZERO) {
|
if (energyCap != null && energyCap.maxBatteryLevel > Decimal.ZERO) {
|
||||||
event.tooltipElements.add(1, Either.right(EnergyStorageGaugeTooltip(energyCap)))
|
event.tooltipElements.add(1, Either.right(EnergyStorageGaugeTooltip(energyCap)))
|
||||||
@ -29,7 +29,7 @@ object MatteryTooltipComponents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun registerComponents(event: RegisterClientTooltipComponentFactoriesEvent) {
|
fun registerComponents(event: RegisterClientTooltipComponentFactoriesEvent) {
|
||||||
event.register(EnergyStorageGaugeTooltip::class.java) { it }
|
event.register(EnergyStorageGaugeTooltip::class.java) { it }
|
||||||
event.register(MatterStorageGaugeTooltip::class.java) { it }
|
event.register(MatterStorageGaugeTooltip::class.java) { it }
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class ChartTooltipElement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal fun register(event: RegisterClientTooltipComponentFactoriesEvent) {
|
fun register(event: RegisterClientTooltipComponentFactoriesEvent) {
|
||||||
event.register(ChartTooltipElement::class.java) { it }
|
event.register(ChartTooltipElement::class.java) { it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import net.minecraft.client.renderer.GameRenderer
|
|||||||
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
|
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
|
||||||
import net.minecraft.world.level.material.FogType
|
import net.minecraft.world.level.material.FogType
|
||||||
import org.joml.Matrix4f
|
import org.joml.Matrix4f
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.core.math.linearInterpolation
|
import ru.dbotthepony.mc.otm.core.math.linearInterpolation
|
||||||
import ru.dbotthepony.mc.otm.milliTime
|
import ru.dbotthepony.mc.otm.milliTime
|
||||||
|
@ -14,8 +14,6 @@ import net.minecraft.world.inventory.tooltip.TooltipComponent
|
|||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.ScreenPos
|
|
||||||
import java.util.Arrays
|
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@ -47,73 +45,6 @@ class MGUIGraphics(val parent: GuiGraphics) {
|
|||||||
drawLine(pose.last().pose(), startX, startY, endX, endY, width, z, color)
|
drawLine(pose.last().pose(), startX, startY, endX, endY, width, z, color)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun drawLine(
|
|
||||||
points: Iterable<LinePoint>,
|
|
||||||
width: Float,
|
|
||||||
color: RGBAColor = RGBAColor.WHITE
|
|
||||||
) {
|
|
||||||
drawLine(pose.last().pose(), points, width, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun drawLine(
|
|
||||||
points: Array<out LinePoint>,
|
|
||||||
width: Float,
|
|
||||||
color: RGBAColor = RGBAColor.WHITE
|
|
||||||
) {
|
|
||||||
drawLine(pose.last().pose(), points, width, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun drawLine(
|
|
||||||
width: Float,
|
|
||||||
color: RGBAColor,
|
|
||||||
vararg points: LinePoint,
|
|
||||||
) {
|
|
||||||
drawLine(pose.last().pose(), points, width, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun drawLine(
|
|
||||||
width: Float,
|
|
||||||
color: RGBAColor,
|
|
||||||
points: Iterable<LinePoint>,
|
|
||||||
) {
|
|
||||||
drawLine(pose.last().pose(), points, width, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun drawLine(
|
|
||||||
width: Float,
|
|
||||||
color: RGBAColor,
|
|
||||||
z: Float,
|
|
||||||
points: List<ScreenPos>,
|
|
||||||
) {
|
|
||||||
require(points.size >= 2) { "Degenerate point list: only ${points.size} defined" }
|
|
||||||
|
|
||||||
val result = ArrayList<LinePoint>(points.size)
|
|
||||||
|
|
||||||
for (i in 1 until points.size) {
|
|
||||||
val (x0, y0) = points[i - 1]
|
|
||||||
val (x1, y1) = points[i]
|
|
||||||
|
|
||||||
result.add(
|
|
||||||
LinePoint(
|
|
||||||
x0, y0,
|
|
||||||
x1, y1,
|
|
||||||
z
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
drawLine(pose.last().pose(), result, width, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun drawLine(
|
|
||||||
width: Float,
|
|
||||||
color: RGBAColor,
|
|
||||||
z: Float,
|
|
||||||
vararg points: ScreenPos,
|
|
||||||
) {
|
|
||||||
drawLine(width, color, z, Arrays.asList(*points))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun renderRect(
|
fun renderRect(
|
||||||
x: Float,
|
x: Float,
|
||||||
y: Float,
|
y: Float,
|
||||||
|
@ -294,65 +294,6 @@ fun renderColoredSphere(pose: PoseStack, radius: Float, color: RGBAColor = RGBAC
|
|||||||
BufferUploader.drawWithShader(builder.buildOrThrow())
|
BufferUploader.drawWithShader(builder.buildOrThrow())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun uploadLineSegment(
|
|
||||||
builder: BufferBuilder,
|
|
||||||
matrix: Matrix4f,
|
|
||||||
startX: Float,
|
|
||||||
startY: Float,
|
|
||||||
endX: Float,
|
|
||||||
endY: Float,
|
|
||||||
width: Float,
|
|
||||||
z: Float,
|
|
||||||
color: RGBAColor = RGBAColor.WHITE
|
|
||||||
) {
|
|
||||||
val length = ((startX - endX).pow(2f) + (startY - endY).pow(2f)).pow(0.5f)
|
|
||||||
var angle = acos((endX - startX) / length)
|
|
||||||
|
|
||||||
if (startY > endY)
|
|
||||||
angle *= -1f
|
|
||||||
|
|
||||||
val cos = cos(angle)
|
|
||||||
val sin = sin(angle)
|
|
||||||
|
|
||||||
val y0 = -width
|
|
||||||
|
|
||||||
val y1 = width
|
|
||||||
|
|
||||||
val x2 = length
|
|
||||||
val y2 = width
|
|
||||||
|
|
||||||
val x3 = length
|
|
||||||
val y3 = -width
|
|
||||||
|
|
||||||
builder.vertex(matrix,
|
|
||||||
startX - y0 * sin,
|
|
||||||
startY + y0 * cos,
|
|
||||||
z).color(color)
|
|
||||||
|
|
||||||
builder.vertex(matrix,
|
|
||||||
startX - y1 * sin,
|
|
||||||
startY + y1 * cos,
|
|
||||||
z).color(color)
|
|
||||||
|
|
||||||
builder.vertex(matrix,
|
|
||||||
startX + x2 * cos - y2 * sin,
|
|
||||||
startY + x2 * sin + y2 * cos,
|
|
||||||
z).color(color)
|
|
||||||
|
|
||||||
builder.vertex(matrix,
|
|
||||||
startX + x3 * cos - y3 * sin,
|
|
||||||
startY + x3 * sin + y3 * cos,
|
|
||||||
z).color(color)
|
|
||||||
}
|
|
||||||
|
|
||||||
data class LinePoint(
|
|
||||||
val startX: Float,
|
|
||||||
val startY: Float,
|
|
||||||
val endX: Float,
|
|
||||||
val endY: Float,
|
|
||||||
val z: Float = 0f,
|
|
||||||
)
|
|
||||||
|
|
||||||
fun drawLine(
|
fun drawLine(
|
||||||
matrix: Matrix4f,
|
matrix: Matrix4f,
|
||||||
startX: Float,
|
startX: Float,
|
||||||
@ -371,46 +312,46 @@ fun drawLine(
|
|||||||
RenderSystem.depthFunc(GL_ALWAYS)
|
RenderSystem.depthFunc(GL_ALWAYS)
|
||||||
|
|
||||||
val builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
|
val builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
|
||||||
uploadLineSegment(builder, matrix, startX, startY, endX, endY, width, z, color)
|
|
||||||
BufferUploader.drawWithShader(builder.buildOrThrow())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun drawLine(
|
val length = ((startX - endX).pow(2f) + (startY - endY).pow(2f)).pow(0.5f)
|
||||||
matrix: Matrix4f,
|
val angle = acos((endX - startX) / length)
|
||||||
points: Iterable<LinePoint>,
|
|
||||||
width: Float,
|
|
||||||
color: RGBAColor = RGBAColor.WHITE
|
|
||||||
) {
|
|
||||||
val itr = points.iterator()
|
|
||||||
|
|
||||||
if (!itr.hasNext()) {
|
val cos = cos(angle)
|
||||||
throw IllegalArgumentException("No line points were provided")
|
val sin = sin(angle)
|
||||||
}
|
|
||||||
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorShader)
|
val y0 = -width
|
||||||
RenderSystem.enableBlend()
|
|
||||||
RenderSystem.defaultBlendFunc()
|
|
||||||
|
|
||||||
if (!is3DContext)
|
val y1 = width
|
||||||
RenderSystem.depthFunc(GL_ALWAYS)
|
|
||||||
|
|
||||||
val builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
|
val x2 = length
|
||||||
|
val y2 = width
|
||||||
|
|
||||||
for ((startX, startY, endX, endY, z) in itr)
|
val x3 = length
|
||||||
uploadLineSegment(builder, matrix, startX, startY, endX, endY, width, z, color)
|
val y3 = -width
|
||||||
|
|
||||||
|
builder.vertex(matrix,
|
||||||
|
startX - y0 * sin,
|
||||||
|
startY + y0 * cos,
|
||||||
|
z).color(color)
|
||||||
|
|
||||||
|
builder.vertex(matrix,
|
||||||
|
startX - y1 * sin,
|
||||||
|
startY + y1 * cos,
|
||||||
|
z).color(color)
|
||||||
|
|
||||||
|
builder.vertex(matrix,
|
||||||
|
startX + x2 * cos - y2 * sin,
|
||||||
|
startY + x2 * sin + y2 * cos,
|
||||||
|
z).color(color)
|
||||||
|
|
||||||
|
builder.vertex(matrix,
|
||||||
|
startX + x3 * cos - y3 * sin,
|
||||||
|
startY + x3 * sin + y3 * cos,
|
||||||
|
z).color(color)
|
||||||
|
|
||||||
BufferUploader.drawWithShader(builder.buildOrThrow())
|
BufferUploader.drawWithShader(builder.buildOrThrow())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun drawLine(
|
|
||||||
matrix: Matrix4f,
|
|
||||||
points: Array<out LinePoint>,
|
|
||||||
width: Float,
|
|
||||||
color: RGBAColor = RGBAColor.WHITE
|
|
||||||
) {
|
|
||||||
return drawLine(matrix, points.asIterable(), width, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
data class ScissorRect(val xStart: Int, val yStart: Int, val xEnd: Int, val yEnd: Int, val lock: Boolean = false) {
|
data class ScissorRect(val xStart: Int, val yStart: Int, val xEnd: Int, val yEnd: Int, val lock: Boolean = false) {
|
||||||
val width: Int
|
val width: Int
|
||||||
get() = (xEnd - xStart).coerceAtLeast(0)
|
get() = (xEnd - xStart).coerceAtLeast(0)
|
||||||
|
@ -7,7 +7,7 @@ import com.mojang.blaze3d.vertex.VertexFormat
|
|||||||
import net.minecraft.client.renderer.GameRenderer
|
import net.minecraft.client.renderer.GameRenderer
|
||||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent
|
import net.neoforged.neoforge.client.event.RenderLevelStageEvent
|
||||||
import org.lwjgl.opengl.GL11.GL_LESS
|
import org.lwjgl.opengl.GL11.GL_LESS
|
||||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||||
import ru.dbotthepony.mc.otm.core.math.Vector
|
import ru.dbotthepony.mc.otm.core.math.Vector
|
||||||
import ru.dbotthepony.mc.otm.core.math.component1
|
import ru.dbotthepony.mc.otm.core.math.component1
|
||||||
import ru.dbotthepony.mc.otm.core.math.component2
|
import ru.dbotthepony.mc.otm.core.math.component2
|
||||||
@ -63,7 +63,7 @@ object ShockwaveRenderer {
|
|||||||
|
|
||||||
private const val EXPANSION_PER_SECOND = 18f
|
private const val EXPANSION_PER_SECOND = 18f
|
||||||
|
|
||||||
internal fun onRender(event: RenderLevelStageEvent) {
|
fun onRender(event: RenderLevelStageEvent) {
|
||||||
if (event.stage !== RenderLevelStageEvent.Stage.AFTER_TRANSLUCENT_BLOCKS) {
|
if (event.stage !== RenderLevelStageEvent.Stage.AFTER_TRANSLUCENT_BLOCKS) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -74,6 +74,6 @@ object ShockwaveRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handle(packet: ShockwaveEffectPacket) {
|
fun handle(packet: ShockwaveEffectPacket) {
|
||||||
State(packet.pos, PlayerConfig.Shockwave.RADIUS_HORIZONTAL.toFloat())
|
State(packet.pos, AndroidConfig.Shockwave.RADIUS_HORIZONTAL.toFloat())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas
|
|||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
|
|
||||||
object WidgetLocation {
|
object WidgetLocation {
|
||||||
val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 90f)
|
val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 72f)
|
||||||
val WIDGET_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_18.png"), 72f, 72f)
|
val WIDGET_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_18.png"), 72f, 72f)
|
||||||
val WIDGET_15 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_15.png"), 60f, 60f)
|
val WIDGET_15 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_15.png"), 60f, 60f)
|
||||||
val WIDGET_8 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_8.png"), 64f, 32f)
|
val WIDGET_8 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_8.png"), 64f, 32f)
|
||||||
|
@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.core.immutableMap
|
|||||||
import ru.dbotthepony.mc.otm.core.math.RelativeSide
|
import ru.dbotthepony.mc.otm.core.math.RelativeSide
|
||||||
|
|
||||||
object Widgets18 {
|
object Widgets18 {
|
||||||
private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 5, columns = 5)
|
private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 4, columns = 5)
|
||||||
|
|
||||||
val SORT_DESCENDING = storageGrid.next()
|
val SORT_DESCENDING = storageGrid.next()
|
||||||
val SORT_ASCENDING = storageGrid.next()
|
val SORT_ASCENDING = storageGrid.next()
|
||||||
@ -24,13 +24,6 @@ object Widgets18 {
|
|||||||
val PLAY = storageGrid.next()
|
val PLAY = storageGrid.next()
|
||||||
val STOP = storageGrid.next()
|
val STOP = storageGrid.next()
|
||||||
val SORT_NOW = storageGrid.next()
|
val SORT_NOW = storageGrid.next()
|
||||||
val MOVE_EVERYTHING_TO_STORAGE = storageGrid.next()
|
|
||||||
val MOVE_EVERYTHING_FROM_STORAGE = storageGrid.next()
|
|
||||||
val RESTOCK_TO_STORAGE = storageGrid.next()
|
|
||||||
val RESTOCK_FROM_STORAGE = storageGrid.next()
|
|
||||||
val RESTOCK_WITH_MOVE_TO_STORAGE = storageGrid.next()
|
|
||||||
val RESTOCK_WITH_MOVE_FROM_STORAGE = storageGrid.next()
|
|
||||||
val SMART_STORAGE_EXCHANGE = storageGrid.next()
|
|
||||||
|
|
||||||
private val miscGrid = WidgetLocation.WIDGET_18.grid(4, 4)
|
private val miscGrid = WidgetLocation.WIDGET_18.grid(4, 4)
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRe
|
|||||||
override val texture: AbstractMatterySprite = WidgetLocation.VERTICAL_GAUGES.sprite(x = 108f, width = 18f)
|
override val texture: AbstractMatterySprite = WidgetLocation.VERTICAL_GAUGES.sprite(x = 108f, width = 18f)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) {
|
fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) {
|
||||||
for (i in 0 .. 11) {
|
for (i in 0 .. 11) {
|
||||||
event.register(ModelResourceLocation.standalone(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/battery$i")))
|
event.register(ModelResourceLocation.standalone(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/battery$i")))
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) :
|
|||||||
override val texture: AbstractMatterySprite = WidgetLocation.VERTICAL_GAUGES.sprite(x = 90f, width = 18f)
|
override val texture: AbstractMatterySprite = WidgetLocation.VERTICAL_GAUGES.sprite(x = 90f, width = 18f)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) {
|
fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) {
|
||||||
for (i in 0 .. 11) {
|
for (i in 0 .. 11) {
|
||||||
event.register(ModelResourceLocation.standalone(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/matter_capacitor$i")))
|
event.register(ModelResourceLocation.standalone(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/matter_capacitor$i")))
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import org.lwjgl.opengl.GL30
|
|||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.ShiftPressedCond
|
import ru.dbotthepony.mc.otm.client.ShiftPressedCond
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.client.render.*
|
import ru.dbotthepony.mc.otm.client.render.*
|
||||||
|
@ -20,13 +20,12 @@ import ru.dbotthepony.mc.otm.core.math.asAngle
|
|||||||
import ru.dbotthepony.mc.otm.core.math.clusterize
|
import ru.dbotthepony.mc.otm.core.math.clusterize
|
||||||
import ru.dbotthepony.mc.otm.core.util.formatPower
|
import ru.dbotthepony.mc.otm.core.util.formatPower
|
||||||
import ru.dbotthepony.mc.otm.core.math.times
|
import ru.dbotthepony.mc.otm.core.math.times
|
||||||
import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource
|
|
||||||
import java.util.Random
|
import java.util.Random
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<EnergyCounterBlockEntity> {
|
class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<EnergyCounterBlockEntity> {
|
||||||
private val random = GJRAND64RandomSource()
|
private val random = Random()
|
||||||
|
|
||||||
override fun render(
|
override fun render(
|
||||||
tile: EnergyCounterBlockEntity,
|
tile: EnergyCounterBlockEntity,
|
||||||
|
@ -17,11 +17,9 @@ import net.neoforged.neoforge.common.NeoForge
|
|||||||
import org.lwjgl.opengl.GL11
|
import org.lwjgl.opengl.GL11
|
||||||
import ru.dbotthepony.kommons.util.getValue
|
import ru.dbotthepony.kommons.util.getValue
|
||||||
import ru.dbotthepony.kommons.util.setValue
|
import ru.dbotthepony.kommons.util.setValue
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
||||||
import ru.dbotthepony.mc.otm.client.render.LinePoint
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||||
import ru.dbotthepony.mc.otm.client.render.translation
|
import ru.dbotthepony.mc.otm.client.render.translation
|
||||||
@ -57,7 +55,6 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
|||||||
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
|
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.CopyOnWriteArrayList
|
import java.util.concurrent.CopyOnWriteArrayList
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
import kotlin.collections.List
|
import kotlin.collections.List
|
||||||
import kotlin.collections.MutableSet
|
import kotlin.collections.MutableSet
|
||||||
import kotlin.collections.isNotEmpty
|
import kotlin.collections.isNotEmpty
|
||||||
@ -693,13 +690,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
|||||||
for (panel in panelsReversed) {
|
for (panel in panelsReversed) {
|
||||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||||
val segments = ArrayList<LinePoint>()
|
panel.render(wrap, mouseXf, mouseYf, partialTick)
|
||||||
|
|
||||||
panel.render(wrap, mouseXf, mouseYf, partialTick, segments)
|
|
||||||
|
|
||||||
if (segments.isNotEmpty()) {
|
|
||||||
wrap.drawLine(0.5f, RGBAColor.GOLD, segments)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!panelsReversed.any { it.updateCursor0() })
|
if (!panelsReversed.any { it.updateCursor0() })
|
||||||
|
@ -52,7 +52,7 @@ open class DecimalHistoryChartPanel<out S : MatteryScreen<*>>(
|
|||||||
|
|
||||||
map[1f] = formatText(maximum)
|
map[1f] = formatText(maximum)
|
||||||
|
|
||||||
for (cluster in chart.asIterable().clusterize(random)) {
|
for (cluster in chart.asIterable().clusterize(randomGenerator)) {
|
||||||
val perc = (cluster.center / maximum).toFloat()
|
val perc = (cluster.center / maximum).toFloat()
|
||||||
|
|
||||||
if (map.keys.none { (it - perc).absoluteValue < 0.08f }) {
|
if (map.keys.none { (it - perc).absoluteValue < 0.08f }) {
|
||||||
|
@ -11,31 +11,94 @@ import net.minecraft.client.gui.components.events.GuiEventListener
|
|||||||
import net.minecraft.client.gui.navigation.FocusNavigationEvent
|
import net.minecraft.client.gui.navigation.FocusNavigationEvent
|
||||||
import net.minecraft.client.gui.navigation.ScreenRectangle
|
import net.minecraft.client.gui.navigation.ScreenRectangle
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
|
import net.minecraft.client.renderer.Rect2i
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.util.RandomSource
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
|
||||||
import ru.dbotthepony.mc.otm.SystemTime
|
import ru.dbotthepony.mc.otm.SystemTime
|
||||||
import ru.dbotthepony.mc.otm.client.CursorType
|
import ru.dbotthepony.mc.otm.client.CursorType
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
||||||
import ru.dbotthepony.mc.otm.client.render.LinePoint
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||||
import ru.dbotthepony.mc.otm.client.render.currentScissorRect
|
import ru.dbotthepony.mc.otm.client.render.currentScissorRect
|
||||||
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
||||||
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
||||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel
|
||||||
|
import ru.dbotthepony.mc.otm.core.RandomSource2Generator
|
||||||
import ru.dbotthepony.mc.otm.core.collect.concatIterators
|
import ru.dbotthepony.mc.otm.core.collect.concatIterators
|
||||||
import ru.dbotthepony.mc.otm.core.collect.flatMap
|
import ru.dbotthepony.mc.otm.core.collect.flatMap
|
||||||
import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.CopyOnWriteArrayList
|
import java.util.concurrent.CopyOnWriteArrayList
|
||||||
import java.util.function.Predicate
|
import java.util.function.Predicate
|
||||||
|
import java.util.random.RandomGenerator
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
data class ScreenPos(val x: Float, val y: Float)
|
||||||
|
|
||||||
|
data class DockProperty(val left: Float = 0f, val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f) {
|
||||||
|
val isEmpty get() = left == 0f && right == 0f && top == 0f && bottom == 0f
|
||||||
|
val horizontal get() = left + right
|
||||||
|
val vertical get() = top + bottom
|
||||||
|
|
||||||
|
operator fun plus(other: DockProperty): DockProperty {
|
||||||
|
return DockProperty(
|
||||||
|
left + other.left,
|
||||||
|
top + other.top,
|
||||||
|
right + other.right,
|
||||||
|
bottom + other.bottom
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun minus(other: DockProperty): DockProperty {
|
||||||
|
return DockProperty(
|
||||||
|
left - other.left,
|
||||||
|
top - other.top,
|
||||||
|
right - other.right,
|
||||||
|
bottom - other.bottom
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun plus(other: Float): DockProperty {
|
||||||
|
return DockProperty(
|
||||||
|
left + other,
|
||||||
|
top + other,
|
||||||
|
right + other,
|
||||||
|
bottom + other
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun minus(other: Float): DockProperty {
|
||||||
|
return DockProperty(
|
||||||
|
left - other,
|
||||||
|
top - other,
|
||||||
|
right - other,
|
||||||
|
bottom - other
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val EMPTY = DockProperty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class Dock {
|
||||||
|
NONE, LEFT, RIGHT, TOP, BOTTOM, FILL
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class DockResizeMode(val changeWidth: Boolean, val changeHeight: Boolean) {
|
||||||
|
ALL(true, true), NONE(false, false), WIDTH(true, false), HEIGHT(false, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Rect2f(val x: Float, val y: Float, val width: Float, val height: Float) {
|
||||||
|
fun toIntRect(): Rect2i {
|
||||||
|
return Rect2i(x.roundToInt(), y.roundToInt(), width.roundToInt(), height.roundToInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open class EditablePanel<out S : Screen>(
|
open class EditablePanel<out S : Screen>(
|
||||||
val screen: S,
|
val screen: S,
|
||||||
parent: EditablePanel<*>?,
|
parent: EditablePanel<*>?,
|
||||||
@ -112,14 +175,18 @@ open class EditablePanel<out S : Screen>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val random: GJRAND64RandomSource by lazy {
|
val random: RandomSource by lazy {
|
||||||
if (screen is MatteryScreen<*>) {
|
if (screen is MatteryScreen<*>) {
|
||||||
screen.menu.random
|
screen.menu.random
|
||||||
} else {
|
} else {
|
||||||
GJRAND64RandomSource()
|
RandomSource.create()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val randomGenerator: RandomGenerator by lazy {
|
||||||
|
RandomSource2Generator(random)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bigger values means lesser priority while docking, rendering and processing inputs.
|
* Bigger values means lesser priority while docking, rendering and processing inputs.
|
||||||
*/
|
*/
|
||||||
@ -283,13 +350,11 @@ open class EditablePanel<out S : Screen>(
|
|||||||
|
|
||||||
if (visibleChildrenParent?.contains(this) == false) {
|
if (visibleChildrenParent?.contains(this) == false) {
|
||||||
visibleChildrenParent.add(this)
|
visibleChildrenParent.add(this)
|
||||||
parent?.invalidateChildrenSorting()
|
|
||||||
parent?.layoutInvalidated = true
|
parent?.layoutInvalidated = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (visibleChildrenParent?.contains(this) == true) {
|
if (visibleChildrenParent?.contains(this) == true) {
|
||||||
visibleChildrenParent.remove(this)
|
visibleChildrenParent.remove(this)
|
||||||
parent?.invalidateChildrenSorting()
|
|
||||||
parent?.layoutInvalidated = true
|
parent?.layoutInvalidated = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -778,12 +843,6 @@ open class EditablePanel<out S : Screen>(
|
|||||||
childrenSortingInvalidated = true
|
childrenSortingInvalidated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun onChildrenAdded(child: EditablePanel<*>) {}
|
|
||||||
protected open fun onChildrenRemoved(child: EditablePanel<*>) {}
|
|
||||||
|
|
||||||
protected open fun onParented(parent: EditablePanel<*>) {}
|
|
||||||
protected open fun onUnParented(parent: EditablePanel<*>) {}
|
|
||||||
|
|
||||||
private fun onParent(child: EditablePanel<*>) {
|
private fun onParent(child: EditablePanel<*>) {
|
||||||
if (childrenInternal.contains(child)) throw IllegalStateException("Already containing $child")
|
if (childrenInternal.contains(child)) throw IllegalStateException("Already containing $child")
|
||||||
childrenInternal.add(child)
|
childrenInternal.add(child)
|
||||||
@ -801,15 +860,11 @@ open class EditablePanel<out S : Screen>(
|
|||||||
else
|
else
|
||||||
updateVisibility = true
|
updateVisibility = true
|
||||||
}
|
}
|
||||||
|
|
||||||
onChildrenAdded(child)
|
|
||||||
child.onParented(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onUnParent(child: EditablePanel<*>) {
|
private fun onUnParent(child: EditablePanel<*>) {
|
||||||
val indexOf = childrenInternal.indexOf(child)
|
val indexOf = childrenInternal.indexOf(child)
|
||||||
if (indexOf == -1) throw IllegalStateException("Already not containing $child")
|
if (indexOf == -1) throw IllegalStateException("Already not containing $child")
|
||||||
child.onUnParented(this)
|
|
||||||
childrenInternal.removeAt(indexOf)
|
childrenInternal.removeAt(indexOf)
|
||||||
invalidateChildrenSorting()
|
invalidateChildrenSorting()
|
||||||
|
|
||||||
@ -821,8 +876,6 @@ open class EditablePanel<out S : Screen>(
|
|||||||
if (child.isVisible() != isVisible()) {
|
if (child.isVisible() != isVisible()) {
|
||||||
updateVisible()
|
updateVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
onChildrenRemoved(child)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sortChildren() {
|
private fun sortChildren() {
|
||||||
@ -891,11 +944,12 @@ open class EditablePanel<out S : Screen>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun render(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float, debugSegments: MutableList<LinePoint>) {
|
fun render(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||||
once = true
|
once = true
|
||||||
|
|
||||||
if (!isVisible())
|
if (!isVisible()) {
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val poseStack = graphics.pose
|
val poseStack = graphics.pose
|
||||||
|
|
||||||
@ -943,19 +997,12 @@ open class EditablePanel<out S : Screen>(
|
|||||||
child.absoluteX = absoluteX + child.x + xOffset
|
child.absoluteX = absoluteX + child.x + xOffset
|
||||||
child.absoluteY = absoluteY + child.y + yOffset
|
child.absoluteY = absoluteY + child.y + yOffset
|
||||||
|
|
||||||
child.render(graphics, mouseX, mouseY, partialTick, debugSegments)
|
child.render(graphics, mouseX, mouseY, partialTick)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scissor) {
|
if (scissor) {
|
||||||
popScissorRect()
|
popScissorRect()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minecraft.entityRenderDispatcher.shouldRenderHitBoxes()) {
|
|
||||||
debugSegments.add(LinePoint(absoluteX, absoluteY, absoluteX + width, absoluteY))
|
|
||||||
debugSegments.add(LinePoint(absoluteX + width, absoluteY, absoluteX + width, absoluteY + height))
|
|
||||||
debugSegments.add(LinePoint(absoluteX + width, absoluteY + height, absoluteX, absoluteY + height))
|
|
||||||
debugSegments.add(LinePoint(absoluteX, absoluteY + height, absoluteX, absoluteY))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateCursor0(): Boolean {
|
fun updateCursor0(): Boolean {
|
||||||
@ -1461,7 +1508,6 @@ open class EditablePanel<out S : Screen>(
|
|||||||
|
|
||||||
if (old != new) {
|
if (old != new) {
|
||||||
child.visibilityChanges(new, old)
|
child.visibilityChanges(new, old)
|
||||||
child.invalidateChildrenSorting()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
child.updateVisible()
|
child.updateVisible()
|
||||||
|
@ -6,8 +6,8 @@ import net.minecraft.client.gui.screens.inventory.InventoryScreen
|
|||||||
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.neoforged.neoforge.network.PacketDistributor
|
import net.neoforged.neoforge.network.PacketDistributor
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets8
|
import ru.dbotthepony.mc.otm.client.render.Widgets8
|
||||||
import ru.dbotthepony.mc.otm.client.render.sprites.sprite
|
import ru.dbotthepony.mc.otm.client.render.sprites.sprite
|
||||||
|
@ -4,8 +4,6 @@ import net.minecraft.client.gui.GuiGraphics
|
|||||||
import net.minecraft.client.gui.components.Renderable
|
import net.minecraft.client.gui.components.Renderable
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.LinePoint
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
|
|
||||||
// before 1.19.3 Renderable was Widget
|
// before 1.19.3 Renderable was Widget
|
||||||
@ -23,17 +21,11 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
|||||||
val yFloat = mouseY.toFloat()
|
val yFloat = mouseY.toFloat()
|
||||||
|
|
||||||
val wrap = MGUIGraphics(graphics)
|
val wrap = MGUIGraphics(graphics)
|
||||||
val segments = ArrayList<LinePoint>()
|
|
||||||
|
|
||||||
panel.tickHovered0(xFloat, yFloat, false)
|
panel.tickHovered0(xFloat, yFloat, false)
|
||||||
panel.tickHovered1()
|
panel.tickHovered1()
|
||||||
panel.tickHovered2()
|
panel.tickHovered2()
|
||||||
panel.render(wrap, xFloat, yFloat, partialTick, segments)
|
panel.render(wrap, xFloat, yFloat, partialTick)
|
||||||
|
|
||||||
if (segments.isNotEmpty()) {
|
|
||||||
wrap.drawLine(0.5f, RGBAColor.GOLD, segments)
|
|
||||||
}
|
|
||||||
|
|
||||||
panel.renderTooltips(wrap, xFloat, yFloat, partialTick)
|
panel.renderTooltips(wrap, xFloat, yFloat, partialTick)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.Rect2i
|
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
data class ScreenPos(val x: Float, val y: Float)
|
|
||||||
|
|
||||||
data class DockProperty(val left: Float = 0f, val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f) {
|
|
||||||
val isEmpty get() = left == 0f && right == 0f && top == 0f && bottom == 0f
|
|
||||||
val horizontal get() = left + right
|
|
||||||
val vertical get() = top + bottom
|
|
||||||
|
|
||||||
operator fun plus(other: DockProperty): DockProperty {
|
|
||||||
return DockProperty(
|
|
||||||
left + other.left,
|
|
||||||
top + other.top,
|
|
||||||
right + other.right,
|
|
||||||
bottom + other.bottom
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun minus(other: DockProperty): DockProperty {
|
|
||||||
return DockProperty(
|
|
||||||
left - other.left,
|
|
||||||
top - other.top,
|
|
||||||
right - other.right,
|
|
||||||
bottom - other.bottom
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun plus(other: Float): DockProperty {
|
|
||||||
return DockProperty(
|
|
||||||
left + other,
|
|
||||||
top + other,
|
|
||||||
right + other,
|
|
||||||
bottom + other
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun minus(other: Float): DockProperty {
|
|
||||||
return DockProperty(
|
|
||||||
left - other,
|
|
||||||
top - other,
|
|
||||||
right - other,
|
|
||||||
bottom - other
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val EMPTY = DockProperty()
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun all(value: Float): DockProperty {
|
|
||||||
return DockProperty(value, value, value, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@JvmOverloads
|
|
||||||
fun topLeft(top: Float, left: Float = top): DockProperty {
|
|
||||||
return DockProperty(left = left, top = top)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun left(value: Float): DockProperty {
|
|
||||||
return DockProperty(left = value)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@JvmOverloads
|
|
||||||
fun topRight(top: Float, right: Float = top): DockProperty {
|
|
||||||
return DockProperty(right = right, top = top)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun right(value: Float): DockProperty {
|
|
||||||
return DockProperty(right = value)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun top(value: Float): DockProperty {
|
|
||||||
return DockProperty(top = value)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@JvmOverloads
|
|
||||||
fun bottomLeft(bottom: Float, left: Float = bottom): DockProperty {
|
|
||||||
return DockProperty(left = left, bottom = bottom)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@JvmOverloads
|
|
||||||
fun bottomRight(bottom: Float, right: Float = bottom): DockProperty {
|
|
||||||
return DockProperty(right = right, bottom = bottom)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun bottom(value: Float): DockProperty {
|
|
||||||
return DockProperty(bottom = value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class Dock {
|
|
||||||
NONE, LEFT, RIGHT, TOP, BOTTOM, FILL
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class DockResizeMode(val changeWidth: Boolean, val changeHeight: Boolean) {
|
|
||||||
ALL(true, true), NONE(false, false), WIDTH(true, false), HEIGHT(false, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
data class Rect2f(val x: Float, val y: Float, val width: Float, val height: Float) {
|
|
||||||
fun toIntRect(): Rect2i {
|
|
||||||
return Rect2i(x.roundToInt(), y.roundToInt(), width.roundToInt(), height.roundToInt())
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,9 +7,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
|||||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||||
import ru.dbotthepony.mc.otm.core.collect.filter
|
import ru.dbotthepony.mc.otm.core.collect.filter
|
||||||
import ru.dbotthepony.mc.otm.core.collect.maybe
|
import ru.dbotthepony.mc.otm.core.collect.maybe
|
||||||
import java.util.stream.IntStream
|
|
||||||
import java.util.stream.Stream
|
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
open class GridPanel<out S : Screen>(
|
open class GridPanel<out S : Screen>(
|
||||||
screen: S,
|
screen: S,
|
||||||
@ -23,150 +20,25 @@ open class GridPanel<out S : Screen>(
|
|||||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||||
var columns: Int = columns
|
var columns: Int = columns
|
||||||
set(value) {
|
set(value) {
|
||||||
if (field != value) {
|
field = value
|
||||||
field = value
|
invalidateLayout()
|
||||||
invalidateLayout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows: Int = rows
|
var rows: Int = rows
|
||||||
set(value) {
|
set(value) {
|
||||||
if (field != value) {
|
field = value
|
||||||
field = value
|
invalidateLayout()
|
||||||
invalidateLayout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var gravity: RenderGravity = RenderGravity.CENTER_CENTER
|
var gravity: RenderGravity = RenderGravity.CENTER_CENTER
|
||||||
set(value) {
|
set(value) {
|
||||||
if (field != value) {
|
field = value
|
||||||
field = value
|
invalidateLayout()
|
||||||
invalidateLayout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var layout: Layout = Layout.TOP_LEFT
|
|
||||||
set(value) {
|
|
||||||
if (field != value) {
|
|
||||||
field = value
|
|
||||||
invalidateLayout()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var columnMajorOrder = false
|
|
||||||
set(value) {
|
|
||||||
if (field != value) {
|
|
||||||
field = value
|
|
||||||
invalidateLayout()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class Layout {
|
|
||||||
TOP_LEFT {
|
|
||||||
override fun get(
|
|
||||||
list: List<EditablePanel<*>>,
|
|
||||||
row: Int,
|
|
||||||
column: Int,
|
|
||||||
rows: Int,
|
|
||||||
columns: Int,
|
|
||||||
columnMajorOrder: Boolean
|
|
||||||
): EditablePanel<*>? {
|
|
||||||
if (columnMajorOrder) {
|
|
||||||
return list.getOrNull(row + column * rows)
|
|
||||||
} else {
|
|
||||||
return list.getOrNull(column + row * columns)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
TOP_RIGHT {
|
|
||||||
override fun get(
|
|
||||||
list: List<EditablePanel<*>>,
|
|
||||||
row: Int,
|
|
||||||
column: Int,
|
|
||||||
rows: Int,
|
|
||||||
columns: Int,
|
|
||||||
columnMajorOrder: Boolean
|
|
||||||
): EditablePanel<*>? {
|
|
||||||
if (columnMajorOrder) {
|
|
||||||
return list.getOrNull(row + (columns - column - 1) * rows)
|
|
||||||
} else {
|
|
||||||
return list.getOrNull((columns - column - 1) + row * columns)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
BOTTOM_LEFT {
|
|
||||||
override fun get(
|
|
||||||
list: List<EditablePanel<*>>,
|
|
||||||
row: Int,
|
|
||||||
column: Int,
|
|
||||||
rows: Int,
|
|
||||||
columns: Int,
|
|
||||||
columnMajorOrder: Boolean
|
|
||||||
): EditablePanel<*>? {
|
|
||||||
if (columnMajorOrder) {
|
|
||||||
return list.getOrNull((rows - row - 1) + column * rows)
|
|
||||||
} else {
|
|
||||||
return list.getOrNull(column + (rows - row - 1) * columns)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
BOTTOM_RIGHT {
|
|
||||||
override fun get(
|
|
||||||
list: List<EditablePanel<*>>,
|
|
||||||
row: Int,
|
|
||||||
column: Int,
|
|
||||||
rows: Int,
|
|
||||||
columns: Int,
|
|
||||||
columnMajorOrder: Boolean
|
|
||||||
): EditablePanel<*>? {
|
|
||||||
if (columnMajorOrder) {
|
|
||||||
return list.getOrNull((rows - row - 1) + (columns - column - 1) * rows)
|
|
||||||
} else {
|
|
||||||
return list.getOrNull((columns - column - 1) + (rows - row - 1) * columns)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
abstract fun get(list: List<EditablePanel<*>>, row: Int, column: Int, rows: Int, columns: Int, columnMajorOrder: Boolean): EditablePanel<*>?
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun sizeToContents() {
|
|
||||||
if (visibleChildren.isEmpty()) {
|
|
||||||
// nothing to size against
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
visibleChildren.forEach { it.sizeToContents() }
|
|
||||||
|
|
||||||
var width = 0f
|
|
||||||
var height = 0f
|
|
||||||
|
|
||||||
val children = visibleChildren.filter { it.dock == Dock.NONE }
|
|
||||||
|
|
||||||
for (row in 0 until rows) {
|
|
||||||
var maxHeight = 0f
|
|
||||||
var rowWidth = 0f
|
|
||||||
|
|
||||||
for (column in 0 until columns) {
|
|
||||||
val nextChild = layout.get(children, row, column, rows, columns, columnMajorOrder) ?: continue
|
|
||||||
rowWidth += nextChild.width + nextChild.dockMargin.horizontal
|
|
||||||
maxHeight = max(maxHeight, nextChild.height + nextChild.dockMargin.vertical)
|
|
||||||
}
|
|
||||||
|
|
||||||
height += maxHeight
|
|
||||||
width = max(width, rowWidth)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.width = width
|
|
||||||
this.height = height
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun performLayout() {
|
override fun performLayout() {
|
||||||
super.performLayout()
|
super.performLayout()
|
||||||
val children = visibleChildren.filter { it.dock == Dock.NONE }
|
var children = visibleChildren.iterator().filter { it.dock == Dock.NONE }
|
||||||
|
|
||||||
var totalWidth = 0f
|
var totalWidth = 0f
|
||||||
var totalHeight = 0f
|
var totalHeight = 0f
|
||||||
@ -176,7 +48,7 @@ open class GridPanel<out S : Screen>(
|
|||||||
var width = 0f
|
var width = 0f
|
||||||
|
|
||||||
for (column in 0 until columns) {
|
for (column in 0 until columns) {
|
||||||
val child = layout.get(children, row, column, rows, columns, columnMajorOrder) ?: continue
|
val child = children.maybe() ?: break
|
||||||
width += child.dockedWidth
|
width += child.dockedWidth
|
||||||
maxHeight = maxHeight.coerceAtLeast(child.dockedHeight)
|
maxHeight = maxHeight.coerceAtLeast(child.dockedHeight)
|
||||||
}
|
}
|
||||||
@ -187,6 +59,7 @@ open class GridPanel<out S : Screen>(
|
|||||||
|
|
||||||
val alignX = gravity.repositionX(width, totalWidth)
|
val alignX = gravity.repositionX(width, totalWidth)
|
||||||
val alignY = gravity.repositionY(height, totalHeight)
|
val alignY = gravity.repositionY(height, totalHeight)
|
||||||
|
children = visibleChildren.iterator().filter { it.dock == Dock.NONE }
|
||||||
|
|
||||||
totalWidth = 0f
|
totalWidth = 0f
|
||||||
totalHeight = 0f
|
totalHeight = 0f
|
||||||
@ -196,7 +69,7 @@ open class GridPanel<out S : Screen>(
|
|||||||
var width = 0f
|
var width = 0f
|
||||||
|
|
||||||
for (column in 0 until columns) {
|
for (column in 0 until columns) {
|
||||||
val child = layout.get(children, row, column, rows, columns, columnMajorOrder) ?: continue
|
val child = children.maybe() ?: break
|
||||||
child.x = alignX + width
|
child.x = alignX + width
|
||||||
child.y = alignY + totalHeight
|
child.y = alignY + totalHeight
|
||||||
width += child.dockedWidth
|
width += child.dockedWidth
|
||||||
|
@ -7,15 +7,15 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
|||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.util.RandomSource
|
|
||||||
import net.minecraft.world.entity.player.Inventory
|
import net.minecraft.world.entity.player.Inventory
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import net.neoforged.neoforge.network.PacketDistributor
|
import net.neoforged.neoforge.network.PacketDistributor
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearch
|
import ru.dbotthepony.mc.otm.android.AndroidResearch
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager
|
import ru.dbotthepony.mc.otm.android.AndroidResearchManager
|
||||||
import ru.dbotthepony.mc.otm.player.android.AndroidResearchType
|
import ru.dbotthepony.mc.otm.android.AndroidResearchType
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||||
import ru.dbotthepony.mc.otm.client.CursorType
|
import ru.dbotthepony.mc.otm.client.CursorType
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
@ -33,9 +33,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel
|
|||||||
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
|
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
|
||||||
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.BooleanButtonPanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.button.BooleanButtonPanel
|
||||||
import ru.dbotthepony.mc.otm.core.nextFloat
|
import ru.dbotthepony.mc.otm.core.RandomSource2Generator
|
||||||
import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu
|
import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu
|
||||||
import ru.dbotthepony.mc.otm.network.AndroidResearchRequestPacket
|
import ru.dbotthepony.mc.otm.network.AndroidResearchRequestPacket
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -542,14 +542,14 @@ class AndroidStationScreen(p_97741_: AndroidStationMenu, p_97742_: Inventory, p_
|
|||||||
|
|
||||||
if (isPreview && !layoutInvalidated) {
|
if (isPreview && !layoutInvalidated) {
|
||||||
if (firstTick) {
|
if (firstTick) {
|
||||||
scroller.init.invoke(this, random)
|
scroller.init.invoke(this, randomGenerator)
|
||||||
}
|
}
|
||||||
|
|
||||||
val status = scroller.scroll.invoke(this, random)
|
val status = scroller.scroll.invoke(this, randomGenerator)
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
scroller = PreviewScrollers.entries.let { it[random.nextInt(it.size)] }
|
scroller = PreviewScrollers.entries.let { it[random.nextInt(it.size)] }
|
||||||
scroller.init.invoke(this, random)
|
scroller.init.invoke(this, randomGenerator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import net.neoforged.fml.ModList
|
|||||||
import net.neoforged.fml.loading.FMLEnvironment
|
import net.neoforged.fml.loading.FMLEnvironment
|
||||||
import net.neoforged.neoforge.network.PacketDistributor
|
import net.neoforged.neoforge.network.PacketDistributor
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||||
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
|
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.sprites.sprite
|
import ru.dbotthepony.mc.otm.client.render.sprites.sprite
|
||||||
@ -40,11 +40,15 @@ val isCuriosLoaded by lazy {
|
|||||||
ModList.get().isLoaded(CuriosApi.MODID)
|
ModList.get().isLoaded(CuriosApi.MODID)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) {
|
fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) {
|
||||||
check(isCuriosLoaded) { "Curios is not loaded!" }
|
check(isCuriosLoaded) { "Curios is not loaded!" }
|
||||||
event.entity.matteryPlayer?.recreateExoPackMenu()
|
event.entity.matteryPlayer?.recreateExoPackMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openCuriosScreen(carriedStack: ItemStack = ItemStack.EMPTY) {
|
||||||
|
if (FMLEnvironment.dist.isClient) PacketDistributor.sendToServer(CPacketOpenCurios(carriedStack))
|
||||||
|
}
|
||||||
|
|
||||||
private fun Player.getCuriosSlotsImpl(): List<PlayerSlot<Slot, Slot>> {
|
private fun Player.getCuriosSlotsImpl(): List<PlayerSlot<Slot, Slot>> {
|
||||||
val handler = getCapability(CuriosCapability.INVENTORY) ?: return listOf()
|
val handler = getCapability(CuriosCapability.INVENTORY) ?: return listOf()
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ import net.minecraft.world.item.Items
|
|||||||
import net.neoforged.neoforge.network.handling.IPayloadContext
|
import net.neoforged.neoforge.network.handling.IPayloadContext
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
import ru.dbotthepony.mc.otm.core.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||||
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
||||||
|
@ -99,7 +99,7 @@ class MatteryChestMenu(
|
|||||||
return MatteryChestMenu(HOPPER, containerId, inventory, 1, 5, container)
|
return MatteryChestMenu(HOPPER, containerId, inventory, 1, 5, container)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun register(bus: IEventBus) {
|
fun register(bus: IEventBus) {
|
||||||
registrar.register(bus)
|
registrar.register(bus)
|
||||||
bus.addListener(this::registerScreens)
|
bus.addListener(this::registerScreens)
|
||||||
}
|
}
|
||||||
|
@ -4,31 +4,16 @@ import ru.dbotthepony.kommons.util.getValue
|
|||||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||||
import ru.dbotthepony.mc.otm.core.math.defineDecimal
|
import ru.dbotthepony.mc.otm.core.math.defineDecimal
|
||||||
|
|
||||||
object PlayerConfig : AbstractConfig("player") {
|
object AndroidConfig : AbstractConfig("androids") {
|
||||||
init {
|
|
||||||
builder.push("Android")
|
|
||||||
}
|
|
||||||
|
|
||||||
val REGENERATE_ENERGY: Boolean by builder
|
val REGENERATE_ENERGY: Boolean by builder
|
||||||
|
.comment("If (technically) hunger is above threshold, it turns into energy")
|
||||||
.comment("This setting controls whenever to regenerate small amount of energy while eating as Android")
|
.comment("This setting controls whenever to regenerate small amount of energy while eating as Android")
|
||||||
.comment("And also whenever to regenerate energy while in peaceful")
|
.comment("And also whenever to regenerate energy while in peaceful")
|
||||||
|
.comment("If this is disabled, any (technically) excess hunger will be nullified, unless playing on peaceful difficulty.")
|
||||||
.define("REGENERATE_ENERGY", true)
|
.define("REGENERATE_ENERGY", true)
|
||||||
|
|
||||||
val REGENERATE_ENERGY_EFFICIENCY_FOOD: Double by builder
|
|
||||||
.comment("How much % of food points to convert to energy")
|
|
||||||
.defineInRange("REGENERATE_ENERGY_EFFICIENCY_FOOD", 0.4, 0.0)
|
|
||||||
|
|
||||||
val REGENERATE_ENERGY_EFFICIENCY_SATURATION: Double by builder
|
|
||||||
.comment("How much % of food saturation points to convert to energy")
|
|
||||||
.defineInRange("REGENERATE_ENERGY_EFFICIENCY_SATURATION", 0.2, 0.0)
|
|
||||||
|
|
||||||
val REGENERATE_ENERGY_IN_PEACEFUL: Boolean by builder
|
|
||||||
.comment("Regenerate energy while in peaceful")
|
|
||||||
.comment("This is disabled by default because this is easily exploitable")
|
|
||||||
.define("REGENERATE_ENERGY_IN_PEACEFUL", false)
|
|
||||||
|
|
||||||
val TIME_BETWEEN_NATURAL_REGENERATION: Int by builder
|
val TIME_BETWEEN_NATURAL_REGENERATION: Int by builder
|
||||||
.comment("Time in ticks between natural health regeneration ticks for Android")
|
.comment("Time in ticks between natural health regeneration ticks")
|
||||||
.comment("Default value is meant to be one of downsides of being an android,")
|
.comment("Default value is meant to be one of downsides of being an android,")
|
||||||
.comment("so please, don't blindly buff it, players have ability to research into Nanobots Regeneration,")
|
.comment("so please, don't blindly buff it, players have ability to research into Nanobots Regeneration,")
|
||||||
.comment("which provide superior regeneration on average than human players.")
|
.comment("which provide superior regeneration on average than human players.")
|
||||||
@ -39,32 +24,6 @@ object PlayerConfig : AbstractConfig("player") {
|
|||||||
.comment("for android players, since 'hunger' (for compatibility) is managed by mod in such case")
|
.comment("for android players, since 'hunger' (for compatibility) is managed by mod in such case")
|
||||||
.defineInRange("TIME_BETWEEN_NATURAL_REGENERATION", 120, 0, Int.MAX_VALUE)
|
.defineInRange("TIME_BETWEEN_NATURAL_REGENERATION", 120, 0, Int.MAX_VALUE)
|
||||||
|
|
||||||
val ANDROID_ENERGY_PER_HUNGER_POINT by builder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO)
|
|
||||||
val ANDROID_MAX_ENERGY by builder
|
|
||||||
.comment("Internal battery of every android has this much storage")
|
|
||||||
.comment("Keep in mind that already existing players won't get their value changed since it is", "stored inside their savedata")
|
|
||||||
.defineDecimal("capacity", Decimal(80_000), Decimal.ZERO)
|
|
||||||
|
|
||||||
val NIGHT_VISION_POWER_DRAW by builder.defineDecimal("nightVisionPowerDraw", Decimal(8), Decimal.ZERO)
|
|
||||||
|
|
||||||
val FALL_DAMAGE_REDUCTION_PER_LEVEL_P: Double by builder
|
|
||||||
.comment("In percent. Level of feature is multiplied by this")
|
|
||||||
.comment("First, fall damage is reduced by flat resistance, then reduced by percentage resistance (this)")
|
|
||||||
.defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_P", 0.2, 0.01, 1.0)
|
|
||||||
|
|
||||||
val FALL_DAMAGE_REDUCTION_PER_LEVEL_F: Double by builder
|
|
||||||
.comment("In flat half of hearts. Level of feature is multiplied by this")
|
|
||||||
.comment("First, fall damage is reduced by flat resistance (this), then reduced by percentage resistance")
|
|
||||||
.defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_F", 1.5, 0.0, Float.MAX_VALUE.toDouble())
|
|
||||||
|
|
||||||
val SWIM_BOOSTERS: Double by builder
|
|
||||||
.comment("Increase per level")
|
|
||||||
.defineInRange("SWIM_BOOSTERS", 0.25, 0.0, Float.MAX_VALUE.toDouble())
|
|
||||||
|
|
||||||
init {
|
|
||||||
builder.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
object NanobotsRegeneration {
|
object NanobotsRegeneration {
|
||||||
init {
|
init {
|
||||||
builder.push("NanobotsRegeneration")
|
builder.push("NanobotsRegeneration")
|
||||||
@ -93,6 +52,27 @@ object PlayerConfig : AbstractConfig("player") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val ANDROID_ENERGY_PER_HUNGER_POINT by builder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO)
|
||||||
|
val ANDROID_MAX_ENERGY by builder
|
||||||
|
.comment("Internal battery of every android has this much storage")
|
||||||
|
.comment("Keep in mind that already existing players won't get their value changed since it is", "stored inside their savedata")
|
||||||
|
.defineDecimal("capacity", Decimal(80_000), Decimal.ZERO)
|
||||||
|
val NIGHT_VISION_POWER_DRAW by builder.defineDecimal("nightVisionPowerDraw", Decimal(8), Decimal.ZERO)
|
||||||
|
|
||||||
|
val FALL_DAMAGE_REDUCTION_PER_LEVEL_P: Double by builder
|
||||||
|
.comment("In percent. Level of feature is multiplied by this")
|
||||||
|
.comment("First, fall damage is reduced by flat resistance, then reduced by percentage resistance (this)")
|
||||||
|
.defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_P", 0.2, 0.01, 1.0)
|
||||||
|
|
||||||
|
val FALL_DAMAGE_REDUCTION_PER_LEVEL_F: Double by builder
|
||||||
|
.comment("In flat half of hearts. Level of feature is multiplied by this")
|
||||||
|
.comment("First, fall damage is reduced by flat resistance (this), then reduced by percentage resistance")
|
||||||
|
.defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_F", 1.5, 0.0, Float.MAX_VALUE.toDouble())
|
||||||
|
|
||||||
|
val SWIM_BOOSTERS: Double by builder
|
||||||
|
.comment("Increase per level")
|
||||||
|
.defineInRange("SWIM_BOOSTERS", 0.25, 0.0, Float.MAX_VALUE.toDouble())
|
||||||
|
|
||||||
object EnderTeleporter {
|
object EnderTeleporter {
|
||||||
init {
|
init {
|
||||||
builder.comment("Ender Teleporter ability").push("EnderTeleporter")
|
builder.comment("Ender Teleporter ability").push("EnderTeleporter")
|
||||||
@ -168,103 +148,4 @@ object PlayerConfig : AbstractConfig("player") {
|
|||||||
Magnet
|
Magnet
|
||||||
Shockwave
|
Shockwave
|
||||||
}
|
}
|
||||||
|
|
||||||
object Food {
|
|
||||||
init {
|
|
||||||
builder
|
|
||||||
.comment("Food related tweaks")
|
|
||||||
.comment("Since OTM overrides FoodData logic (to make room for Android logic)")
|
|
||||||
.comment("these settings are provided for tweaking FoodData behavior")
|
|
||||||
.push("Food")
|
|
||||||
}
|
|
||||||
|
|
||||||
val SOFT_FOOD_LIMIT: Int by builder
|
|
||||||
.comment("Soft food points limit, which dictate upper bound where player is considered 'hungry',")
|
|
||||||
.comment("e.g. they can eat food which is not marked as 'can always eat'")
|
|
||||||
.defineInRange("SOFT_FOOD_LIMIT", 20, 0)
|
|
||||||
|
|
||||||
val HARD_FOOD_LIMIT: Int by builder
|
|
||||||
.comment("Hard food points limit, which dictate upper bound of food points,")
|
|
||||||
.comment("e.g. hunger can not go above this value")
|
|
||||||
.comment("This is extremely buffed in OTM by default to remove annoyance regarding consuming foodstuffs")
|
|
||||||
.comment("when you are running low on food, so you can eat high-quality food without fear")
|
|
||||||
.comment("that food points will go to waste (especially when you need to regenerate lots of HP)")
|
|
||||||
.defineInRange("HARD_FOOD_LIMIT", 40, 1)
|
|
||||||
|
|
||||||
val OVERSATURATION_LIMIT: Double by builder
|
|
||||||
.comment("Controls how much 'saturation' can be stored above hunger level.")
|
|
||||||
.comment("Negative values will decrease maximum saturation achievable.")
|
|
||||||
.defineInRange("OVERSATURATION_LIMIT", 0.0, -Float.MAX_VALUE.toDouble() + 1.0, Float.MAX_VALUE.toDouble() - 1.0)
|
|
||||||
|
|
||||||
val EXHAUSTION_LIMIT: Double by builder
|
|
||||||
.comment("Controls technical aspect how much 'exhaustion' player can accumulate")
|
|
||||||
.comment("This should not be confused with how much 'exhaustion' is considered as 1 hunger point")
|
|
||||||
.comment("Usually, this should not be changed, since it is a very technical detail;")
|
|
||||||
.comment("but if you have a mod installed which easily hits this limit (and somehow hunger system can't keep up,)")
|
|
||||||
.comment("e.g. it pushes exhaustion over its limit in one call), you can increase this value")
|
|
||||||
.defineInRange("EXHAUSTION_LIMIT", 40.0, 4.0, Float.MAX_VALUE.toDouble() - 1.0)
|
|
||||||
|
|
||||||
private fun defineRegeneration(
|
|
||||||
threshold: Int,
|
|
||||||
requiresSaturation: Boolean,
|
|
||||||
ticks: Int,
|
|
||||||
): IFoodRegenerationValues {
|
|
||||||
return object : IFoodRegenerationValues {
|
|
||||||
override val foodLimit: Int by builder
|
|
||||||
.defineInRange("FOOD_THRESHOLD", threshold, 1)
|
|
||||||
|
|
||||||
override val requiresSaturation: Boolean by builder
|
|
||||||
.define("REQUIRES_SATURATION", requiresSaturation)
|
|
||||||
|
|
||||||
override val ticks: Int by builder
|
|
||||||
.defineInRange("TICKS", ticks, 0)
|
|
||||||
|
|
||||||
override val regenerationSlowdown: Boolean by builder
|
|
||||||
.comment("Slowdown regeneration based on remaining saturation (given REQUIRES_SATURATION is true)")
|
|
||||||
.comment("This replicates vanilla behavior where fast regeneration speed linearly slowdowns the moment")
|
|
||||||
.comment("saturation falls below 6 hunger points (configurable through SATURATION_SLOWDOWN_BOUND)")
|
|
||||||
.comment("This is disabled in OTM by default to buff humans compared to androids when it comes to regeneration")
|
|
||||||
.define("SATURATION_SLOWDOWN", false)
|
|
||||||
|
|
||||||
override val upperSlowdownBound: Double by builder
|
|
||||||
.defineInRange("SATURATION_SLOWDOWN_BOUND", 6.0, 1.0, Float.MAX_VALUE - 1.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val FAST_REGEN: IFoodRegenerationValues
|
|
||||||
val SLOW_REGEN: IFoodRegenerationValues
|
|
||||||
|
|
||||||
init {
|
|
||||||
builder.push("FAST_REGENERATION")
|
|
||||||
FAST_REGEN = defineRegeneration(20, true, 10)
|
|
||||||
builder.pop()
|
|
||||||
|
|
||||||
builder.push("SLOW_REGENERATION")
|
|
||||||
SLOW_REGEN = defineRegeneration(18, false, 80)
|
|
||||||
builder.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
val ENABLE_STARVATION: Boolean by builder
|
|
||||||
.define("ENABLE_STARVATION", true)
|
|
||||||
|
|
||||||
val STARVATION_TICKS: Int by builder
|
|
||||||
.defineInRange("STARVATION_TICKS", 80, 1)
|
|
||||||
|
|
||||||
val STARVATION_HEALTH_LIMIT_EASY: Double by builder
|
|
||||||
.defineInRange("STARVATION_HEALTH_LIMIT_EASY", 10.0, 0.0)
|
|
||||||
|
|
||||||
val STARVATION_HEALTH_LIMIT_NORMAL: Double by builder
|
|
||||||
.defineInRange("STARVATION_HEALTH_LIMIT_NORMAL", 1.0, 0.0)
|
|
||||||
|
|
||||||
val STARVATION_HEALTH_LIMIT_HARD: Double by builder
|
|
||||||
.defineInRange("STARVATION_HEALTH_LIMIT_HARD", 0.0, 0.0)
|
|
||||||
|
|
||||||
init {
|
|
||||||
builder.pop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
Food
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.config
|
|
||||||
|
|
||||||
interface IFoodRegenerationValues {
|
|
||||||
val foodLimit: Int
|
|
||||||
val requiresSaturation: Boolean
|
|
||||||
val ticks: Int
|
|
||||||
val regenerationSlowdown: Boolean
|
|
||||||
val upperSlowdownBound: Double
|
|
||||||
}
|
|
@ -83,5 +83,5 @@ object ServerConfig : AbstractConfig("misc") {
|
|||||||
|
|
||||||
val WITHER_SKELETON_SWORD_CHANCE: Double by builder
|
val WITHER_SKELETON_SWORD_CHANCE: Double by builder
|
||||||
.comment("Chance of Wither Skeleton spawning with Withered Steel sword")
|
.comment("Chance of Wither Skeleton spawning with Withered Steel sword")
|
||||||
.defineInRange("WITHER_SKELETON_SWORD_CHANCE", 0.24, 0.0, 1.0)
|
.defineInRange("WITHER_SKELETON_HELMET_CHANCE", 0.24, 0.0, 1.0)
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.core
|
|
||||||
|
|
||||||
import net.minecraft.util.RandomSource
|
|
||||||
import net.minecraft.world.level.Level
|
|
||||||
import net.neoforged.fml.ModList
|
|
||||||
|
|
||||||
interface IMatteryLevel {
|
|
||||||
val otmRandom: RandomSource?
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OTM provided [RandomSource], which has better statistical parameters
|
|
||||||
*
|
|
||||||
* Original Minecraft use LCG, which may show bad behavior when repeatedly sampled *a lot*,
|
|
||||||
* which is what [Level]'s random is used for. OTM provided PRNG should behave better in this scenario.
|
|
||||||
*
|
|
||||||
* The way OTM uses random generator in its code will quickly cause LCG used in Minecraft to show its bias
|
|
||||||
* because LCG in minecraft samples its highest 48 bits, which gives us at best 2^16 period in the lowest bit returned by LCG.
|
|
||||||
* Which it doesn't sound bad, it quickly causes RNG become biased the quicker/more it is sampled on each tick, especially considering
|
|
||||||
* some may use `level.random.nextInt(chance) == 0` to determine chance of something happening,
|
|
||||||
* which will get extremely biased on heavy RNG congested environment
|
|
||||||
* If we avoid sampling Level's generator this much, we won't suffer from bias in our own code, as well as avoid biasing other mods this much.
|
|
||||||
*
|
|
||||||
* The "2^16 period" problem is also might be the reason why Entities get their own instance of RandomSource,
|
|
||||||
* and Mob Goals use random exactly the way described above (`nextInt(chance)`), which can and will suffer
|
|
||||||
* from bias the moment mob exists in world for more than 2^16 ticks (but actual bias will happen sooner
|
|
||||||
* because RNG is not sampled only once per tick, obviously)
|
|
||||||
*/
|
|
||||||
val Level.otmRandom: RandomSource get() = (this as IMatteryLevel).otmRandom ?: random
|
|
@ -1,7 +1,6 @@
|
|||||||
package ru.dbotthepony.mc.otm.core.math
|
package ru.dbotthepony.mc.otm.core.math
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList
|
||||||
import net.minecraft.util.RandomSource
|
|
||||||
import ru.dbotthepony.mc.otm.core.random
|
import ru.dbotthepony.mc.otm.core.random
|
||||||
import java.util.random.RandomGenerator
|
import java.util.random.RandomGenerator
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@ -89,7 +88,7 @@ private class MutableCluster<V : Comparable<V>>(var center: V) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun <V : Comparable<V>> Iterable<V>.clusterize(
|
private fun <V : Comparable<V>> Iterable<V>.clusterize(
|
||||||
random: RandomSource,
|
random: RandomGenerator,
|
||||||
initialClusters: Int = 1,
|
initialClusters: Int = 1,
|
||||||
zeroBound: Boolean = false,
|
zeroBound: Boolean = false,
|
||||||
identity: V,
|
identity: V,
|
||||||
@ -203,7 +202,7 @@ private fun <V : Comparable<V>> Iterable<V>.clusterize(
|
|||||||
// TODO: could use some tweaking
|
// TODO: could use some tweaking
|
||||||
private val DECIMAL_ERROR_TOLERANCE = Decimal("0.02")
|
private val DECIMAL_ERROR_TOLERANCE = Decimal("0.02")
|
||||||
|
|
||||||
fun Iterable<Decimal>.clusterize(random: RandomSource, clusters: Int? = null, zeroBound: Boolean = false): List<Cluster<Decimal>> {
|
fun Iterable<Decimal>.clusterize(random: RandomGenerator, clusters: Int? = null, zeroBound: Boolean = false): List<Cluster<Decimal>> {
|
||||||
return clusterize(random, clusters ?: 1, zeroBound, Decimal.ZERO, Decimal::plus, Decimal::minus, Decimal::div, Decimal::absoluteValue) { min, max, error ->
|
return clusterize(random, clusters ?: 1, zeroBound, Decimal.ZERO, Decimal::plus, Decimal::minus, Decimal::div, Decimal::absoluteValue) { min, max, error ->
|
||||||
if (clusters != null)
|
if (clusters != null)
|
||||||
false
|
false
|
||||||
|
@ -9,7 +9,6 @@ import net.minecraft.network.chat.FormattedText
|
|||||||
import net.minecraft.network.chat.MutableComponent
|
import net.minecraft.network.chat.MutableComponent
|
||||||
import net.minecraft.world.inventory.tooltip.TooltipComponent
|
import net.minecraft.world.inventory.tooltip.TooltipComponent
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.THREAD_LOCAL_RANDOM
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.ChartLevelLabels
|
import ru.dbotthepony.mc.otm.client.render.ChartLevelLabels
|
||||||
import ru.dbotthepony.mc.otm.client.render.ChartTooltipElement
|
import ru.dbotthepony.mc.otm.client.render.ChartTooltipElement
|
||||||
import ru.dbotthepony.mc.otm.config.ClientConfig
|
import ru.dbotthepony.mc.otm.config.ClientConfig
|
||||||
@ -454,8 +453,10 @@ private fun formatHistoryChart(
|
|||||||
labelNames[0f] = (-maxTransferred).formatSiComponent(suffix, decimals, formatAsReadable = verbose, bias = bias)
|
labelNames[0f] = (-maxTransferred).formatSiComponent(suffix, decimals, formatAsReadable = verbose, bias = bias)
|
||||||
labelNames[1f] = maxReceived.formatSiComponent(suffix, decimals, formatAsReadable = verbose, bias = bias)
|
labelNames[1f] = maxReceived.formatSiComponent(suffix, decimals, formatAsReadable = verbose, bias = bias)
|
||||||
|
|
||||||
|
val rand = java.util.Random()
|
||||||
|
|
||||||
if (maxTransferred.isNotZero && transferredMult > 0.2f) {
|
if (maxTransferred.isNotZero && transferredMult > 0.2f) {
|
||||||
for (cluster in widget.transferred.clusterize(THREAD_LOCAL_RANDOM, zeroBound = true)) {
|
for (cluster in widget.transferred.clusterize(rand, zeroBound = true)) {
|
||||||
val perc = (cluster.center / maxTransferred).toFloat() * transferredMult
|
val perc = (cluster.center / maxTransferred).toFloat() * transferredMult
|
||||||
|
|
||||||
if (labelNames.keys.none { (it - perc).absoluteValue < 0.08f })
|
if (labelNames.keys.none { (it - perc).absoluteValue < 0.08f })
|
||||||
@ -464,7 +465,7 @@ private fun formatHistoryChart(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (maxReceived.isNotZero && receivedMult > 0.2f) {
|
if (maxReceived.isNotZero && receivedMult > 0.2f) {
|
||||||
for (cluster in widget.received.clusterize(THREAD_LOCAL_RANDOM, zeroBound = true)) {
|
for (cluster in widget.received.clusterize(rand, zeroBound = true)) {
|
||||||
val perc = zero + (cluster.center / maxReceived).toFloat() * receivedMult
|
val perc = zero + (cluster.center / maxReceived).toFloat() * receivedMult
|
||||||
|
|
||||||
if (labelNames.keys.none { (it - perc).absoluteValue < 0.08f })
|
if (labelNames.keys.none { (it - perc).absoluteValue < 0.08f })
|
||||||
@ -472,7 +473,7 @@ private fun formatHistoryChart(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val clusters = diff.asIterable().clusterize(THREAD_LOCAL_RANDOM, zeroBound = true)
|
val clusters = diff.asIterable().clusterize(rand, zeroBound = true)
|
||||||
|
|
||||||
for (cluster in clusters) {
|
for (cluster in clusters) {
|
||||||
val perc: Float
|
val perc: Float
|
||||||
|
@ -2,12 +2,15 @@ package ru.dbotthepony.mc.otm.core.util
|
|||||||
|
|
||||||
import net.minecraft.util.Mth
|
import net.minecraft.util.Mth
|
||||||
import net.minecraft.util.RandomSource
|
import net.minecraft.util.RandomSource
|
||||||
|
import net.minecraft.world.level.levelgen.MarsagliaPolarGaussian
|
||||||
import net.minecraft.world.level.levelgen.PositionalRandomFactory
|
import net.minecraft.world.level.levelgen.PositionalRandomFactory
|
||||||
import net.minecraft.world.level.levelgen.RandomSupport
|
import net.minecraft.world.level.levelgen.RandomSupport
|
||||||
import ru.dbotthepony.kommons.random.GJRAND64Random
|
import ru.dbotthepony.kommons.random.GJRAND64Random
|
||||||
import java.lang.StringBuilder
|
import java.lang.StringBuilder
|
||||||
|
|
||||||
class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator {
|
class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator {
|
||||||
|
private val gaussian = MarsagliaPolarGaussian(this)
|
||||||
|
|
||||||
constructor() : super(RandomSupport.generateUniqueSeed(), RandomSupport.generateUniqueSeed())
|
constructor() : super(RandomSupport.generateUniqueSeed(), RandomSupport.generateUniqueSeed())
|
||||||
constructor(seed: Long) : super(seed)
|
constructor(seed: Long) : super(seed)
|
||||||
constructor(seed0: Long, seed1: Long) : super(seed0, seed1)
|
constructor(seed0: Long, seed1: Long) : super(seed0, seed1)
|
||||||
@ -16,6 +19,10 @@ class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator {
|
|||||||
return nextLong().ushr(32).toInt()
|
return nextLong().ushr(32).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun nextGaussian(): Double {
|
||||||
|
return gaussian.nextGaussian()
|
||||||
|
}
|
||||||
|
|
||||||
override fun fork(): RandomSource {
|
override fun fork(): RandomSource {
|
||||||
return GJRAND64RandomSource(nextLong(), nextLong())
|
return GJRAND64RandomSource(nextLong(), nextLong())
|
||||||
}
|
}
|
||||||
@ -26,6 +33,7 @@ class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator {
|
|||||||
|
|
||||||
override fun setSeed(seed: Long) {
|
override fun setSeed(seed: Long) {
|
||||||
reinitialize(seed)
|
reinitialize(seed)
|
||||||
|
gaussian.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
class Positional(private val seed0: Long, private val seed1: Long) : PositionalRandomFactory {
|
class Positional(private val seed0: Long, private val seed1: Long) : PositionalRandomFactory {
|
||||||
|
@ -26,7 +26,5 @@ interface IRandomSourceGenerator : RandomSource, RandomGenerator {
|
|||||||
return super.nextDouble()
|
return super.nextDouble()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun nextGaussian(): Double {
|
override fun nextGaussian(): Double
|
||||||
return super.nextGaussian()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ object FlywheelMaterials : SimpleJsonResourceReloadListener(GsonBuilder().setPre
|
|||||||
).apply(it, ::Entry)
|
).apply(it, ::Entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun reloadEvent(event: AddReloadListenerEvent) {
|
fun reloadEvent(event: AddReloadListenerEvent) {
|
||||||
event.addListener(this)
|
event.addListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ object FlywheelMaterials : SimpleJsonResourceReloadListener(GsonBuilder().setPre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun onDataPackSync(event: OnDatapackSyncEvent) {
|
fun onDataPackSync(event: OnDatapackSyncEvent) {
|
||||||
if (event.player == null) {
|
if (event.player == null) {
|
||||||
PacketDistributor.sendToAllPlayers(SyncPacket(elements))
|
PacketDistributor.sendToAllPlayers(SyncPacket(elements))
|
||||||
} else {
|
} else {
|
||||||
@ -235,7 +235,7 @@ object FlywheelMaterials : SimpleJsonResourceReloadListener(GsonBuilder().setPre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun tooltipEvent(event: ItemTooltipEvent) {
|
fun tooltipEvent(event: ItemTooltipEvent) {
|
||||||
if (minecraft.window.isShiftDown) {
|
if (minecraft.window.isShiftDown) {
|
||||||
val item = event.itemStack.item
|
val item = event.itemStack.item
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import net.minecraft.world.level.storage.loot.LootContext
|
|||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams
|
||||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition
|
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition
|
||||||
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType
|
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.data.get
|
import ru.dbotthepony.mc.otm.data.get
|
||||||
import ru.dbotthepony.mc.otm.registry.data.MLootItemConditions
|
import ru.dbotthepony.mc.otm.registry.data.MLootItemConditions
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams
|
|||||||
import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition
|
import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition
|
||||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition
|
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition
|
||||||
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType
|
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType
|
||||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||||
import ru.dbotthepony.mc.otm.data.get
|
import ru.dbotthepony.mc.otm.data.get
|
||||||
import ru.dbotthepony.mc.otm.registry.data.MLootItemConditions
|
import ru.dbotthepony.mc.otm.registry.data.MLootItemConditions
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ abstract class DecimalProvider : SampledDecimal {
|
|||||||
registror.register("uniform") { UniformDecimal }
|
registror.register("uniform") { UniformDecimal }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun register(bus: IEventBus) {
|
fun register(bus: IEventBus) {
|
||||||
bus.addListener(registryHolder::build)
|
bus.addListener(registryHolder::build)
|
||||||
registror.register(bus)
|
registror.register(bus)
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user