3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-25 15:50:12 +01:00

Make 1.11->1.10, 1.10->1.9 sounds configurable, fix some sound issues

Closes #279
Dieser Commit ist enthalten in:
KennyTV 2020-11-15 12:20:04 +01:00
Ursprung a982d8c0f0
Commit 9fbfcb3851
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
14 geänderte Dateien mit 270 neuen und 274 gelöschten Zeilen

Datei anzeigen

@ -11,6 +11,7 @@
package nl.matsv.viabackwards; package nl.matsv.viabackwards;
import nl.matsv.viabackwards.api.ViaBackwardsPlatform; import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
import nl.matsv.viabackwards.listener.FireDamageListener;
import nl.matsv.viabackwards.listener.FireExtinguishListener; import nl.matsv.viabackwards.listener.FireExtinguishListener;
import nl.matsv.viabackwards.listener.LecternInteractListener; import nl.matsv.viabackwards.listener.LecternInteractListener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -35,6 +36,9 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getVersion()) { if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getVersion()) {
loader.storeListener(new LecternInteractListener(this)).register(); loader.storeListener(new LecternInteractListener(this)).register();
} }
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_12.getVersion()) {
loader.storeListener(new FireDamageListener(this)).register();
}
} }
@Override @Override

Datei anzeigen

@ -0,0 +1,34 @@
package nl.matsv.viabackwards.listener;
import nl.matsv.viabackwards.BukkitPlugin;
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
public class FireDamageListener extends ViaBukkitListener {
public FireDamageListener(BukkitPlugin plugin) {
super(plugin, Protocol1_11_1To1_12.class);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFireDamage(EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER) return;
if (event.getCause() != EntityDamageEvent.DamageCause.FIRE
&& event.getCause() != EntityDamageEvent.DamageCause.FIRE_TICK
&& event.getCause() != EntityDamageEvent.DamageCause.LAVA) {
return;
}
Player player = (Player) event.getEntity();
if (isOnPipe(player)) {
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_HURT, SoundCategory.PLAYERS, 1, 1);
}
}
}

Datei anzeigen

