Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Cleanup and fixes
Dieser Commit ist enthalten in:
Ursprung
521b9f3dce
Commit
5162d4516d
@ -346,7 +346,7 @@ public class CommandRegistry implements EventRegistrar {
|
|||||||
|
|
||||||
List<CommandOverloadData> data = new ArrayList<>();
|
List<CommandOverloadData> data = new ArrayList<>();
|
||||||
for (var node : commandTree.children()) {
|
for (var node : commandTree.children()) {
|
||||||
List<List<CommandParamData>> params = createParamData(node);
|
List<List<CommandParamData>> params = createParamData(session, node);
|
||||||
params.forEach(param -> data.add(new CommandOverloadData(false, param.toArray(CommandParamData[]::new))));
|
params.forEach(param -> data.add(new CommandOverloadData(false, param.toArray(CommandParamData[]::new))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +358,13 @@ public class CommandRegistry implements EventRegistrar {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<List<CommandParamData>> createParamData(CommandNode<GeyserCommandSource> node) {
|
private List<List<CommandParamData>> createParamData(GeyserSession session, CommandNode<GeyserCommandSource> node) {
|
||||||
|
var command = node.command();
|
||||||
|
if (command != null && !session.hasPermission(command.commandPermission().permissionString())) {
|
||||||
|
// Triggers with subcommands like Geyser dump, stop, etc.
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
CommandParamData data = new CommandParamData();
|
CommandParamData data = new CommandParamData();
|
||||||
var component = node.component();
|
var component = node.component();
|
||||||
data.setName(component.name());
|
data.setName(component.name());
|
||||||
@ -396,7 +402,7 @@ public class CommandRegistry implements EventRegistrar {
|
|||||||
// If a node has multiple children, this will need to be represented
|
// If a node has multiple children, this will need to be represented
|
||||||
// by creating a new list/branch for each and cloning this node down each line.
|
// by creating a new list/branch for each and cloning this node down each line.
|
||||||
for (var child : children) {
|
for (var child : children) {
|
||||||
collectiveData.addAll(createParamData(child));
|
collectiveData.addAll(createParamData(session, child));
|
||||||
}
|
}
|
||||||
collectiveData.forEach(list -> list.add(0, data));
|
collectiveData.forEach(list -> list.add(0, data));
|
||||||
return collectiveData;
|
return collectiveData;
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.inventory.recipe;
|
package org.geysermc.geyser.inventory.recipe;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,6 +36,5 @@ public interface GeyserRecipe {
|
|||||||
*/
|
*/
|
||||||
boolean isShaped();
|
boolean isShaped();
|
||||||
|
|
||||||
@Nullable
|
|
||||||
SlotDisplay result();
|
SlotDisplay result();
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.inventory.recipe;
|
package org.geysermc.geyser.inventory.recipe;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.ShapedCraftingRecipeDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.ShapedCraftingRecipeDisplay;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public record GeyserShapedRecipe(int width, int height, List<SlotDisplay> ingredients, @Nullable SlotDisplay result) implements GeyserRecipe {
|
public record GeyserShapedRecipe(int width, int height, List<SlotDisplay> ingredients, SlotDisplay result) implements GeyserRecipe {
|
||||||
|
|
||||||
public GeyserShapedRecipe(ShapedCraftingRecipeDisplay data) {
|
public GeyserShapedRecipe(ShapedCraftingRecipeDisplay data) {
|
||||||
this(data.width(), data.height(), data.ingredients(), data.result());
|
this(data.width(), data.height(), data.ingredients(), data.result());
|
||||||
|
@ -25,13 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.inventory.recipe;
|
package org.geysermc.geyser.inventory.recipe;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.ShapelessCraftingRecipeDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.ShapelessCraftingRecipeDisplay;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public record GeyserShapelessRecipe(List<SlotDisplay> ingredients, @Nullable SlotDisplay result) implements GeyserRecipe {
|
public record GeyserShapelessRecipe(List<SlotDisplay> ingredients, SlotDisplay result) implements GeyserRecipe {
|
||||||
|
|
||||||
public GeyserShapelessRecipe(ShapelessCraftingRecipeDisplay data) {
|
public GeyserShapelessRecipe(ShapelessCraftingRecipeDisplay data) {
|
||||||
this(data.ingredients(), data.result());
|
this(data.ingredients(), data.result());
|
||||||
|
@ -196,11 +196,10 @@ public final class BlockRegistryPopulator {
|
|||||||
GeyserBedrockBlock[] bedrockRuntimeMap = new GeyserBedrockBlock[blockStates.size()];
|
GeyserBedrockBlock[] bedrockRuntimeMap = new GeyserBedrockBlock[blockStates.size()];
|
||||||
for (int i = 0; i < blockStates.size(); i++) {
|
for (int i = 0; i < blockStates.size(); i++) {
|
||||||
NbtMap tag = blockStates.get(i);
|
NbtMap tag = blockStates.get(i);
|
||||||
if (blockStateOrderedMap.containsKey(tag)) {
|
GeyserBedrockBlock block = new GeyserBedrockBlock(i, tag);
|
||||||
|
if (blockStateOrderedMap.put(tag, block) != null) {
|
||||||
throw new AssertionError("Duplicate block states in Bedrock palette: " + tag);
|
throw new AssertionError("Duplicate block states in Bedrock palette: " + tag);
|
||||||
}
|
}
|
||||||
GeyserBedrockBlock block = new GeyserBedrockBlock(i, tag);
|
|
||||||
blockStateOrderedMap.put(tag, block);
|
|
||||||
bedrockRuntimeMap[i] = block;
|
bedrockRuntimeMap[i] = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,12 +229,12 @@ public final class BedrockPlayerAuthInputTranslator extends PacketTranslator<Pla
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (vehicle instanceof ClientVehicle) {
|
if (vehicle instanceof ClientVehicle) {
|
||||||
session.getPlayerEntity().setVehicleInput(packet.getAnalogMoveVector());
|
session.getPlayerEntity().setVehicleInput(packet.getMotion());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean sendMovement = false;
|
boolean sendMovement = false;
|
||||||
if (vehicle instanceof AbstractHorseEntity && !(vehicle instanceof LlamaEntity)) {
|
if (vehicle instanceof AbstractHorseEntity && !(vehicle instanceof LlamaEntity)) {
|
||||||
sendMovement = true;
|
sendMovement = !(vehicle instanceof ClientVehicle);
|
||||||
} else if (vehicle instanceof BoatEntity) {
|
} else if (vehicle instanceof BoatEntity) {
|
||||||
if (vehicle.getPassengers().size() == 1) {
|
if (vehicle.getPassengers().size() == 1) {
|
||||||
// The player is the only rider
|
// The player is the only rider
|
||||||
@ -261,16 +261,18 @@ public final class BedrockPlayerAuthInputTranslator extends PacketTranslator<Pla
|
|||||||
if (wasJumping && !holdingJump) {
|
if (wasJumping && !holdingJump) {
|
||||||
// Jump released
|
// Jump released
|
||||||
// Yes, I'm fairly certain that entity ID is correct.
|
// Yes, I'm fairly certain that entity ID is correct.
|
||||||
|
int finalVehicleJumpStrength = GenericMath.floor(session.getInputCache().getJumpScale() * 100f);
|
||||||
session.sendDownstreamGamePacket(new ServerboundPlayerCommandPacket(session.getPlayerEntity().getEntityId(),
|
session.sendDownstreamGamePacket(new ServerboundPlayerCommandPacket(session.getPlayerEntity().getEntityId(),
|
||||||
PlayerState.START_HORSE_JUMP, GenericMath.floor(session.getInputCache().getJumpScale() * 100f)));
|
PlayerState.START_HORSE_JUMP, finalVehicleJumpStrength));
|
||||||
session.getInputCache().setJumpingTicks(-10);
|
session.getInputCache().setJumpingTicks(-10);
|
||||||
|
session.getPlayerEntity().setVehicleJumpStrength(finalVehicleJumpStrength);
|
||||||
} else if (!wasJumping && holdingJump) {
|
} else if (!wasJumping && holdingJump) {
|
||||||
session.getInputCache().setJumpingTicks(0);
|
session.getInputCache().setJumpingTicks(0);
|
||||||
session.getInputCache().setJumpScale(0);
|
session.getInputCache().setJumpScale(0);
|
||||||
} else if (holdingJump) {
|
} else if (holdingJump) {
|
||||||
session.getInputCache().setJumpingTicks(++currentJumpingTicks);
|
session.getInputCache().setJumpingTicks(++currentJumpingTicks);
|
||||||
if (currentJumpingTicks < 10) {
|
if (currentJumpingTicks < 10) {
|
||||||
session.getInputCache().setJumpScale(session.getInputCache().getJumpScale() * 0.1F);
|
session.getInputCache().setJumpScale(session.getInputCache().getJumpingTicks() * 0.1F);
|
||||||
} else {
|
} else {
|
||||||
session.getInputCache().setJumpScale(0.8f + 2.0f / (currentJumpingTicks - 9) * 0.1f);
|
session.getInputCache().setJumpScale(0.8f + 2.0f / (currentJumpingTicks - 9) * 0.1f);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren