mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-23 00:39:16 +00:00
fix compile
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ishland.c2me.opts.dfc.common.ast;
|
||||
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.AddNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.DivNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.MaxNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.MaxShortNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.MinNode;
|
||||
@@ -75,6 +76,7 @@ public class McToAst {
|
||||
case CUBE -> new CubeNode(toAst(f.input()));
|
||||
case HALF_NEGATIVE -> new NegMulNode(toAst(f.input()), 0.5);
|
||||
case QUARTER_NEGATIVE -> new NegMulNode(toAst(f.input()), 0.25);
|
||||
case INVERT -> new DivNode(new ConstantNode(1.0), toAst(f.input()));
|
||||
case SQUEEZE -> new SqueezeNode(toAst(f.input()));
|
||||
};
|
||||
case DensityFunctions.RangeChoice f -> new RangeChoiceNode(toAst(f.input()), f.minInclusive(), f.maxExclusive(), toAst(f.whenInRange()), toAst(f.whenOutOfRange()));
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ishland.c2me.opts.dfc.common.ast.binary;
|
||||
|
||||
import com.ishland.c2me.opts.dfc.common.ast.AstNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.EvalType;
|
||||
import com.ishland.c2me.opts.dfc.common.gen.BytecodeGen;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
public class DivNode extends AbstractBinaryNode {
|
||||
public DivNode(AstNode left, AstNode right) {
|
||||
super(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AstNode newInstance(AstNode left, AstNode right) {
|
||||
return new DivNode(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double evalSingle(int x, int y, int z, EvalType type) {
|
||||
return this.left.evalSingle(x, y, z, type) / this.right.evalSingle(x, y, z, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evalMulti(double[] res, int[] x, int[] y, int[] z, EvalType type) {
|
||||
double[] res1 = new double[res.length];
|
||||
this.left.evalMulti(res, x, y, z, type);
|
||||
this.right.evalMulti(res1, x, y, z, type);
|
||||
for (int i = 0; i < res1.length; i++) {
|
||||
res[i] /= res1[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doBytecodeGenSingle(BytecodeGen.Context context, InstructionAdapter m, BytecodeGen.Context.LocalVarConsumer localVarConsumer) {
|
||||
super.doBytecodeGenSingle(context, m, localVarConsumer);
|
||||
m.div(Type.DOUBLE_TYPE);
|
||||
m.areturn(Type.DOUBLE_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bytecodeGenMultiBody(InstructionAdapter m, int idx, int res1) {
|
||||
m.load(1, InstructionAdapter.OBJECT_TYPE);
|
||||
m.load(idx, Type.INT_TYPE);
|
||||
m.dup2();
|
||||
m.aload(Type.DOUBLE_TYPE);
|
||||
m.load(res1, InstructionAdapter.OBJECT_TYPE);
|
||||
m.load(idx, Type.INT_TYPE);
|
||||
m.aload(Type.DOUBLE_TYPE);
|
||||
m.div(Type.DOUBLE_TYPE);
|
||||
m.astore(Type.DOUBLE_TYPE);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bxteam.divinemc.command.subcommands;
|
||||
|
||||
import ca.spottedleaf.moonrise.common.time.TickData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -59,7 +60,7 @@ public final class MSPTCommand extends DivineSubCommandPermission {
|
||||
}
|
||||
|
||||
private void displayCompactStats(CommandSender sender, MinecraftServer server) {
|
||||
List<Component> serverTimes = eval(server.tickTimes5s.getTimes());
|
||||
List<Component> serverTimes = evalFromTickData(server.tickTimes5s, server.tickRateManager().nanosecondsPerTick());
|
||||
sender.sendMessage(Component.text("Server: ", GOLD)
|
||||
.append(joinComponents(serverTimes, SLASH)));
|
||||
|
||||
@@ -68,7 +69,7 @@ public final class MSPTCommand extends DivineSubCommandPermission {
|
||||
|
||||
for (int i = 0; i < worlds.size(); i++) {
|
||||
ServerLevel level = worlds.get(i);
|
||||
List<Component> worldTimes = eval(level.tickTimes5s.getTimes());
|
||||
List<Component> worldTimes = evalFromTickData(level.getServer().tickTimes5s, server.tickRateManager().nanosecondsPerTick());
|
||||
sender.sendMessage(Component.text(level.getWorld().getName() + ": ", GOLD)
|
||||
.append(joinComponents(worldTimes, SLASH)));
|
||||
if (i < worlds.size() - 1) {
|
||||
@@ -81,9 +82,10 @@ public final class MSPTCommand extends DivineSubCommandPermission {
|
||||
sender.sendMessage(Component.text("Server tick times ", GOLD)
|
||||
.append(Component.text("(avg/min/max)", YELLOW)));
|
||||
|
||||
sendTickLine(sender, " 5s: ", eval(server.tickTimes5s.getTimes()), GOLD, SLASH);
|
||||
sendTickLine(sender, " 10s: ", eval(server.tickTimes10s.getTimes()), GOLD, SLASH);
|
||||
sendTickLine(sender, " 60s: ", eval(server.tickTimes60s.getTimes()), GOLD, SLASH);
|
||||
long tickInterval = server.tickRateManager().nanosecondsPerTick();
|
||||
sendTickLine(sender, " 5s: ", evalFromTickData(server.tickTimes5s, tickInterval), GOLD, SLASH);
|
||||
sendTickLine(sender, " 10s: ", evalFromTickData(server.tickTimes10s, tickInterval), GOLD, SLASH);
|
||||
sendTickLine(sender, " 60s: ", evalFromTickData(server.tickTimes1m, tickInterval), GOLD, SLASH);
|
||||
}
|
||||
|
||||
private void displayWorldMSPT(CommandSender sender, MinecraftServer server) {
|
||||
@@ -133,6 +135,26 @@ public final class MSPTCommand extends DivineSubCommandPermission {
|
||||
return Arrays.asList(getColoredValue(avg), getColoredValue(min), getColoredValue(max));
|
||||
}
|
||||
|
||||
private static List<Component> evalFromTickData(ca.spottedleaf.moonrise.common.time.TickData tickData, long tickInterval) {
|
||||
TickData.TickReportData report = tickData.generateTickReport(null, System.nanoTime(), tickInterval);
|
||||
|
||||
if (report == null) {
|
||||
return Arrays.asList(
|
||||
Component.text("N/A", GRAY),
|
||||
Component.text("N/A", GRAY),
|
||||
Component.text("N/A", GRAY)
|
||||
);
|
||||
}
|
||||
|
||||
TickData.SegmentData segmentAll = report.timePerTickData().segmentAll();
|
||||
|
||||
double avg = segmentAll.average() * 1.0E-6;
|
||||
double min = segmentAll.least() * 1.0E-6;
|
||||
double max = segmentAll.greatest() * 1.0E-6;
|
||||
|
||||
return Arrays.asList(getColoredValue(avg), getColoredValue(min), getColoredValue(max));
|
||||
}
|
||||
|
||||
private static Component getColoredValue(double value) {
|
||||
NamedTextColor color = value >= 50 ? RED
|
||||
: value >= 40 ? YELLOW
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.bxteam.divinemc.config.annotations.Experimental;
|
||||
import org.bxteam.divinemc.async.pathfinding.PathfindTaskRejectPolicy;
|
||||
import org.bxteam.divinemc.region.EnumRegionFileExtension;
|
||||
import org.bxteam.divinemc.region.type.LinearRegionFile;
|
||||
import org.bxteam.divinemc.async.AsyncJoinHandler;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.simpleyaml.configuration.comments.CommentType;
|
||||
import org.simpleyaml.configuration.file.YamlFile;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class AppleSkinProtocol implements LeavesProtocol {
|
||||
|
||||
@ProtocolHandler.MinecraftRegister(onlyNamespace = true)
|
||||
public static void onPlayerSubscribed(@NotNull Context context, ResourceLocation id) {
|
||||
subscribedChannels.computeIfAbsent(context.profile().getId(), k -> new HashSet<>()).add(id.getPath());
|
||||
subscribedChannels.computeIfAbsent(context.profile().id(), k -> new HashSet<>()).add(id.getPath());
|
||||
}
|
||||
|
||||
@ProtocolHandler.Ticker
|
||||
|
||||
@@ -36,9 +36,8 @@ public enum CampfireProvider implements IServerExtensionProvider<ItemStack> {
|
||||
}
|
||||
stack = stack.copy();
|
||||
|
||||
CustomData customData = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
||||
.update(NbtOps.INSTANCE, COOKING_TIME_CODEC, campfire.cookingTime[i] - campfire.cookingProgress[i])
|
||||
.getOrThrow();
|
||||
int time = campfire.cookingTime[i] - campfire.cookingProgress[i];
|
||||
CustomData customData = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).update(tag -> tag.putInt("jade:cooking", time));
|
||||
stack.set(DataComponents.CUSTOM_DATA, customData);
|
||||
|
||||
list.add(stack);
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.ItemStorageProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider;
|
||||
|
||||
import static net.minecraft.world.level.block.CampfireBlock.FACING;
|
||||
|
||||
public enum ChiseledBookshelfProvider implements StreamServerDataProvider<BlockAccessor, ItemStack> {
|
||||
INSTANCE;
|
||||
|
||||
@@ -20,7 +22,7 @@ public enum ChiseledBookshelfProvider implements StreamServerDataProvider<BlockA
|
||||
|
||||
@Override
|
||||
public @Nullable ItemStack streamData(@NotNull BlockAccessor accessor) {
|
||||
int slot = ((ChiseledBookShelfBlock) accessor.getBlock()).getHitSlot(accessor.getHitResult(), accessor.getBlockState()).orElse(-1);
|
||||
int slot = ((ChiseledBookShelfBlock) accessor.getBlock()).getHitSlot(accessor.getHitResult(), accessor.getBlockState().getValue(FACING)).orElse(-1);
|
||||
if (slot == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
package org.leavesmc.leaves.protocol.jade.provider.entity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ComponentSerialization;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.Services;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.players.NameAndId;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityReference;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.OwnableEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.protocol.jade.JadeProtocol;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessor;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.util.CommonUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public enum AnimalOwnerProvider implements StreamServerDataProvider<EntityAccessor, String> {
|
||||
public enum AnimalOwnerProvider implements StreamServerDataProvider<EntityAccessor, Component> {
|
||||
INSTANCE;
|
||||
|
||||
private static final ResourceLocation MC_ANIMAL_OWNER = JadeProtocol.mc_id("animal_owner");
|
||||
@@ -32,17 +37,37 @@ public enum AnimalOwnerProvider implements StreamServerDataProvider<EntityAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public String streamData(@NotNull EntityAccessor accessor) {
|
||||
return CommonUtil.getLastKnownUsername(getOwnerUUID(accessor.getEntity()));
|
||||
public Component streamData(@NotNull EntityAccessor accessor) {
|
||||
ServerLevel level = accessor.getLevel();
|
||||
UUID uuid = getOwnerUUID(accessor.getEntity());
|
||||
Entity entity = level.getEntity(uuid);
|
||||
if (entity != null) {
|
||||
return entity.getName();
|
||||
}
|
||||
String name = lookupPlayerName(uuid, level.getServer().services());
|
||||
return name == null ? null : Component.literal(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String lookupPlayerName(@Nullable UUID uuid, Services services) {
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
String name = services.nameToIdCache().get(uuid).map(NameAndId::name).orElse(null);
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
GameProfile profile = services.profileResolver().fetchById(uuid).orElse(null);
|
||||
return profile == null ? null : profile.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull StreamCodec<RegistryFriendlyByteBuf, String> streamCodec() {
|
||||
return ByteBufCodecs.STRING_UTF8.cast();
|
||||
public @NotNull StreamCodec<RegistryFriendlyByteBuf, Component> streamCodec() {
|
||||
return ComponentSerialization.STREAM_CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return MC_ANIMAL_OWNER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
package org.leavesmc.leaves.protocol.jade.util;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.boss.EnderDragonPart;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.LeavesLogger;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.Accessor;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.IServerExtensionProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommonUtil {
|
||||
|
||||
@@ -42,16 +37,6 @@ public class CommonUtil {
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public static String getLastKnownUsername(@Nullable UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
Optional<GameProfile> optional = SkullBlockEntity.fetchGameProfile(String.valueOf(uuid)).getNow(Optional.empty());
|
||||
return optional.map(GameProfile::getName).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
public static <T> Map.Entry<ResourceLocation, List<ViewGroup<T>>> getServerExtensionData(
|
||||
Accessor<?> accessor,
|
||||
WrappedHierarchyLookup<IServerExtensionProvider<T>> lookup) {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CommunicationManager implements LeavesProtocol {
|
||||
final VersionHandshakeServer hi = new VersionHandshakeServer(newPlayer);
|
||||
playerMap.put(newPlayer, player);
|
||||
final GameProfile profile = player.getGameProfile();
|
||||
SyncmaticaProtocol.getPlayerIdentifierProvider().updateName(profile.getId(), profile.getName());
|
||||
SyncmaticaProtocol.getPlayerIdentifierProvider().updateName(profile.id(), profile.name());
|
||||
startExchangeUnchecked(hi);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class CommunicationManager implements LeavesProtocol {
|
||||
final UUID placementId = packetBuf.readUUID();
|
||||
final ServerPlacement placement = SyncmaticaProtocol.getSyncmaticManager().getPlacement(placementId);
|
||||
if (placement != null) {
|
||||
if (!getGameProfile(source).getId().equals(placement.getOwner().uuid)) {
|
||||
if (!getGameProfile(source).id().equals(placement.getOwner().uuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PlayerIdentifierProvider {
|
||||
}
|
||||
|
||||
public PlayerIdentifier createOrGet(final @NotNull GameProfile gameProfile) {
|
||||
return createOrGet(gameProfile.getId(), gameProfile.getName());
|
||||
return createOrGet(gameProfile.id(), gameProfile.name());
|
||||
}
|
||||
|
||||
public PlayerIdentifier createOrGet(final UUID uuid, final String playerName) {
|
||||
|
||||
Reference in New Issue
Block a user