Skip to content

Commit

Permalink
wip: perfect
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jun 13, 2024
1 parent edab248 commit 63cbe64
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public void entityInside(BlockState blockState, Level world, BlockPos pos, Entit

@Override
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
if (state.getValue(STATUS) == WarpPlateStatus.WARPING || state.getValue(STATUS) == WarpPlateStatus.ATTUNING) {
final var status = state.getValue(STATUS);
if (status == WarpPlateStatus.WARPING) {
for (int i = 0; i < 50; i++) {
world.addParticle(ParticleTypes.CRIMSON_SPORE,
pos.getX() + Math.random(),
Expand All @@ -138,10 +139,17 @@ public void animateTick(BlockState state, Level world, BlockPos pos, RandomSourc
0f,
0f);
}
} else if (state.getValue(STATUS) == WarpPlateStatus.WARPING_INVALID) {
} else if (status == WarpPlateStatus.WARPING_INVALID) {
for (int i = 0; i < 10; i++) {
world.addParticle(ParticleTypes.SMOKE, pos.getX() + Math.random(), pos.getY(), pos.getZ() + Math.random(), 0f, 0.01f, 0f);
}
} else if(status == WarpPlateStatus.ATTUNING) {
for (int i = 0; i < 10; i++) {
world.addParticle(ParticleTypes.WARPED_SPORE, pos.getX() + Math.random(), pos.getY(), pos.getZ() + Math.random(), 0f, 0f, 0f);
}
for (int i = 0; i < 10; i++) {
world.addParticle(ParticleTypes.SOUL_FIRE_FLAME, pos.getX() + Math.random(), pos.getY(), pos.getZ() + Math.random(), 0f, 0f, 0f);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package net.blay09.mods.waystones.block.entity;

import net.blay09.mods.balm.api.Balm;
import net.blay09.mods.waystones.api.*;
import net.blay09.mods.waystones.api.WaystoneTypes;
import net.blay09.mods.waystones.api.error.WaystoneTeleportError;
import net.blay09.mods.waystones.block.WarpPlateBlock;
import net.blay09.mods.waystones.config.WaystonesConfig;
import net.blay09.mods.waystones.core.*;
import net.blay09.mods.waystones.item.ModItems;
import net.blay09.mods.waystones.network.message.WarpPlateEjectEffectMessage;
import net.blay09.mods.waystones.tag.ModItemTags;
import net.blay09.mods.waystones.worldgen.namegen.NameGenerationMode;
import net.blay09.mods.waystones.worldgen.namegen.NameGeneratorManager;
Expand All @@ -16,6 +18,9 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySelector;
Expand Down Expand Up @@ -304,6 +309,10 @@ public void attuneShard() {
shardItem);
level.addFreshEntity(shardEntity);
setShardItem(ItemStack.EMPTY);
if (level instanceof ServerLevel serverLevel) {
Balm.getNetworking().sendToTracking(serverLevel, worldPosition, new WarpPlateEjectEffectMessage(worldPosition));
level.playSound(null, worldPosition, SoundEvents.CHICKEN_EGG, SoundSource.PLAYERS, 1f, 1f);
}
}
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static void initialize(BalmNetworking networking) {
networking.registerClientboundPacket(SortingIndexMessage.TYPE, SortingIndexMessage.class, SortingIndexMessage::encode, SortingIndexMessage::decode, SortingIndexMessage::handle);
networking.registerClientboundPacket(TeleportEffectMessage.TYPE, TeleportEffectMessage.class, TeleportEffectMessage::encode, TeleportEffectMessage::decode, TeleportEffectMessage::handle);
networking.registerClientboundPacket(PlayerWaystoneCooldownsMessage.TYPE, PlayerWaystoneCooldownsMessage.class, PlayerWaystoneCooldownsMessage::encode, PlayerWaystoneCooldownsMessage::decode, PlayerWaystoneCooldownsMessage::handle);
networking.registerClientboundPacket(WarpPlateEjectEffectMessage.TYPE, WarpPlateEjectEffectMessage.class, WarpPlateEjectEffectMessage::encode, WarpPlateEjectEffectMessage::decode, WarpPlateEjectEffectMessage::handle);

SyncConfigMessage.register(SyncWaystonesConfigMessage.TYPE, SyncWaystonesConfigMessage.class, SyncWaystonesConfigMessage::new, WaystonesConfigData.class, WaystonesConfigData::new);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.blay09.mods.waystones.network.message;

import net.blay09.mods.waystones.Waystones;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

public class WarpPlateEjectEffectMessage implements CustomPacketPayload {

public static final Type<WarpPlateEjectEffectMessage> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Waystones.MOD_ID,
"warp_plate_eject_effect"));

private final BlockPos pos;

public WarpPlateEjectEffectMessage(BlockPos pos) {
this.pos = pos;
}

public static void encode(FriendlyByteBuf buf, WarpPlateEjectEffectMessage message) {
buf.writeBlockPos(message.pos);
}

public static WarpPlateEjectEffectMessage decode(FriendlyByteBuf buf) {
BlockPos pos = buf.readBlockPos();
return new WarpPlateEjectEffectMessage(pos);
}

public static void handle(Player player, WarpPlateEjectEffectMessage message) {
Level level = player.level();
if (level != null) {
for (int i = 0; i < 10; i++) {
level.addParticle(ParticleTypes.SMALL_GUST, message.pos.getX() + 0.5 + (level.random.nextDouble() - 0.5), message.pos.getY() + level.random.nextDouble(), message.pos.getZ() + 0.5 + (level.random.nextDouble() - 0.5), (level.random.nextDouble() - 0.5) * 2, -level.random.nextDouble(), (level.random.nextDouble() - 0.5) * 2);
// TODO sound
}
}
}

@Override
public Type<? extends CustomPacketPayload> type() {
return TYPE;
}
}

0 comments on commit 63cbe64

Please sign in to comment.