mirror of
https://github.com/TeamMidnightDust/VisualOverhaul.git
synced 2025-12-16 14:05:08 +01:00
Fancy Furnace, better packet handling, config translations
This commit is contained in:
@@ -21,30 +21,30 @@ import java.util.stream.Stream;
|
||||
@Mixin(JukeboxBlockEntity.class)
|
||||
public abstract class MixinJukeboxBlockEntity extends BlockEntity implements Tickable {
|
||||
|
||||
|
||||
@Shadow private ItemStack record;
|
||||
Boolean sendData = true;
|
||||
Boolean invUpdate = true;
|
||||
int playerUpdate = -1;
|
||||
|
||||
private MixinJukeboxBlockEntity(BlockEntityType<?> blockEntityType) {
|
||||
super(blockEntityType);
|
||||
|
||||
}
|
||||
|
||||
@Unique
|
||||
public void tick() {
|
||||
if (!this.world.isClient) {
|
||||
if (!this.world.isClient && (invUpdate || world.getPlayers().size() == playerUpdate)) {
|
||||
Stream<PlayerEntity> watchingPlayers = PlayerStream.watching(world, getPos());
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeBlockPos(pos);
|
||||
passedData.writeItemStack(record);
|
||||
|
||||
watchingPlayers.forEach(player -> ServerSidePacketRegistryImpl.INSTANCE.sendToPlayer(player, VisualOverhaul.UPDATE_RECORD, passedData));
|
||||
sendData = false;
|
||||
invUpdate = false;
|
||||
}
|
||||
playerUpdate = world.getPlayers().size();
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "getRecord", cancellable = true)
|
||||
public void getRecord(CallbackInfoReturnable cir) {
|
||||
this.sendData = true;
|
||||
this.invUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user