@ -24,7 +24,7 @@ public class BackwardsMappings extends MappingData {
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass, boolean hasDiffFile) { public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass, boolean hasDiffFile) {
super(oldVersion, newVersion, hasDiffFile); super(oldVersion, newVersion, hasDiffFile);
Preconditions.checkArgument(!vvProtocolClass.isAssignableFrom(BackwardsProtocol.class)); Preconditions.checkArgument(vvProtocolClass == null || !vvProtocolClass.isAssignableFrom(BackwardsProtocol.class));
this.vvProtocolClass = vvProtocolClass; this.vvProtocolClass = vvProtocolClass;
// Just re-use ViaVersion's item id map // Just re-use ViaVersion's item id map
loadItems = false; loadItems = false;

Datei anzeigen

@ -24,7 +24,7 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
@Nullable @Nullable
public Item handleItemToClient(Item item) { public Item handleItemToClient(Item item) {
if (item == null) return null; if (item == null) return null;
if (protocol.getMappingData() != null) { if (protocol.getMappingData() != null && protocol.getMappingData().getItemMappings() != null) {
item.setIdentifier(protocol.getMappingData().getNewItemId(item.getIdentifier())); item.setIdentifier(protocol.getMappingData().getNewItemId(item.getIdentifier()));
} }
return item; return item;
@ -33,7 +33,7 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
@Nullable @Nullable
public Item handleItemToServer(Item item) { public Item handleItemToServer(Item item) {
if (item == null) return null; if (item == null) return null;
if (protocol.getMappingData() != null) { if (protocol.getMappingData() != null && protocol.getMappingData().getItemMappings() != null) {
item.setIdentifier(protocol.getMappingData().getOldItemId(item.getIdentifier())); item.setIdentifier(protocol.getMappingData().getOldItemId(item.getIdentifier()));
} }
restoreDisplayTag(item); restoreDisplayTag(item);

Datei anzeigen

@ -14,6 +14,7 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap; import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
@Deprecated
public abstract class LegacySoundRewriter<T extends BackwardsProtocol> extends Rewriter<T> { public abstract class LegacySoundRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
protected final Int2ObjectMap<SoundData> soundRewrites = new Int2ObjectOpenHashMap<>(64); protected final Int2ObjectMap<SoundData> soundRewrites = new Int2ObjectOpenHashMap<>(64);

Datei anzeigen

@ -2,6 +2,7 @@ package nl.matsv.viabackwards.api.rewriters;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType; import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
@ -19,20 +20,7 @@ public class SoundRewriter extends us.myles.ViaVersion.api.rewriters.SoundRewrit
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // Sound identifier map(Type.STRING); // Sound identifier
handler(wrapper -> { handler(getNamedSoundHandler());
String soundId = wrapper.get(Type.STRING, 0);
if (soundId.startsWith("minecraft:")) {
soundId = soundId.substring(10);
}
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
if (mappedId == null) return;
if (!mappedId.isEmpty()) {
wrapper.set(Type.STRING, 0, mappedId);
} else {
wrapper.cancel();
}
});
} }
}); });
} }
@ -41,34 +29,55 @@ public class SoundRewriter extends us.myles.ViaVersion.api.rewriters.SoundRewrit
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(getStopSoundHandler());
byte flags = wrapper.passthrough(Type.BYTE);
if ((flags & 0x02) == 0) return; // No sound specified
if ((flags & 0x01) != 0) {
wrapper.passthrough(Type.VAR_INT); // Source
}
String soundId = wrapper.read(Type.STRING);
if (soundId.startsWith("minecraft:")) {
soundId = soundId.substring(10);
}
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
if (mappedId == null) {
// No mapping found
wrapper.write(Type.STRING, soundId);
return;
}
if (!mappedId.isEmpty()) {
wrapper.write(Type.STRING, mappedId);
} else {
// Cancel if set to empty
wrapper.cancel();
}
});
} }
}); });
} }
public PacketHandler getNamedSoundHandler() {
return wrapper -> {
String soundId = wrapper.get(Type.STRING, 0);
if (soundId.startsWith("minecraft:")) {
soundId = soundId.substring(10);
}
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
if (mappedId == null) return;
if (!mappedId.isEmpty()) {
wrapper.set(Type.STRING, 0, mappedId);
} else {
wrapper.cancel();
}
};
}
public PacketHandler getStopSoundHandler() {
return wrapper -> {
byte flags = wrapper.passthrough(Type.BYTE);
if ((flags & 0x02) == 0) return; // No sound specified
if ((flags & 0x01) != 0) {
wrapper.passthrough(Type.VAR_INT); // Source
}
String soundId = wrapper.read(Type.STRING);
if (soundId.startsWith("minecraft:")) {
soundId = soundId.substring(10);
}
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
if (mappedId == null) {
// No mapping found
wrapper.write(Type.STRING, soundId);
return;
}
if (!mappedId.isEmpty()) {
wrapper.write(Type.STRING, mappedId);
} else {
// Cancel if set to empty
wrapper.cancel();
}
};
}
} }

Datei anzeigen

@ -11,11 +11,12 @@
package nl.matsv.viabackwards.protocol.protocol1_10to1_11; package nl.matsv.viabackwards.protocol.protocol1_10to1_11;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.data.BackwardsMappings;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.BlockItemPackets1_11; import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.BlockItemPackets1_11;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.EntityPackets1_11; import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.EntityPackets1_11;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11; import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.SoundPackets1_11;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker; import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
@ -24,6 +25,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> { public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.11", "1.10", null, true);
private EntityPackets1_11 entityPackets; // Required for the item rewriter private EntityPackets1_11 entityPackets; // Required for the item rewriter
private BlockItemPackets1_11 blockItemPackets; private BlockItemPackets1_11 blockItemPackets;
@ -36,7 +38,10 @@ public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_
(entityPackets = new EntityPackets1_11(this)).register(); (entityPackets = new EntityPackets1_11(this)).register();
new PlayerPackets1_11().register(this); new PlayerPackets1_11().register(this);
(blockItemPackets = new BlockItemPackets1_11(this)).register(); (blockItemPackets = new BlockItemPackets1_11(this)).register();
new SoundPackets1_11(this).register();
SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerNamedSound(ClientboundPackets1_9_3.NAMED_SOUND);
soundRewriter.registerSound(ClientboundPackets1_9_3.SOUND);
} }
@Override @Override
@ -66,4 +71,14 @@ public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_
public BlockItemPackets1_11 getBlockItemPackets() { public BlockItemPackets1_11 getBlockItemPackets() {
return blockItemPackets; return blockItemPackets;
} }
@Override
public BackwardsMappings getMappingData() {
return MAPPINGS;
}
@Override
public boolean hasMappingDataToLoad() {
return true;
}
} }

