Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 08:10:11 +01:00
Damage will now show again.
Dieser Commit ist enthalten in:
Ursprung
777c69a21e
Commit
2436b2b1be
29
core/src/main/java/org/geysermc/geyser/level/DamageType.java
Normale Datei
29
core/src/main/java/org/geysermc/geyser/level/DamageType.java
Normale Datei
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.geyser.level;
|
||||||
|
|
||||||
|
public class DamageType {
|
||||||
|
}
|
@ -116,6 +116,7 @@ import org.geysermc.geyser.inventory.Inventory;
|
|||||||
import org.geysermc.geyser.inventory.PlayerInventory;
|
import org.geysermc.geyser.inventory.PlayerInventory;
|
||||||
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
||||||
import org.geysermc.geyser.inventory.recipe.GeyserStonecutterData;
|
import org.geysermc.geyser.inventory.recipe.GeyserStonecutterData;
|
||||||
|
import org.geysermc.geyser.level.DamageType;
|
||||||
import org.geysermc.geyser.level.JavaDimension;
|
import org.geysermc.geyser.level.JavaDimension;
|
||||||
import org.geysermc.geyser.level.WorldManager;
|
import org.geysermc.geyser.level.WorldManager;
|
||||||
import org.geysermc.geyser.level.physics.CollisionManager;
|
import org.geysermc.geyser.level.physics.CollisionManager;
|
||||||
@ -345,6 +346,8 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
|
|
||||||
private final Int2ObjectMap<TextDecoration> chatTypes = new Int2ObjectOpenHashMap<>(7);
|
private final Int2ObjectMap<TextDecoration> chatTypes = new Int2ObjectOpenHashMap<>(7);
|
||||||
|
|
||||||
|
private final Int2ObjectMap<DamageType> damageTypes = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private int breakingBlock;
|
private int breakingBlock;
|
||||||
|
|
||||||
@ -1012,7 +1015,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
// Server is offline, probably
|
// Server is offline, probably
|
||||||
disconnectMessage = GeyserLocale.getPlayerLocaleString("geyser.network.remote.server_offline", locale());
|
disconnectMessage = GeyserLocale.getPlayerLocaleString("geyser.network.remote.server_offline", locale());
|
||||||
} else {
|
} else {
|
||||||
disconnectMessage = MessageTranslator.convertMessageLenient(event.getReason());
|
disconnectMessage = MessageTranslator.convertMessage(event.getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downstream instanceof LocalSession) {
|
if (downstream instanceof LocalSession) {
|
||||||
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.translator.protocol.java;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
||||||
|
import com.github.steveice10.opennbt.SNBTIO;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||||
import com.nukkitx.protocol.bedrock.data.GameRuleData;
|
import com.nukkitx.protocol.bedrock.data.GameRuleData;
|
||||||
@ -38,6 +39,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|||||||
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
|
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
import org.geysermc.geyser.api.network.AuthType;
|
||||||
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
|
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
|
||||||
|
import org.geysermc.geyser.level.DamageType;
|
||||||
import org.geysermc.geyser.level.JavaDimension;
|
import org.geysermc.geyser.level.JavaDimension;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.text.TextDecoration;
|
import org.geysermc.geyser.text.TextDecoration;
|
||||||
@ -49,6 +51,7 @@ import org.geysermc.geyser.util.DimensionUtils;
|
|||||||
import org.geysermc.geyser.util.JavaCodecUtil;
|
import org.geysermc.geyser.util.JavaCodecUtil;
|
||||||
import org.geysermc.geyser.util.PluginMessageUtils;
|
import org.geysermc.geyser.util.PluginMessageUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Translator(packet = ClientboundLoginPacket.class)
|
@Translator(packet = ClientboundLoginPacket.class)
|
||||||
@ -64,6 +67,12 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
|
|
||||||
JavaDimension.load(packet.getRegistry(), dimensions);
|
JavaDimension.load(packet.getRegistry(), dimensions);
|
||||||
|
|
||||||
|
try {
|
||||||
|
SNBTIO.writeTag(System.out, packet.getRegistry().get("minecraft:damage_type"), true);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
Int2ObjectMap<TextDecoration> chatTypes = session.getChatTypes();
|
Int2ObjectMap<TextDecoration> chatTypes = session.getChatTypes();
|
||||||
chatTypes.clear();
|
chatTypes.clear();
|
||||||
for (CompoundTag tag : JavaCodecUtil.iterateAsTag(packet.getRegistry().get("minecraft:chat_type"))) {
|
for (CompoundTag tag : JavaCodecUtil.iterateAsTag(packet.getRegistry().get("minecraft:chat_type"))) {
|
||||||
@ -78,6 +87,13 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
chatTypes.put(id, textDecoration);
|
chatTypes.put(id, textDecoration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Int2ObjectMap<DamageType> damageTypes = session.getDamageTypes();
|
||||||
|
damageTypes.clear();
|
||||||
|
for (CompoundTag tag : JavaCodecUtil.iterateAsTag(packet.getRegistry().get("minecraft:damage_type"))) {
|
||||||
|
int id = ((IntTag) tag.get("id")).getValue();
|
||||||
|
CompoundTag element = tag.get("element");
|
||||||
|
}
|
||||||
|
|
||||||
// If the player is already initialized and a join game packet is sent, they
|
// If the player is already initialized and a join game packet is sent, they
|
||||||
// are swapping servers
|
// are swapping servers
|
||||||
if (session.isSpawned()) {
|
if (session.isSpawned()) {
|
||||||
|
@ -83,15 +83,6 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
|
|||||||
session.sendAdventureSettings();
|
session.sendAdventureSettings();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// EntityEventType.HURT sends extra data depending on the type of damage. However this appears to have no visual changes
|
|
||||||
case LIVING_BURN:
|
|
||||||
case LIVING_DROWN:
|
|
||||||
case LIVING_HURT:
|
|
||||||
case LIVING_HURT_SWEET_BERRY_BUSH:
|
|
||||||
case LIVING_HURT_THORNS:
|
|
||||||
case LIVING_FREEZE:
|
|
||||||
entityEventPacket.setType(EntityEventType.HURT);
|
|
||||||
break;
|
|
||||||
case LIVING_DEATH:
|
case LIVING_DEATH:
|
||||||
entityEventPacket.setType(EntityEventType.DEATH);
|
entityEventPacket.setType(EntityEventType.DEATH);
|
||||||
if (entity.getDefinition() == EntityDefinitions.EGG) {
|
if (entity.getDefinition() == EntityDefinitions.EGG) {
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.geyser.translator.protocol.java.entity.spawn;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundDamageEventPacket;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||||
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
|
import org.geysermc.geyser.level.DamageType;
|
||||||
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
|
|
||||||
|
@Translator(packet = ClientboundDamageEventPacket.class)
|
||||||
|
public class JavaDamageEventTranslator extends PacketTranslator<ClientboundDamageEventPacket> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void translate(GeyserSession session, ClientboundDamageEventPacket packet) {
|
||||||
|
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||||
|
if (entity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityEventPacket entityEventPacket = new EntityEventPacket();
|
||||||
|
entityEventPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
|
entityEventPacket.setType(EntityEventType.HURT);
|
||||||
|
DamageType damageType = session.getDamageTypes().get(packet.getSourceTypeId());
|
||||||
|
|
||||||
|
session.sendUpstreamPacket(entityEventPacket);
|
||||||
|
}
|
||||||
|
}
|
@ -57,10 +57,10 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
|
|||||||
} else if (packet.getValue() instanceof EndGatewayValue) {
|
} else if (packet.getValue() instanceof EndGatewayValue) {
|
||||||
blockEventPacket.setEventType(1);
|
blockEventPacket.setEventType(1);
|
||||||
session.sendUpstreamPacket(blockEventPacket);
|
session.sendUpstreamPacket(blockEventPacket);
|
||||||
// } else if (packet.getValue() instanceof NoteBlockValue) {
|
} else if (packet.getValue() instanceof NoteBlockValue) {
|
||||||
// int blockState = session.getGeyser().getWorldManager().getBlockAt(session, position);
|
int blockState = session.getGeyser().getWorldManager().getBlockAt(session, position);
|
||||||
// blockEventPacket.setEventData(BlockStateValues.getNoteblockPitch(blockState));
|
blockEventPacket.setEventData(BlockStateValues.getNoteblockPitch(blockState));
|
||||||
// session.sendUpstreamPacket(blockEventPacket);
|
session.sendUpstreamPacket(blockEventPacket);
|
||||||
} else if (packet.getValue() instanceof PistonValue pistonValue) {
|
} else if (packet.getValue() instanceof PistonValue pistonValue) {
|
||||||
PistonValueType action = (PistonValueType) packet.getType();
|
PistonValueType action = (PistonValueType) packet.getType();
|
||||||
Direction direction = Direction.fromPistonValue(pistonValue.getDirection());
|
Direction direction = Direction.fromPistonValue(pistonValue.getDirection());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren