Sound Effects and Improve Diviner
All checks were successful
Twine/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-06-17 20:19:08 -04:00
parent bf99c5c460
commit 1fe136b3a8
5 changed files with 39 additions and 7 deletions

View File

@ -53,6 +53,7 @@ Each player has a "personal" stage of an area, the highest online player's diffi
### Stage 5 ### Stage 5
- Neutral Mobs Are Always Hostile - Neutral Mobs Are Always Hostile
- Mobs No Longer Have Knockback
### Stage 6 ### Stage 6
- Mobs No Longer Burn In Sunlight - Mobs No Longer Burn In Sunlight

View File

@ -1,10 +1,13 @@
package com.thebrokenrail.twine.component; package com.thebrokenrail.twine.component;
import com.thebrokenrail.twine.Twine; import com.thebrokenrail.twine.Twine;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.PersistentState; import net.minecraft.world.PersistentState;
@ -51,14 +54,32 @@ public class StageDataComponent extends PersistentState {
public long findEffectiveTimeOfChunk(ServerWorld world, BlockPos pos) { public long findEffectiveTimeOfChunk(ServerWorld world, BlockPos pos) {
long time = 0; long time = 0;
int stage = findEffectiveStageOfChunk(world, pos);
for (Map.Entry<UUID, StageData[]> entry : data.entrySet()) { for (Map.Entry<UUID, StageData[]> entry : data.entrySet()) {
if (world.getPlayerByUuid(entry.getKey()) != null) { if (world.getPlayerByUuid(entry.getKey()) != null) {
time = Math.max(time, entry.getValue()[findStageOfChunk(pos, entry.getValue())].time); int personalStage = findStageOfChunk(pos, entry.getValue());
if (personalStage == stage) {
time = Math.max(time, entry.getValue()[stage].time);
}
} }
} }
return time; return time;
} }
public Text findEffectiveCauseOfChunk(ServerWorld world, BlockPos pos) {
int stage = findEffectiveStageOfChunk(world, pos);
for (Map.Entry<UUID, StageData[]> entry : data.entrySet()) {
PlayerEntity player = world.getPlayerByUuid(entry.getKey());
if (player != null) {
int personalStage = findStageOfChunk(pos, entry.getValue());
if (personalStage == stage) {
return player.getDisplayName();
}
}
}
return new LiteralText("");
}
public static StageDataComponent getFromWorld(ServerWorld world) { public static StageDataComponent getFromWorld(ServerWorld world) {
return world.getPersistentStateManager().getOrCreate(() -> new StageDataComponent(STAGE_DATA_ID), STAGE_DATA_ID); return world.getPersistentStateManager().getOrCreate(() -> new StageDataComponent(STAGE_DATA_ID), STAGE_DATA_ID);
} }

View File

@ -10,7 +10,10 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
@ -41,9 +44,12 @@ public class DivinerItem extends Item {
user.sendMessage(new TranslatableText("chat.twine.diviner_info_1", new LiteralText(String.valueOf(stage + 1)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false); user.sendMessage(new TranslatableText("chat.twine.diviner_info_1", new LiteralText(String.valueOf(stage + 1)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_2", (stage + 1 >= Twine.STAGE_COUNT ? new TranslatableText("chat.twine.diviner_info_never") : new LiteralText(String.valueOf(Twine.STAGE_TIME - component.findEffectiveTimeOfChunk((ServerWorld) world, pos)))).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false); user.sendMessage(new TranslatableText("chat.twine.diviner_info_2", (stage + 1 >= Twine.STAGE_COUNT ? new TranslatableText("chat.twine.diviner_info_never") : new LiteralText(String.valueOf(Twine.STAGE_TIME - component.findEffectiveTimeOfChunk((ServerWorld) world, pos)))).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_3", new LiteralText(String.valueOf(effectiveStage + 1)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false); user.sendMessage(new TranslatableText("chat.twine.diviner_info_3", component.findEffectiveCauseOfChunk((ServerWorld) world, pos).shallowCopy().formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_4", new LiteralText(String.valueOf(personalData[effectiveStage].x)).formatted(Formatting.WHITE), new LiteralText(String.valueOf(personalData[effectiveStage].z)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false); user.sendMessage(new TranslatableText("chat.twine.diviner_info_4", new LiteralText(String.valueOf(effectiveStage + 1)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_5", (effectiveStage + 1 >= Twine.STAGE_COUNT ? new TranslatableText("chat.twine.diviner_info_never") : new LiteralText(String.valueOf(Twine.STAGE_TIME - personalData[effectiveStage].time))).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false); user.sendMessage(new TranslatableText("chat.twine.diviner_info_5", new LiteralText(String.valueOf(personalData[effectiveStage].x)).formatted(Formatting.WHITE), new LiteralText(String.valueOf(personalData[effectiveStage].z)).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
user.sendMessage(new TranslatableText("chat.twine.diviner_info_6", (effectiveStage + 1 >= Twine.STAGE_COUNT ? new TranslatableText("chat.twine.diviner_info_never") : new LiteralText(String.valueOf(Twine.STAGE_TIME - personalData[effectiveStage].time))).formatted(Formatting.WHITE)).formatted(Formatting.YELLOW), false);
world.playSound(null, user.getBlockPos(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 1f, 1f);
stack.damage(1, user, e -> e.sendToolBreakStatus(hand)); stack.damage(1, user, e -> e.sendToolBreakStatus(hand));
} }

View File

@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.screen.SimpleNamedScreenHandlerFactory; import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -88,6 +89,8 @@ public class MixinBoatEntity implements BoatUtil {
setChestItem(newStack); setChestItem(newStack);
newMode.triggerAdvancement((ServerPlayerEntity) player); newMode.triggerAdvancement((ServerPlayerEntity) player);
player.getEntityWorld().playSound(null, ((BoatEntity) (Object) this).getBlockPos(), SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, ((BoatEntity) (Object) this).getSoundCategory(), 1f, 1f);
} }
info.setReturnValue(ActionResult.SUCCESS); info.setReturnValue(ActionResult.SUCCESS);
} else if (player.isSneaking()) { } else if (player.isSneaking()) {

View File

@ -41,9 +41,10 @@
"chat.twine.diviner_info_1": "Effective Stage Of Area: %s", "chat.twine.diviner_info_1": "Effective Stage Of Area: %s",
"chat.twine.diviner_info_2": "Effective Stage Of Area Increases In: %s Ticks", "chat.twine.diviner_info_2": "Effective Stage Of Area Increases In: %s Ticks",
"chat.twine.diviner_info_3": "Personal Stage Of Area: %s", "chat.twine.diviner_info_3": "Effective Stage Of Area Caused By: %s",
"chat.twine.diviner_info_4": "Personal Center Of Area: X: %s Z: %s", "chat.twine.diviner_info_4": "Personal Stage Of Area: %s",
"chat.twine.diviner_info_5": "Personal Stage Of Area Increases In: %s Ticks", "chat.twine.diviner_info_5": "Personal Center Of Area: X: %s Z: %s",
"chat.twine.diviner_info_6": "Personal Stage Of Area Increases In: %s Ticks",
"chat.twine.diviner_info_never": "Never", "chat.twine.diviner_info_never": "Never",
"block.twine.creative_url_opener": "Creative URL Opener", "block.twine.creative_url_opener": "Creative URL Opener",