Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/dev/amble/ait/AITMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public class AITMod implements ModInitializer {
public static final GameRules.Key<GameRules.BooleanRule> TARDIS_FIRE_GRIEFING = GameRuleRegistry.register("tardisFireGriefing",
GameRules.Category.MISC, GameRuleFactory.createBooleanRule(false));

public static final GameRules.Key<GameRules.BooleanRule> TARDIS_SUICIDAL = GameRuleRegistry.register("tardisCanBeSuicidal",
GameRules.Category.MISC, GameRuleFactory.createBooleanRule(false));


public static final RegistryKey<PlacedFeature> CUSTOM_GEODE_PLACED_KEY = RegistryKey.of(RegistryKeys.PLACED_FEATURE,
new Identifier(MOD_ID, "zeiton_geode"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.function.Supplier;

import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import dev.amble.lib.data.CachedDirectedGlobalPos;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -122,7 +123,8 @@ public enum Id implements IdLike {
ENVIRONMENT(ExteriorEnvironmentHandler.class, ExteriorEnvironmentHandler::new),
INTERIOR(InteriorChangingHandler.class, InteriorChangingHandler::new),
SEQUENCE(SequenceHandler.class, SequenceHandler::new),
MOOD(MoodHandler.class, MoodHandler::new),
//MOOD(MoodHandler.class, MoodHandler::new),
MOOD(MoodHandler2.class, MoodHandler2::new),
FUEL(FuelHandler.class, FuelHandler::new),
HADS(HadsHandler.class, HadsHandler::new),
SIEGE(SiegeHandler.class, SiegeHandler::new),
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/dev/amble/ait/config/AITServerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public class AITServerConfig {
@Boolean(formatter = Boolean.Formatter.YES_NO, colored = true)
@SerialEntry public boolean tntCanTeleportThroughDoors = true;

@AutoGen(category = CATEGORY)
@Boolean(formatter = Boolean.Formatter.YES_NO, colored = true)
@SerialEntry public boolean moodEnabled = false;

@AutoGen(category = CATEGORY)
@FloatSlider(min = 0, max = 1, step = 0.0000001f)
@SerialEntry public float passiveEmotionMultiplier = 0.0000001f;

@AutoGen(category = CATEGORY)
@Boolean(formatter = Boolean.Formatter.YES_NO, colored = true)
@SerialEntry public boolean hypercubesEnabled = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.amble.ait.core.blockentities;

import dev.amble.ait.api.tardis.TardisComponent;
import dev.amble.ait.core.tardis.handler.mood.v2.Emotion;
import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import dev.amble.lib.data.CachedDirectedGlobalPos;
import dev.amble.lib.data.DirectedBlockPos;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -82,7 +85,10 @@ public static <T extends BlockEntity> void tick(World world, BlockPos pos, Block
}

if (blockState.get(Properties.WATERLOGGED) && world.getRandom().nextBoolean()) {
serverWorld.getPlayers().forEach(player -> tardis.loyalty().subLevel(player, 2));
serverWorld.getPlayers().forEach(player -> {
tardis.loyalty().subLevel(player, 2);
tardis.<MoodHandler2>handler(TardisComponent.Id.MOOD).add(Emotion.Type.UPSET, 0.001f);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wont this cause it to lose 0.001 based on the amount of players in the interior

});
}

ChunkPos exteriorChunkPos = new ChunkPos(exteriorPos);
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/dev/amble/ait/core/blocks/ConsoleBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.util.Random;

import dev.amble.ait.api.tardis.TardisComponent;
import dev.amble.ait.core.tardis.handler.mood.v2.Emotion;
import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import dev.amble.lib.api.ICantBreak;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -174,16 +177,18 @@ public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity enti
player.addVelocity(0.15f * x_random * (is_x_negative ? -1 : 1), 0.1f * y_random,
0.15f * z_random * (is_z_negative ? -1 : 1));

if (player instanceof ServerPlayerEntity) {
if (world instanceof TardisServerWorld serverWorld) {
MoodHandler2 mood = serverWorld.getTardis().handler(TardisComponent.Id.MOOD);
mood.add(Emotion.Type.UPSET, 0.01f);

for (int i = 0; i < 100; i++) {
((ServerWorld) world).spawnParticles(ParticleTypes.ANGRY_VILLAGER,
serverWorld.spawnParticles(ParticleTypes.ANGRY_VILLAGER,
pos.getX() + random.nextFloat(-2, 3), pos.getY() + random.nextFloat(2),
pos.getZ() + random.nextFloat(-2, 3), 1, random.nextFloat(-5, 5), random.nextFloat(-5, 5),
random.nextFloat(-5, 5), 1f);
}
}
}
super.onSteppedOn(world, pos, state, entity);
}

// This will literally never happen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;

import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import net.minecraft.server.command.ServerCommandSource;

import dev.amble.ait.AITMod;
Expand All @@ -28,7 +29,8 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
private static int triggerMoodRollCommand(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerTardis tardis = TardisArgumentType.getTardis(context, "tardis");

tardis.<MoodHandler>handler(TardisComponent.Id.MOOD).rollForMoodDictatedEvent();
System.out.println(tardis.<MoodHandler2>handler(TardisComponent.Id.MOOD).container.toString());
Comment thread
drtheodor marked this conversation as resolved.
//tardis.<MoodHandler2>handler(TardisComponent.Id.MOOD).runEvent();

return Command.SINGLE_SUCCESS;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/dev/amble/ait/core/item/HammerItem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package dev.amble.ait.core.item;

import dev.amble.ait.api.tardis.TardisComponent;
import dev.amble.ait.core.tardis.handler.mood.v2.Emotion;
import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import dev.amble.ait.core.tardis.util.TardisUtil;
import org.joml.Vector3f;

import net.minecraft.block.BlockState;
Expand Down Expand Up @@ -76,6 +80,7 @@ public ActionResult useOnBlock(ItemUsageContext context) {
world.playSound(null, consoleBlockEntity.getPos(), AITSounds.HAMMER_HIT, SoundCategory.BLOCKS,
1f, 1.0f);
tardis.loyalty().subLevel((ServerPlayerEntity) player, 10); // safe cast since its on server already
tardis.<MoodHandler2>handler(TardisComponent.Id.MOOD).add(Emotion.Type.ANGER, 0.05f);

if (hammerUses > 3) {
world.playSoundFromEntity(null, player, AITSounds.HAMMER_STRIKE, SoundCategory.PLAYERS, 0.5f, 0.2f);
Expand Down Expand Up @@ -103,6 +108,7 @@ public ActionResult useOnBlock(ItemUsageContext context) {
World.ExplosionSourceType.MOB);

tardis.loyalty().subLevel((ServerPlayerEntity) player, 50); // safe cast since its on server already
tardis.<MoodHandler2>handler(TardisComponent.Id.MOOD).add(Emotion.Type.ANGER, 0.2f);
player.getItemCooldownManager().set(stack.getItem(), 10 * 20);
return ActionResult.SUCCESS;
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/dev/amble/ait/core/item/KeyItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import java.util.Collection;
import java.util.List;

import dev.amble.ait.api.tardis.TardisComponent;
import dev.amble.ait.core.tardis.handler.mood.v2.Emotion;
import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import dev.amble.ait.core.util.WorldUtil;
import dev.amble.ait.core.world.TardisServerWorld;
import dev.amble.lib.data.CachedDirectedGlobalPos;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -121,6 +126,8 @@ public void onItemEntityDestroyed(ItemEntity entity) {
return;

tardis.loyalty().subLevel(player, 10);
tardis.<MoodHandler2>handler(TardisComponent.Id.MOOD).add(Emotion.Type.UPSET, 0.01f);

tardis.getDesktop().playSoundAtEveryConsole(AITSounds.CLOISTER);
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/amble/ait/core/likes/Opinion.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.util.Optional;

import dev.amble.ait.api.tardis.TardisComponent;
import dev.amble.ait.core.tardis.handler.mood.v2.Emotion;
import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import dev.amble.lib.api.Identifiable;

import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -18,6 +21,7 @@ default boolean likes() {
}
default void apply(ServerTardis tardis, ServerPlayerEntity target) {
tardis.loyalty().addLevel(target, loyalty());
tardis.<MoodHandler2>handler(TardisComponent.Id.MOOD).add(Emotion.Type.GRATEFUL, 0.001f);
Comment thread
drtheodor marked this conversation as resolved.
}

enum Type {
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/dev/amble/ait/core/tardis/TardisDesktop.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public static void playSoundAtConsole(World dim, BlockPos console, SoundEvent so
}

public void playSoundAtEveryConsole(SoundEvent sound, SoundCategory category, float volume, float pitch) {
if (!this.isServer()) return;
if (!this.isServer() || !this.tardis.asServer().hasWorld()) return;

ServerWorld world = this.tardis.asServer().world();

Expand All @@ -274,12 +274,11 @@ public void playSoundAtEveryConsole(SoundEvent sound, SoundCategory category, fl
}

public void forcePlaySoundAtEveryConsole(Identifier soundId, SoundCategory category) {
if (!this.isServer()) return;
if (!this.isServer() || !this.tardis.asServer().hasWorld()) return;

RegistryKey<World> worldKey = this.tardis.asServer().world().getRegistryKey();
this.getConsolePos().forEach(consolePos -> {
NetworkUtil.playSound(worldKey, consolePos, soundId, category, 1);
});
this.getConsolePos().forEach(consolePos ->
NetworkUtil.playSound(worldKey, consolePos, soundId, category, 1));
}

public void playSoundAtEveryConsole(SoundEvent sound, SoundCategory category) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package dev.amble.ait.core.tardis.control;

import dev.amble.ait.api.tardis.TardisComponent;
import dev.amble.ait.api.tardis.TardisEvents;
import dev.amble.ait.core.tardis.handler.mood.v2.Emotion;
import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import dev.amble.lib.api.Identifiable;

import net.minecraft.particle.ParticleTypes;
Expand Down Expand Up @@ -64,6 +68,7 @@ public void addToControlSequence(Tardis tardis, ServerPlayerEntity player, Block

if (AITMod.RANDOM.nextInt(0, 20) == 4) {
tardis.loyalty().addLevel(player, 1);
tardis.<MoodHandler2>handler(TardisComponent.Id.MOOD).add(Emotion.Type.RELIEVED, 0.005f);

player.getServerWorld().spawnParticles(ParticleTypes.HEART, pos.toCenterPos().getX(),
pos.toCenterPos().getY() + 1, pos.toCenterPos().getZ(), 1, 0f, 1F, 0f, 5.0F);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package dev.amble.ait.core.tardis.control.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import dev.amble.ait.api.tardis.TardisComponent;
import dev.amble.ait.core.tardis.handler.mood.v2.MoodHandler2;
import dev.amble.lib.data.CachedDirectedGlobalPos;
import dev.drtheo.queue.api.ActionQueue;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.Nullable;

import net.minecraft.item.Item;
Expand Down Expand Up @@ -162,6 +166,18 @@ public Result runServer(Tardis tardis, ServerPlayerEntity player, ServerWorld wo
return Result.SUCCESS;
}

if (player.isSneaking()) {
MoodHandler2 mood = tardis.handler(TardisComponent.Id.MOOD);

Arrays.stream(mood.container.emotions)
.sorted((o1, o2) -> Float.compare(o1.value, o2.value))
.limit(3).forEach(emotion -> {
player.sendMessage(Text.literal("Your tardis is feeling " + emotion.type).formatted(Formatting.YELLOW, Formatting.ITALIC));
});
Comment thread
drtheodor marked this conversation as resolved.

return Result.SUCCESS;
}

Text text = Text.translatable("tardis.message.control.telepathic.choosing");
player.sendMessage(text, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@

import net.minecraft.util.Identifier;

import dev.amble.ait.AITMod;
import dev.amble.ait.core.tardis.ServerTardis;

public interface MoodDictatedEvent {

default Identifier id() {
return AITMod.id("mood_dictated_event");
}
Identifier id();

void execute(ServerTardis tardis);

Expand Down Expand Up @@ -56,6 +53,7 @@ public int getCost() {

@Override
public void execute(ServerTardis tardis) {
System.out.println("executing mood event");
this.execute.run(tardis);
}

Expand Down
Loading
Loading