mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Sync recipes on reload (untested)
This commit is contained in:
1 parent
e9c669034e
commit
ea84b87c0d
11 files changed
+314
-11
No files matched your search
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
@@ -15,9 +16,12 @@ import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class PacketHandler {
|
||||
private static final String PROTOCOL = "1";
|
||||
private static final SimpleChannel HANDLER = NetworkRegistry.newSimpleChannel(
|
||||
public static final SimpleChannel HANDLER = NetworkRegistry.newSimpleChannel(
|
||||
new ResourceLocation(LibMisc.MOD_ID, "chan"),
|
||||
() -> PROTOCOL,
|
||||
PROTOCOL::equals,
|
||||
@@ -31,6 +35,7 @@ public final class PacketHandler {
|
||||
HANDLER.registerMessage(id++, PacketDodge.class, PacketDodge::encode, PacketDodge::decode, PacketDodge::handle);
|
||||
HANDLER.registerMessage(id++, PacketJump.class, PacketJump::encode, PacketJump::decode, PacketJump::handle);
|
||||
HANDLER.registerMessage(id++, PacketItemAge.class, PacketItemAge::encode, PacketItemAge::decode, PacketItemAge::handle);
|
||||
HANDLER.registerMessage(id++, PacketSyncRecipes.class, PacketSyncRecipes::encode, PacketSyncRecipes::decode, PacketSyncRecipes::handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,6 +45,7 @@ public final class PacketHandler {
|
||||
if(world instanceof ServerWorld) {
|
||||
ServerWorld ws = (ServerWorld) world;
|
||||
|
||||
// todo 1.14 this sends duplicates
|
||||
for (ServerPlayerEntity playerMP : ws.getPlayers()) {
|
||||
if (playerMP.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) < 64 * 64) {
|
||||
HANDLER.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunkAt(pos)), toSend);
|
||||
|
||||
Reference in new issue
Block a user