Add back in explosion translator, add identifier support for sounds

Some sounds require an identifier be added, otherwise they don't properly play.
This commit is contained in:
RednedEpic 2020-05-02 01:56:08 -05:00
parent 99e8ca83ab
commit d7592d8216
5 changed files with 55 additions and 5 deletions

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2019-2020 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.connector.network.translators.java.world;
import com.github.steveice10.mc.protocol.data.game.world.block.ExplodedBlockRecord;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerExplosionPacket;
import com.nukkitx.math.vector.Vector3i;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.utils.ChunkUtils;
@Translator(packet = ServerExplosionPacket.class)
public class JavaExplosionTranslator extends PacketTranslator<ServerExplosionPacket> {
@Override
public void translate(ServerExplosionPacket packet, GeyserSession session) {
for (ExplodedBlockRecord record : packet.getExploded()) {
ChunkUtils.updateBlock(session, BlockTranslator.AIR, Vector3i.from(record.getX(), record.getY(), record.getZ()));
}
}
}

View file

@ -77,7 +77,7 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
} else {
soundPacket.setExtraData(soundMapping.getExtraData());
}
soundPacket.setIdentifier(":"); // ???
soundPacket.setIdentifier(soundMapping.getIdentifier()); // ???
soundPacket.setBabySound(false); // might need to adjust this in the future
soundPacket.setRelativeVolumeDisabled(false);
session.getUpstream().sendPacket(soundPacket);

View file

@ -71,7 +71,7 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
break;
// TODO: Check these three
case EXPLOSION:
effect.setType(LevelEventType.PARTICLE_EXPLODE);
effect.setType(LevelEventType.PARTICLE_LARGE_EXPLOSION);
break;
case MOB_SPAWN:
effect.setType(LevelEventType.ENTITY_SPAWN);

View file

@ -65,7 +65,8 @@ public class SoundUtils {
next.getKey(),
brMap.has("bedrock_mapping") && brMap.get("bedrock_mapping").isTextual() ? brMap.get("bedrock_mapping").asText() : null,
brMap.has("playsound_mapping") && brMap.get("playsound_mapping").isTextual() ? brMap.get("playsound_mapping").asText() : null,
brMap.has("extra_data") && brMap.get("extra_data").isInt() ? brMap.get("extra_data").asInt() : -1
brMap.has("extra_data") && brMap.get("extra_data").isInt() ? brMap.get("extra_data").asInt() : -1,
brMap.has("identifier") && brMap.get("identifier").isTextual() ? brMap.get("identifier").asText() : null
)
);
}
@ -100,12 +101,14 @@ public class SoundUtils {
private final String bedrock;
private final String playsound;
private final int extraData;
private String identifier;
public SoundMapping(String java, String bedrock, String playsound, int extraData) {
public SoundMapping(String java, String bedrock, String playsound, int extraData, String identifier) {
this.java = java;
this.bedrock = bedrock == null || bedrock.equalsIgnoreCase("") ? null : bedrock;
this.playsound = playsound == null || playsound.equalsIgnoreCase("") ? null : playsound;
this.extraData = extraData;
this.identifier = identifier == null || identifier.equalsIgnoreCase("") ? ":" : identifier;
}
}
}

@ -1 +1 @@
Subproject commit 9d801ea70edf1ae36f38b91a5c17bf2245315a68
Subproject commit f3ddcd8b537f4064a5f858df866efec2e620f631