Datei anzeigen

@ -1,116 +0,0 @@
/*
* Copyright (c) 2016 Matsv
*
* 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.
*/
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
import nl.matsv.viabackwards.api.rewriters.LegacySoundRewriter;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
public class SoundPackets1_11 extends LegacySoundRewriter<Protocol1_10To1_11> {
public SoundPackets1_11(Protocol1_10To1_11 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
protocol.registerOutgoing(ClientboundPackets1_9_3.NAMED_SOUND, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING); // 0 - Sound name
map(Type.VAR_INT); // 1 - Sound Category
map(Type.INT); // 2 - x
map(Type.INT); // 3 - y
map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume
map(Type.FLOAT); // 6 - Pitch
}
});
protocol.registerOutgoing(ClientboundPackets1_9_3.SOUND, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Sound name
map(Type.VAR_INT); // 1 - Sound Category
map(Type.INT); // 2 - x
map(Type.INT); // 3 - y
map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume
map(Type.FLOAT); // 6 - Pitch
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int oldId = wrapper.get(Type.VAR_INT, 0);
int newId = handleSounds(oldId);
if (newId == -1)
wrapper.cancel();
else {
if (hasPitch(oldId))
wrapper.set(Type.FLOAT, 1, handlePitch(oldId));
wrapper.set(Type.VAR_INT, 0, newId);
}
}
});
}
});
}
@Override
protected void registerRewrites() {
// Sound replacements, suggestions are always welcome
// Automatically generated from PAaaS
added(85, 121, 0.5f); // block.shulker_box.close -> block.wooden_trapdoor.close
added(86, 122, 0.5f); // block.shulker_box.open -> block.wooden_trapdoor.open
added(176, 227); // entity.elder_guardian.flop -> entity.guardian.flop
// 1.10 entity.experience_orb.touch was removed; subtract id and properly map ender pearl sound on that id
soundRewrites.put(196, new SoundData(193, false, -1, false));
added(197, 402, 1.8f); // entity.evocation_fangs.attack -> entity.zombie.attack_iron_door
added(198, 370, 0.4f); // entity.evocation_illager.ambient -> entity.villager.ambient
added(199, 255, 1.3f); // entity.evocation_illager.cast_spell -> entity.irongolem.hurt
added(200, 418, 1.3f); // entity.evocation_illager.death -> entity.zombie_villager.death
added(201, 372, 1.3f); // entity.evocation_illager.hurt -> entity.villager.hurt
added(202, 137, 0.8f); // entity.evocation_illager.prepare_attack -> entity.elder_guardian.curse
added(203, 78, 2f); // entity.evocation_illager.prepare_summon -> block.portal.trigger
added(204, 376, 0.6f); // entity.evocation_illager.prepare_wololo -> entity.witch.ambient
added(279, 230, 1.5f); // entity.llama.ambient -> entity.horse.ambient
added(280, 231, 1.6f); // entity.llama.angry -> entity.horse.angry
added(281, 164); // entity.llama.chest -> entity.donkey.chest
added(282, 165, 1.2f); // entity.llama.death -> entity.donkey.death
added(283, 235, 1.1f); // entity.llama.eat -> entity.horse.eat
added(284, 166); // entity.llama.hurt -> entity.donkey.hurt
added(285, 323, 1.7f); // entity.llama.spit -> entity.shulker.shoot
added(286, 241, 0.8f); // entity.llama.step -> entity.horse.step
added(287, 423, 0.5f); // entity.llama.swag -> item.armor.equip_generic
added(296, 164); // entity.mule.chest -> entity.donkey.chest
added(390, 233, 0.1f); // entity.vex.ambient -> entity.horse.breathe
added(391, 168, 2f); // entity.vex.charge -> entity.elder_guardian.ambient
added(392, 144, 0.5f); // entity.vex.death -> entity.cat.death
added(393, 146, 2f); // entity.vex.hurt -> entity.cat.hurt
added(400, 370, 0.7f); // entity.vindication_illager.ambient -> entity.villager.ambient
added(401, 371, 0.8f); // entity.vindication_illager.death -> entity.villager.death
added(402, 372, 0.7f); // entity.vindication_illager.hurt -> entity.villager.hurt
added(450, 423, 1.1f); // item.armor.equip_elytra -> item.armor.equip_generic
added(455, 427, 1.1f); // item.bottle.empty -> item.bottle.fill
added(470, 2, 0.5f); // item.totem.use -> block.anvil.destroy
}
}

