Silent Gear

Silent Gear

19M Downloads

Erroneous posting of BlockEvent.BreakEvent on the client side

srs-bsns opened this issue ยท 0 comments

commented

Versions

  • Silent Gear: 2.1.0+161 (This issue has always existed for the saw item)

In net.silentchaos512.gear.item.gear.CoreSaw the override for IForgeItem#onBlockStartBreak calls CoreSaw#breakTree on both the client and server sides (as per its general contract for SMP), which results in the posting of BlockEvent.BreakEvent on both sides when it should only ever be posted on the server side.

This results in the event (client-side) being sent with a reference to ClientPlayerEntity which will then cause a ClassCastException for anyone doing a blind cast on the PlayerEntity -> ServerPlayerEntity. An argument can be made about the bad practice of blind casts, but it can also be inferred that since this event should only be sent on the server it should only ever be a ServerPlayerEntity.

The simple solution is to to just insert a side check here, since CoreSaw#breakTree only needs to be called on the server.

Additionally, the side check here can removed, as it would then be redundant.