a
This commit is contained in:
@@ -92,6 +92,7 @@ public class SzarClient implements ClientModInitializer {
|
|||||||
// Apply the cosmetic profile on the main thread
|
// Apply the cosmetic profile on the main thread
|
||||||
client.execute(() -> {
|
client.execute(() -> {
|
||||||
ClientCosmetics.fetchMojangCapes(playerUuid);
|
ClientCosmetics.fetchMojangCapes(playerUuid);
|
||||||
|
System.out.println("got it client");
|
||||||
ClientCosmetics.apply(playerUuid, nameType, staticColor, gradientStart, gradientEnd, capeTexture);
|
ClientCosmetics.apply(playerUuid, nameType, staticColor, gradientStart, gradientEnd, capeTexture);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ import net.minecraft.util.Hand;
|
|||||||
import net.minecraft.util.TypedActionResult;
|
import net.minecraft.util.TypedActionResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class FaszItem extends BlockItem {
|
public class FaszItem extends BlockItem {
|
||||||
|
|
||||||
public FaszItem(Block block, Settings settings) {
|
public FaszItem(Block block, Settings settings) {
|
||||||
@@ -22,7 +26,7 @@ public class FaszItem extends BlockItem {
|
|||||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||||
ItemStack stack = user.getStackInHand(hand);
|
ItemStack stack = user.getStackInHand(hand);
|
||||||
|
|
||||||
if (!world.isClient && stack.isOf(this)) {
|
if (!world.isClient && stack.isOf(this) && new Random().nextInt(5) == 1) {
|
||||||
ServerWorld serverWorld = (ServerWorld) world;
|
ServerWorld serverWorld = (ServerWorld) world;
|
||||||
|
|
||||||
// Get the direction the player's torso is looking
|
// Get the direction the player's torso is looking
|
||||||
|
|||||||
@@ -217,7 +217,16 @@ public class ServerCosmetics {
|
|||||||
/* ---------------- SYNC ---------------- */
|
/* ---------------- SYNC ---------------- */
|
||||||
|
|
||||||
public static void sync(ServerPlayerEntity player, UserCosmetics user) {
|
public static void sync(ServerPlayerEntity player, UserCosmetics user) {
|
||||||
for (ServerPlayerEntity p : player.getServer().getPlayerManager().getPlayerList()) {
|
System.out.println("Syncing player: " + player.getName().getString() + " user: " + user.toString());
|
||||||
|
List<ServerPlayerEntity> original =
|
||||||
|
player.getServer().getPlayerManager().getPlayerList();
|
||||||
|
List<ServerPlayerEntity> list = new ArrayList<>(original);
|
||||||
|
if (!list.contains(player)) {list.add(player);}
|
||||||
|
System.out.println(
|
||||||
|
player.getServer().getPlayerManager().getPlayerList().size()
|
||||||
|
);
|
||||||
|
for (ServerPlayerEntity p : list) {
|
||||||
|
System.out.println("sending sync : " + player.getName().getString() + " to user: " + p.getName().getString());
|
||||||
PacketByteBuf buf = PacketByteBufs.create();
|
PacketByteBuf buf = PacketByteBufs.create();
|
||||||
|
|
||||||
// Write player UUID first
|
// Write player UUID first
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
|||||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||||
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent;
|
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent;
|
||||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
|
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
|
||||||
@@ -64,13 +65,13 @@ import net.minecraft.world.poi.PointOfInterestType;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static dev.tggamesyt.szar.ServerCosmetics.USERS;
|
||||||
|
import static dev.tggamesyt.szar.ServerCosmetics.sync;
|
||||||
|
|
||||||
public class Szar implements ModInitializer {
|
public class Szar implements ModInitializer {
|
||||||
public static final String MOD_ID = "szar";
|
public static final String MOD_ID = "szar";
|
||||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||||
@@ -286,6 +287,22 @@ public class Szar implements ModInitializer {
|
|||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
ServerCosmetics.init();
|
ServerCosmetics.init();
|
||||||
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
|
ServerPlayerEntity player = handler.getPlayer();
|
||||||
|
|
||||||
|
ServerCosmetics.UserCosmetics user = USERS.get(player.getUuid());
|
||||||
|
if (user != null) {
|
||||||
|
|
||||||
|
// AUTO SELECT FIRST CAPE IF NONE SELECTED
|
||||||
|
if (user.selectedCape == null && !user.ownedCapes.isEmpty()) {
|
||||||
|
user.selectedCape = user.ownedCapes.get(0);
|
||||||
|
} else {
|
||||||
|
user.selectedCape = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
sync(player, user);
|
||||||
|
}
|
||||||
|
});
|
||||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||||
SERVER = server;
|
SERVER = server;
|
||||||
});
|
});
|
||||||
@@ -1153,8 +1170,12 @@ public class Szar implements ModInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void givePregnantEffect(ServerPlayerEntity player, ServerPlayerEntity partner) {
|
private void givePregnantEffect(ServerPlayerEntity player, ServerPlayerEntity partner) {
|
||||||
player.addStatusEffect(new StatusEffectInstance(PREGNANT, 20 * 60 * 20, 0, false, false, true));
|
Random r = new Random();
|
||||||
pregnantPartners.put(player.getUuid(), partner.getUuid());
|
System.out.println(r.nextInt());
|
||||||
|
if (r.nextInt(10) == 6) {
|
||||||
|
player.addStatusEffect(new StatusEffectInstance(PREGNANT, 20 * 60 * 20, 0, false, false, true));
|
||||||
|
pregnantPartners.put(player.getUuid(), partner.getUuid());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user