Datei anzeigen

@ -73,6 +73,9 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
//TODO use the diff file to also have named sound remaps
// (there were *A LOT* of refactored names)
// Replacement sounds, suggestions are always welcome // Replacement sounds, suggestions are always welcome
// Automatically generated from PAaaS // Automatically generated from PAaaS
added(26, 277, 1.4f); // block.end_portal.spawn -> entity.lightning.thunder added(26, 277, 1.4f); // block.end_portal.spawn -> entity.lightning.thunder

Datei anzeigen

@ -11,12 +11,15 @@
package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10; package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.data.BackwardsMappings;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10; import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets1_10; import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets1_10;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.SoundPackets1_10; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
@ -24,6 +27,12 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> { public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.10", "1.9.4", null, true);
private static final ValueTransformer<Float, Short> TO_OLD_PITCH = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) {
public Short transform(PacketWrapper packetWrapper, Float inputValue) throws Exception {
return (short) Math.round(inputValue * 63.5F);
}
};
private EntityPackets1_10 entityPackets; // Required for the item rewriter private EntityPackets1_10 entityPackets; // Required for the item rewriter
private BlockItemPackets1_10 blockItemPackets; private BlockItemPackets1_10 blockItemPackets;
@ -32,10 +41,37 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9
} }
protected void registerPackets() { protected void registerPackets() {
new SoundPackets1_10(this).register();
(entityPackets = new EntityPackets1_10(this)).register(); (entityPackets = new EntityPackets1_10(this)).register();
(blockItemPackets = new BlockItemPackets1_10(this)).register(); (blockItemPackets = new BlockItemPackets1_10(this)).register();
SoundRewriter soundRewriter = new SoundRewriter(this);
registerOutgoing(ClientboundPackets1_9_3.NAMED_SOUND, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING); // 0 - Sound name
map(Type.VAR_INT); // 1 - Sound Category
map(Type.INT); // 2 - x
map(Type.INT); // 3 - y
map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume
map(Type.FLOAT, TO_OLD_PITCH); // 6 - Pitch
handler(soundRewriter.getNamedSoundHandler());
}
});
registerOutgoing(ClientboundPackets1_9_3.SOUND, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Sound name
map(Type.VAR_INT); // 1 - Sound Category
map(Type.INT); // 2 - x
map(Type.INT); // 3 - y
map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume
map(Type.FLOAT, TO_OLD_PITCH); // 6 - Pitch
handler(soundRewriter.getSoundHandler());
}
});
registerIncoming(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketRemapper() { registerIncoming(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -67,4 +103,14 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9
public BlockItemPackets1_10 getBlockItemPackets() { public BlockItemPackets1_10 getBlockItemPackets() {
return blockItemPackets; return blockItemPackets;
} }
@Override
public BackwardsMappings getMappingData() {
return MAPPINGS;
}
@Override
public boolean hasMappingDataToLoad() {
return true;
}
} }

Datei anzeigen

@ -1,110 +0,0 @@
/*
* Copyright (c) 2016 Matsv
*
* 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.
*/
package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets;
import nl.matsv.viabackwards.api.rewriters.LegacySoundRewriter;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
public class SoundPackets1_10 extends LegacySoundRewriter<Protocol1_9_4To1_10> {
protected static ValueTransformer<Float, Short> toOldPitch = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) {
public Short transform(PacketWrapper packetWrapper, Float inputValue) throws Exception {
return (short) Math.round(inputValue * 63.5F);
}
};
public SoundPackets1_10(Protocol1_9_4To1_10 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
protocol.registerOutgoing(ClientboundPackets1_9_3.NAMED_SOUND, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING); // 0 - Sound name
map(Type.VAR_INT); // 1 - Sound Category
map(Type.INT); // 2 - x
map(Type.INT); // 3 - y
map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume
map(Type.FLOAT, toOldPitch); // 6 - Pitch
}
});
protocol.registerOutgoing(ClientboundPackets1_9_3.SOUND, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Sound name
map(Type.VAR_INT); // 1 - Sound Category
map(Type.INT); // 2 - x
map(Type.INT); // 3 - y
map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume
map(Type.FLOAT, toOldPitch); // 6 - Pitch
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int oldId = wrapper.get(Type.VAR_INT, 0);
int newId = handleSounds(oldId);
if (newId == -1) {
wrapper.cancel();
return;
}
if (hasPitch(oldId)) {
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) Math.round(handlePitch(oldId) * 63.5F));
}
wrapper.set(Type.VAR_INT, 0, newId);
}
});
}
});
}
@Override
protected void registerRewrites() {
added(24, -1); // Enchantment table sound
// Husk
added(249, 381); // Husk -> Zombie ambient
added(250, 385); // Husk -> Zombie death
added(251, 386); // Husk -> Zombie hurt
added(252, 388); // Husk -> Zombie step
// Polar bear
added(301, 381, .6F); // Polar bear ambient -> Zombie ambient
added(302, 381, 1.9F); // Polar baby bear ambient -> Zombie ambient
added(303, 385, .7F); // Polar bear death -> Zombie death
added(304, 309, .6F); // Polar bear hurt -> Shulker hurt
added(305, 240, .6F); // Polar bear step -> Horse step
added(306, 374, 1.2F); // Polar bear warning -> Wolf growl
// Stray
added(365, 320); // Stray -> Skeleton ambient
added(366, 321); // Stray -> Skeleton death
added(367, 322); // Stray -> Skeleton hurt
added(368, 324); // Stray -> Skeleton step
// Wither skeleton
added(387, 320); // Wither skeleton -> Skeleton ambient
added(388, 321); // Wither skeleton -> Skeleton death
added(389, 322); // Wither skeleton -> Skeleton hurt
added(390, 324); // Wither skeleton -> Skeleton step
}
}

