mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-02 17:08:00 +01:00
Merge branch '1.20.2' into 1.20.4
This commit is contained in:
commit
a420c9ec38
19 changed files with 107 additions and 28 deletions
|
@ -15,9 +15,11 @@ public class Config extends com.minelittlepony.common.util.settings.Config {
|
||||||
.addComment("whilst any ones left off are not permitted")
|
.addComment("whilst any ones left off are not permitted")
|
||||||
.addComment("An empty list disables whitelisting entirely.");
|
.addComment("An empty list disables whitelisting entirely.");
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public final Setting<Set<String>> wantItNeedItEntityExcludelist = value("server", "wantItNeedItEntityExcludelist", (Set<String>)new HashSet<>(Set.of("minecraft:creeper")))
|
public final Setting<Set<String>> wantItNeedItEntityExcludelist = value("server", "wantItNeedItEntityExcludelist", (Set<String>)new HashSet<>(Set.of("minecraft:creeper")))
|
||||||
.addComment("A list of entity types that are immune to the want it need it spell's effects");
|
.addComment("A list of entity types that are immune to the want it need it spell's effects");
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public final Setting<Set<String>> dimensionsWithoutAtmosphere = value("server", "dimensionsWithoutAtmosphere", (Set<String>)new HashSet<String>())
|
public final Setting<Set<String>> dimensionsWithoutAtmosphere = value("server", "dimensionsWithoutAtmosphere", (Set<String>)new HashSet<String>())
|
||||||
.addComment("A list of dimensions ids that do not have an atmosphere, and thus shouldn't allow pegasi to fly.");
|
.addComment("A list of dimensions ids that do not have an atmosphere, and thus shouldn't allow pegasi to fly.");
|
||||||
|
|
||||||
|
@ -66,4 +68,8 @@ public class Config extends com.minelittlepony.common.util.settings.Config {
|
||||||
.registerTypeAdapter(Race.class, RegistryTypeAdapter.of(Race.REGISTRY))
|
.registerTypeAdapter(Race.class, RegistryTypeAdapter.of(Race.REGISTRY))
|
||||||
), GamePaths.getConfigDirectory().resolve("unicopia.json"));
|
), GamePaths.getConfigDirectory().resolve("unicopia.json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SyncedConfig toSynced() {
|
||||||
|
return new SyncedConfig(wantItNeedItEntityExcludelist.get(), dimensionsWithoutAtmosphere.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public interface EquineContext {
|
||||||
|
|
||||||
static EquineContext of(ShapeContext context) {
|
static EquineContext of(ShapeContext context) {
|
||||||
if (context == ShapeContext.absent()) {
|
if (context == ShapeContext.absent()) {
|
||||||
return InteractionManager.getInstance().getClientPony().map(EquineContext.class::cast).orElse(ABSENT);
|
return InteractionManager.getInstance().getEquineContext();
|
||||||
}
|
}
|
||||||
EquineContext result = context instanceof Container c ? c.get() : ABSENT;
|
EquineContext result = context instanceof Container c ? c.get() : ABSENT;
|
||||||
return result == null ? ABSENT : result;
|
return result == null ? ABSENT : result;
|
||||||
|
|
|
@ -34,6 +34,11 @@ public class InteractionManager {
|
||||||
|
|
||||||
private static InteractionManager INSTANCE = new InteractionManager();
|
private static InteractionManager INSTANCE = new InteractionManager();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private SyncedConfig config;
|
||||||
|
|
||||||
|
private EquineContext equineContext = EquineContext.ABSENT;
|
||||||
|
|
||||||
public static InteractionManager getInstance() {
|
public static InteractionManager getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +108,14 @@ public class InteractionManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEquineContext(EquineContext context) {
|
||||||
|
equineContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EquineContext getEquineContext() {
|
||||||
|
return getClientPony().map(EquineContext.class::cast).orElse(equineContext);
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<Pony> getClientPony() {
|
public Optional<Pony> getClientPony() {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -110,4 +123,15 @@ public class InteractionManager {
|
||||||
public final Race getClientSpecies() {
|
public final Race getClientSpecies() {
|
||||||
return getClientPony().map(Pony::getSpecies).orElse(Race.HUMAN);
|
return getClientPony().map(Pony::getSpecies).orElse(Race.HUMAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSyncedConfig(SyncedConfig config) {
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SyncedConfig getSyncedConfig() {
|
||||||
|
if (config == null) {
|
||||||
|
config = Unicopia.getConfig().toSynced();
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.minelittlepony.unicopia;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public record SyncedConfig (
|
||||||
|
Set<String> wantItNeedItExcludeList,
|
||||||
|
Set<String> dimensionsWithoutAtmosphere) {
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
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 com.minelittlepony.unicopia.ability.Abilities;
|
import com.minelittlepony.unicopia.ability.Abilities;
|
||||||
import com.minelittlepony.unicopia.ability.data.tree.TreeTypeLoader;
|
import com.minelittlepony.unicopia.ability.data.tree.TreeTypeLoader;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||||
|
|
|
@ -91,12 +91,6 @@ public class JarBlock extends TransparentBlock implements Waterloggable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@Override
|
|
||||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
|
||||||
super.onStateReplaced(state, world, pos, newState, moved);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
|
public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
|
||||||
if (asItem() instanceof WeatherJarItem jar) {
|
if (asItem() instanceof WeatherJarItem jar) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class CloudBedBlock extends FancyBedBlock implements CloudLike {
|
||||||
private final CloudBlock baseBlock;
|
private final CloudBlock baseBlock;
|
||||||
|
|
||||||
public CloudBedBlock(String base, BlockState baseState, Settings settings) {
|
public CloudBedBlock(String base, BlockState baseState, Settings settings) {
|
||||||
super(base, settings);
|
super(base, settings.dynamicBounds());
|
||||||
this.baseState = baseState;
|
this.baseState = baseState;
|
||||||
this.baseBlock = (CloudBlock)baseState.getBlock();
|
this.baseBlock = (CloudBlock)baseState.getBlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class CloudBlock extends Block implements CloudLike {
|
||||||
protected final boolean meltable;
|
protected final boolean meltable;
|
||||||
|
|
||||||
public CloudBlock(boolean meltable, Settings settings) {
|
public CloudBlock(boolean meltable, Settings settings) {
|
||||||
super((meltable ? settings.ticksRandomly() : settings).nonOpaque());
|
super((meltable ? settings.ticksRandomly() : settings).nonOpaque().dynamicBounds());
|
||||||
this.meltable = meltable;
|
this.meltable = meltable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class CloudChestBlock extends ChestBlock implements CloudLike {
|
||||||
};
|
};
|
||||||
|
|
||||||
public CloudChestBlock(BlockState baseState, Settings settings) {
|
public CloudChestBlock(BlockState baseState, Settings settings) {
|
||||||
super(settings, () -> UBlockEntities.CLOUD_CHEST);
|
super(settings.dynamicBounds(), () -> UBlockEntities.CLOUD_CHEST);
|
||||||
this.baseState = baseState;
|
this.baseState = baseState;
|
||||||
this.baseBlock = (CloudBlock)baseState.getBlock();
|
this.baseBlock = (CloudBlock)baseState.getBlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class CloudDoorBlock extends DoorBlock implements CloudLike {
|
||||||
private final CloudBlock baseBlock;
|
private final CloudBlock baseBlock;
|
||||||
|
|
||||||
public CloudDoorBlock(BlockState baseState, BlockSetType blockSet, Settings settings) {
|
public CloudDoorBlock(BlockState baseState, BlockSetType blockSet, Settings settings) {
|
||||||
super(blockSet, settings);
|
super(blockSet, settings.dynamicBounds());
|
||||||
this.baseState = baseState;
|
this.baseState = baseState;
|
||||||
this.baseBlock = (CloudBlock)baseState.getBlock();
|
this.baseBlock = (CloudBlock)baseState.getBlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class CloudStairsBlock extends StairsBlock implements CloudLike {
|
||||||
private final CloudBlock baseBlock;
|
private final CloudBlock baseBlock;
|
||||||
|
|
||||||
public CloudStairsBlock(BlockState baseState, Settings settings) {
|
public CloudStairsBlock(BlockState baseState, Settings settings) {
|
||||||
super(baseState, settings);
|
super(baseState, settings.dynamicBounds());
|
||||||
this.baseBlock = (CloudBlock)baseState.getBlock();
|
this.baseBlock = (CloudBlock)baseState.getBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,12 @@ import java.util.HashSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import com.minelittlepony.common.util.settings.Config;
|
|
||||||
import com.minelittlepony.common.util.settings.Setting;
|
import com.minelittlepony.common.util.settings.Setting;
|
||||||
|
import com.minelittlepony.unicopia.Config;
|
||||||
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
import com.minelittlepony.unicopia.network.Channel;
|
||||||
|
import com.minelittlepony.unicopia.network.MsgConfigurationChange;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||||
|
@ -36,10 +39,10 @@ public class ConfigCommand {
|
||||||
return CommandManager.literal(configName)
|
return CommandManager.literal(configName)
|
||||||
.then(CommandManager.literal("clear").executes(source -> {
|
.then(CommandManager.literal("clear").executes(source -> {
|
||||||
source.getSource().sendFeedback(() -> Text.translatable("command.unicopia.config.clear", configName), true);
|
source.getSource().sendFeedback(() -> Text.translatable("command.unicopia.config.clear", configName), true);
|
||||||
return changeProperty(configName, values -> new HashSet<>());
|
return changeProperty(source.getSource(), configName, values -> new HashSet<>());
|
||||||
}))
|
}))
|
||||||
.then(CommandManager.literal("add").then(
|
.then(CommandManager.literal("add").then(
|
||||||
CommandManager.argument("id", IdentifierArgumentType.identifier()).suggests(suggestions).executes(source -> ConfigCommand.<Set<String>>changeProperty(configName, values -> {
|
CommandManager.argument("id", IdentifierArgumentType.identifier()).suggests(suggestions).executes(source -> ConfigCommand.<Set<String>>changeProperty(source.getSource(), configName, values -> {
|
||||||
String value = IdentifierArgumentType.getIdentifier(source, "id").toString();
|
String value = IdentifierArgumentType.getIdentifier(source, "id").toString();
|
||||||
source.getSource().sendFeedback(() -> Text.translatable("command.unicopia.config.add", value, configName), true);
|
source.getSource().sendFeedback(() -> Text.translatable("command.unicopia.config.add", value, configName), true);
|
||||||
values.add(value);
|
values.add(value);
|
||||||
|
@ -52,7 +55,7 @@ public class ConfigCommand {
|
||||||
.map(Identifier::tryParse)
|
.map(Identifier::tryParse)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.toList(), builder);
|
.toList(), builder);
|
||||||
}).executes(source -> ConfigCommand.<Set<String>>changeProperty(configName, values -> {
|
}).executes(source -> ConfigCommand.<Set<String>>changeProperty(source.getSource(), configName, values -> {
|
||||||
String value = IdentifierArgumentType.getIdentifier(source, "id").toString();
|
String value = IdentifierArgumentType.getIdentifier(source, "id").toString();
|
||||||
source.getSource().sendFeedback(() -> Text.translatable("command.unicopia.config.remove", value, configName), true);
|
source.getSource().sendFeedback(() -> Text.translatable("command.unicopia.config.remove", value, configName), true);
|
||||||
values.remove(value);
|
values.remove(value);
|
||||||
|
@ -73,11 +76,18 @@ public class ConfigCommand {
|
||||||
return (context, builder) -> CommandSource.suggestIdentifiers(wrapper.streamKeys().map(RegistryKey::getValue), builder);
|
return (context, builder) -> CommandSource.suggestIdentifiers(wrapper.streamKeys().map(RegistryKey::getValue), builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> int changeProperty(String configName, Function<T, T> changer) {
|
private static <T> int changeProperty(ServerCommandSource source, String configName, Function<T, T> changer) {
|
||||||
Config config = Unicopia.getConfig();
|
Config config = Unicopia.getConfig();
|
||||||
Setting<T> setting = config.getCategory("server").get(configName);
|
Setting<T> setting = config.getCategory("server").get(configName);
|
||||||
setting.set(changer.apply(setting.get()));
|
setting.set(changer.apply(setting.get()));
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
|
MsgConfigurationChange msg = new MsgConfigurationChange(config.toSynced());
|
||||||
|
InteractionManager.getInstance().setSyncedConfig(msg.config());
|
||||||
|
source.getServer().getPlayerManager().getPlayerList().forEach(recipient -> {
|
||||||
|
Channel.CONFIGURATION_CHANGE.sendToPlayer(msg, recipient);
|
||||||
|
});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Affinity;
|
import com.minelittlepony.unicopia.Affinity;
|
||||||
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
|
||||||
import com.minelittlepony.unicopia.WeaklyOwned;
|
import com.minelittlepony.unicopia.WeaklyOwned;
|
||||||
import com.minelittlepony.unicopia.ability.magic.*;
|
import com.minelittlepony.unicopia.ability.magic.*;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Spell;
|
import com.minelittlepony.unicopia.ability.magic.spell.Spell;
|
||||||
|
@ -147,7 +147,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned.Mutabl
|
||||||
|
|
||||||
DynamicTargetGoal targetter = new DynamicTargetGoal((MobEntity)entity);
|
DynamicTargetGoal targetter = new DynamicTargetGoal((MobEntity)entity);
|
||||||
targets.add(1, targetter);
|
targets.add(1, targetter);
|
||||||
if (!Unicopia.getConfig().wantItNeedItEntityExcludelist.get().contains(EntityType.getId(entity.getType()).toString())) {
|
if (!InteractionManager.getInstance().getSyncedConfig().wantItNeedItExcludeList().contains(EntityType.getId(entity.getType()).toString())) {
|
||||||
goals.add(1, new WantItTakeItGoal(this, targetter));
|
goals.add(1, new WantItTakeItGoal(this, targetter));
|
||||||
}
|
}
|
||||||
if (entity.getType().getSpawnGroup() == SpawnGroup.MONSTER) {
|
if (entity.getType().getSpawnGroup() == SpawnGroup.MONSTER) {
|
||||||
|
|
|
@ -199,7 +199,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
DimensionType dimension = entity.getWorld().getDimension();
|
DimensionType dimension = entity.getWorld().getDimension();
|
||||||
|
|
||||||
if ((RegistryUtils.isIn(entity.getWorld(), dimension, RegistryKeys.DIMENSION_TYPE, UTags.DimensionTypes.HAS_NO_ATMOSPHERE)
|
if ((RegistryUtils.isIn(entity.getWorld(), dimension, RegistryKeys.DIMENSION_TYPE, UTags.DimensionTypes.HAS_NO_ATMOSPHERE)
|
||||||
|| Unicopia.getConfig().dimensionsWithoutAtmosphere.get().contains(RegistryUtils.getId(entity.getWorld(), dimension, RegistryKeys.DIMENSION_TYPE).toString()))
|
|| InteractionManager.getInstance().getSyncedConfig().dimensionsWithoutAtmosphere().contains(RegistryUtils.getId(entity.getWorld(), dimension, RegistryKeys.DIMENSION_TYPE).toString()))
|
||||||
&& !OxygenApi.API.get().hasOxygen(entity.getWorld(), entity.getBlockPos())) {
|
&& !OxygenApi.API.get().hasOxygen(entity.getWorld(), entity.getBlockPos())) {
|
||||||
return FlightType.NONE;
|
return FlightType.NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.item;
|
package com.minelittlepony.unicopia.item;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.block.UBlocks;
|
|
||||||
import com.minelittlepony.unicopia.entity.IItemEntity;
|
import com.minelittlepony.unicopia.entity.IItemEntity;
|
||||||
import com.minelittlepony.unicopia.entity.ItemImpl;
|
import com.minelittlepony.unicopia.entity.ItemImpl;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.LightningEntity;
|
import net.minecraft.entity.LightningEntity;
|
||||||
|
@ -24,8 +21,6 @@ public class EmptyJarItem extends BlockItem implements ItemImpl.GroundTickCallba
|
||||||
public ActionResult onGroundTick(IItemEntity item) {
|
public ActionResult onGroundTick(IItemEntity item) {
|
||||||
ItemEntity entity = item.get().asEntity();
|
ItemEntity entity = item.get().asEntity();
|
||||||
|
|
||||||
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), UBlocks.CLOUD_JAR, UBlocks.STORM_JAR, UBlocks.LIGHTNING_JAR, UBlocks.ZAP_JAR);
|
|
||||||
|
|
||||||
entity.setInvulnerable(true);
|
entity.setInvulnerable(true);
|
||||||
|
|
||||||
if (!entity.getWorld().isClient
|
if (!entity.getWorld().isClient
|
||||||
|
|
|
@ -5,7 +5,10 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.EquineContext;
|
||||||
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -34,4 +37,13 @@ abstract class MixinPlayerManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "respawnPlayer", at = @At("HEAD"))
|
||||||
|
private void beforeRespawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> info) {
|
||||||
|
InteractionManager.getInstance().setEquineContext(EquineContext.of(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "respawnPlayer", at = @At("RETURN"))
|
||||||
|
private void afterRespawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> info) {
|
||||||
|
InteractionManager.getInstance().setEquineContext(EquineContext.ABSENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ public interface Channel {
|
||||||
S2CPacketType<MsgOtherPlayerCapabilities> SERVER_OTHER_PLAYER_CAPABILITIES = SimpleNetworking.serverToClient(Unicopia.id("other_player_capabilities"), MsgOtherPlayerCapabilities::new);
|
S2CPacketType<MsgOtherPlayerCapabilities> SERVER_OTHER_PLAYER_CAPABILITIES = SimpleNetworking.serverToClient(Unicopia.id("other_player_capabilities"), MsgOtherPlayerCapabilities::new);
|
||||||
S2CPacketType<MsgPlayerAnimationChange> SERVER_PLAYER_ANIMATION_CHANGE = SimpleNetworking.serverToClient(Unicopia.id("other_player_animation_change"), MsgPlayerAnimationChange::new);
|
S2CPacketType<MsgPlayerAnimationChange> SERVER_PLAYER_ANIMATION_CHANGE = SimpleNetworking.serverToClient(Unicopia.id("other_player_animation_change"), MsgPlayerAnimationChange::new);
|
||||||
S2CPacketType<MsgSkyAngle> SERVER_SKY_ANGLE = SimpleNetworking.serverToClient(Unicopia.id("sky_angle"), MsgSkyAngle::new);
|
S2CPacketType<MsgSkyAngle> SERVER_SKY_ANGLE = SimpleNetworking.serverToClient(Unicopia.id("sky_angle"), MsgSkyAngle::new);
|
||||||
|
S2CPacketType<MsgConfigurationChange> CONFIGURATION_CHANGE = SimpleNetworking.serverToClient(Unicopia.id("config"), MsgConfigurationChange::new);
|
||||||
S2CPacketType<MsgZapAppleStage> SERVER_ZAP_STAGE = SimpleNetworking.serverToClient(Unicopia.id("zap_stage"), MsgZapAppleStage::new);
|
S2CPacketType<MsgZapAppleStage> SERVER_ZAP_STAGE = SimpleNetworking.serverToClient(Unicopia.id("zap_stage"), MsgZapAppleStage::new);
|
||||||
|
|
||||||
static void bootstrap() {
|
static void bootstrap() {
|
||||||
|
@ -53,8 +54,8 @@ public interface Channel {
|
||||||
}
|
}
|
||||||
sender.sendPacket(SERVER_RESOURCES.id(), new MsgServerResources().toBuffer());
|
sender.sendPacket(SERVER_RESOURCES.id(), new MsgServerResources().toBuffer());
|
||||||
sender.sendPacket(SERVER_SKY_ANGLE.id(), new MsgSkyAngle(UnicopiaWorldProperties.forWorld(handler.getPlayer().getServerWorld()).getTangentalSkyAngle()).toBuffer());
|
sender.sendPacket(SERVER_SKY_ANGLE.id(), new MsgSkyAngle(UnicopiaWorldProperties.forWorld(handler.getPlayer().getServerWorld()).getTangentalSkyAngle()).toBuffer());
|
||||||
ZapAppleStageStore store = ZapAppleStageStore.get(handler.player.getServerWorld());
|
sender.sendPacket(CONFIGURATION_CHANGE.id(), new MsgConfigurationChange(InteractionManager.getInstance().getSyncedConfig()).toBuffer());
|
||||||
sender.sendPacket(SERVER_ZAP_STAGE.id(), new MsgZapAppleStage(store.getStage()).toBuffer());
|
sender.sendPacket(SERVER_ZAP_STAGE.id(), new MsgZapAppleStage(ZapAppleStageStore.get(handler.player.getServerWorld()).getStage()).toBuffer());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.minelittlepony.unicopia.network;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.SyncedConfig;
|
||||||
|
import com.sollace.fabwork.api.packets.Packet;
|
||||||
|
|
||||||
|
import net.minecraft.network.PacketByteBuf;
|
||||||
|
|
||||||
|
public record MsgConfigurationChange(SyncedConfig config) implements Packet {
|
||||||
|
public MsgConfigurationChange(PacketByteBuf buffer) {
|
||||||
|
this(new SyncedConfig(
|
||||||
|
buffer.readCollection(HashSet::new, PacketByteBuf::readString),
|
||||||
|
buffer.readCollection(HashSet::new, PacketByteBuf::readString)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBuffer(PacketByteBuf buffer) {
|
||||||
|
buffer.writeCollection(config.wantItNeedItExcludeList(), PacketByteBuf::writeString);
|
||||||
|
buffer.writeCollection(config.dimensionsWithoutAtmosphere(), PacketByteBuf::writeString);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.network.handler;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.ability.data.Rot;
|
import com.minelittlepony.unicopia.ability.data.Rot;
|
||||||
import com.minelittlepony.unicopia.ability.data.tree.TreeTypes;
|
import com.minelittlepony.unicopia.ability.data.tree.TreeTypes;
|
||||||
|
@ -35,6 +36,7 @@ public class ClientNetworkHandlerImpl {
|
||||||
Channel.SERVER_ZAP_STAGE.receiver().addPersistentListener(this::handleZapStage);
|
Channel.SERVER_ZAP_STAGE.receiver().addPersistentListener(this::handleZapStage);
|
||||||
Channel.SERVER_PLAYER_ANIMATION_CHANGE.receiver().addPersistentListener(this::handlePlayerAnimation);
|
Channel.SERVER_PLAYER_ANIMATION_CHANGE.receiver().addPersistentListener(this::handlePlayerAnimation);
|
||||||
Channel.SERVER_REQUEST_PLAYER_LOOK.receiver().addPersistentListener(this::handleCasterLookRequest);
|
Channel.SERVER_REQUEST_PLAYER_LOOK.receiver().addPersistentListener(this::handleCasterLookRequest);
|
||||||
|
Channel.CONFIGURATION_CHANGE.receiver().addPersistentListener(this::handleConfigurationChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleTribeScreen(PlayerEntity sender, MsgTribeSelect packet) {
|
private void handleTribeScreen(PlayerEntity sender, MsgTribeSelect packet) {
|
||||||
|
@ -93,4 +95,8 @@ public class ClientNetworkHandlerImpl {
|
||||||
|
|
||||||
Channel.CLIENT_CASTER_LOOK.sendToServer(new Reply(packet.spellId(), Rot.of(player)));
|
Channel.CLIENT_CASTER_LOOK.sendToServer(new Reply(packet.spellId(), Rot.of(player)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleConfigurationChange(PlayerEntity sender, MsgConfigurationChange packet) {
|
||||||
|
InteractionManager.getInstance().setSyncedConfig(packet.config());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue