forked from GeyserMC/Geyser
Fix bell sound and visuals (#1502)
* Fix bell sound and visuals The bell sound now correctly plays. Bells will also visually ring when rung by another player. * Compress elses * Add more whitespace to new code
This commit is contained in:
parent
ce64dd2788
commit
434a2e1500
3 changed files with 42 additions and 13 deletions
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package org.geysermc.connector.network.translators.java.world;
|
package org.geysermc.connector.network.translators.java.world;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.block.value.*;
|
import com.github.steveice10.mc.protocol.data.game.world.block.value.*;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockValuePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockValuePacket;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
|
@ -53,16 +54,12 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
|
||||||
blockEventPacket.setEventType(1);
|
blockEventPacket.setEventType(1);
|
||||||
blockEventPacket.setEventData(value.getViewers() > 0 ? 1 : 0);
|
blockEventPacket.setEventData(value.getViewers() > 0 ? 1 : 0);
|
||||||
session.sendUpstreamPacket(blockEventPacket);
|
session.sendUpstreamPacket(blockEventPacket);
|
||||||
}
|
} else if (packet.getValue() instanceof EndGatewayValue) {
|
||||||
if (packet.getValue() instanceof EndGatewayValue) {
|
|
||||||
blockEventPacket.setEventType(1);
|
blockEventPacket.setEventType(1);
|
||||||
session.sendUpstreamPacket(blockEventPacket);
|
session.sendUpstreamPacket(blockEventPacket);
|
||||||
}
|
} else if (packet.getValue() instanceof NoteBlockValue) {
|
||||||
if (packet.getValue() instanceof NoteBlockValue) {
|
|
||||||
NoteblockBlockEntityTranslator.translate(session, packet.getPosition());
|
NoteblockBlockEntityTranslator.translate(session, packet.getPosition());
|
||||||
return;
|
} else if (packet.getValue() instanceof PistonValue) {
|
||||||
}
|
|
||||||
if (packet.getValue() instanceof PistonValue) {
|
|
||||||
PistonValueType type = (PistonValueType) packet.getType();
|
PistonValueType type = (PistonValueType) packet.getType();
|
||||||
|
|
||||||
// Unlike everything else, pistons need a block entity packet to convey motion
|
// Unlike everything else, pistons need a block entity packet to convey motion
|
||||||
|
@ -73,14 +70,46 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
|
||||||
} else {
|
} else {
|
||||||
retractPiston(session, position, 1.0f, 1.0f);
|
retractPiston(session, position, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
} else if (packet.getValue() instanceof MobSpawnerValue) {
|
||||||
if (packet.getValue() instanceof MobSpawnerValue) {
|
|
||||||
blockEventPacket.setEventType(1);
|
blockEventPacket.setEventType(1);
|
||||||
session.sendUpstreamPacket(blockEventPacket);
|
session.sendUpstreamPacket(blockEventPacket);
|
||||||
}
|
} else if (packet.getValue() instanceof EndGatewayValue) {
|
||||||
if (packet.getValue() instanceof EndGatewayValue) {
|
|
||||||
blockEventPacket.setEventType(1);
|
blockEventPacket.setEventType(1);
|
||||||
session.sendUpstreamPacket(blockEventPacket);
|
session.sendUpstreamPacket(blockEventPacket);
|
||||||
|
} else if (packet.getValue() instanceof GenericBlockValue && packet.getBlockId() == 677) {
|
||||||
|
// TODO: Remove hardcode? Remove hardcodes for all of these? (EndGatewayValue for example still hardcodes the block)
|
||||||
|
// Bells - needed to show ring from other players
|
||||||
|
GenericBlockValue bellValue = (GenericBlockValue) packet.getValue();
|
||||||
|
Position position = packet.getPosition();
|
||||||
|
|
||||||
|
BlockEntityDataPacket blockEntityPacket = new BlockEntityDataPacket();
|
||||||
|
blockEntityPacket.setBlockPosition(Vector3i.from(position.getX(), position.getY(), position.getZ()));
|
||||||
|
|
||||||
|
NbtMapBuilder builder = NbtMap.builder();
|
||||||
|
builder.putInt("x", position.getX());
|
||||||
|
builder.putInt("y", position.getY());
|
||||||
|
builder.putInt("z", position.getZ());
|
||||||
|
builder.putString("id", "Bell");
|
||||||
|
int bedrockRingDirection;
|
||||||
|
switch (bellValue.getValue()) {
|
||||||
|
case 3: // north
|
||||||
|
bedrockRingDirection = 0;
|
||||||
|
break;
|
||||||
|
case 4: // east
|
||||||
|
bedrockRingDirection = 1;
|
||||||
|
break;
|
||||||
|
case 5: // west
|
||||||
|
bedrockRingDirection = 3;
|
||||||
|
break;
|
||||||
|
default: // south (2) is identical
|
||||||
|
bedrockRingDirection = bellValue.getValue();
|
||||||
|
}
|
||||||
|
builder.putInt("Direction", bedrockRingDirection);
|
||||||
|
builder.putByte("Ringing", (byte) 1);
|
||||||
|
builder.putInt("Ticks", 0);
|
||||||
|
|
||||||
|
blockEntityPacket.setData(builder.build());
|
||||||
|
session.sendUpstreamPacket(blockEntityPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a4125be98fefea6cefd43dc52ccb2ade4e70573e
|
Subproject commit b7ef31bd9c45aa3a0735883764c231f30cb55bfa
|
|
@ -1 +1 @@
|
||||||
Subproject commit c87cc5fb05eb92beac638234906d836f9f1178ed
|
Subproject commit 555dbabe56bdf9da44c08e338f7a2321afa14ca7
|
Loading…
Reference in a new issue