Datei anzeigen

@ -0,0 +1,35 @@
{
"sounds": {
"block.shulker_box.close": "block.wooden_trapdoor.close",
"block.shulker_box.open": "block.wooden_trapdoor.open",
"entity.elder_guardian.flop": "entity.guardian.flop",
"entity.evocation_fangs.attack": "entity.zombie.attack_iron_door",
"entity.evocation_illager.ambient": "entity.villager.ambient",
"entity.evocation_illager.cast_spell": "entity.irongolem.hurt",
"entity.evocation_illager.death": "entity.zombie_villager.death",
"entity.evocation_illager.hurt": "entity.villager.hurt",
"entity.evocation_illager.prepare_attack": "entity.elder_guardian.curse",
"entity.evocation_illager.prepare_summon": "block.portal.trigger",
"entity.evocation_illager.prepare_wololo": "entity.witch.ambient",
"entity.llama.ambient": "entity.horse.ambient",
"entity.llama.angry": "entity.horse.angry",
"entity.llama.chest": "entity.donkey.chest",
"entity.llama.death": "entity.donkey.death",
"entity.llama.eat": "entity.horse.eat",
"entity.llama.hurt": "entity.donkey.hurt",
"entity.llama.spit": "entity.shulker.shoot",
"entity.llama.step": "entity.horse.step",
"entity.llama.swag": "item.armor.equip_generic",
"entity.mule.chest": "entity.donkey.chest",
"entity.vex.ambient": "entity.horse.breathe",
"entity.vex.charge": "entity.elder_guardian.ambient",
"entity.vex.death": "entity.cat.death",
"entity.vex.hurt": "entity.cat.hurt",
"entity.vindication_illager.ambient": "entity.villager.ambient",
"entity.vindication_illager.death": "entity.villager.death",
"entity.vindication_illager.hurt": "entity.villager.hurt",
"item.armor.equip_elytra": "item.armor.equip_generic",
"item.bottle.empty": "item.bottle.fill",
"item.totem.use": "block.anvil.destroy"
}
}

Datei anzeigen

