Skip to content

Commit

Permalink
Translate ITEM_BREAK particles correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
bundabrg committed Feb 17, 2021
1 parent dc8123f commit 1d7e06a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,24 @@ public LevelEventHandler_Bedrock(BedrockTranslator translator) {

@Override
public boolean fromDownstream(LevelEventPacket packet) {
int id;
int face;
int damage;
switch (packet.getType()) {
case PARTICLE_DESTROY_BLOCK:
case PARTICLE_DESTROY_BLOCK: // block
case PARTICLE_DESTROY_BLOCK_NO_SOUND:
case PARTICLE_FALLING_DUST:
packet.setData(getTranslator().getRegisteredTranslator().getBlockMapper().mapRuntimeIdToUpstream(packet.getData()));
break;
case PARTICLE_CRACK_BLOCK:
int block = packet.getData() & 16777215;
int face = packet.getData() >> 24;
packet.setData(getTranslator().getRegisteredTranslator().getBlockMapper().mapRuntimeIdToUpstream(block) | (face << 24));
case PARTICLE_CRACK_BLOCK: // (face << 24) | block
id = packet.getData() & 16777215;
face = packet.getData() >> 24;
packet.setData(getTranslator().getRegisteredTranslator().getBlockMapper().mapRuntimeIdToUpstream(id) | (face << 24));
break;
case PARTICLE_ITEM_BREAK: // (id << 16) | damage
id = packet.getData() >> 16;
damage = packet.getData() & 65535;
packet.setData((getTranslator().getRegisteredTranslator().getItemMapper().mapRuntimeIdToUpstream(id) << 16) | damage);
break;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,15 @@ public NbtMap mapEnchantmentNbtToUpstream(NbtMap original) {
return original;
}

public int mapRuntimeIdToUpstream(int original) {
List<RuntimeItemMapperEntry> translatedItems = itemToUpstreamMap.get(original);
if (translatedItems == null) {
return original;
}

return translatedItems.get(0).getUpstream().getId();
}


/**
* Provides an entry for the ItemMapper
Expand Down

0 comments on commit 1d7e06a

Please sign in to comment.