generated from NeoForgeMDKs/MDK-1.21.1-ModDevGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # src/main/java/net/nayrus/noteblockmaster/NoteBlockMaster.java # src/main/java/net/nayrus/noteblockmaster/block/TuningCore.java # src/main/java/net/nayrus/noteblockmaster/item/ComposersNote.java # src/main/java/net/nayrus/noteblockmaster/item/TunerItem.java # src/main/java/net/nayrus/noteblockmaster/screen/base/BaseTunerScreen.java # src/main/java/net/nayrus/noteblockmaster/setup/Registry.java
- Loading branch information
Showing
17 changed files
with
236 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/net/nayrus/noteblockmaster/network/NetworkUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.nayrus.noteblockmaster.network; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import net.nayrus.noteblockmaster.network.payload.ScheduleCoreSound; | ||
import net.neoforged.neoforge.network.PacketDistributor; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.List; | ||
|
||
public class NetworkUtil { | ||
|
||
public static void broadcastPayload( | ||
List<ServerPlayer> players, | ||
@Nullable Player except, | ||
double x, | ||
double y, | ||
double z, | ||
double radius, | ||
ResourceKey<Level> dimension, | ||
CustomPacketPayload payload | ||
) { | ||
for (ServerPlayer serverplayer : players) { | ||
if (serverplayer != except && serverplayer.level().dimension() == dimension) { | ||
double d0 = x - serverplayer.getX(); | ||
double d1 = y - serverplayer.getY(); | ||
double d2 = z - serverplayer.getZ(); | ||
if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius) { | ||
PacketDistributor.sendToPlayer(serverplayer, payload); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static void broadcastCoreSound(ServerLevel level, ScheduleCoreSound payload){ | ||
BlockPos pos = payload.pos(); | ||
broadcastPayload(level.players(), null, pos.getX(), pos.getY(), pos.getZ(), 64, level.dimension(), payload); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.