@ -0,0 +1,52 @@
{
"sounds": {
"block.end_portal.spawn": "entity.lightning.thunder",
"block.note.bell": "block.note.harp",
"block.note.chime": "block.note.harp",
"block.note.flute": "block.note.harp",
"block.note.guitar": "block.note.harp",
"block.note.xylophone": "block.note.harp",
"entity.illusion_illager.ambient": "entity.evocation_illager.ambient",
"entity.illusion_illager.cast_spell": "entity.evocation_illager.cast_spell",
"entity.illusion_illager.death": "entity.evocation_illager.death",
"entity.illusion_illager.hurt": "entity.evocation_illager.hurt",
"entity.illusion_illager.mirror_move": "entity.endermen.teleport",
"entity.illusion_illager.prepare_blindness": "entity.evocation_illager.prepare_summon",
"entity.illusion_illager.prepare_mirror": "entity.evocation_illager.prepare_attack",
"entity.parrot.ambient": "entity.bat.ambient",
"entity.parrot.death": "entity.bat.death",
"entity.parrot.eat": "entity.generic.eat",
"entity.parrot.fly": "entity.bat.loop",
"entity.parrot.hurt": "entity.bat.hurt",
"entity.parrot.imitate.blaze": "entity.blaze.ambient",
"entity.parrot.imitate.creeper": "entity.creeper.primed",
"entity.parrot.imitate.elder_guardian": "entity.elder_guardian.ambient",
"entity.parrot.imitate.enderdragon": "entity.enderdragon.ambient",
"entity.parrot.imitate.enderman": "entity.endermen.ambient",
"entity.parrot.imitate.endermite": "entity.endermite.ambient",
"entity.parrot.imitate.evocation_illager": "entity.evocation_illager.ambient",
"entity.parrot.imitate.ghast": "entity.ghast.ambient",
"entity.parrot.imitate.husk": "entity.husk.ambient",
"entity.parrot.imitate.illusion_illager": "entity.evocation_illager.ambient",
"entity.parrot.imitate.magmacube": "entity.magmacube.squish",
"entity.parrot.imitate.polar_bear": "entity.polar_bear.ambient",
"entity.parrot.imitate.shulker": "entity.shulker.ambient",
"entity.parrot.imitate.silverfish": "entity.silverfish.ambient",
"entity.parrot.imitate.skeleton": "entity.skeleton.ambient",
"entity.parrot.imitate.slime": "entity.slime.squish",
"entity.parrot.imitate.spider": "entity.spider.ambient",
"entity.parrot.imitate.stray": "entity.stray.ambient",
"entity.parrot.imitate.vex": "entity.vex.ambient",
"entity.parrot.imitate.vindication_illager": "entity.vindication_illager.ambient",
"entity.parrot.imitate.witch": "entity.witch.ambient",
"entity.parrot.imitate.wither": "entity.wither.ambient",
"entity.parrot.imitate.wither_skeleton": "entity.wither_skeleton.ambient",
"entity.parrot.imitate.wolf": "entity.wolf.ambient",
"entity.parrot.imitate.zombie": "entity.zombie.ambient",
"entity.parrot.imitate.zombie_pigman": "entity.zombie_pig.ambient",
"entity.parrot.imitate.zombie_villager": "entity.zombie_villager.ambient",
"entity.parrot.step": "entity.chicken.step",
"entity.player.hurt_drown": "entity.player.hurt",
"entity.player.hurt_on_fire": "entity.player.hurt"
}
}

Datei anzeigen

@ -0,0 +1,23 @@
{
"sounds": {
"block.enchantment_table.use": "",
"entity.husk.ambient": "entity.zombie.ambient",
"entity.husk.death": "entity.zombie.death",
"entity.husk.hurt": "entity.zombie.hurt",
"entity.husk.step": "entity.zombie.step",
"entity.polar_bear.ambient": "entity.zombie.ambient",
"entity.polar_bear.baby_ambient": "entity.zombie.ambient",
"entity.polar_bear.death": "entity.zombie.death",
"entity.polar_bear.hurt": "entity.shulker.hurt",
"entity.polar_bear.step": "entity.horse.step",
"entity.polar_bear.warning": "entity.wolf.growl",
"entity.stray.ambient": "entity.skeleton.ambient",
"entity.stray.death": "entity.skeleton.death",
"entity.stray.hurt": "entity.skeleton.hurt",
"entity.stray.step": "entity.skeleton.step",
"entity.wither_skeleton.ambient": "entity.skeleton.ambient",
"entity.wither_skeleton.death": "entity.skeleton.death",
"entity.wither_skeleton.hurt": "entity.skeleton.hurt",
"entity.wither_skeleton.step": "entity.skeleton.step"
}
}