Fancy Furnace, better packet handling, config translations

This commit is contained in:
Motschen
2021-01-23 19:37:41 +01:00
parent fe5c2a7e1b
commit 792e81f4ca
22 changed files with 575 additions and 30 deletions

View File

@@ -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;
}
}